// popup window
function popupWin(url, theWidth, theHeight, displayScroll, resize) {
	newwindow=window.open(url,'name', 'width='+ theWidth +', height='+ theHeight +', scrollbars='+ displayScroll +',resizable='+ resize +'');
	if (window.focus) {newwindow.focus()}
	return false;
}

// end popup window



// don't eat the yellow snow! that's where the huskies go!!
if(window.attachEvent)
	window.attachEvent("onload",setListeners);
	
	function setListeners(){
	inputList = document.getElementsByTagName("INPUT");
	for(i=0;i<inputList.length;i++){
	  inputList[i].attachEvent("onpropertychange",restoreStyles);
	  inputList[i].style.backgroundColor = "";
	}
	selectList = document.getElementsByTagName("SELECT");
	for(i=0;i<selectList.length;i++){
	  selectList[i].attachEvent("onpropertychange",restoreStyles);
	  selectList[i].style.backgroundColor = "";
	}
	}
	
	function restoreStyles(){
	if(event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "#a0d0ff"){
	  event.srcElement.style.backgroundColor = "#444444"; 
	  document.all['googleblurb'].style.display = "block";
	}
	}
// en yellow input field fix







var shome = shome || '.';
var sroot = sroot || '..';

// --------------------- start display panels for register, login and sign up

var utils = 
{
	$: function(A, C)
	{
		if (C)
		{
			//D = D || 'PARENT';
			//var node = D == 'PARENT' ? A.parentNode : A.child;
			var node = A.parentNode;
			while (node.nodeName != C && node.nodeName != 'BODY')
			{
				node = node.parentNode;
			}
			return node;
		}
		else
			return document.getElementById(A);
	},

	$$: function(A)
	{
		var elementArray = [];
		if (document.all)
			elementArray = document.all;
		else
			elementArray = document.getElementsByTagName("*");

		var matchedArray = [];
		var pattern = new RegExp("(^| )" + A + "( |$)");

		for (var i = 0; i < elementArray.length; i++)
		{
			if (pattern.test(elementArray[i].className))
				{ matchedArray[matchedArray.length] = elementArray[i]; }
		}
		return matchedArray;
	},

	addClass: function(E, A)
	{
		if (!utils.hasClass(E, A))
		{
			E.className += ' ' + A;
		}
	},

	removeClass: function(E, A)
	{
		if (utils.hasClass(E, A))
		{
			E.className = E.className.replace(new RegExp("(^|\\s)" + A + "(?:\\s|$)"), "$1");
			E.className = E.className.replace(new RegExp("(\\s$)"), "");
		}
		return E;
	},

	hasClass: function(E, A)
	{
		var pattern = new RegExp("(?:^|\\s)" + A + "(?:\\s|$)");
		if (pattern.test(E.className)) 
			{ return true; }
		return false;
	},

	href_update: function(H, A, B)
	{
		return H.replace(new RegExp("(.*"+A+"=)([^&]*)(.*)"), "$1" + B + "$3");
	},

	href_append: function(H, A, B)
	{
		if (typeof H.length != 'undefined')
		{
			for (var i = 0; i < H.length; i++)
			{
				if (utils.href_contains(H[i].href, A))
					H[i].href = utils.href_update(H[i].href, A, B);
				else
					H[i].href = utils.href_add(H[i].href, A, B);
			}
		}
		else
		{
			if (utils.href_contains(H.href, A))
				H.href = utils.href_update(H.href, A, B);
			else
				H.href = utils.href_add(H.href, A, B);
		}
	},

	href_contains: function(H, A)
	{
		var pattern = new RegExp("(\\?|\\&)" + A + "(.*|$)");
		return pattern.test(H);
	},

	href_add: function(H, A, B)
	{
		return H + utils.href_conj(H) + A + '=' + B;
	},

	href_conj: function(H)
	{
		return (new RegExp("\\?").test(H)) ? '&' : '?';
	},

	href_remove: function(H, A)
	{
		H = H.replace(new RegExp("(.*)((\\?|\\&)*" + A + "=[^&]*(?:\\&)?)(.*)"), "$1" + '' + "$3$4");
		H = H.replace(new RegExp("(.*)(\\?|\\&)$"), "$1");
		return H;
	},

	href_rewrite: function(H, A, T)
	{
		T = T || '';
		H.href = A;
		H.title = T;
	}
}



