//////////////////////////////////////////////////////////////////////////////
///////// Common Script //////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
var currentHost = window.location.host;
var CurrentUser = retrieveSSOCookieUserId();
var screenname = retrieveSSOCookieUserId();
var GuidelineTextArray = Array("Ask great questions. Share what you know. Correct others politely if they're wrong.","Start a dialogue. Being part of a community means expressing differing views with others. Defend your viewpoint with facts and opinions, not name calling and attacks.","The site is meant for the entire community. Explicit language and content is not welcome. If it's inappropriate for The Simpsons, it's probably inappropriate here.","Don't encourage acts of violence. The only people likely to meet you for a fight are the police.","Being part of a community means tolerating differing views, as well as helping keep order. Report comments that are inappropriate, not just those with which you don't agree.","Don't pretend to be someone else, and don't give out the information or identity of others.","We take numerous measures to protect the information you share with this site. We recommend you take care with what you share with others.","We hope that you will base your opinions on facts and logic. But we can't certify that anyone does; the only comments we endorse are those we write.","No one wins in a flame war. This is your community, make it a better place by sharing what you have to say.","Stay on target. A focused conversation makes for a better community. Use your personal blog to introduce new topics to the community.","This is a public community. Comments submitted will remain in public view unless they violate our site’s Terms of Use. Please think before you click submit.");
screenname = screenname.replace('+',' ');

function searchBoxOnfocus(formId, inputId, checkString) {
	if(document.getElementById(formId).elements[inputId].value == checkString) document.getElementById(formId).elements[inputId].value = '';
}
function searchBoxOnblur(formId, inputId, checkString) {
	if(document.getElementById(formId).elements[inputId].value == '') document.getElementById(formId).elements[inputId].value = checkString;
}
function createIE6Message() {
	tempCookieValue = getCookie("IE6Closed");
	if (tempCookieValue == "") {
		document.write("<div style='border:1px solid #F7941D;background:#fff2e2;text-align:center;clear:both;height:41px;position:relative;'>");
		document.write("<div style='position:absolute;right:3px;top:3px;font-family:courier new;font-weight:bold;'><a href='#' onclick='javascript:this.parentNode.parentNode.style.display=\"none\";setIE6Cookie();return false;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg' style='border:none;' alt='Close this notice'/></a></div>");
		document.write("<div style='width:1000px;margin:0px auto;text-align:left;padding:0px;overflow:hidden;color:black;'>");
		document.write("<div style='width:50px;float:left;'><img src='"+publicusPath+"/Global/images/ie6nomore-warning.jpg' alt='Warning!' width='50' height='41'/></div>");
		document.write("<div style='width:255px;float:left;font-family:Arial,sans-serif;'>");
		document.write("<div style='font-size:14px;font-weight:bold;margin-top:12px;'>You are using an outdated browser</div>");
		document.write("</div>");
		document.write("<div style='width:290px;float:left;font-family:\"Trebuchet MS\",Times,sans-serif;'>");
		document.write("<div style='font-size:12px;margin-top:6px;line-height:14px;'>For a better experience using this site, please upgrade to a modern web browser as shown here:</div>");
		document.write("</div>");
		document.write("<div style='width:90px;float:left;'><a href='http://www.firefox.com' target='_blank'><img src='"+publicusPath+"/Global/images/ie6nomore-firefox.jpg' alt='Get Firefox 3.5' width='90' height='41' style='border: none;'/></a></div>");
		document.write("<div style='width:88px;float:left;'><a href='http://www.browserforthebetter.com/download.html' target='_blank'><img src='"+publicusPath+"/Global/images/ie6nomore-ie8.jpg' alt='Get Internet Explorer 8' width='88' height='41' style='border: none;'/></a></div>");
		document.write("<div style='width:88px;float:left;'><a href='http://www.apple.com/safari/download/' target='_blank'><img src='"+publicusPath+"/Global/images/ie6nomore-safari.jpg' alt='Get Safari 4' width='88' height='41' style='border: none;'/></a></div>");
		document.write("<div style='float:left;'><a href='http://www.google.com/chrome' target='_blank'><img src='"+publicusPath+"/Global/images/ie6nomore-chrome.jpg' alt='Get Google Chrome' width='81' height='41' style='border: none;'/></a></div>");
		document.write("</div>");
		document.write("</div>");
	}
}
function setIE6Cookie() {
	document.cookie = "IE6Closed=1;domain=" + gFPCDom + ";path=/";
}
function changeSubSearchType(formId,subSearchType, linkIndex, highestLinkIndex) {
	if (document.getElementById(formId).elements['subSearchType']) {
		// first, update the hidden field
		document.getElementById(formId).elements['subSearchType'].value = subSearchType;
		// second, set the classes for the links 
		for (var i=0;i<=highestLinkIndex;i++) {
			if (linkIndex != i) {
				document.getElementById('lnk'+formId+i).className = "general_black";
			} else {
				document.getElementById('lnk'+formId+i).className = "active general_black";
			}
		}			
	}
}

function onTabOver(tabType,tabSelectedNumber) {
	// only do over if not active 
	if (document.getElementById("tab"+tabType+tabSelectedNumber).className != "activeTab") {
		document.getElementById("tab"+tabType+tabSelectedNumber+"Left").className = "hoverTabLeft";
		document.getElementById("tab"+tabType+tabSelectedNumber).className = "hoverTab";
		document.getElementById("tab"+tabType+tabSelectedNumber+"Right").className = "hoverTabRight";
	}
}

function onTabOut(tabType,tabSelectedNumber) {
	// only do out if not active
	if (document.getElementById("tab"+tabType+tabSelectedNumber).className != "activeTab") {
		document.getElementById("tab"+tabType+tabSelectedNumber+"Left").className = "inactiveTabLeft";
		document.getElementById("tab"+tabType+tabSelectedNumber).className = "inactiveTab";
		document.getElementById("tab"+tabType+tabSelectedNumber+"Right").className = "inactiveTabRight";
	}
}

/*************
* tabType: Blogs, Media, News
**************/
function tabOnMouseOver(tabId) {
	$('#mtwt' + tabId).removeClass('tabUnselected');
	$('#mtwt' + tabId).addClass('tabSelected');
}
function tabOnMouseOut(tabId) {
	$('#mtwt' + tabId).removeClass('tabSelected');
	$('#mtwt' + tabId).addClass('tabUnselected');
}
function onTabClick(tabType,tabSelectedNumber,tabHighestNumber) {
	// change the background images
	// set non selected tabs inactive
	setTabsInactive(tabType,tabSelectedNumber,tabHighestNumber);
	
	// set correct tab active
	document.getElementById("tab"+tabType+tabSelectedNumber+"Left").className = "activeTabLeft";
	document.getElementById("tab"+tabType+tabSelectedNumber).className = "activeTab";
	document.getElementById("tab"+tabType+tabSelectedNumber+"Right").className = "activeTabRight";
	document.getElementById("link"+tabType+tabSelectedNumber).className = "active";
	document.getElementById("content"+tabType+tabSelectedNumber).style.display = "block";
}

// tab click for members hub
function onMhTabClick(tabType,tabSelectedNumber,tabHighestNumber) {
	// change the background images
	// set non selected tabs inactive
	setTabsInactive(tabType,tabSelectedNumber,tabHighestNumber);
	
	// set correct tab active
	document.getElementById("tab"+tabType+tabSelectedNumber+"Left").className = "activeTabLeft";
	document.getElementById("tab"+tabType+tabSelectedNumber).className = "activeTab";
	document.getElementById("tab"+tabType+tabSelectedNumber+"Right").className = "activeTabRight";
	document.getElementById("link"+tabType+tabSelectedNumber).className = "active";
	document.getElementById("content"+tabType+tabSelectedNumber).style.display = "block";
}

function setTabsInactive(tabType,tabSelectedNumber,tabHighestNumber) {
	for (var i=0;i<=tabHighestNumber;i++) {
		if (tabSelectedNumber != i) {
			document.getElementById("tab"+tabType+i+"Left").className = "inactiveTabLeft";
			document.getElementById("tab"+tabType+i).className = "inactiveTab";
			document.getElementById("tab"+tabType+i+"Right").className = "inactiveTabRight";
			document.getElementById("link"+tabType+i).className = "inactive";
			
			document.getElementById("content"+tabType+i).style.display = "none";
		}
	}
}
/*****************************
** Pluck formatting objects **
******************************/
function deactivateMTWTab(id) {
	if (g_timer!=null) clearTimeout(g_timer);
	g_curtab = -1;
}
function activateMTWTab(id, blnForce) {
	if (blnForce) {
		if (g_timer!=null) clearTimeout(g_timer);
		g_timer = null;
		g_curtab = id;
		showTab();
	} else if (id!=g_curtab) {
		if (g_timer!=null) clearTimeout(g_timer);
		g_curtab = id;
		g_timer = setTimeout(showTab, 500);
	}
	return false;
}
function showTab() {
	/*  Commented out the next line because it caused failure of IR 6 & 7 load for the homepage */
	//console.debug("showTab %d", g_curtab);
	id = g_curtab;
	var cnt = 0;
	var tempID = 1
	while (e = document.getElementById('mtwt'+cnt)) {
		if (id == cnt) {
			e.className = e.className.replace(/tabUnselected/, "tabSelected");
			if (e = document.getElementById('mtwta'+cnt)) e.style.display = "block";
			if (e = document.getElementById('mtwtc'+cnt)) e.style.display = "block";
			if (document.getElementById("tempTabSelected"+(cnt+1)))
				document.getElementById("tempTabSelected"+(cnt+1)).value=1;
		} else {
			e.className = e.className.replace(/tabSelected/, "tabUnselected");
			if (e = document.getElementById('mtwta'+cnt)) e.style.display = "none";
			if (e = document.getElementById('mtwtc'+cnt)) e.style.display = "none";
			if (document.getElementById("tempTabSelected"+(cnt+1)))
				document.getElementById("tempTabSelected"+(cnt+1)).value=0;
		}
		cnt++;
		e = document.getElementById('mtwt' + cnt);
	}
}


/*
function deactivateHTWTab(id) {
	if (g_timer!=null) clearTimeout(g_timer);
	g_curtab = -1;
}
*/
function activateHTWTab(id, blnForce) {
	if (blnForce) {
		if (g_timer!=null) clearTimeout(g_timer);
		g_timer = null;
		g_curtab = id;
		showHubTab();
	} else if (id!=g_curtab) {
		if (g_timer!=null) clearTimeout(g_timer);
		g_curtab = id;
		g_timer = setTimeout(showTab, 500);
	}
	return false;
}
function showHubTab() {
	/*  Commented out the next line because it caused failure of IR 6 & 7 load for the homepage */
	//console.debug("showTab %d", g_curtab);
	id = g_curtab;
	var cnt = 0;
	var tempID = 1
	while (e = document.getElementById('htwt'+cnt)) {
		if (id == cnt) {
			e.className = e.className.replace(/tabUnselected/, "tabSelected");
			if (e = document.getElementById('htwta'+cnt)) e.style.display = "block";
			if (e = document.getElementById('htwtc'+cnt)) e.style.display = "block";
			if (document.getElementById("tempHubTabSelected"+(cnt+1)))
				document.getElementById("tempHubTabSelected"+(cnt+1)).value=1;
		} else {
			e.className = e.className.replace(/tabSelected/, "tabUnselected");
			if (e = document.getElementById('htwta'+cnt)) e.style.display = "none";
			if (e = document.getElementById('htwtc'+cnt)) e.style.display = "none";
			if (document.getElementById("tempHubTabSelected"+(cnt+1)))
				document.getElementById("tempHubTabSelected"+(cnt+1)).value=0;
		}
		cnt++;
		e = document.getElementById('htwt' + cnt);
	}
}

function initHeader() {
	/* fix up any access control issues */
	var blnPBSLoggedIn = (getCookie("aalo")!="" && getCookie("AT")!="");
	
	var screenname = RetrieveSSOCookieDisplayName();	
	jQuery("#user_screenname1").html(screenname);	// screenname is a global
	jQuery("#user_screenname2").html(screenname);	// screenname is a global
	if (blnPBSLoggedIn) {
		jQuery("aaMembersHubHybrid").hide();
		jQuery("#aaMembersHub").hide("slow", function() {
			jQuery("#aaMembersHubLogon").show("slow");
		});
		jQuery("#subscribePopUpLoggedOut").hide();
		jQuery("#subscribePopUpLoggedIn").show();
		jQuery(".entry-titlePREMIUM").css({backgroundImage:'none'});
		jQuery(".entry-titlePREMIUM").css({"padding-left":"0px"});
	} else {
		// Need to look for AT.  If AT is present, then we are logged into the registration system
		// but there is no Publicus login, so show the hybrid view (probably due to a subscription/daypass expiration)
		if (getCookie('AT')!="") {
			jQuery("#aaMembersHub").hide("slow", function() {
				jQuery("#aaMembersHubHybrid").show("slow");
			});
			jQuery(".entry-titlePREMIUM").css({backgroundImage:'none'});
			
		}
		jQuery("#subscribePopUpLoggedIn").hide();
			jQuery("#subscribePopUpLoggedOut").show();
	}
}

