var qrystr=''; //keep this, used for tracking some qrystr parameters for have lowt quiz.

function goToExternalSite(u){
	popWindowNoScroll('leaving.html?u='+u,'LeaveSiteWin','435','590');
}

function goToSendFriend(href){
	var currentURL = document.URL;				//set url of current page

	
	var test1 = currentURL.indexOf('sendtofriend');		//check if page is sendtofriend
	var test2 = currentURL.indexOf('sendtocolleague');	//check if page is sendtocolleague
	if(test1==-1 && test2==-1)				//if not either, then set the cookie for back button
		setCookie("returnURL", currentURL);		//this avoids loop with send to friend page.
		
	window.location = href;
}

function getSendToFriendBackURL(){
	
	var url = getCookie('returnURL');

	if(url==null || url==false || url=="")
		return "index.html";
	else
		return url;
}

var prepend = "";
var u3 = document.URL;
if(u3.indexOf("/locator")!=-1) prepend = "../";

var fs = getCookie("androgelFS");
if(!fs){
 document.write('<link id="fontSize" href="'+prepend+'styles/fontMedium.css" rel="stylesheet" type="text/css">');
}
else{
  if(fs=="1"){
	document.write('<link id="fontSize" href="'+prepend+'styles/fontSmall.css" rel="stylesheet" type="text/css">');
  }
  if(fs=="2"){
	document.write('<link id="fontSize" href="'+prepend+'styles/fontMedium.css" rel="stylesheet" type="text/css">');
  }
  if(fs=="3"){
	document.write('<link id="fontSize" href="'+prepend+'styles/fontLarge.css" rel="stylesheet" type="text/css">');
  }
}


function preloadNavImages()
{
	preloadImages('/images/nav_home_on.gif',
			  '/images/nav_about_low_on.gif',
			  '/images/nav_about_on.gif',
			  '/images/nav_extras_on.gif',
			  '/images/nav_low_on.gif',
			  '/images/icon_small_a_on.gif',
			  '/images/icon_medium_a_on.gif',
			  '/images/icon_large_a_on.gif');

		var size = getCookie("androgelFS");
		//alert(size);
		if(!size){
			setCookie("androgelFS", "2");
			changeFontSize("2");
		}
		else {
			changeFontSize(size);
		}
}

function changeFontSize(size)
{
		//alert(size);
		var currsize = getCookie("androgelFS");
		if(currsize!=size){
			setCookie("androgelFS", size);
		}

		if(size=='1'){
			document.getElementById("fontSize").href = "styles/fontSmall.css";
		}
		if(size=='2'){
			document.getElementById("fontSize").href = "styles/fontMedium.css";
		}
		if(size=='3'){
			document.getElementById("fontSize").href = "styles/fontLarge.css";
		}
}

function changeFontSizeIF(size)
{
		//alert(size);
		var currsize = getCookie("androgelFS");
		if(currsize!=size){
			setCookie("androgelFS", size);
		}

		if(size=='1'){
			document.getElementById("fontSize").href = "styles/fontSmall.css";
			window.top.frames["navspace1"].document.getElementById("fontSize").href = "styles/fontSmall.css";
		}
		if(size=='2'){
			document.getElementById("fontSize").href = "styles/fontMedium.css";
			window.top.frames["navspace1"].document.getElementById("fontSize").href = "styles/fontMedium.css";
		}
		if(size=='3'){
			document.getElementById("fontSize").href = "styles/fontLarge.css";
			window.top.frames["navspace1"].document.getElementById("fontSize").href = "styles/fontLarge.css";
		}
}

function openPrinterFriendly(url){

           popWindow(url,'PrinterFriendly','760','600');

}




/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}