var Evnt = {};

Evnt.eType = typeof document.addEventListener != 'undefined' ? 'addEventListener' : typeof document.attachEvent != 'undefined' ? 'attachEvent' : 'none';
Evnt.ePref = (Evnt.eType == 'attachEvent' ? 'on' : '');




var indexTabs = new Array('right-col-register', 'right-col-login', 'right-col-signup', 'right-col-forgot', 'right-col-y', 'right-col-z');

function show_register()
{
	if (!utils.$('right-col-register')) { setTimeout(function() { show_register(); }, 1000); return;}
	for (var i = 0; i < indexTabs.length; i++) if (utils.$(indexTabs[i])) utils.$(indexTabs[i]).style.display = indexTabs[i] == 'right-col-register' ? 'block' : 'none';
}

function show_login()
{
	if (!utils.$('right-col-login')) { setTimeout(function() { show_login(); }, 1000); return;}
	for (var i = 0; i < indexTabs.length; i++) if (utils.$(indexTabs[i])) utils.$(indexTabs[i]).style.display = indexTabs[i] == 'right-col-login' ? 'block' : 'none';
}

function show_signup()
{
	if (!utils.$('right-col-login')) { setTimeout(function() { show_signup(); }, 1000); return;}
	for (var i = 0; i < indexTabs.length; i++) if (utils.$(indexTabs[i])) utils.$(indexTabs[i]).style.display = indexTabs[i] == 'right-col-signup' ? 'block' : 'none';
}

function show_forgot()
{
	if (!utils.$('right-col-forgot')) { setTimeout(function() { show_forgot(); }, 1000); return;}
	for (var i = 0; i < indexTabs.length; i++) if (utils.$(indexTabs[i])) utils.$(indexTabs[i]).style.display = indexTabs[i] == 'right-col-forgot' ? 'block' : 'none';
}

function show_y()
{
	for (var i = 0; i < indexTabs.length; i++) if (utils.$(indexTabs[i])) utils.$(indexTabs[i]).style.display = indexTabs[i] == 'right-col-y' ? 'block' : 'none';
}

function show_z()
{
	for (var i = 0; i < indexTabs.length; i++) if (utils.$(indexTabs[i])) utils.$(indexTabs[i]).style.display = indexTabs[i] == 'right-col-z' ? 'block' : 'none';
}
// --------------------- end display panels for register, login and sign up

function show_special_login()
{
	utils.$('special-login-box').style.display = 'block';
	utils.$('forgot-box').style.display = 'none';
	utils.$('login-box').style.display = 'block';
	utils.$('login-username').focus();
}

function show_special_register()
{
	hideFlashAd();
	utils.$('special-registration-box').style.display = 'block';
	utils.$('login-username').focus();
}

function show_special_add_comment()
{
	utils.$('special-add-comment-box').style.display = 'block';
	utils.$('comment-text').focus();
}






//----------------------  expand and collapse the side layers
var filterState = 'CLOSED';
function show_filter_div()
{
	if (utils.$("filter-updown-arrow"))
	{
		if (filterState == 'CLOSED')// when clicked expand
		{
			utils.$('filter-updown-arrow').src = shome + '/images/buttons/collapse_filter_form.gif';
			//utils.$('top-filter').style.display = 'none';
			utils.$("top-filter").style.display = "none";
			utils.$("filter-tbl-div").style.display = "block";
			utils.$("filter-div").style.height = 181+"px";
			utils.$("list-101-div").style.height = 140+"px";
			filterState = 'OPEN';
		}
		else // when clicked collapse
		{
			utils.$('filter-updown-arrow').src = shome + '/images/buttons/expand_filter_form.gif';
			utils.$("top-filter").style.display = "block";
			utils.$("filter-div").style.height = 15+"px";
			utils.$("filter-tbl-div").style.display = "none";
			utils.$("list-101-div").style.height = 306+"px";
			filterState = 'CLOSED';
		}
	}
}