function initFrontpage() {
	
	showImageHome();
	var blnPBSLoggedIn = (getCookie("aalo")!="" && getCookie("AT")!="");
	if (typeof(blnUseAccessControl)=="undefined") blnUseAccessControl = false;
	if (typeof(blnPBSLoggedIn)=="undefined") blnPBSLoggedIn = false;
	if (typeof(photoGalleryFormat)=="undefined") photoGalleryFormat = 1;

	if (blnUseAccessControl && !blnPBSLoggedIn)
		photoGalleryFormat = 2;
	else if (blnUseAccessControl)
		photoGalleryFormat = 1;
	
	

	/* fix up any access control issues */
	if (blnPBSLoggedIn && blnUseAccessControl) {
		jQuery(".listedPREMIUM").removeClass("listedPREMIUM").addClass("listed");
		jQuery(".listed_nobulletPREMIUM").removeClass("listed_nobulletPREMIUM").addClass("listed_nobullet");
		jQuery(".listed_smallPREMIUM").removeClass("listed_smallPREMIUM").addClass("listed_small");
		jQuery(".titlePREMIUM").removeClass("titlePREMIUM").addClass("title");
		jQuery("#featuredBox_WaitMsg").hide("slow", function() {
			jQuery("#featuredBox_PREMIUM").show("slow");
		});
		jQuery("#breaking_news_section").removeClass("PREMIUM");
	} else if (blnUseAccessControl) {
		// activateMTWTab(1,true);
		jQuery("#featuredBox_WaitMsg").hide("slow", function() {
			jQuery("#featuredBox_LoggedOut").show("slow");
		});
	} else {
		jQuery("#featuredBox_WaitMsg").html("<i>Sorry - this system is not configured for Access control.  Something went wrong.</i>");
	}
	
	/* if we are in a breaking news story, we need a little JS magic to fix the width of the caption under the photo */
	$("#breaking_news_caption").width( $("#breaking_news_image").width() + "px" );
	
	pluckPageLoadCallback();		// takes care of invalidation if required
}

function rotateImage(oldImageIndex, newImageIndex) {
	if (jQuery("#imageTable tr td").size() <= newImageIndex) newImageIndex = 0;
	if (oldImageIndex>=0) 
		jQuery("#imageTable tr td:eq(" + oldImageIndex + ")").fadeOut("slow", function() {
			riFadeIn(newImageIndex);
		});
	else
		riFadeIn(newImageIndex);
}

function riFadeIn(newImageIndex) {
	jQuery("#imageTable tr td:eq(" + newImageIndex + ")").fadeIn("slow");
	setTimeout("rotateImage("+newImageIndex+", "+(newImageIndex+1)+");", 5000);
}

function initGenOvr() {
	/* fix up any access control issues */
	if (blnPBSLoggedIn && blnUseAccessControl) {
		jQuery(".entry-titlePREMIUM").removeClass("entry-titlePREMIUM").addClass("entry-title");
	} else if (blnUseAccessControl) {
	}
}


function initGenPageNoPluck() {
    if (document.getElementById("avatar")) {
        var avatar = getCookie('AVATAR');
        if (!getCookie('AT') && avatar) {
        	// If the user isn't logged in, we need to wipe out their avatar setting.  If logout code is working ok, this should rarely happen
            var cookie_date = new Date ( );  // current date & time
            cookie_date.setFullYear ( cookie_date.getFullYear() - 1 );
            document.cookie = "AVATAR" + "=; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
        } else if (avatar) {
             document.getElementById("avatar").src = avatar;
        }
    }
}

function initArtPage() {

	pluckPageLoadCallback();		// takes care of invalidation, if required, and loading comments
}

function initAppsPage() {

	pluckPageLoadCallback();		// takes care of invalidation if required
}

function showImageHome () {

}

function displayAvatar(src) {

}

/* call all of the registered pluck callback functions with the response object */
function pluckPageLoadCallback() {

}

function invalidateCache() {

}

function invalidateValueCache() {

}

function invalidateFrameLoaded() {

}

function issueResponses() {

}

function pluckResponseHandler(responseBatch) {

}
function pluckResponsePersonaHandler(responseBatch) {

}

/* Registers a callback function that will be called when the
   page's Pluck callback routines complete
   function should have this prototype:
   		function functionName(ResponseBatch)
*/
function registerPluckPageCallback(strFnName) {

}
function registerPluckPageCallbackPersona(strFnName) {

}
function activateSubMenu(iTopMenu, iSubMenu, blnKeepLit) {
	
}

function activateDefaultMenu() {
	
}

function wordReplace(findMe, replaceWithMe, inMe, bAddIfNotFound) {
	var arWords = inMe.split(" ");
	var ret = "";
	var bFound = false;
	for ($i=0; $i<arWords.length; $i++)
		if (arWords[$i]==findMe) {
			ret += replaceWithMe + " ";
			bFound = true;
		} else
			ret += arWords[$i] + " ";
	if (bAddIfNotFound && !bFound)
		ret += replaceWithMe + " ";
	return ret;
}
function populateWelcomeText() {

}
function SaveEmail() {
	document.newsletterform.Remove.value="0";
	document.newsletterform.Subject.value="Subscribe to the newsletter";
}
function cleanDefault(searchfield) {
	if (searchfield.defaultValue==searchfield.value)
		searchfield.value = "";
}
function checknumber(x){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(x))
		testresult=true
	else{
		alert("Please input a valid number!")
		testresult=false
	}
	return (testresult)
}
function checkForZero(field) {
	if ((field.value == 0 || field.value.length == 0) && checknumber(field.value)) {
		alert ("This field can't be 0!");
		field.focus();
	}
}
function cmdCalc_Click(form) {
	if ((form.price.value == 0 || form.price.value.length == 0) && checknumber(form.price.value)) {
		alert ("You must enter a valid Price!");
		form.price.focus();
	} else if ((form.ir.value == 0 || form.ir.value.length == 0) && checknumber(form.price.value)) {
		alert ("You must enter a valid Interest Rate!");
		form.ir.focus();
	} else if ((form.term.value == 0 || form.term.value.length == 0) && checknumber(form.price.value)) {
		alert ("You must enter a valid Term!");
		form.term.focus();
	} else
		calculatePayment(form);
}
function calculatePayment(form) {
	var tempPrice = form.price.value
	tempPrice=tempPrice.replace(",", "")
	var tempDP = form.dp.value
	tempDP = tempDP.replace(",", "")
	var princ = tempPrice - tempDP;
	var intRate = (form.ir.value/100);
	var intEffRate = (1+intRate/12)-1;
	var months = form.term.value * 12;
	var paymentsFactor = (1-Math.pow((1/(1+intEffRate)),months))/intEffRate;
	var monthlyPayment = princ/paymentsFactor;
	var totalTopay = (monthlyPayment*months)+tempDP;
	var ResultText = "Mortgage Principle: $"+princ+"<br />";
	ResultText = ResultText+"Number of Payments: "+months+"<br />";
	ResultText = ResultText+"Monthly Payment: $"+Math.ceil(monthlyPayment)+"<br />";
	ResultText = ResultText+"Total Amount Paid over the life of the loan: $"+Math.ceil(totalTopay)+"<br />";
	document.getElementById('mortgagecalculatorresults').innerHTML = ResultText;
}
function showImageArticle (nextImage) {

}
function articleCallback() {
	//call the init method on the proxy object to determine if the user is logged in
	slFB.init(initFB);
}
function initFB() {
	refreshFBInterface();
}
function refreshFBInterface() {
	if (slFB.connectEnabled()) {
		// Add any code required for the iface "fix up" here
	} else {
	}
}
function showHideSearchOption(option,searchForm) {
	// option - what option should be visible
	// searchForm - which search form are we working with
	var onElementId = option;
	var offElementId = 'reg'
	var region = null;
	var community = null;
	var radius = null;
	if (searchForm == '2') {
		region = regionSelect2;
		community = communitySelect2;
		tempZip = document.quickSearch2.tempZipValue2.value;
		tempRadius = document.quickSearch2.tempRadiusValue2.value;
		tempRegion = document.quickSearch2.tempRegionValue2.value;
		tempCommunity = document.quickSearch2.tempCommunityValue2.value;
		radius = document.quickSearch2.distance;
		if (comSwiftRERegionSearch2 == 0) {
			option = 'city';
			var searchOption = document.getElementById('searchOption'+searchForm);
			if (searchOption) {
				searchOption.style.display = 'none';
				document.getElementById('swiftOption'+searchForm+"2").checked=true
				document.getElementById('swiftOption'+searchForm+"1").checked=false;
			}
		}
	} else if (searchForm == '3') {
		region = regionSelect3;
		community = communitySelect3;
		tempZip = document.quickSearch3.tempZipValue3.value;
		tempRadius = document.quickSearch3.tempRadiusValue3.value;
		tempRegion = document.quickSearch3.tempRegionValue3.value;
		tempCommunity = document.quickSearch3.tempCommunityValue3.value;
		radius = document.quickSearch3.distance;
		if (comSwiftRERegionSearch3 == 0) {
			option = 'city';
			var searchOption = document.getElementById('searchOption'+searchForm);
			if (searchOption) {
				searchOption.style.display = 'none';
				document.getElementById('swiftOption'+searchForm+"2").checked=true
				document.getElementById('swiftOption'+searchForm+"1").checked=false;
			}
		}
	} else if (searchForm == '4') {
		region = regionSelect4;
		community = communitySelect4;
		tempZip = document.quickSearch4.tempZipValue4.value;
		tempRadius = document.quickSearch4.tempRadiusValue4.value;
		tempRegion = document.quickSearch4.tempRegionValue4.value;
		tempCommunity = document.quickSearch4.tempCommunityValue4.value;
		radius = document.quickSearch4.distance;
		if (comSwiftRERegionSearch4 == 0) {
			option = 'city';
			var searchOption = document.getElementById('searchOption'+searchForm);
			if (searchOption) {
				searchOption.style.display = 'none';
				document.getElementById('swiftOption'+searchForm+"2").checked=true
				document.getElementById('swiftOption'+searchForm+"1").checked=false;
			}
		}
	} else if (searchForm == '5') {
		region = regionSelect5;
		community = communitySelect5;
		tempZip = document.quickSearch5.tempZipValue5.value;
		tempRadius = document.quickSearch5.tempRadiusValue5.value;
		tempRegion = document.quickSearch5.tempRegionValue5.value;
		tempCommunity = document.quickSearch5.tempCommunityValue5.value;
		radius = document.quickSearch5.distance;
		if (comSwiftRERegionSearch5 == 0) {
			option = 'city';
			var searchOption = document.getElementById('searchOption'+searchForm);
			if (searchOption) {
				searchOption.style.display = 'none';
				document.getElementById('swiftOption'+searchForm+"2").checked=true
				document.getElementById('swiftOption'+searchForm+"1").checked=false;
			}
		}
	} else {
		region = regionSelect;
		community = communitySelect;
		tempZip = document.quickSearch1.tempZipValue1.value;
		tempRadius = document.quickSearch1.tempRadiusValue1.value;
		tempRegion = document.quickSearch1.tempRegionValue1.value;
		tempCommunity = document.quickSearch1.tempCommunityValue1.value;
		radius = document.quickSearch1.distance;
		if (comSwiftRERegionSearch1 == 0) {
			option = 'city';
			var searchOption = document.getElementById('searchOption'+searchForm);
			if (searchOption) {
				searchOption.style.display = 'none';
				document.getElementById('swiftOption'+searchForm+"2").checked=true
				document.getElementById('swiftOption'+searchForm+"1").checked=false;
			}
		}
	}
	// check to see if regions are available
	// if not, default to city and hide radio buttons
	if (regionList.length < 1) {
		option = 'city';
		var searchOption = document.getElementById('searchOption'+searchForm);
		if (searchOption) {
			searchOption.style.display = 'none';
		}
	}
	if (option == 'reg') {
		// default region
		if (tempRegion == "DEFAULT") {
			region.selectedIndex = comSwiftRERegion;
		} else {
			region.selectedIndex = tempRegion;
		}
		fillCommunities(region,community);
		if (tempCommunity != "DEFAULT") {
			community.selected = true;
			if (tempCommunity.search(/|/i) > -1) {
				var tempCommunitySelectedList = tempCommunity.split ("|");
				for (var i = 0; i < tempCommunitySelectedList.length; i++) {
					community.options[tempCommunitySelectedList[i]].selected = true;
				}
			} else {
				community.selectedIndex = tempCommunity;
			}
		}
		offElementId = 'city';
		if (radius != null) {
			radius.selected = false;
			radius.selectedIndex = '';
		}
	} else {
		// clear region
		if (radius != null) {
			radius.selected = true;
			if (tempRadius == "DEFAULT") {
				radius.selectedIndex = 1;
			} else {
				radius.selectedIndex = tempRadius;
			}
		}
		region.selected = false;
		region.selectedIndex = '';
		community.selected = false;
		community.selectedIndex = '';
		fillCommunities(region,community);
	}
	var msie = ((navigator.appVersion.indexOf("MSIE")!= -1)&&!window.opera)? true : false;
	var rowStyle = 'inline';
	if (!msie) rowStyle = 'table-row';
	var onElement1 = document.getElementById(onElementId+searchForm+'1');
	var offElement1 = document.getElementById(offElementId+searchForm+'1');
	onElement1.style.display = rowStyle;
	offElement1.style.display = 'none';
}
function selectCurrentOption() {
	var swiftOption2 = document.getElementById("swiftOption2");
	if (swiftOption2 != null) {
		if (swiftOption2.checked) {
			showHideSearchOption('city','1');
		}
	}
	var swiftOption4 = document.getElementById("swiftOption4");
	if (swiftOption4 != null) {
		if (swiftOption4.checked) {
			showHideSearchOption('city','2');
		}
	}
	var swiftOption6 = document.getElementById("swiftOption6");
	if (swiftOption6 != null) {
		if (swiftOption6.checked) {
			showHideSearchOption('city','3');
		}
	}
	var swiftOption8 = document.getElementById("swiftOption8");
	if (swiftOption8 != null) {
		if (swiftOption8.checked) {
			showHideSearchOption('city','4');
		}
	}
	var swiftOption10 = document.getElementById("swiftOption10");
	if (swiftOption10 != null) {
		if (swiftOption10.checked) {
			showHideSearchOption('city','5');
		}
	}
}
function clearZip(cityObject, searchForm) {
}
function updateTempZip(zipObject, searchForm) {
}
function updateTempRegion(regionObject, searchForm) {
	document.getElementById("tempRegionValue"+searchForm).value=regionObject.selectedIndex;
}
function updateTempComunity(communityObject, searchForm) {
	var communitySelectedList = "";
	var communitySelectedListSeparator = ""
	for (var i = 0; i < communityObject.options.length; i++) {
		if (communityObject.options[i].selected) {
			communitySelectedList = communitySelectedListSeparator+i;
			communitySelectedListSeparator = "|";
		}
	}
	document.getElementById("tempCommunityValue"+searchForm).value=communitySelectedList;
}
function updateTempRadius(radiusObject, searchForm) {
	document.getElementById("tempRadiusValue"+searchForm).value=radiusObject.selectedIndex;
}
function search_date() {
	month=document.getElementById("month").value;
	day=document.getElementById("day").value;
	year=document.getElementById("year").value;
	var daterange = "";
	var endDate = new Date();
	if (year == "") {
		daterange = '19980101,'+endDate.getFullYear()+''+((endDate.getMonth()<9)?'0'+(endDate.getMonth()+1):(endDate.getMonth()+1))+''+((endDate.getDate()<10)?'0'+endDate.getDate():endDate.getDate());
		document.date.IncludeNoDateArt.value = 0
	} else if (month == "")
		daterange = year+'0101,'+year+'1231';
	else if (day == "")
		daterange = year+''+month+'01,'+year+''+month+'31';
	else
		daterange = year+''+month+''+day+','+year+''+month+''+day;
	document.date.daterange.value=daterange;
}
function trim (str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

function validateText(fieldId, blnRequired, errLabelId) {
	e = document.getElementById(fieldId);
	errId = errLabelId==null?(fieldId + "-error"):errLabelId;
	eErrMsg = document.getElementById(errId);
	if (blnRequired && (trim(e.value)=="")) {
		if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> this field is required</span>";
		return false;
	} else {
		if (eErrMsg) eErrMsg.innerHTML = "";
		return true;
	}
}

function validateEmail(fieldId, blnRequired, errLabelId) {
	e = document.getElementById(fieldId);
	errId = errLabelId==null?(fieldId + "-error"):errLabelId;
	eErrMsg = document.getElementById(errId);
	if (blnRequired && (trim(e.value)=="")) {
		if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> this field is required</span>";
		return false;
	} else {
		/* Thanks to Ramesh Javale, http://dreamtechworld.wordpress.com/2008/06/10/email-validation-using-javascript/ */
		//regex email verification version 1:
		var emailStr = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

		//regex email verification version 2 - adds <..>@q.<..> email addresses, for any single letter replacing 'q'
		var emailStr2 = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@([a-zA-Z0-9][\w\.-]+)*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

		/*regex email verification version 2 - adds <..>@qq.<..> email addresses, for any double letter combo
		replacing 'qq', and allowing the trailing <..> to contain (but not end with) an underscore or number*/

		var emailStr3 = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9]*([a-zA-Z0-9][\w\.-]+)*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\._]*[a-zA-Z]$/;

		var emailStr4 = /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9]*([a-zA-Z0-9][\w\.-]+)*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\._]*[a-zA-Z]$/;

		if (emailStr4.test(e.value) == false) {
			if (eErrMsg) eErrMsg.innerHTML = " invalid email address";
			return false;
		} else {
			if (eErrMsg) eErrMsg.innerHTML = "";
			return true;
		}
	}
}

