function toggleDisplay(id) {
	var topicStyle  = document.getElementById(id).className;
	var hideID = id + "a";
	var showID = id + "b";
	if (topicStyle == "no-display") {
		document.getElementById(id).className = "display";		
		document.getElementById(hideID).className = "display";
		document.getElementById(showID).className = "no-display";
	} else {
		document.getElementById(id).className = "no-display";
		document.getElementById(hideID).className = "no-display";
		document.getElementById(showID).className = "display";
	}
}
function toggleCompareDisplay(id) {
	var hideID = id + "a";
	var showID = id + "b";	
	if (document.getElementById(hideID).className == "no-display") {
		document.getElementById(hideID).className = "";
		document.getElementById(showID).className = "no-display";	
	} else {
		document.getElementById(hideID).className = "no-display";
		document.getElementById(showID).className = "";
	}
}
function sbsAdd(val){
    ShowLoading();
	if (val != ""){
		var url 			= "/members/compare.aspx";
		var yVal 			= "";
		var zVal 			= "";
		var args 			= location.search.substr(1).split("?");
		var arParams		= args[0].split("&");
		var arArg			= "";	
		for (a = 0; a < arParams.length; a++){
			arArg = arParams[a].split("=");
			switch(arArg[0])
			{
				case "y" : 
					yVal 	= arArg[1];
					continue;
				case "z" : 
					zVal 	= arArg[1];
					continue;
				default : 
					continue;
			}	
		}
		if (zVal == ""){
			zVal = val;
		}else{
			zVal += "," + val;
		}
		document.body.style.cursor = "wait";
		location.href = (url + "?y=" + yVal + "&z=" + zVal).replace(" ","");	
	}
}
function sbsRemove(val){
    ShowLoading();
	if (val != ""){
		var url 			= "/members/compare.aspx";
		var yVal 			= "";
		var zVal 			= "";
		var args 			= location.search.substr(1).split("?");
		var arParams		= args[0].split("&");
		var arArg			= "";	
		for (a = 0; a < arParams.length; a++){
			arArg = arParams[a].split("=");
			switch(arArg[0])
			{
				case "y" : 
					yVal 	= arArg[1];
					continue;
				case "z" : 
					zVal 	= arArg[1];
					continue;
				default : 
					continue;
			}	
		}
		if (zVal != ""){
			var zVals = zVal.split(",");
			zVal = "";
			for (i = 0; i < zVals.length; i++){
				if (zVals[i] != val){
					zVal += zVals[i] + ",";
				}		
			}
			zVal = zVal.substring(0,zVal.length - 1);
		}
		document.body.style.cursor = "wait";
		location.href = (url + "?y=" + yVal + "&z=" + zVal).replace(" ","");
	}
}

function launchwin(winurl,winname,winfeatures)
{
	if (winname == null) {
		winname = 'print';
	}
	if (winfeatures == null) {
		winfeatures = 'height=500,width=500,resizable=yes,scrollbars=yes,toolbar=yes';
	}
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	newwin = window.open(winurl,winname,winfeatures);
}
//start cookie code
var cook = document.cookie;
function getCookie(name) { 
	var index = cook.indexOf(name + "=");
    if (index == -1) return null;
   	index = cook.indexOf("=", index) + 1;
    var endstr = cook.indexOf(";", index);
    if (endstr == -1) endstr = cook.length;
    return unescape(cook.substring(index, endstr));
}

var today = new Date();
var expiry = new Date(today.getTime() + 30 * 60 * 1000); //set to expire after 30 min.

function setCookie(name, value) {
   	if (value != null && value != ""){
      	document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
	}
	cook = document.cookie;
}

// this deletes the cookie when called ex. deleteCookie('cookie name', '/', '')
function deleteCookie( name, pth, domain ) {
var path = "/";
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//end cookie
//begin no-copy
var allow = true;
function noCopy(obj){  	
  	obj.galleryimg="no"
    obj.onmouseup=function(){coverIt(obj)}
}
function coverIt(e){
	if (!allow){
		var shield=document.images.imgShield;
		if(shield){
			shield.width=e.width;
			shield.height=e.height;
			shield.style.left=el_L(e);
			shield.style.top=el_T(e);
		}
	}
}
function el_L(el){
	var lft = el.offsetLeft;
	var pel = el.offsetParent; 
	while (pel != null){
		lft += pel.offsetLeft; 
		pel = pel.offsetParent;
	}
	return lft;
} 
function el_T(el){
	var tp = el.offsetTop;
	var pel = el.offsetParent; 
	while (pel != null){
		tp += pel.offsetTop; 
		pel = pel.offsetParent;
	}
	return tp;
}
function clickIE() {
	allowClick();
	if (event.button!=1){
		allow = false;
	}else{
		allow = true;
	}
}
function clickNS(e) {
	allowClick();
	if (e.which!=1){
		allow = false;
	}else{
		allow = true;
	}
}
function allowClick(){
	var shield=document.images.imgShield;
	if(shield){
		shield.width=0;
		shield.height=0;
	}
}
if (document.all){
	document.onmousedown=clickIE;
}else{
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
}
//end no-copy
function checkTextMaster(obj,textVal){
    if (obj.value == textVal){
        obj.value = "";
        obj.style.color = "#333333";
    }
}
function validateSizeMaster(obj, limit){
    var val = trimSSString(obj.value);
    if (val.length > limit){
        alert("You have exceeded the field limit of " + limit + " characters.");
        obj.value = val.substring(0, limit);
    }
}
function trimStringMaster(str)
{
    if (!(str == "")) {
    while('' + str.charAt(0) == ' '){
        str=str.substring(1,str.length);
    }
    }
    //take out trailing spaces
    if (!(str == "")) {
    while (str.charAt(str.length - 1) == ' '){
        str = str.substring(0, str.length - 1);
    }
    }
    return str;
}