function show_list_div()
{
	show_filter_div();
}
//----------------------  end expand and collapse the side layers				

function hideFlashAd() {
	if (utils.$('chris_awesome_ad'))
		utils.$('chris_awesome_ad').style.display = 'none';
}
function showFlashAd() {
	if (utils.$('chris_awesome_ad'))
		utils.$('chris_awesome_ad').style.display = 'block';
}

function flashOpen() 
{
	utils.$('side-gallery').style.width  = '610px';
	utils.$('side-gallery').style.height = '350px';
//	utils.$('side-gallery').style.backgroundColor = '#E5E5E5';
	utils.$('sub-main-col').style.overflow = 'hidden';
	
	hideFlashAd();
	utils.$('chris_awesome').style.display = 'none';
}
function flashClose() 
{
	utils.$('side-gallery').style.width  = '200px';
	utils.$('side-gallery').style.height = '160px';
//	utils.$('side-gallery').style.backgroundColor = 'transparent';	
	utils.$('sub-main-col').style.overflow = 'auto';
	
	showFlashAd();
	utils.$('chris_awesome').style.display = 'block';
}


//----------------------  expand and collapse the top banner section

/*var tmpToggle = '<img src=\"'+ shome + '\/images\/buttons\/open-top-btn.jpg\" alt=\"Toggle\" title=\"Toggle\" width=\"32\" height=\"32\" \/>';
function show_hide()
{*/
	//alert(shome+'/Classes/pro_header_toggle.php');
	//location.href = shome + '/pro_header_toggle.php';
	/*var bannerState = utils.$('photo-banner').style.display == 'block' ? 'open' : 'closed';
	utils.$('photo-banner').style.display = (bannerState == 'open') ? 'block' : 'none';
	//utils.$('curl-top-top').style.display = (bannerState == 'closed') ? 'none'  : 'block';
	utils.$('toggle').innerHTML = (bannerState == 'closed') ? '<img src=\"'+ shome + '\/images\/buttons\/close-top-btn.jpg\" alt=\"Toggle\" width=\"32\" height=\"32\" \/>' : tmpToggle;
	bannerState = (bannerState == 'closed') ? 'opened' : 'closed';*/
//}
//----------------------  end expand top function






 
//---------------------- start main nav image rollover 
if (document.images)
{
	nav0_on = new Image();
	nav0_off = new Image();
	nav0_on.src = shome + "/images/nav/home_on.gif";
	nav0_off.src = shome + "/images/nav/home_off.gif";

	nav1_on = new Image();
	nav1_off = new Image();
	nav1_on.src = shome + "/images/nav/101map_on.gif";
	nav1_off.src = shome + "/images/nav/101map_off.gif";

	nav2_on = new Image();
	nav2_off = new Image();
	nav2_on.src = shome + "/images/nav/101gallery_on.gif";
	nav2_off.src = shome + "/images/nav/101gallery_off.gif";

	nav3_on = new Image();
	nav3_off = new Image();
	nav3_on.src = shome + "/images/nav/prizes_on.gif";
	nav3_off.src = shome + "/images/nav/prizes_off.gif";					   

	nav4_on = new Image();
	nav4_off = new Image();
	nav4_on.src = shome + "/images/buttons/101weekends-btn-on.jpg";
	nav4_off.src = shome + "/images/buttons/101weekends-btn-off.jpg";

	nav5_on = new Image();
	nav5_off = new Image();
	nav5_on.src = shome + "/images/buttons/101mustdo-btn-on.jpg";
	nav5_off.src = shome + "/images/buttons/101mustdo-btn-off.jpg";

	nav6_on = new Image();
	nav6_off = new Image();
	nav6_on.src = shome + "/images/buttons/regional101-btn-on.jpg";
	nav6_off.src = shome + "/images/buttons/regional101-btn-off.jpg";

	nav7_on = new Image();
	nav7_off = new Image();
	nav7_on.src = shome + "/images/nav/search_on.gif";
	nav7_off.src = shome + "/images/nav/search_off.gif";
	
	nav8_on = new Image();
	nav8_off = new Image();
	nav8_on.src = shome + "/images/nav/regional_on.gif";
	nav8_off.src = shome + "/images/nav/regional_off.gif";
	
	nav9_on = new Image();
	nav9_off = new Image();
	nav9_on.src = shome + "/images/nav/101game_on.gif";
	nav9_off.src = shome + "/images/nav/101game_off.gif";
}