function validatePhoneNumber(fieldId, blnRequired) {
	e = document.getElementById(fieldId);
	val = trim(e.value);
	eErrMsg = document.getElementById(fieldId + "-error");
	if (blnRequired && (val=="")) {
		if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> this field is required</span>";
		return false;
	} else if (val != "") {
		var exp = /^1?\d{10}$|^(1\s)?\(\d{3}\)\s?\d{3}[.-]\d{4}$|^(1[ .-])?\d{3}[ .-]?\d{3}[ .-]?\d{4}|\+.?$/
		if (exp.test(val)) {
			if (eErrMsg) eErrMsg.innerHTML = "";
			return true;
		} else {
			if (eErrMsg) eErrMsg.innerHTML = " phone number invalid. Example: 530-477-4257";
			return false;
		}
	} else {
		if (eErrMsg) eErrMsg.innerHTML = "";
		return true;
	}
}

function validateInteger(fieldId, blnRequired, intMin, intMax) {
	e = document.getElementById(fieldId);
	val = trim(e.value);
	eErrMsg = document.getElementById(fieldId + "-error");
	if (blnRequired && (val=="")) {
		if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> this field is required</span>";
		return false;
	} else if (val != "") {
		var exp = /^-?\d+$/
		if (exp.test(val)) {
			var num = Number(val);
			if ((intMin != null)&&(num < intMin)) {
				if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> number is less than the minimum value of " + intMin + "</span>";
				return false;
			} else if ((intMax != null) && (num > intMax)) {
				if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> number is greater than the maximum value of " + intMax + "</span>";
				return false;
			} else {
				if (eErrMsg) eErrMsg.innerHTML = "";
				return true;
			}
		} else {
			if (eErrMsg) eErrMsg.innerHTML = " number invalid";
			return false;
		}
	} else {
		if (eErrMsg) eErrMsg.innerHTML = "";
		return true;
	}
}

function validateCurrency(fieldId, blnRequired, intMin, intMax) {
	e = document.getElementById(fieldId);
	val = trim(e.value);
	eErrMsg = document.getElementById(fieldId + "-error");
	if (blnRequired && (val=="")) {
		if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> this field is required</span>";
		return false;
	} else if (val != "") {
		var exp = /^\$?-?\d+(.\d\d?)?$/
		if (exp.test(val)) {
			var num = Number(val);
			if ((intMin != null)&&(num < intMin)) {
				if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> number is less than the minimum value of " + intMin + "</span>";
				return false;
			} else if ((intMax != null) && (num > intMax)) {
				if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> number is greater than the maximum value of " + intMax + "</span>";
				return false;
			} else {
				if (eErrMsg) eErrMsg.innerHTML = "";
				return true;
			}
		} else {
			if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> number invalid</span>";
			return false;
		}
	} else {
		if (eErrMsg) eErrMsg.innerHTML = "";
		return true;
	}
}

function validateTextArea(fieldId, blnRequired, intMaxWords) {
	e = document.getElementById(fieldId);
	val = trim(e.value);
	eErrMsg = document.getElementById(fieldId + "-error");
	if (blnRequired && (val=="")) {
		if (eErrMsg) eErrMsg.innerHTML = "<span class='formsError'> this field is required</span>";
		return false;
	} else if (intMaxWords > 0) {
		return validateWordCount(fieldId, intMaxWords);
	} else {
		if (eErrMsg) eErrMsg.innerHTML = "";
		return true;
	}
}

function validateWordCount(fieldId, intMaxWords) {
	e = document.getElementById(fieldId);
	val = trim(e.value);
	eErrMsg = document.getElementById(fieldId + "-error");
	iWordCount = wordCount(val);
	if ((intMaxWords > 0) && (iWordCount > intMaxWords)) {
		if (eErrMsg) {
			eErrMsg.className = "formsError";
			eErrMsg.innerHTML = "<span class='formsError'> max word count of " + intMaxWords + " exceeded by " + (iWordCount-intMaxWords) + " words.</span>";
		}
		return true;
	} else {
		if (eErrMsg) {
			eErrMsg.className = "statusMsg";
			eErrMsg.innerHTML = "word count: " + iWordCount + " of " + intMaxWords;
		}
		return true;
	}
}

function wordCount(str) {
	var str1 = str.replace(/\s+/g," ");		// drop multiple spaces, replacing with a single space
	var ar = str1.split(" ");
	return ar.length;
}
/*****************************
** My Membership Pop Up
*****************************/
function viewMyMembershipPopUp() {
	document.getElementById('myMembershipPopUp').style.display="block";
	document.getElementById('myMembershipPopUpFooter').style.display="block";
	document.getElementById('myMembershipPopUpFooter').style.minHeight="8px";
	document.getElementById('myMembershipPopUp').style.minHeight="65px";
	document.getElementById('myMembershipPopUpFooter').style.top="-20px";
	document.getElementById('myMembershipPopUp').style.top="-20px";
	document.getElementById('myMembershipTab').style.display="block";
	document.getElementById('linkMyMembership').style.visibility = 'hidden';
	document.getElementById('linkMyMembership').style.display = 'none';
}
function closeMyMembershipPopUp() {
	document.getElementById('myMembershipPopUpFooter').style.display="none";
	document.getElementById('myMembershipPopUp').style.display="none";
	document.getElementById('myMembershipPopUpFooter').style.height="0px";
	document.getElementById('myMembershipPopUp').style.height="0px";
	document.getElementById('myMembershipTab').style.display="none";
	document.getElementById('linkMyMembership').style.display = 'inline';
	document.getElementById('linkMyMembership').style.visibility = 'visible';
}
/*****************************
** Logon Code               **
*****************************/
function openLogonPopUp() {
	var currentURL = encodeURIComponent(document.URL);
	location.href = appsPath + "/utils/ureg/ui/logon.php?returnURL=" + currentURL;
	return false;
	/* document.getElementById('logonPopUp').style.display="block";
	document.getElementById('logonPopUpFooter').style.display="block";
	document.getElementById('logonPopUpFooter').style.minHeight="8px";
	document.getElementById('logonPopUp').style.minHeight="130px";
	document.getElementById('logonPopUpFooter').style.top="-20px";
	document.getElementById('logonPopUp').style.top="-20px";
	document.getElementById('logonTab').style.display="block";
	document.getElementById('linkLogin').style.visibility = 'hidden';
	document.getElementById('linkLogin').style.display = 'none';
	document.getElementById('logon_email').focus(); */
}
/* function closeLogonPopUp() {
	document.getElementById('logonPopUpFooter').style.display="none";
	document.getElementById('logonPopUp').style.display="none";
	document.getElementById('logonPopUpFooter').style.height="0px";
	document.getElementById('logonPopUp').style.height="0px";
	document.getElementById('logonTab').style.display="none";
	document.getElementById('linkLogin').style.display = 'inline';
	document.getElementById('linkLogin').style.visibility = 'visible';
} */

/*
 * THE SSO/AUTH KEY IS NOW SET VIA PHP EXCLUSIVELY
 * 
function setCookie(ssokey, emailaddress, screenname, rememberme, cookieDomain) {
	var cookie_value = ssokey + "|" + screenname + "||" + emailaddress;
	if (rememberme == "YES") {
		// set cookie expires out a year
		var cookie_date = new Date ( );  // current date & time
		cookie_date.setFullYear(cookie_date.getFullYear() + 2);
		document.cookie = "HD" + "=" + cookie_value + "; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
	} else {
		// session cookie
		document.cookie = "HD" + "=" + cookie_value + "; domain=" + cookieDomain + ";path=/";
	}
}
*/