function mouse_on (imgId)
{
	if (document.images)
	{
		navOn = eval (imgId + "_on.src");
		utils.$(imgId).src = navOn;
	}
}

function mouse_off (imgId)
{
	if (document.images)
	{
		navOff = eval (imgId + "_off.src");
		utils.$(imgId).src = navOff;
	}
}
//---------------------- end main nav image rollover







//--------------------- start link fade script

/* File    : JSFX_LinkFader.js  © JavaScript-FX.com
* Created : 2002/09/05 
* Author  : Roy Whittle  (Roy@Whittle.com) www.Roy.Whittle.com 
* Purpose : To create a more dynamic a:hover using fading
* History 
* Date         Version        Description 
* 2002-09-05	1.0		First version */

/*** Create some global variables ***/
if(!window.JSFX)JSFX=new Object();

var LinkFadeInStep=20;
var LinkFadeOutStep=10;
var LinkEndColor="BBBBBB"

var LinkStartColor="000000";
var LinkFadeRunning=false;

document.onmouseover = theOnOver;
document.onmouseout  = theOnOut;
if(document.captureEvents)
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);

/***********************************************
*
* Function    : getColor
*
* Parameters  :	start - the start color (in the form "RRGGBB" e.g. "FF00AC")
*			end - the end color (in the form "RRGGBB" e.g. "FF00AC")
*			percent - the percent (0-100) of the fade between start & end
*
* returns	  : color in the form "#RRGGBB" e.g. "#FA13CE"
*
* Description : This is a utility function. Given a start and end color and
*		    a percentage fade it returns a color in between the 2 colors
*
* Author	  : www.JavaScript-FX.com
*
*************************************************/
function hex2dec(hex){return(parseInt(hex,16));}
function dec2hex(dec){return (dec < 16 ? "0" : "") + dec.toString(16);} 
function getColor(start, end, percent)
{
	var r1=hex2dec(start.slice(0,2));
	var g1=hex2dec(start.slice(2,4));
	var b1=hex2dec(start.slice(4,6));

	var r2=hex2dec(end.slice(0,2));
	var g2=hex2dec(end.slice(2,4));
	var b2=hex2dec(end.slice(4,6));

	var pc=percent/100;

	var r=Math.floor(r1+(pc*(r2-r1)) + .5);
	var g=Math.floor(g1+(pc*(g2-g1)) + .5);
	var b=Math.floor(b1+(pc*(b2-b1)) + .5);

	return("#" + dec2hex(r) + dec2hex(g) + dec2hex(b));
}
/************************************************/
JSFX.getCurrentElementColor = function(el) 
{ 
	var result = LinkStartColor;

	if (el.currentStyle) 
		result = (el.currentStyle.color); 
	else if (document.defaultView) 
		result = (document.defaultView.getComputedStyle(el,'').getPropertyValue('color'));
	else if(el.style.color) //Opera
		result = el.style.color;

	if(result.charAt(0) == "#")      //color is of type #rrggbb
		result = result.slice(1, 8);
	else if(result.charAt(0) == "r") //color is of type rgb(r, g, b)
	{
		var v1 = result.slice(result.indexOf("(")+1, result.indexOf(")") );
		var v2 = v1.split(",");
		result = (dec2hex(parseInt(v2[0])) + dec2hex(parseInt(v2[1])) + dec2hex(parseInt(v2[2])));
	}

	return result;
} 
JSFX.findTagIE = function(el)
{
      while (el && el.tagName != 'A')
            el = el.parentElement;
	return(el);
}
JSFX.findTagNS= function(el)
{
      while (el && el.nodeName != 'A')
            el = el.parentNode;
	return(el);
}
function theOnOver(e)
{
	var lnk;
	if(window.event)
		lnk=JSFX.findTagIE(event.srcElement);
	else
		lnk=JSFX.findTagNS(e.target);

	if(lnk)
		JSFX.linkFadeUp(lnk);
}
JSFX.linkFadeUp = function(lnk)
{
	if(lnk.state == null)
	{
		lnk.state = "OFF";
		lnk.index = 0;
		lnk.startColor = JSFX.getCurrentElementColor(lnk);
		lnk.endColor = LinkEndColor;
	}

	if(lnk.state == "OFF")
	{
		lnk.state = "FADE_UP";
		JSFX.startLinkFader();
	}
	else if( lnk.state == "FADE_UP_DOWN"
		|| lnk.state == "FADE_DOWN")
	{
		lnk.state = "FADE_UP";
	}
}
function theOnOut(e)
{
	var lnk;
	if(window.event)
		lnk=JSFX.findTagIE(event.srcElement);
	else
		lnk=JSFX.findTagNS(e.target);

	if(lnk)
		JSFX.linkFadeDown(lnk);
}
JSFX.linkFadeDown = function(lnk)
{
	if(lnk.state=="ON")
	{
		lnk.state="FADE_DOWN";
		JSFX.startLinkFader();
	}
	else if(lnk.state == "FADE_UP")
	{
		lnk.state="FADE_UP_DOWN";
	}
}
JSFX.startLinkFader = function()
{
	if(!LinkFadeRunning)
		JSFX.LinkFadeAnimation();
}
/*******************************************************************
*
* Function    : LinkFadeAnimation
*
* Description : This function is based on the Animate function
*		        of animate.js (animated rollovers).
*		        Each fade object has a state. This function
*		        modifies each object and changes its state.
*****************************************************************/
JSFX.LinkFadeAnimation = function()
{
	LinkFadeRunning = false;
	for(i=0 ; i<document.links.length ; i++)
	{
		var lnk = document.links[i];
		if(lnk.state)
		{
			if(lnk.state == "FADE_UP")
			{
				lnk.index+=LinkFadeInStep;
				if(lnk.index > 100)
					lnk.index = 100;
				lnk.style.color=getColor(lnk.startColor, lnk.endColor, lnk.index);

				if(lnk.index == 100)
					lnk.state="ON";
				else
					LinkFadeRunning = true;
			}
			else if(lnk.state == "FADE_UP_DOWN")
			{
				lnk.index+=LinkFadeOutStep;
				if(lnk.index>100)
					lnk.index = 100;
				lnk.style.color=getColor(lnk.startColor, lnk.endColor, lnk.index);

				if(lnk.index == 100)
					lnk.state="FADE_DOWN";
				LinkFadeRunning = true;
			}
			else if(lnk.state == "FADE_DOWN")
			{
				lnk.index-=LinkFadeOutStep;
				if(lnk.index<0)
					lnk.index = 0;
				lnk.style.color=getColor(lnk.startColor, lnk.endColor, lnk.index);
	
				if(lnk.index == 0)
					lnk.state="OFF";
				else
					LinkFadeRunning = true;
			}
		}
	}
	/*** Check to see if we need to animate any more frames. ***/
	if(LinkFadeRunning)
		setTimeout("JSFX.LinkFadeAnimation()", 40);
}

//--------------------- end link fade script

//add new hidden node to search form
//created by: Richard
function addNewNodeToForm (formID,newNodeElement , newNodeName, newNodeType, newNodeValue){
	appendForm=document.getElementById(formID);
	newnode=document.createElement(newNodeElement);
	newnode.type=newNodeType;
	newnode.name=newNodeName;
	newnode.value = newNodeValue;
	appendForm.appendChild(newnode);
	
}