// COOKIE VALUE RETRIEVAL - and SSO COOKIE HANDLING
function getCookie(c_name) {
	if (document.cookie.length>0) {
		var c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
			c_start=c_start + c_name.length+1; 
			var c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
function retrieveSSOCookieUserId() {
	var cookieValue = getCookie("AT");
	var cookieValue2 = getCookie("suicSwift");
	if (cookieValue.length > 0 && cookieValue2.length > 0) {
		return getKeyValueFromStr(cookieValue, "u");
	} else if (cookieValue.length > 0 || cookieValue2.length > 0) {
		var cookie_date = new Date ( );  // current date & time
		cookie_date.setFullYear ( cookie_date.getFullYear() - 1 );
		document.cookie = "AT" + "=; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
		document.cookie = "suicSwift" + "=; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
		return "";
	} else {
		return "";
	}
}
function RetrieveSSOCookieDisplayName() {
	var cookieValue = getCookie("AT");
	var cookieValue2 = getCookie("suicSwift");
	if (cookieValue.length > 0 && cookieValue2.length > 0) {
		return getKeyValueFromStr(cookieValue, "a");
	} else if (cookieValue.length > 0 || cookieValue2.length > 0) {
		var cookie_date = new Date ( );  // current date & time
		cookie_date.setFullYear ( cookie_date.getFullYear() - 1 );
		document.cookie = "AT" + "=; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
		document.cookie = "suicSwift" + "=; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
		return "";
	} else {
		return "";
	}
}
function logout(cookieDomain, redirectOnLogout) {
	// remove AT cookie
	var cookie_date = new Date ( );  // current date & time
	cookie_date.setFullYear ( cookie_date.getFullYear() - 1 );
	document.cookie = "AT" + "=; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
	document.cookie = "suicSwift" + "=; expires=" + cookie_date.toGMTString() + ";domain=" + cookieDomain + ";path=/";
	// refresh the current document; if we need to redirect away from the caller, go to the update page
	if (redirectOnLogout)
		window.location.href=appsPath + "/utils/ureg/ui/updateaccount.php?showLogoutSuccessful=true";
	else
		location.reload(true);
}
function NewWindow(width,height,url) {
	window.open(url,"PopUp","menubar=0,scrollbars=1,resizable=1,height="+height+",width="+width);
}
/* Used to activate a tab and its content for any of the right column widgets */
function activateWidgetTab(widgetPrefix,tabToActivate) {
	var cnt = 0;
	if (eleft = document.getElementById(widgetPrefix+cnt+".l"))
		if (tabToActivate==0)
			eleft.className = eleft.className.replace(/left_off/, "left_on");
		else
			eleft.className = eleft.className.replace(/left_on/, "left_off");
	while ((emid = document.getElementById(widgetPrefix+cnt+".m")) && (eright = document.getElementById(widgetPrefix+cnt+".r"))) {
		erightnext = document.getElementById(widgetPrefix+(cnt+1)+".r");
		if (tabToActivate == cnt) {
			emid.className = emid.className.replace(/off/, "on");
			if (erightnext)
				eright.className = eright.className.replace(new RegExp("_offon|_offoff", "g" ), "_onoff");
			else
				eright.className = eright.className.replace(/right_off/, "right_on");
			if (econtent = document.getElementById(widgetPrefix+(cnt)+".c")) econtent.style.display = "block";
		} else {
			emid.className = emid.className.replace(/on/, "off");
			if (erightnext)
				eright.className = eright.className.replace(new RegExp("_offon|_onoff|_offoff", "g"), tabToActivate==(cnt+1)?"_offon":"_offoff");
			else
				eright.className = eright.className.replace(/right_on/, "right_off");
			if (econtent = document.getElementById(widgetPrefix+(cnt)+".c")) econtent.style.display = "none";
		}
		cnt++;
	}
	return false;
}
function activateWidgetTabNew(widgetPrefix,tabToActivate) {
	var cnt = 0;
	while ((emid = document.getElementById(widgetPrefix+cnt+".m")) && (eright = document.getElementById(widgetPrefix+cnt+".r"))) {
		eleft = document.getElementById(widgetPrefix+(cnt)+".l");
		if (tabToActivate == cnt) {
			emid.className = emid.className.replace(/off/, "on");
			eright.className = eright.className.replace(/off/, "on");
			if (eleft = document.getElementById(widgetPrefix+(cnt)+".l")) eleft.className = eright.className.replace(/off/, "on");
			if (econtent = document.getElementById(widgetPrefix+(cnt)+".c")) econtent.style.display = "block";
		} else {
			emid.className = emid.className.replace(/on/, "off");
			eright.className = eright.className.replace(/on/, "off");
			if (eleft = document.getElementById(widgetPrefix+(cnt)+".l")) eleft.className = eright.className.replace(/on/, "off");
			if (econtent = document.getElementById(widgetPrefix+(cnt)+".c")) econtent.style.display = "none";
		}
		cnt++;
	}
	return false;
}
/* Used to activate a tab and its content for any of the right column widgets */
function switchTabStatus(widgetPrefix) {
	var cnt = 0;
	if (emid = document.getElementById(widgetPrefix)) {
		if (emid.className.search(/on/i)>=0)
			emid.className = emid.className.replace(/on/ig, "off");
		else
			emid.className = emid.className.replace(/off/ig, "on");
	}
	return false;
}
/* Great function for debugging: returns output for an object tree
   Call like this:
   		alert(dumpObj(myObject, "myobjectname", "", 0));
*/
var MAX_DUMP_DEPTH = 10;
function dumpObj(obj, name, indent, depth) {
	if (depth > MAX_DUMP_DEPTH) {
		return indent + name + ": <Maximum Depth Reached>\n";
	}
	if (typeof obj == "object") {
		var child = null;
		var output = indent + name + "\n";
		indent += "\t";
		for (var item in obj) {
			try {
				child = obj[item];
			} catch (e) {
				child = "<Unable to Evaluate>";
			}
			if (typeof child == "object") {
				output += dumpObj(child, item, indent, depth + 1);
			} else {
				output += indent + item + ": " + child + "\n";
			}
		}
		return output;
	} else {
		return obj;
	}
}
function multipleFormSubmit(formSubmitButton) {
	document.getElementById(formSubmitButton).disabled=true;
	var d = new Date();
	var tempValue = hex_md5(document.getElementById("formId").value);
	tempValue = tempValue.concat(d.getTime());
	if (document.getElementById("formMultipleIdSubmit").value == "") {
		document.getElementById("formMultipleIdSubmit").value = tempValue;
		return true;
	} else {
		return false;
	}
}
//////////////////////////////////////////////////////////////////////////////
///////// Logon Script End //////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
///////// Text Preview Script ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

g_intTPOpac = 0;
g_blnTPFadingIn = false;
g_tFadeIn = null;
function showTextPreview(objArtLink, strArtText){
	g_blnTPFadingIn = true;
	var coordsLink = findPos(objArtLink);	// gets coordsLink in absolute coordinates
	var div = document.getElementById('textPreview');	// this is the main text preview box
	var coordsDivAdj = findPos(div.offsetParent);
	var divText = document.getElementById('textPreviewText');	// inner text div
	divText.innerHTML = strArtText;
	div.style.position = "absolute";	// just make sure it is absolutely positioned
	div.style.left = (coordsLink[0]-coordsDivAdj[0])+"px";	// align box with left of link
	div.style.top = (coordsLink[1]+objArtLink.offsetHeight-coordsDivAdj[1])+"px";	// bottom of link
	//document.body.appendChild(div);		// Sometimes textPreview is not a parent of body, so the coordsLink are relative to it's parent.  This ensures coordsLink are absolute.
	fadeIn("textPreview");
	if (document.getElementsByTagName) {
		if (!objArtLink.Overlap) {
			objArtLink.Overlap = new Array ();
			HideControl ("IFRAME", document.getElementById("textPreview"), objArtLink);
			HideControl ("SELECT", document.getElementById("textPreview"), objArtLink);
			HideControl ("OBJECT", document.getElementById("textPreview"), objArtLink);
			HideControl ("EMBED", document.getElementById("textPreview"), objArtLink);
		}
	}
	return false;
}
function hideTextPreview(objArtLink){
	clearTimeout(g_tFadeIn);
	g_blnTPFadingIn = false;
	fadeOut('textPreview');
	ShowControl (objArtLink);
	return false;
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
function fadeIn(layerId){
	var div = document.getElementById(layerId);
	if (div.style.visibility!="visible") div.style.visibility="visible";
}
function fadeOut(layerId){
	var div = document.getElementById(layerId);
	div.style.visibility = "hidden";
}
function HideControl (tagName, subMenu, mainMenu) {
	var agt=navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var x = GetX (subMenu);
	var y = GetY (subMenu);
	var w = subMenu.offsetWidth;
	var h = subMenu.offsetHeight;
	var i;
	for (i = 0; i < document.getElementsByTagName(tagName).length; ++i) {
		var obj = document.getElementsByTagName(tagName)[i];
		if (!obj || !obj.offsetParent)
			continue;
		var ox = GetX (obj);
		var oy = GetY (obj);
		var ow = obj.offsetWidth;
		var oh = obj.offsetHeight;
		if (ox > (x + w) || (ox + ow) < x)
			continue;
		if (oy > (y + h) || (oy + oh) < y)
			continue;
		if(obj.style.visibility == "hidden")
			continue;
		mainMenu.Overlap[mainMenu.Overlap.length] = obj;
		obj.style.visibility = "hidden";
	}
}
function ShowControl (subMenu) {
	var agt=navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	if (subMenu.Overlap) {
		var i;
		for (i = 0; i < subMenu.Overlap.length; ++i) {
			subMenu.Overlap[i].style.visibility = "visible";
		}
	}
	subMenu.Overlap = null;
}
function GetX (obj) {
	var x = 0;
	do {
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	} while (obj);
	return x;
}
function GetY (obj) {
	var y = 0;
	do {
		y += obj.offsetTop;
		obj = obj.offsetParent;
	} while (obj);
	return y;
}

//////////////////////////////////////////////////////////////////////////////
///////// Text Preview Script End ////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
///////// Webtrends Script ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

// WebTrends SmartSource Data Collector Tag
// Version: 8.6.1	 
// Tag Builder Version: 2.2
// Created: 3/16/2009 5:15:49 PM
function WebTrends(gDcsId,gTimeZone,gFPCDom,gOnSiteDom){
	var that=this;
	// begin: user modifiable
	this.dcsid=gDcsId;
	this.domain="wt-sdc.swiftcom.com";
	this.timezone=gTimeZone;
	this.fpcdom=gFPCDom;
	this.onsitedoms=gOnSiteDom;
	this.navigationtag="DIV";
	this.metanames="WT.au,WT.site,WT.viewed,WT.published,WT.published,WT.Classified_Dealers";
	this.trackevents=true;
	this.trimoffsiteparams=false;
	this.enabled=true;
	this.i18n=false;
	this.fpc="WT_FPC";
	this.paidsearchparams="gclid";
	// end: user modifiable
	this.DCS={};
	this.WT={};
	this.DCSext={};
	this.images=[];
	this.index=0;
	this.exre=(function(){return(window.RegExp?new RegExp("dcs(uri)|(ref)|(aut)|(met)|(sta)|(sip)|(pro)|(byt)|(dat)|(p3p)|(cfg)|(redirect)|(cip)","i"):"");})();
	this.re=(function(){return(window.RegExp?(that.i18n?{"%25":/\%/g}:{"%09":/\t/g,"%20":/ /g,"%23":/\#/g,"%26":/\&/g,"%2B":/\+/g,"%3F":/\?/g,"%5C":/\\/g,"%22":/\"/g,"%7F":/\x7F/g,"%A0":/\xA0/g}):"");})();
}
WebTrends.prototype.dcsQuantcast = function(){
	var i,val,val2;
	var WT=this.WT;
	var dcsEncode=this.dcsEncode;
	var keys=["mc_id","pi","oss"];
	var cg_n=WT.cg_n?WT.cg_n.split(";"):[];
	var cg_s=WT.cg_s?WT.cg_s.split(";"):[];
	var si_n=WT.si_n?WT.si_n.split(";"):[];
	var si_x=WT.si_x?WT.si_x.split(";"):[];
	var si_p=WT.si_p?WT.si_p.split(";"):[];
	var result="";
	for (i=0;i<keys.length;i++){
		val=WT[keys[i]]||"";
		if (val.length>0){
			result+=(result.length?",":"")+"WT."+keys[i]+"."+dcsEncode(val);
		}
	}
	for (i=0;i<cg_n.length;i++){
		result+=(result.length?",":"")+"WT.cg."+dcsEncode(cg_n[i]);
		val=cg_s[i]||"";
		if (val.length>0){
			result+="."+dcsEncode(val);
		}
	}
	for (i=0;i<si_n.length;i++){
		result+=(result.length?",":"")+"WT.si."+dcsEncode(si_n[i]);
		val=si_x[i]||"";
		val2=si_p[i]||"";
		if (val.length>0){
			result+="."+dcsEncode(val);
		}
		else if (val2.length>0){
			result+="."+dcsEncode(val2);
		}
	}
	return result;
}
WebTrends.prototype.dcsGetId=function(){
	if (this.enabled&&(document.cookie.indexOf(this.fpc+"=")==-1)&&(document.cookie.indexOf("WTLOPTOUT=")==-1)){
		document.write("<scr"+"ipt type='text/javascript' src='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+this.domain+"/"+this.dcsid+"/wtid.js"+"'><\/scr"+"ipt>");
	}
}
WebTrends.prototype.dcsGetCookie=function(name){
	var cookies=document.cookie.split("; ");
	var cmatch=[];
	var idx=0;
	var i=0;
	var namelen=name.length;
	var clen=cookies.length;
	for (i=0;i<clen;i++){
		var c=cookies[i];
		if ((c.substring(0,namelen+1))==(name+"=")){
			cmatch[idx++]=c;
		}
	}
	var cmatchCount=cmatch.length;
	if (cmatchCount>0){
		idx=0;
		if ((cmatchCount>1)&&(name==this.fpc)){
			var dLatest=new Date(0);
			for (i=0;i<cmatchCount;i++){
				var lv=parseInt(this.dcsGetCrumb(cmatch[i],"lv"));
				var dLst=new Date(lv);
				if (dLst>dLatest){
					dLatest.setTime(dLst.getTime());
					idx=i;
				}
			}
		}
		return unescape(cmatch[idx].substring(namelen+1));
	}
	else{
		return null;
	}
}
WebTrends.prototype.dcsGetCrumb=function(cval,crumb,sep){
	var aCookie=cval.split(sep||":");
	for (var i=0;i<aCookie.length;i++){
		var aCrumb=aCookie[i].split("=");
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
WebTrends.prototype.dcsGetIdCrumb=function(cval,crumb){
	var id=cval.substring(0,cval.indexOf(":lv="));
	var aCrumb=id.split("=");
	for (var i=0;i<aCrumb.length;i++){
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
WebTrends.prototype.dcsIsFpcSet=function(name,id,lv,ss){
	var c=this.dcsGetCookie(name);
	if (c){
		return ((id==this.dcsGetIdCrumb(c,"id"))&&(lv==this.dcsGetCrumb(c,"lv"))&&(ss==this.dcsGetCrumb(c,"ss")))?0:3;
	}
	return 2;
}
WebTrends.prototype.dcsFPC=function(){
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var WT=this.WT;
	var name=this.fpc;
	var dCur=new Date();
	var adj=(dCur.getTimezoneOffset()*60000)+(this.timezone*3600000);
	dCur.setTime(dCur.getTime()+adj);
	var dExp=new Date(dCur.getTime()+315360000000);
	var dSes=new Date(dCur.getTime());
	WT.co_f=WT.vtid=WT.vtvs=WT.vt_f=WT.vt_f_a=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
	if (document.cookie.indexOf(name+"=")==-1){
		if ((typeof(gWtId)!="undefined")&&(gWtId!="")){
			WT.co_f=gWtId;
		}
		else if ((typeof(gTempWtId)!="undefined")&&(gTempWtId!="")){
			WT.co_f=gTempWtId;
			WT.vt_f="1";
		}
		else{
			WT.co_f="2";
			var curt=dCur.getTime().toString();
			for (var i=2;i<=(32-curt.length);i++){
				WT.co_f+=Math.floor(Math.random()*16.0).toString(16);
			}
			WT.co_f+=curt;
			WT.vt_f="1";
		}
		if (typeof(gWtAccountRollup)=="undefined"){
			WT.vt_f_a="1";
		}
		WT.vt_f_s=WT.vt_f_d="1";
		WT.vt_f_tlh=WT.vt_f_tlv="0";
	}
	else{
		var c=this.dcsGetCookie(name);
		var id=this.dcsGetIdCrumb(c,"id");
		var lv=parseInt(this.dcsGetCrumb(c,"lv"));
		var ss=parseInt(this.dcsGetCrumb(c,"ss"));
		if ((id==null)||(id=="null")||isNaN(lv)||isNaN(ss)){
			return;
		}
		WT.co_f=id;
		var dLst=new Date(lv);
		WT.vt_f_tlh=Math.floor((dLst.getTime()-adj)/1000);
		dSes.setTime(ss);
		if ((dCur.getTime()>(dLst.getTime()+1800000))||(dCur.getTime()>(dSes.getTime()+28800000))){
			WT.vt_f_tlv=Math.floor((dSes.getTime()-adj)/1000);
			dSes.setTime(dCur.getTime());
			WT.vt_f_s="1";
		}
		if ((dCur.getDay()!=dLst.getDay())||(dCur.getMonth()!=dLst.getMonth())||(dCur.getYear()!=dLst.getYear())){
			WT.vt_f_d="1";
		}
	}
	WT.co_f=escape(WT.co_f);
	WT.vtid=(typeof(this.vtid)=="undefined")?WT.co_f:(this.vtid||"");
	WT.vtvs=(dSes.getTime()-adj).toString();
	var expiry="; expires="+dExp.toGMTString();
	var cur=dCur.getTime().toString();
	var ses=dSes.getTime().toString();
	document.cookie=name+"="+"id="+WT.co_f+":lv="+cur+":ss="+ses+expiry+"; path=/"+(((this.fpcdom!=""))?("; domain="+this.fpcdom):(""));
	var rc=this.dcsIsFpcSet(name,WT.co_f,cur,ses);
	if (rc!=0){
		WT.co_f=WT.vtvs=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
		if (typeof(this.vtid)=="undefined"){
			WT.vtid="";
		}
		WT.vt_f=WT.vt_f_a=rc;
	}
}
// Code section for Enable SmartView Transition Page tracking
WebTrends.prototype.dcsTP=function(){
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var name="WT_DC";
	var expiry="; expires=Thu, 31-Dec-2020 08:00:00 GMT";
	var pth="; path=/";
	var domain="";
	if (document.cookie.indexOf(name+"=tsp=1")!=-1){
		this.WT.ttp="1";
	}
	if (this.dcsGetMeta("SmartView_Page")=="1"){
		this.WT.tsp="1";
		document.cookie=name+"=tsp=1"+expiry+pth+domain;
	}
	else{
		document.cookie=name+"=; expires=Sun, 1-Jan-1995 00:00:00 GMT;"+pth+domain;
	}
}
WebTrends.prototype.dcsGetMeta=function(name){
	var elems;
	if (document.all){
		elems=document.all.tags("meta");
	}
	else if (document.documentElement){
		elems=document.getElementsByTagName("meta");
	}
	if (typeof(elems)!="undefined"){
		for (var i=1;i<=elems.length;i++){
			var meta=elems.item(i-1);
			if (meta.name&&(meta.name.indexOf(name)==0)){
				return meta.content;
				break;
			}
		}
	}
	return null;
}
WebTrends.prototype.dcsIsOnsite=function(host){
	if (host.length>0){
		host=host.toLowerCase();
		if (host==window.location.hostname.toLowerCase()){
			return true;
		}
		if (typeof(this.onsitedoms.test)=="function"){
			return this.onsitedoms.test(host);
		}
		else if (this.onsitedoms.length>0){
			var doms=this.dcsSplit(this.onsitedoms);
			var len=doms.length;
			for (var i=0;i<len;i++){
				if (host==doms[i]){
					return true;
				}
			}
		}
	}
	return false;
}
WebTrends.prototype.dcsEvt=function(evt,tag){
	var e=evt.target||evt.srcElement;
	while (e.tagName&&(e.tagName!=tag)){
		e=e.parentElement||e.parentNode;
	}
	return e;
}
WebTrends.prototype.dcsNavigation=function(evt){
	var e=this.dcsEvt(evt,this.navigationtag);
	var id=e.getAttribute?e.getAttribute("id"):"";
	var cname=e.className||"";
	return id?id:cname;
}
WebTrends.prototype.dcsBind=function(event,func){
	if ((typeof(func)=="function")&&document.body){
		if (document.body.addEventListener){
			document.body.addEventListener(event, func.wtbind(this), true);
		}
		else if(document.body.attachEvent){
			document.body.attachEvent("on"+event, func.wtbind(this));
		}
	}
}
WebTrends.prototype.dcsET=function(){
	var e=(navigator.appVersion.indexOf("MSIE")!=-1)?"click":"mousedown";
	this.dcsBind(e,this.dcsDynamic);
	this.dcsBind(e,this.dcsFormButton);
	this.dcsBind(e,this.dcsOffsite);
	this.dcsBind(e,this.dcsAnchor);
	this.dcsBind(e,this.dcsImageMap);
}
WebTrends.prototype.dcsMultiTrack=function(){
	var args=dcsMultiTrack.arguments?dcsMultiTrack.arguments:arguments;
	if (args.length%2==0){
		this.dcsSetProps(args);
		var dCurrent=new Date();
		this.DCS.dcsdat=dCurrent.getTime();
		this.dcsFPC();
		this.dcsTag();
	}
}
WebTrends.prototype.dcsCleanUp=function(){
	this.DCS={};
	this.WT={};
	this.DCSext={};
	if (arguments.length%2==0){
		this.dcsSetProps(arguments);
	}
}
WebTrends.prototype.dcsSetProps=function(args){
	for (var i=0;i<args.length;i+=2){
		if (args[i].indexOf('WT.')==0){
			this.WT[args[i].substring(3)]=args[i+1];
		}
		else if (args[i].indexOf('DCS.')==0){
			this.DCS[args[i].substring(4)]=args[i+1];
		}
		else if (args[i].indexOf('DCSext.')==0){
			this.DCSext[args[i].substring(7)]=args[i+1];
		}
	}
}
WebTrends.prototype.dcsSplit=function(list){
	var items=list.toLowerCase().split(",");
	var len=items.length;
	for (var i=0;i<len;i++){
		items[i]=items[i].replace(/^\s*/,"").replace(/\s*$/,"");
	}
	return items;
}
// Code section for Track clicks to dynamic links.
WebTrends.prototype.dcsDynamic=function(evt){
	evt=evt||(window.event||"");
	if (evt&&((typeof(evt.which)!="number")||(evt.which==1))){
		var e=this.dcsEvt(evt,"A");
		if (e.href&&e.protocol){
			var qry=e.search?e.search.substring(e.search.indexOf("?")+1,e.search.length):"";
			if (e.protocol=="javascript:"){
				this.dcsMultiTrack("DCS.dcssip","","DCS.dcsuri",e.href,"WT.ti","JavaScript:"+e.innerHTML,"WT.dl","22","WT.nv",this.dcsNavigation(evt));
				this.DCS.dcssip=this.DCS.dcsuri=this.WT.ti=this.WT.cl=this.WT.nv="";
			}
			else if (e.protocol=="mailto:"){
				this.dcsMultiTrack("DCS.dcssip","","DCS.dcsuri",e.href,"WT.ti","MailTo:"+e.innerHTML,"WT.dl","23","WT.nv",this.dcsNavigation(evt));
				this.DCS.dcssip=this.DCS.dcsuri=this.WT.ti=this.WT.dl=this.WT.nv="";
			}
		}
	}
}
// Code section for Track form button clicks.
WebTrends.prototype.dcsFormButton=function(evt){
	evt=evt||(window.event||"");
	if (evt&&((typeof(evt.which)!="number")||(evt.which==1))){
		var tags=["INPUT","BUTTON"];
		for (var j=0;j<tags.length;j++){
			var e=this.dcsEvt(evt,tags[j]);
			var type=e.type||"";
			if (type&&((type=="submit")||(type=="image")||(type=="button")||(type=="reset"))||((type=="text")&&((evt.which||evt.keyCode)==13))){
				var uri="";
				var ttl="";
				var id=0;
				if (e.form){
					// begin: field capture
					// end: field capture
					uri=e.form.action||window.location.pathname;
					ttl=e.form.id||e.form.name||e.form.className||"Unknown";
					id=(e.form.method&&(e.form.method.toLowerCase()=="post"))?"27":"26";
				}
				else{
					uri=window.location.pathname;
					ttl=e.name||e.id||"Unknown";
					id=(tags[j].toLowerCase()=="input")?"28":"29";
				}
				if (uri&&ttl&&(evt.keyCode!=9)){
					this.dcsMultiTrack("DCS.dcsuri",uri,"WT.ti","FormButton:"+ttl,"WT.dl",id,"WT.nv",this.dcsNavigation(evt));
				}
				this.DCS.dcsuri=this.WT.ti=this.WT.dl=this.WT.nv="";
				break;
			}
		}
	}
}
// Code section for Track clicks to links leading offsite.
WebTrends.prototype.dcsOffsite=function(evt){
	evt=evt||(window.event||"");
	if (evt&&((typeof(evt.which)!="number")||(evt.which==1))){
		var e=this.dcsEvt(evt,"A");
		if (e.href){
			var hn=e.hostname?(e.hostname.split(":")[0]):"";
			var pr=e.protocol||"";
			if ((hn.length>0)&&(pr.indexOf("http")==0)&&!this.dcsIsOnsite(hn)){
				var qry=e.search?e.search.substring(e.search.indexOf("?")+1,e.search.length):"";
				var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/";
				this.dcsMultiTrack("DCS.dcssip",hn,"DCS.dcsuri",pth,"DCS.dcsqry",this.trimoffsiteparams?"":qry,"DCS.dcsref",window.location,"WT.ti","Offsite:"+hn+pth+"?"+qry,"WT.dl","24","WT.nv",this.dcsNavigation(evt));
				this.DCS.dcssip=this.DCS.dcsuri=this.DCS.dcsqry=this.DCS.dcsref=this.WT.ti=this.WT.dl=this.WT.nv="";
			}
		}
	}
}
// Code section for Track clicks to links that contain anchors.
WebTrends.prototype.dcsAnchor=function(evt){
	evt=evt||(window.event||"");
	if (evt&&((typeof(evt.which)!="number")||(evt.which==1))){
		var e=this.dcsEvt(evt,"A");
		if (e.href){
			var hn=e.hostname?(e.hostname.split(":")[0]):"";
			if (this.dcsIsOnsite(hn)&&e.hash&&(e.hash!="")&&(e.hash!="#")){
				var qry=e.search?e.search.substring(e.search.indexOf("?")+1,e.search.length):"";
				var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/";
				this.dcsMultiTrack("DCS.dcssip",hn,"DCS.dcsuri",pth+e.hash,"WT.ti","Anchor:"+e.hash,"WT.dl","21","WT.nv",this.dcsNavigation(evt));
				this.DCS.dcssip=this.DCS.dcsuri=this.WT.ti=this.WT.dl=this.WT.nv="";
			}
		}
	}
}
// Code section for clicks to image maps.
WebTrends.prototype.dcsImageMap=function(evt){
	evt=evt||(window.event||"");
	if (evt){
		var e=this.dcsEvt(evt,"AREA");
		if (e.href){
			var hn=e.hostname?(e.hostname.split(":")[0]):"";
			if ((hn!="")&&e.protocol&&(e.protocol.indexOf("http")!=-1)){
				var ttl="";
				var map=this.dcsEvt(evt,"MAP");
				if (map){
					if (map.name){
						ttl=map.name;
					}
					else if (map.id){
						ttl=map.id;
					}
				}
				var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/";
				this.dcsMultiTrack("DCS.dcssip",hn,"DCS.dcsuri",pth,"DCS.dcsqry",e.search||"","WT.ti","ImageMap:"+ttl,"WT.dl","30","WT.nv",this.dcsNavigation(evt));
				this.DCS.dcssip=this.DCS.dcsuri=this.DCS.dcsqry=this.WT.ti=this.WT.dl=this.WT.nv="";
			}
		}
	}
}
// Code section for Enable custom meta tag capture.
WebTrends.prototype.dcsMetaCap=function(){
	var elems;
	if (document.all){
		elems=document.all.tags("meta");
	}
	else if (document.documentElement){
		elems=document.getElementsByTagName("meta");
	}
	if (typeof(elems)!="undefined"){
		var names=this.dcsSplit(this.metanames);
		var nlen=names.length;
		var elen=elems.length;
		for (var i=0;i<elen;i++){
			var name=elems.item(i).name.toLowerCase();
			var content=elems.item(i).content;
			if ((name.length>0)&&(content.length>0)){
				for(var j=0;j<nlen;j++){
					if (name==names[j]){
						this.DCSext["meta_"+names[j]]=content;
						break;
					}
				}
			}
		}
	}
}
WebTrends.prototype.dcsAdv=function(){
	if (this.trackevents&&(typeof(this.dcsET)=="function")){
		if (window.addEventListener){
			window.addEventListener("load",this.dcsET.wtbind(this),false);
		}
		else if (window.attachEvent){
			window.attachEvent("onload",this.dcsET.wtbind(this));
		}
	}
	this.dcsFPC();
	this.dcsTP();
	this.dcsMetaCap();
}
WebTrends.prototype.dcsVar=function(){
	var dCurrent=new Date();
	var WT=this.WT;
	var DCS=this.DCS;
	WT.tz=parseInt(dCurrent.getTimezoneOffset()/60*-1)||"0";
	WT.bh=dCurrent.getHours()||"0";
	WT.ul=navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
	if (typeof(screen)=="object"){
		WT.cd=navigator.appName=="Netscape"?screen.pixelDepth:screen.colorDepth;
		WT.sr=screen.width+"x"+screen.height;
	}
	if (typeof(navigator.javaEnabled())=="boolean"){
		WT.jo=navigator.javaEnabled()?"Yes":"No";
	}
	if (document.title){
		if (window.RegExp){
			var tire=new RegExp("^"+window.location.protocol+"//"+window.location.hostname+"\\s-\\s");
			WT.ti=document.title.replace(tire,"");
		}
		else{
			WT.ti=document.title;
		}
	}
	WT.js="Yes";
	WT.jv=(function(){
		var agt=navigator.userAgent.toLowerCase();
		var major=parseInt(navigator.appVersion);
		var mac=(agt.indexOf("mac")!=-1);
		var ff=(agt.indexOf("firefox")!=-1);
		var ff0=(agt.indexOf("firefox/0.")!=-1);
		var ff10=(agt.indexOf("firefox/1.0")!=-1);
		var ff15=(agt.indexOf("firefox/1.5")!=-1);
		var ff20=(agt.indexOf("firefox/2.0")!=-1);
		var ff3up=(ff&&!ff0&&!ff10&!ff15&!ff20);
		var nn=(!ff&&(agt.indexOf("mozilla")!=-1)&&(agt.indexOf("compatible")==-1));
		var nn4=(nn&&(major==4));
		var nn6up=(nn&&(major>=5));
		var ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));
		var ie4=(ie&&(major==4)&&(agt.indexOf("msie 4")!=-1));
		var ie5up=(ie&&!ie4);
		var op=(agt.indexOf("opera")!=-1);
		var op5=(agt.indexOf("opera 5")!=-1||agt.indexOf("opera/5")!=-1);
		var op6=(agt.indexOf("opera 6")!=-1||agt.indexOf("opera/6")!=-1);
		var op7up=(op&&!op5&&!op6);
		var jv="1.1";
		if (ff3up){
			jv="1.8";
		}
		else if (ff20){
			jv="1.7";
		}
		else if (ff15){
			jv="1.6";
		}
		else if (ff0||ff10||nn6up||op7up){
			jv="1.5";
		}
		else if ((mac&&ie5up)||op6){
			jv="1.4";
		}
		else if (ie5up||nn4||op5){
			jv="1.3";
		}
		else if (ie4){
			jv="1.2";
		}
		return jv;
	})();
	WT.ct="unknown";
	if (document.body&&document.body.addBehavior){
		try{
			document.body.addBehavior("#default#clientCaps");
			WT.ct=document.body.connectionType||"unknown";
			document.body.addBehavior("#default#homePage");
			WT.hp=document.body.isHomePage(location.href)?"1":"0";
		}
		catch(e){
		}
	}
	if (document.all){
		WT.bs=document.body?document.body.offsetWidth+"x"+document.body.offsetHeight:"unknown";
	}
	else{
		WT.bs=window.innerWidth+"x"+window.innerHeight;
	}
	WT.fv=(function(){
		var i,flash;
		if (window.ActiveXObject){
			for(i=10;i>0;i--){
				try{
					flash=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
					return i+".0";
				}
				catch(e){
				}
			}
		}
		else if (navigator.plugins&&navigator.plugins.length){
			for (i=0;i<navigator.plugins.length;i++){
				if (navigator.plugins[i].name.indexOf('Shockwave Flash')!=-1){
					return navigator.plugins[i].description.split(" ")[2];
				}
			}
		}
		return "Not enabled";
	})();
	WT.slv=(function(){
		var slv="Not enabled";
		try{	 
			if (navigator.userAgent.indexOf('MSIE')!=-1){
				var sli = new ActiveXObject('AgControl.AgControl');
				if (sli){
					slv="Unknown";
				}
			}
			else if (navigator.plugins["Silverlight Plug-In"]){
				slv="Unknown";
			}
		}
		catch(e){
		}
		if (slv!="Not enabled"){
			var i,j,v;
			if ((typeof(Silverlight)=="object")&&(typeof(Silverlight.isInstalled)=="function")){
				for (j=9;j>=0;j--){
					for(i=3;i>0;i--){
						v=i+"."+j;
						if (Silverlight.isInstalled(v)){
							slv=v;
							break;
						}
					}
					if (slv==v){
						break;
					}
				}
			}
		}
		return slv;
	})();
	if (this.i18n){
		if (typeof(document.defaultCharset)=="string"){
			WT.le=document.defaultCharset;
		} 
		else if (typeof(document.characterSet)=="string"){
			WT.le=document.characterSet;
		}
		else{
			WT.le="unknown";
		}
	}
	WT.tv="8.6.1";
//	WT.sp="@@SPLITVALUE@@";
	WT.dl="0";
	WT.ssl=(window.location.protocol.indexOf('https:')==0)?"1":"0";
	DCS.dcsdat=dCurrent.getTime();
	DCS.dcssip=window.location.hostname;
	DCS.dcsuri=window.location.pathname;
	WT.es=DCS.dcssip+DCS.dcsuri;
	if (window.location.search){
		DCS.dcsqry=window.location.search;
	}
	if (DCS.dcsqry){
		var dcsqry=DCS.dcsqry.toLowerCase();
		var params=this.paidsearchparams.length?this.paidsearchparams.toLowerCase().split(","):[];
		for (var i=0;i<params.length;i++){
			if (dcsqry.indexOf(params[i]+"=")!=-1){
				WT.srch="1";
				break;
			}
		}
	}
	if ((window.document.referrer!="")&&(window.document.referrer!="-")){
		if (!(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)<4)){
			DCS.dcsref=window.document.referrer;
		}
	}
}
WebTrends.prototype.dcsEscape=function(S, REL){
	if (REL!=""){
		S=S.toString();
		for (var R in REL){
			if (REL[R] instanceof RegExp){
				S=S.replace(REL[R],R);
			}
		}
		return S;
	}
	else{
		return escape(S);
	}
}
WebTrends.prototype.dcsA=function(N,V){
	if (this.i18n&&(this.exre!="")&&!this.exre.test(N)){
		if (N=="dcsqry"){
			var newV="";
			var params=V.substring(1).split("&");
			for (var i=0;i<params.length;i++){
				var pair=params[i];
				var pos=pair.indexOf("=");
				if (pos!=-1){
					var key=pair.substring(0,pos);
					var val=pair.substring(pos+1);
					if (i!=0){
						newV+="&";
					}
					newV+=key+"="+this.dcsEncode(val);
				}
			}
			V=V.substring(0,1)+newV;
		}
		else{
			V=this.dcsEncode(V);
		}
	}
	return "&"+N+"="+this.dcsEscape(V, this.re);
}
WebTrends.prototype.dcsEncode=function(S){
	return (typeof(encodeURIComponent)=="function")?encodeURIComponent(S):escape(S);
}
WebTrends.prototype.dcsCreateImage=function(dcsSrc){
	if (document.images){
		this.images[this.index]=new Image();
		this.images[this.index].src=dcsSrc;
		this.index++;
	}
	else{
		document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="'+dcsSrc+'">');
	}
}
WebTrends.prototype.dcsMeta=function(){
	var elems;
	if (document.all){
		elems=document.all.tags("meta");
	}
	else if (document.documentElement){
		elems=document.getElementsByTagName("meta");
	}
	if (typeof(elems)!="undefined"){
		var length=elems.length;
		for (var i=0;i<length;i++){
			var name=elems.item(i).name;
			var content=elems.item(i).content;
			var equiv=elems.item(i).httpEquiv;
			if (name.length>0){
				if (name.toUpperCase().indexOf("WT.")==0){
					this.WT[name.substring(3)]=content;
				}
				else if (name.toUpperCase().indexOf("DCSEXT.")==0){
					this.DCSext[name.substring(7)]=content;
				}
				else if (name.toUpperCase().indexOf("DCS.")==0){
					this.DCS[name.substring(4)]=content;
				}
			}
		}
	}
}
WebTrends.prototype.dcsTag=function(){
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var WT=this.WT;
	var DCS=this.DCS;
	var DCSext=this.DCSext;
	var i18n=this.i18n;
	var P="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+this.domain+(this.dcsid==""?'':'/'+this.dcsid)+"/dcs.gif?";
	if (i18n){
		WT.dep="";
	}
	for (var N in DCS){
		if (DCS[N]&&(typeof DCS[N]!="function")){
			P+=this.dcsA(N,DCS[N]);
		}
	}
	var keys=["co_f","vtid","vtvs","vt_f_tlv"];
	for (var i=0;i<keys.length;i++){
		var key=keys[i];
		if (WT[key]){
			P+=this.dcsA("WT."+key,WT[key]);
			delete WT[key];
		}
	}
	for (N in WT){
		if (WT[N]&&(typeof WT[N]!="function")){
			P+=this.dcsA("WT."+N,WT[N]);
		}
	}
	for (N in DCSext){
		if (DCSext[N]&&(typeof DCSext[N]!="function")){
			if (i18n){
				WT.dep=(WT.dep.length==0)?N:(WT.dep+";"+N);
			}
			P+=this.dcsA(N,DCSext[N]);
		}
	}
	if (i18n&&(WT.dep.length>0)){
		P+=this.dcsA("WT.dep",WT.dep);
	}
	if (P.length>2048&&navigator.userAgent.indexOf('MSIE')>=0){
		P=P.substring(0,2040)+"&WT.tu=1";
	}
	this.dcsCreateImage(P);
	this.WT.ad="";
}
WebTrends.prototype.dcsDebug=function(){
	var t=this;
	var i=t.images[0].src;
	var q=i.indexOf("?");
	var r=i.substring(0,q).split("/");
	var m="<b>Protocol</b><br><code>"+r[0]+"<br></code>";
	m+="<b>Domain</b><br><code>"+r[2]+"<br></code>";
	m+="<b>Path</b><br><code>/"+r[3]+"/"+r[4]+"<br></code>";
	m+="<b>Query Params</b><code>"+i.substring(q+1).replace(/\&/g,"<br>")+"</code>";
	m+="<br><b>Cookies</b><br><code>"+document.cookie.replace(/\;/g,"<br>")+"</code>";
	if (t.w&&!t.w.closed){
		t.w.close();
	}
	t.w=window.open("","dcsDebug","width=500,height=650,scrollbars=yes,resizable=yes");
	t.w.document.write(m);
	t.w.focus();
}
WebTrends.prototype.dcsCollect=function(){
	if (this.enabled){
		this.dcsVar();
		this.dcsMeta();
		this.dcsAdv();
		this.dcsTag();
	}
}
function dcsMultiTrack(){
	if (typeof(_tag)!="undefined"){
		return(_tag.dcsMultiTrack());
	}
}
function dcsDebug(){
	if (typeof(_tag)!="undefined"){
		return(_tag.dcsDebug());
	}
}
Function.prototype.wtbind = function(obj){
	var method=this;
	var temp=function(){
		return method.apply(obj,arguments);
	};
	return temp;
}

//////////////////////////////////////////////////////////////////////////////
///////// Webtrends Script End ///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
///////// Ureg Script ////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

function logon(formName) {
	// clear the error message
	if (document.getElementById("errorDiv")) {
		document.getElementById("errorDiv").innerHTML = "";
	}

	// test the inputs
	var logon_form = document.getElementById(formName);
	var emailaddress_logon = "";
	var password_logon = "";
	
	for (var i = 0; i < logon_form.length; i++)
	{
		var control = logon_form[i];
		if (control.id == "emailaddress") {
			emailaddress_logon = control.value;
		} else if (control.id == "password") {
			password_logon = control.value;
		}
	}
	
	if (emailaddress_logon.length > 0 && password_logon.length > 0)	{
		// get the form
		var frmLogon = document.getElementById(formName);
		frmLogon.submit();
	} else {
		// show the errors
		var errorMessage = "";
		if (emailaddress_logon.length == 0) {
			errorMessage = "  You must enter an email address.<br />";
		}
		if (password_logon.length == 0) {
			errorMessage = errorMessage + "  You must enter a password.<br />";
		}
		
		if (errorMessage.length > 0) {
			errorMessage = "<p>" + errorMessage + "</p>";
		}
		
		// show the error message
		if (document.getElementById("errorDiv")) {
			document.getElementById("errorDiv").innerHTML = errorMessage;
		}
	}
}

function clearForm(formName) {
	// clear the error message
	if (document.getElementById("errorDiv")) {
		document.getElementById("errorDiv").innerHTML = "";
	}
	
	var objForm = document.getElementById(formName);
	objForm.reset();
}

function createAccount() {
	// clear the error message
	if (document.getElementById("errorDiv")) {
		document.getElementById("errorDiv").innerHTML = "";
	}
	
	// test the required inputs
	var create_emailaddress = document.getElementById("create_emailaddress").value;
	var create_password = document.getElementById("create_password").value;
	var create_confirmpassword = document.getElementById("create_confirmpassword").value;
	//var create_reminderquestion = document.getElementById("create_reminderquestion").value;
	//var create_reminderanswer = document.getElementById("create_reminderanswer").value;
	var create_screenname = document.getElementById("create_screenname").value;
	var create_zip = document.getElementById("create_zip").value;
	var tou = document.getElementById("tou").checked;
	
	if (create_emailaddress.length > 0 &&  create_password.length > 5 && create_confirmpassword.length > 0 
		&& create_screenname.length > 1 && tou) {
		
		if (create_password != create_confirmpassword) {
			errorMessage = "  The password must match the confirmation password.<br />";
			
			// show the error message
			if (document.getElementById("errorDiv")) {
				errorMessage = "<p>" + errorMessage + "</p>";
				document.getElementById("errorDiv").innerHTML = errorMessage;
				// need to scroll the page to the error message area
				location.href='#errorArea';
			}
		} else {
			// fill-in the checkedbusinessofferings
			var checkedbusinessofferings = "";
			var create_form = document.getElementById("frmCreateAccount");
			for (var i = 0; i < create_form.length; i++)
			{
				var control = create_form[i];
				if (control.checked) {
					if (control.id.indexOf("newsletter_") > -1) {
						checkedbusinessofferings += control.value  + "||";
					}
				}
			}
			// put the value in the hidden form field
			document.getElementById("checkedbusinessofferings").value = checkedbusinessofferings;
			
			// submit the form
			create_form.submit();
		}
	} else {
		
		// show the error messages
		var errorMessage = "";
		if (!tou) {
			errorMessage = errorMessage + " You must agree to the Terms of Use to become an online community member.<br />";
		}
		if (create_emailaddress.length == 0) {
			errorMessage = errorMessage + "  You must enter an email address.<br />";
		}
		if (create_password.length < 6) {
			errorMessage = errorMessage + "  Your password must be at least 6 characters.<br />";
		}
		if (create_confirmpassword.length == 0) {
			errorMessage = errorMessage + "  You must enter a confirmation password.<br />";
		} else if (create_password != create_confirmpassword) {
			errorMessage = errorMessage + "  The password much match the confirmation password.<br />";
		}
		if (create_screenname.length < 2) {
			errorMessage = errorMessage + "  Your screen name must be at least 2 characters.<br />";
		}
		
		// show the error message
		if (document.getElementById("errorDiv")) {		
			errorMessage = "<p>" + errorMessage + "</p>";
			
			document.getElementById("errorDiv").innerHTML = errorMessage;
			// need to scroll the page to the error message area
			window.location.href='#errorArea';
		}
	}
}

function validateRemindMeEmailAddress() {
	with (document.getElementById('emailaddress'))
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos < 1 || dotpos-apos < 2) {
			alert('You must enter a valid email address.');
		} else {
			document.getElementById('frmResetStep1').submit();
		}
	}
}

function updateAccount() {
	// clear the error message
	if (document.getElementById("errorDiv")) {
		document.getElementById("errorDiv").innerHTML = "";
	}

	// test the required inputs
	var update_emailaddress = document.getElementById("update_emailaddress").value;
	var update_password = document.getElementById("update_password").value;
	var update_confirmpassword = document.getElementById("update_confirmpassword").value;
	var update_reminderquestion = document.getElementById("update_reminderquestion").value;
	var update_reminderanswer = document.getElementById("update_reminderanswer").value;
	var update_screenname = document.getElementById("update_screenname").value;
	var update_zip = document.getElementById("update_zip").value;

	if (update_emailaddress.length > 0 &&  update_password.length > 5 && update_confirmpassword.length > 0 
		&& update_reminderquestion.length > 0 && update_reminderanswer.length > 0 
		&& update_screenname.length > 1) {
		
		if (update_password != update_confirmpassword) {
			errorMessage = "  The password must match the confirmation password.<br />";
			// show the error message
			if (document.getElementById("errorDiv")) {
				errorMessage = "<p>" + errorMessage + "</p>";
				document.getElementById("errorDiv").innerHTML = errorMessage;
				// need to scroll the page to the error message area
				location.href='#errorArea';
			}
		} else {
			// fill-in the checkedbusinessofferings
			var checkedbusinessofferings = "";
			var update_form = document.getElementById("frmUpdateAccount");
			for (var i = 0; i < update_form.length; i++)
			{
				var control = update_form[i];
				if (control.checked) {
					if (control.id.indexOf("newsletter_") > -1) {
						checkedbusinessofferings += control.value  + "||";
					}
				}
			}
			// put the value in the hidden form field
			document.getElementById("checkedbusinessofferings").value = checkedbusinessofferings;
			
			// submit the form
			update_form.submit();
		}
	} else {
		// show the error messages
		var errorMessage = "";
		if (update_emailaddress.length == 0) {
			errorMessage = "  You must enter an email address.<br />";
		}
		if (update_password.length < 6) {
			errorMessage = errorMessage + "  Your password must be at least 6 characters.<br />";
		}
		if (update_confirmpassword.length == 0) {
			errorMessage = errorMessage + "  You must enter a confirmation password.<br />";
		} else if (update_password != update_confirmpassword) {
			errorMessage = errorMessage + "  The password much match the confirmation password.<br />";
		}
		if (update_reminderquestion.length == 0) {
			errorMessage = errorMessage + "  You must select a reminder question.<br />";
		}
		if (update_reminderanswer.length == 0) {
			errorMessage = errorMessage + "  You must enter a reminder answer.<br />";
		}
		if (update_screenname.length < 2) {
			errorMessage = errorMessage + "  Your screen name must be at least 2 characters.<br />";
		}
		
		// show the error message
		if (document.getElementById("errorDiv")) {
			errorMessage = "<p>" + errorMessage + "</p>";
			document.getElementById("errorDiv").innerHTML = errorMessage;
			// need to scroll the page to the error message area
			location.href='#errorArea';
		}
	}
}
function updateSubscribeAccount() {
	// clear the error message
	if (document.getElementById("errorDiv")) {
		document.getElementById("errorDiv").innerHTML = "";
	}

	// test the required inputs
	var update_emailaddress = document.getElementById("emailaddress").value;
	var update_password = document.getElementById("upd_password").value;
	var update_confirmpassword = document.getElementById("confirmpassword").value;
	var update_screenname = document.getElementById("screenname").value;
	var phonenumber = document.getElementById("phone").value;
	var firstname = document.getElementById("firstname").value;
	var lastname = document.getElementById("lastname").value;

	var address = document.getElementById("address1").value;
	var city = document.getElementById("city").value;
	var state = document.getElementById("state").value;
	var zip = document.getElementById("zip").value;

	var businessAddress = document.getElementById("billing_address1").value;
	var businessCity = document.getElementById("billing_city").value;
	var businessState = document.getElementById("billing_state").value;
	var businessZip = document.getElementById("billing_zip").value;
	var ccName = document.getElementById("ccName").value;
	var ccNumber = document.getElementById("ccNumber").value;
	var ccExpMon = $('#ccExpMon').val();
	var ccExpYear = $('#ccExpYear').val();
	var CVN = document.getElementById("CVN").value;
	var subscriptionId = $('input:radio[name=subscriptionId]:checked').val();
	var subscriptionOptions = subscriptionId.split("|");

	if (update_emailaddress.length > 0 &&  update_password.length > 5 && update_confirmpassword.length > 0 
		&& update_screenname.length > 1 && phonenumber.length > 1 && firstname.length > 1 && lastname.length > 1 &&
		(($('#deliveryInformation').is(':visible') && address.length > 1 && city.length > 1 && state.length > 1 && zip.length > 1 ) || $('#deliveryInformation').is(':visible')==false) &&
		(($('#billingInformation').is(':visible') && businessAddress.length > 1 && businessCity.length > 1 && businessState.length > 1 && businessZip.length > 1) || $('#billingInformation').is(':visible')==false)) {

		if (update_password != update_confirmpassword) {
			errorMessage = "  The password must match the confirmation password.<br />";
			// show the error message
			if (document.getElementById("errorDiv")) {
				errorMessage = "<p>" + errorMessage + "</p>";
				document.getElementById("errorDiv").innerHTML = errorMessage;
				// need to scroll the page to the error message area
				location.href='#errorArea';
			}
		} else {
			// fill-in the checkedbusinessofferings
			var checkedbusinessofferings = "";
			var update_form = document.getElementById("frmUpdateAccount");
			for (var i = 0; i < update_form.length; i++)
			{
				var control = update_form[i];
				if (control.checked) {
					if (control.id.indexOf("newsletter_") > -1) {
						checkedbusinessofferings += control.value  + "||";
					}
				}
			}
			// put the value in the hidden form field
			document.getElementById("checkedbusinessofferings").value = checkedbusinessofferings;
			
			if ($('#billingInformation').is(':visible')) {
				$('#dialog-confirm').html("<p>If you continue your Credit Card will be charged $" + subscriptionOptions[1] +".</p>" );
				$( "#dialog-confirm" ).dialog( "open" );
			} else {
				// submit the form
				update_form.submit();
			}
		}
	} else {
		// show the error messages
		var errorMessage = "";
		if (update_emailaddress.length == 0) {
			errorMessage = "  You must enter an email address.<br />";
		}
		if (update_password.length < 6) {
			errorMessage = errorMessage + "  Your password must be at least 6 characters.<br />";
		}
		if (update_confirmpassword.length == 0) {
			errorMessage = errorMessage + "  You must enter a confirmation password.<br />";
		} else if (update_password != update_confirmpassword) {
			errorMessage = errorMessage + "  The password much match the confirmation password.<br />";
		}
		if (update_screenname.length < 2) {
			errorMessage = errorMessage + "  Your screen name must be at least 2 characters.<br />";
		}
		if (phonenumber.length < 2) {
			errorMessage = errorMessage + "  Your must enter your Phone Number.<br />";
		}
		if (firstname.length < 2) {
			errorMessage = errorMessage + "  You must enter your First Name.<br />";
		}
		if (lastname.length < 2) {
			errorMessage = errorMessage + "  You must enter your Last Name.<br />";
		}
		if ($('#deliveryInformation').is(':visible')) {
			if (address.length < 2) {
				errorMessage = errorMessage + "  You must enter your Address.<br />";
			}
			if (city.length < 2) {
				errorMessage = errorMessage + "  You must enter your City.<br />";
			}
			if (state.length < 2) {
				errorMessage = errorMessage + "  You must enter your State.<br />";
			}
			if (zip.length < 2) {
				errorMessage = errorMessage + "  You must enter your Zip.<br />";
			}
		}
		if ($('#billingInformation').is(':visible')) {
			if (businessAddress.length < 2) {
				errorMessage = errorMessage + "  You must enter your Billing Address.<br />";
			}
			if (businessCity.length < 2) {
				errorMessage = errorMessage + "  You must enter your Billing City.<br />";
			}
			if (businessState.length < 2) {
				errorMessage = errorMessage + "  You must enter your Billing State.<br />";
			}
			if (businessZip.length < 2) {
				errorMessage = errorMessage + "  You must enter your Billing Zip.<br />";
			}
			if (ccName.length < 2) {
				errorMessage = errorMessage + "  You must enter the Name on your Credit Card.<br />";
			}
			if (ccNumber.length < 2) {
				errorMessage = errorMessage + "  You must enter your Credit Card Number.<br />";
			}
			if (ccExpMon == "") {
				errorMessage = errorMessage + "  You must select the Month your Credit Card Expires.<br />";
			}
			if (ccExpYear == "") {
				errorMessage = errorMessage + "  You must select the Year your Credit Card Expires.<br />";
			}
			if (CVN.length < 2) {
				errorMessage = errorMessage + "  You must enter your Credit Card Verification Number (CVN) located on the back of your Credit Card.<br />";
			}
		}
		// show the error message
		if (document.getElementById("errorDiv")) {
			errorMessage = "<p>" + errorMessage + "</p>";
			document.getElementById("errorDiv").innerHTML = errorMessage;
			// need to scroll the page to the error message area
			location.href='#errorArea';
		}
	}
}
function subscribeFormDisplay () {
	SelectedOptionValue = $('input[type="radio"]:checked').val();
	if (SelectedOptionValue != "") {
		optionArray = SelectedOptionValue.split("|");
		if (optionArray[4] == 1)
			$("#deliveryInformation").show();
		else
			$("#deliveryInformation").hide();
		if (optionArray[5] == 1)
			$("#billingInformation").show();
		else
			$("#billingInformation").hide();
		$("#selectSubscribeOptions").slideUp('slow', function () { $("#selectSubscribeOptionsAlt").slideDown('slow'); });
		// If this is print only, don't bother showing the TOU
		if (((optionArray[4]==1) && (optionArray[2]!=1))) {
			$("#touRow").hide();
			$("#tou").attr('checked','checked');
		}
	}
}
function subscribeFormHide () {
	$("#selectSubscribeOptionsAlt").slideUp('slow', function () { $("#selectSubscribeOptions").slideDown('slow'); });
}
//////////////////////////////////////////////////////////////////////////////
///////// Ureg Script End ////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
///////// Remote Logon Script ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

// create the page level variables to store information
var ssokey = "";
var emailaddress = "";
var emailField = "";
var passwordField = "";
var screenname = "";
var rememberme = "";
var url = "";
var cookieDomain = "";
var interval = "";
var redirectAfterLogin = false;

// This gets the hidden iframe "logonFrame"
function getComFrame(){
	var iwin;
	if(navigator.userAgent.indexOf("Safari") != -1){
		iwin = frames["logonFrame"];
	}else{
		if (document.getElementById("logonFrame")) {
			iwin = document.getElementById("logonFrame").contentWindow;
		}
	}
	return iwin;
}

// This sends a message to the hidden iframe
function sendLogonMessage(input_url, email_field, password_field, rememberme_field, input_cookiedomain, input_userRegPath, input_redirectAfterLogin){
	// set the page level variables
	url = input_url;
	cookieDomain = input_cookiedomain;
	userRegPath = input_userRegPath;
	emailField = email_field;
	passwordField = password_field;
	redirectAfterLogin = input_redirectAfterLogin;

	var emailaddress = document.getElementById(email_field).value;
	var password = document.getElementById(password_field).value;
	var rememberme = document.getElementById(rememberme_field).checked;
	rememberme = (rememberme?"YES":"NO");

	var frameLocation = url+"?em="+emailaddress+"&pwd="+password+"&rm="+rememberme;
	getComFrame().location.href = frameLocation;

	interval = setInterval(checkForMessages, 200);
}

function checkForMessages() {
	if (screenname.length == 0) {
		if (getComFrame()) {
			var hiddenFrame = getComFrame().location;
			if (hiddenFrame.hash && hiddenFrame.hash != screenname)
			{
				hash = hiddenFrame.hash.replace('#','');
				hash = hash.replace("%0A",'');
				if (hash!="FAILURE") {
					split = hash.split("||");
					ssokey = split[0];
					emailaddress = split[1];
					screenname = split[2];
					rememberme = split[3];
				}
				logonCallback(hash)
			}
		}
	}
}

function logonCallback(hash) {
	clearInterval(interval);
	if (hash.length > 0 && hash != "undefined" && hash != "FAILURE") {
		setCookie(ssokey, emailaddress, screenname, rememberme, cookieDomain); // this is the actual logon

		// clear the email address and password
		document.getElementById(emailField).value = "";
		document.getElementById(passwordField).value = "";
		if (document.getElementById('logon_title')) {
			document.getElementById('logon_title').style.display="block";
			document.getElementById('logon_title').style.visibility="visible";
		}
		document.getElementById("logon_error").innerHTML = "";
		closeLogonPopUp();

		// need to update pages if functionality requires
		if (redirectAfterLogin)
			window.location.href=appsPath + "/utils/ureg/ui/updateaccount.php?showLoginSuccessful=true";
		else
			location.reload(true);
	} else {
		// unable to logon
		logonError();
	}
}

function logonError() {
	emailaddress = "";
	emailField = "";
	passwordField = "";
	screenname = "";
	rememberme = "";
	url = "";
	cookieDomain = "";
	userRegPath = "";
	// var errormessage = "Unable to login. Please try again.";
	var errormessage = "We couldn't find your Login info in the system. Here are possible reasons:";
	errormessage += "<br />1. Check the spelling of your Email or Screen Name.";
	errormessage += "<br />2. Your account needs to be verified. <a href='"+appsPath+"/utils/ureg/ui/resendvalidation.php' class='YellowToWhite'><span class='YellowToWhite'>Verify here</span></a>.";
	errormessage += "<br />3. You are not yet registered.  <a href='"+appsPath+"/utils/ureg/ui/createaccount.php' class='YellowToWhite'><span class='YellowToWhite'>Register here</span></a>.";	
	// need to show the error message
	document.getElementById("logon_error").innerHTML = errormessage;
	if (document.getElementById('logon_title')) {
		document.getElementById('logon_title').style.display="none";
		document.getElementById('logon_title').style.visibility="hidden";
	}
}

function stripComments(textToStrip) {
	// Now using new stripping library
	return StripCommentSGML(textToStrip);

}
//////////////////////////////////////////////////////////////////////////////
///////// Remote Logon Script End ////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
///////// MD5 Script /////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 */
/*
 * Configurable variables. You may need to tweak these to be compatible with
 * the server-side, but the defaults work in most cases.
 */
/*
 * These are the functions you'll usually want to call
 * They take string arguments and return either hex or base-64 encoded strings
 */
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
 * Perform a simple self-test to see if the VM is working
 */
function md5_vm_test()
{
  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
 * Calculate the MD5 of an array of little-endian words, and a bit length
 */
function core_md5(x, len)
{
  /* append padding */
  x[len >> 5] |= 0x80 << ((len) % 32);
  x[(((len + 64) >>> 9) << 4) + 14] = len;
  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;
  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;
    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
    b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
    c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
    b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
    b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
    a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
    c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
    b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
    b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
    c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
  }
  return Array(a, b, c, d);
}
/*
 * These functions implement the four basic operations the algorithm uses.
 */
function md5_cmn(q, a, b, x, s, t)
{
  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
 * Calculate the HMAC-MD5, of a key and some data
 */
function core_hmac_md5(key, data)
{
  var bkey = str2binl(key);
  if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  var ipad = Array(16), opad = Array(16);
  for(var i = 0; i < 16; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }
  var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  return core_md5(opad.concat(hash), 512 + 128);
}
/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}
/*
 * Bitwise rotate a 32-bit number to the left.
 */
function bit_rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}
/*
 * Convert a string to an array of little-endian words
 * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
 */
function str2binl(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  return bin;
}
/*
 * Convert an array of little-endian words to a string
 */
function binl2str(bin)
{
  var str = "";
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < bin.length * 32; i += chrsz)
    str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  return str;
}
/*
 * Convert an array of little-endian words to a hex string.
 */
function binl2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
  }
  return str;
}
/*
 * Convert an array of little-endian words to a base-64 string
 */
function binl2b64(binarray)
{
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i += 3)
  {
    var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
                | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
                |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++)
    {
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}

//////////////////////////////////////////////////////////////////////////////
///////// MD5 Script End /////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
///////// LoadAds Script Start ///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

function dipslayPageAds() {
	var ad_count=1;
	var ord1=Math.random()*10000000000000000;
	var adurl;
	var elementBydojoId;
	if (document.getElementById('DoubleClickTarget728x90')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.'+DoubleClickSite+'/'+DoubleClickZone+';adtype=iframe;tile=' + ad_count + ';sz=728x90;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads728x90";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="728" 
		IFR.height="90"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
	}
	if (document.getElementById('DoubleClickTarget88x31')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.'+DoubleClickSite+'/'+DoubleClickZone+';adtype=iframe;tile=' + ad_count + ';sz=88x31;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads88x31";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="88" 
		IFR.height="31"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
		ad_count+=1;
	}
	ad_count = 3;
	if (document.getElementById('DoubleClickTarget300x250Top')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.'+DoubleClickSite+'/'+DoubleClickZone+';adtype=iframe;tile=' + ad_count + ';sz=300x250;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads300x250Top";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="300" 
		IFR.height="250"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
		ad_count+=1;
	}
	if (document.getElementById('DoubleClickTarget300x250Middle')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.'+DoubleClickSite+'/'+DoubleClickZone+';adtype=iframe;tile=' + ad_count + ';sz=300x250;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads300x250Middle";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="300" 
		IFR.height="250"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
		ad_count+=1;
	}
	if (document.getElementById('DoubleClickTarget300x250Bottom')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.'+DoubleClickSite+'/'+DoubleClickZone+';adtype=iframe;tile=' + ad_count + ';sz=300x250;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads300x250Bottom";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="300" 
		IFR.height="250"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
		ad_count+=1;
	}
	if (document.getElementById('DoubleClickTarget300x600Bottom')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.'+DoubleClickSite+'/'+DoubleClickZone+';adtype=iframe;tile=' + ad_count + ';sz=300x600;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads300x600Bottom";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="300" 
		IFR.height="600"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
		ad_count+=1;
	}
	if (document.getElementById('DoubleClickTarget88x31RealEstate')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.realestate/home;adtype=iframe;tile=' + ad_count + ';sz=88x31;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads88x31RealEstate";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="88" 
		IFR.height="31"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
	}
	if (document.getElementById('DoubleClickTarget120x60RealEstateTop')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.realestate/home;adtype=iframe;tile=' + ad_count + ';sz=120x60;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads120x60RealEstateTop";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="120" 
		IFR.height="60"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
	}
	if (document.getElementById('DoubleClickTarget120x60RealEstateMiddle')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.realestate/home;adtype=iframe;tile=' + ad_count + ';sz=120x60;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads120x60RealEstateMiddle";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="120" 
		IFR.height="60"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
	}
	if (document.getElementById('DoubleClickTarget120x60RealEstateBottom')) {
		adurl='http://ad.doubleclick.net/adi/swc.'+DoubleClickDomain+'.realestate/home;adtype=iframe;tile=' + ad_count + ';sz=120x60;ord='+ord1+'?';
		var IFR =document.createElement('iframe');
		var target="DoubleClickads120x60RealEstateBottom";
		var VariableName = "" + new Date().getTime();
		IFR.name = IFR.id = "iframe-" + VariableName
		IFR.width="120" 
		IFR.height="60"
		IFR.frameBorder="0" 
		IFR.scrolling="no" 
		IFR.allowTransparency="allowtransparency"
		IFR.src=adurl;
		document.getElementById(target).innerHTML="";
		document.getElementById(target).appendChild(IFR);
	}
	//dcsMultiTrack();
	pageTracker._trackPageview();
	return;
}

//////////////////////////////////////////////////////////////////////////////
///////// LoadAds Script End /////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function MM_showHideLayers() { //v9.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*
 * Generic functions
 */
// consoleDebug -- debug an object
// safe even in production environments that do not have console
function consoleDebug(obj) {
	var loc = window.location.hostname;
	if (loc.search(/dev\.|stage\./i)!=-1 && typeof console != 'undefined') 
		console.debug(obj);
}
// strip unwanted tags from a string, leaving ones that are specified
function stripTags(str, taglist) {
	// why not use regex?  I tried; scoured the net for one that worked, and they all seemed to fail.  This is my workaround.  Better solutions welcome.
	var arTagList = taglist.split(",");
	var strOut = "";
	for (i=0; i<str.length; i++) {
		if (str.charAt(i)=="<") {
			var iOrig = i;	// save initial position
			// check for </xxx> tags
			if (str.charAt(i+1)=="/") i++;
			// allowed tag, or not?
			var bAllowed = false;
			for (a=0; a<arTagList.length; a++) {
				var iposttagpos = i+1+arTagList[a].length;
				if (str.substr(i+1,arTagList[a].length).toLowerCase()==arTagList[a].toLowerCase() &&
					iposttagpos < str.length &&
					(str.charAt(iposttagpos).toLowerCase() < "a" ||
					str.charAt(iposttagpos).toLowerCase() > "z")) bAllowed=true;
			}
			// find end of tag
			for (j=i; j<str.length; j++)
				if (str.charAt(j)==">") break;
			if (j==str.length) j=str.length-1;	// in case > isn't found, put it at the end of the string
			if (bAllowed)
				strOut += str.substr(iOrig, j-iOrig+1);
			i = j;	// want to set it to j+1, so put it at j and let the loop do it
		} else
			strOut += str.charAt(i);
	}
	return strOut;
}
function stripCommentSGML(strMod){
    //Thanks to: http://www.faqts.com/knowledge_base/view.phtml/aid/21761
    strMod=strMod.replace(/<!(?:--[sS]*?--s*)?>s*/g,''); //double dashes escaped cuz of SGML comment
    return strMod;
}
// Look for all URLs in the text and replace them with tagged URLs (that open externally)
function tagURLs(strText) {
	// Going to use a very, very basic URL substitution that doesn't do much (any?) error checking
	var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
	var expanded = strText.replace(exp,"<a href='$1' target='_blank' rel='nofollow'>$1</a>"); 
	return expanded;
}
// Given a string of key/value pairs separated by "&", get one of the values
// Case insensitive
// returns "" on not found; value otherwise
// NOTE:  returns the FIRST value for strKey
function getKeyValueFromStr(strKeyValues, strKey) {
	var istrKey = strKey.toLowerCase();
	var ar = strKeyValues.split("&");
	for (var i=0; i<ar.length; i++) {
		var arPair = ar[i].split("=");
		if (arPair[0].toLowerCase()==istrKey) return arPair[1];
	}
	return "";
}
function displayAthleteGroup(displyAthleteGroup) {
	var athletesListDiv = document.getElementById("athletesList");
	var athleteListDivText = athleteList[displyAthleteGroup];
	if (athleteListCount > 1) {
		athleteListDivText = athleteListDivText + '<br clear="left" style="clear:left;" /><div class="athleteListFooter"><a href="#" onclick="displayAthleteGroup(' + (((displyAthleteGroup-1)<0)?(athleteListCount-1):(displyAthleteGroup-1)) + ');return false;"><img src="'+publicusPath+'/Global/images/olympics/left_arrow.gif" border="0" alt="" /></a>';
		for (x=0;x<athleteListCount;x++) {
			athleteListDivText = athleteListDivText + '<a href="#" onclick="displayAthleteGroup(' + x + ');return false;"><img src="'+publicusPath+'/Global/images/olympics/circle_' + ((displyAthleteGroup==x)?'active':'inactive') + '.gif" border="0" alt="" /></a>';
		}
		athleteListDivText = athleteListDivText + '<a href="#" onclick="displayAthleteGroup(' + (((displyAthleteGroup+1)==athleteListCount)?0:(displyAthleteGroup+1)) + ');return false;"><img src="'+publicusPath+'/Global/images/olympics/right_arrow.gif" border="0" alt="" /></a></div>';
	}
	athletesListDiv.innerHTML = athleteListDivText;
}

function articleCommentMatcher() {
	var url = window.location.href;
	var pattern = /&mode=comments/i;
	if(url.match(pattern))
		{return"comments";}
	else
		{return "none";}
		
}

function displayComments(mode)
{
	if(mode =="comments")
		$("#articleDisplay").hide();
	else
		$("#commentDisplay").hide();
	$("#toolbarTop").css("border-top", "none")
}

function setDefaultTab(tabType,tabSelectedNumber,tabHighestNumber) {
	// change the background images
	// set non selected tabs inactive
	setTabsInactive(tabType,tabSelectedNumber,tabHighestNumber);
	
	// set correct tab active
	document.getElementById("tab"+tabType+tabSelectedNumber+"Left").className = "activeTabLeft";
	document.getElementById("tab"+tabType+tabSelectedNumber).className = "activeTab";
	document.getElementById("tab"+tabType+tabSelectedNumber+"Right").className = "activeTabRight";
	document.getElementById("link"+tabType+tabSelectedNumber).className = "active";
	document.getElementById("content"+tabType+tabSelectedNumber).style.display = "block";
	}
	
function setDropDownText(useEedition)
{
	if(useEedition)
	{
		$("#noEedition").hide();
	}
	else
	{
		$("#eEditionText").hide();
		$("#ePaperLink").hide();
	}
}

function previousArtCookie(value, basedomain)
{	
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "previousArt="+value+expires+"; path=/; domain=" +basedomain+";";
}


