<!--
/// standard things to make our life easier
var giftcert='';
var coupon='';
var Customerlogincid=2;

function swapimgsrc(imgName,swith){
	document[imgName].src= swith;
}

function cleanajaxpost(d){
cleanedstring=d;
cleanedstring = cleanedstring.replace("'","\'");
cleanedstring = cleanedstring.replace("(","\(");
cleanedstring = cleanedstring.replace("(","\)");
cleanedstring = cleanedstring.replace("!","\!");
cleanedstring = cleanedstring.replace("*","\*");
cleanedstring = cleanedstring.replace("~","\~");
cleanajaxpost = cleanedstring
}
///

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function changeclass(e,c){
	if (c=="prod-thumbs-list" || c=="prod-thumbs-md"){
		location.reload(true);
	}else {
		document.getElementById(e).className=c;
	}
}

function changeBox(box,sform) {
	box.checked = true;
	if(sform){
		submitoncat();
	}
}

function ajaxLoader(url, id, post, variables, func, abortstuff, runfunc) {
	
	var statesdrop = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
var shipzip = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
var citystate = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	
  if (document.getElementById) {
	if (abortstuff!=undefined && abortstuff!=''){
		//if (eval(abortstuff+".readyState") != 0) {
			//eval(abortstuff+".abort();");
		//}
		eval(abortstuff).onreadystatechange = function() {
			if (eval(abortstuff+".readyState") == 4 && eval(abortstuff+".status") == 200){
				if (func){
					eval(eval(abortstuff+".responseText"));
				} else {
					el = document.getElementById(id);
					eval("el.innerHTML = "+abortstuff+".responseText;");
				}
				if (runfunc!=''){
					eval(runfunc);
				}
			}
		}
    	eval(abortstuff+".open(post, url, true);");
		eval(abortstuff+".setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');");
		eval(abortstuff+".send(variables);");
	} else {
		var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		x.onreadystatechange = function() {
		  if (x.readyState == 4 && x.status == 200) {
				if (func){
					eval(x.responseText);
				} else {
					el = document.getElementById(id);
					//alert(id);
					if(id=="strGiftcertificate"){
						document.write(id)
						el.value = x.responseText;
					}else{
						el.innerHTML = x.responseText;
					}
				}
				if (runfunc!=''){
					eval(runfunc);
				}
		  }
		}
		x.open(post, url, true);
		  x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		x.send(variables);
	}
  }
}

function loaduszipcitystate(zip,ship){
	if (zip.length==5){
		if (document.shipping.strcountry.options[document.shipping.strcountry.selectedIndex].value=='US' && ship==''){
			ajaxLoader('/includes/cartcitystatezip.asp?postalcode='+zip+'&ship='+ship, '', 'GET','',true,'citystate','onstatechange();');
		}
		if (document.shipping.shipcountry.options[document.shipping.shipcountry.selectedIndex].value=='US' && ship){
			ajaxLoader('/includes/cartcitystatezip.asp?postalcode='+zip+'&ship='+ship, '', 'GET','',true,'citystate','onstatechange();');
		}
	} else {
		oncountrychange('','','zip');
	}
}

function setcityandstate(city, state, shiporbill){
		if (shiporbill=="ship"){
			var dc=document.shipping.shiptown;
			var ds=document.shipping.shipstate;
		} else {
			var dc=document.shipping.strcity;
			var ds=document.shipping.strstate;
		};
		
		dc.value=city;
		for (i=0; i <= ds.options.length - 1; i++){
			if(ds.options[i].value==state){
				ds.selectedIndex=i;
				break;
			}
		}

}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

////////////// set cookie crap
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

////////////// get cookie crap

function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

// delete cookie crap
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

//////////////// done with cookie crap

function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ShowContentB(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "block") { document.getElementById(d).style.display = "none"; }
else { document.getElementById(d).style.display = "block"; }
}
function divreplace(id,d) {
el = document.getElementById(id);
el.innerHTML = d;
}


function ReverseContentTree(d,img) {
if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "block") {
		document.getElementById(d).style.display = "none";
		document[img].src='/assets/navigation/tree-closed.gif';
	} else {
		document.getElementById(d).style.display = "block";
		document[img].src='/assets/navigation/tree-opened.gif';
	}
}

function generateshipdropdown() {
sz=document.shipping.shipzip;
bz=document.shipping.strpostcode;
if (sz.value.length>0){
	zipcode=sz.value;
	zipfield=sz;
}else{
	zipcode=bz.value;
	zipfield=bz;
}
	if (zipfield.value.length>4){
document.getElementById("shipcosts").innerHTML = "<img src='/assets/navigation/ajax-loader-lightgreen.gif' valign='absmiddle'> Retreiving shipping rates from FedEx.com";
ajaxLoader('/upsrates/ups-rates.asp?dtype=radio&postcode='+escape(zipcode), 'shipcosts', 'GET','','','shipzip');
}
}

function loadupshipping(csvalue){
	document.getElementById("shipcosts").innerHTML = "<img src='/assets/navigation/ajax-loader-lightgreen.gif' valign='absmiddle'> Retreiving shipping rates from UPS.com";
	ajaxLoader('/upsrates/ups-rates.asp?dtype=radio&'+csvalue, 'shipcosts', 'GET','','','shipzip');
}

function loadupstates(bills, ships, type, country){
	if (type=="ships"){
			ajaxLoader('/includes/cartstatesajax.asp?field=shipstate&tax=true&value='+ships+'&country='+country, 'shipstate', 'GET','','','statesdrop');
	} else if (type=="bills"){
			ajaxLoader('/includes/cartstatesajax.asp?field=strstate&tax=true&value='+bills+'&country='+country, 'strstate', 'GET','','','statesdrop');
	}
}

function oncountrychange(bills, ships, type){
	divreplace('shipcosts','<div  style="padding:10px;">Shipping will be calculated</div></div>');
alreadysubmitted=true; // We do this to prevent them from submitting the form while ajax shipping is loading
sc=document.shipping.shipcountry;
bc=document.shipping.strcountry;
sz=document.shipping.shipzip;
bz=document.shipping.strpostcode;
ss=document.shipping.shipstate;
bs=document.shipping.strstate;
co=document.shipping.copy;

////// if not US then uncheck the different shipping and disable it
if (bc.options[bc.selectedIndex].value!='US' && 1==1){ // the 1==1 is used to turn off the international only allowed to ship to billing feature
	/*
	document.shipping.copy.checked=false;
	displayshipaddress(false);
	document.shipping.copy.disabled=true;
	ShowContent('intship');
	HideContent('altship');
	*/
	/* temporary to allow international billing but only with domestic shipping */
	co.disabled=false;
	HideContent('intship');
	ShowContent('burtonintship');
	ShowContent('altship');
	HideContent('billusphone');
	ShowContent('billintphone');
} else {
	co.disabled=false;
	HideContent('intship');
	ShowContent('altship');
	HideContent('burtonintship');
	ShowContent('billusphone');
	HideContent('billintphone');
}
//////

if (co.checked){
	zipcode=sz.value;
	zipfield=sz;
	statecode=ss.value;
}else{
	zipcode=bz.value;
	zipfield=bz;
	statecode=bs.value;
}
	if (type!="zip"){
		if (type=="bills"){
			loadupstates(bills,ships,'bills',bc.options[bc.selectedIndex].value);
		} else if (type=="ships") {
			loadupstates(bills,ships,'ships',sc.options[sc.selectedIndex].value);
		} else {
			loadupstates(bills,ships,'bills',bc.options[bc.selectedIndex].value);
			loadupstates(bills,ships,'ships',sc.options[sc.selectedIndex].value);
		}
	}
	if (sc.options[sc.selectedIndex].value!='' && co.checked){
		if (sc.options[sc.selectedIndex].value!='US'){
			//if (type!="zip"){
				ShowContent('duties');
				if (zipfield.value.length>2 && statecode!=''){
					loadupshipping('postcode='+zipcode+'&country='+sc.value+'&statecode='+statecode);
				}
			//}
			HideContent('shipusphone');
			ShowContent('shipintphone');
		}else{
			HideContent('duties');
			if (zipfield.value.length>4){
				loadupshipping('postcode='+zipcode+'&statecode='+statecode);
			}
			ShowContent('shipusphone');
			HideContent('shipintphone');
		}
	} else {
		if (bc.options[bc.selectedIndex].value!='US'){
			//if (type!="zip"){
				ShowContent('duties');
				if (zipfield.value.length>2 && statecode!=''){
					loadupshipping('postcode='+zipcode+'&country='+bc.value+'&statecode='+statecode);
				}
			//}
		}else{
			HideContent('duties');
			if (zipfield.value.length>4){
				loadupshipping('postcode='+zipcode+'&statecode='+statecode);
			}
		}
	}
alreadysubmitted=false; //////////// ok they can now submit the form.
}

function onstatechange(){
sc=document.shipping.shipcountry;
bc=document.shipping.strcountry;
ss=document.shipping.shipstate;
bs=document.shipping.strstate;
cc=document.shipping.copy.checked;
//sig=document.shipping.signature.checked;
sig=false;
	if (cc){
		//ajaxLoader('/shopping/ajaxtax.asp?display=MINI&refreshfull=true&state='+ss.options[ss.selectedIndex].value+'&signature='+sig, 'dmini', 'GET', '');
		if (ss.selectedIndex==undefined){
			ajaxLoader('/includes/cartincludeajax.asp?state='+ss.value+'&signature='+sig, 'dfull', 'GET', '');
		}else{
			ajaxLoader('/includes/cartincludeajax.asp?state='+ss.options[ss.selectedIndex].value+'&signature='+sig, 'dfull', 'GET', '');
		}
	} else {
		//ajaxLoader('/shopping/ajaxtax.asp?display=MINI&refreshfull=true&state='+bs.options[bs.selectedIndex].value+'&signature='+sig, 'dmini', 'GET', '');
		if (bs.selectedIndex==undefined){
			ajaxLoader('/includes/cartincludeajax.asp?state='+bs.value+'&signature='+sig, 'dfull', 'GET', '');
		}else{
			ajaxLoader('/includes/cartincludeajax.asp?state='+bs.options[bs.selectedIndex].value+'&signature='+sig, 'dfull', 'GET', '');
		}
	}
oncountrychange('','','zip');
}

function displayshipaddress(showcountrychange){
	sf=document.shipping;
	onstatechange();
	if (sf.copy.checked!=true) {
		HideContent('shipstuff');
		sf.shipname.value='';
		sf.shipcountry.value='';
		sf.shipaddress.value='';
		sf.shipAddress2.value='';
		sf.shiptown.value='';
		sf.shipstate.value='';
		sf.shipzip.value='';
		sf.shipcompany.value='';
		if (showcountrychange){
			oncountrychange('','','ships');
		}
	}else{
		ShowContent('shipstuff');
	}
}

function oncountrychangegift(bills){
	bc=document.shipping.strcountry;
	loadupstatesgift(bills,bc.options[bc.selectedIndex].value);
}

function loadupstatesgift(bills,country){
			ajaxLoader('/includes/cartstatesajax.asp?tax=false&field=strstate&value='+bills+'&country='+country, 'strstate', 'GET','','','statesdrop');
}

function confirmstuff(message,url)
{
 confirming= confirm(message);
if (confirming== true) {
  window.location=url;
 }
}


////////// this is used to submit forms on enter key
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}
//

function submitminishipping(){
	if (document.minishipform.country.value!=""){
		ajaxLoader('/upsrates/ups-rates.asp?dtype=radio&country='+escape(document.minishipform.country.value), 'minishipping', 'GET','','','shipzip');divreplace('minishipzip','<img src=\'/assets/navigation/ajax-loader-lightgreen.gif\' align=\'absmiddle\'> <font color=\'#000000\'>Please wait while we lookup your shipping rates</font>');
	} else {
		ajaxLoader('/upsrates/ups-rates.asp?dtype=radio&postcode='+escape(document.minishipform.postcode.value), 'minishipping', 'GET','','','shipzip');divreplace('minishipzip','<img src=\'/assets/navigation/ajax-loader-lightgreen.gif\' align=\'absmiddle\'> <font color=\'#000000\'>Please wait while we lookup your shipping rates</font>');
	}
	return false;
}

function loadupcartwithgift(t){
	if(t.checked){
		ajaxLoader('/includes/cartincludeajax.asp?addgift='+t.value, 'dfull', 'GET', '');
	} else {
		ajaxLoader('/includes/cartincludeajax.asp?removegift='+t.value, 'dfull', 'GET', '');
	}
}

function submitoncat(){
document.fbrands.submit();
}

String.prototype.trim = function () {
  return this.replace(/^\s+|\s+$/g,'');
};

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}


function searchproducts(fnum){
	searchtype = fnum;
	newformurl = ""
	newformurl = newformurl + "search_";
	searchfilter = document["fsearch1"].KW.value;
	searchfilter = searchfilter.trim();
	searchfilter = searchfilter.replace(/ /gi,"-");
	searchfilter = searchfilter.replace(/--/gi,"-");
	searchfilter = searchfilter.replace(/'/gi,"");
	newformurl = newformurl + searchfilter;

	if (searchtype==1){
		document["fsearch1"].action = "/shop/"+newformurl+"/search_0.asp";
	} else if (searchtype==2) {
		document["fsearch1"].action = "/shop/"+newformurl+"/Wiki/search_0.asp";
	} else if (searchtype==3) {
		newformurl ="/forum/search_process.asp";
		document["fsearch1"].action = newformurl;
	} else if (searchtype==4) {
		newformurl ="/advice/snowboard-advice.asp";
		document["fsearch"+fnum].action = newformurl;
	} else if (searchtype==5) {
		newformurl ="/forum/members.asp";
		document["fsearch"+fnum].action = newformurl;
	}
	return true
}

function updatesearch(type,fnum){
	Set_Cookie( 'searchType', type, '', '/', '', '' );
	if (type==1){
		newformurl ="/shop/search_0.asp";
		document["fsearch"+fnum].action = newformurl;
	} else if (type==2) {
		newformurl ="/shop/Wiki/search_0.asp";
		document["fsearch"+fnum].action = newformurl;
	} else if (type==3) {
		newformurl ="/forum/search_process.asp";
		document["fsearch"+fnum].action = newformurl;
	} else if (type==4) {
		newformurl ="/advice/snowboard-advice.asp";
		document["fsearch"+fnum].action = newformurl;
	} else if (type==5) {
		newformurl ="/forum/members.asp";
		document["fsearch"+fnum].action = newformurl;
	}
}

function updatenarrowby(url,department,brand,terrain,price,sortby,size,gearselector){
		document.pnarrowby.action =url;
		document.pnarrowby.department_filter.value=department;
		document.pnarrowby.brands_filter.value=brand;
		document.pnarrowby.terrain_filter.value=terrain;
		document.pnarrowby.price_filter.value=price;
		document.pnarrowby.sortby.value=sortby;
		document.pnarrowby.size_filter.value=size;
		document.pnarrowby.updatefilter.value="true";
		document.pnarrowby.gearselector.value=gearselector;
		document.pnarrowby.submit();
}

function addtocart(checksize,selectedsize,replacewith,formname,ajaxdiv,shippingdiv){

var submitgo=true;

// START check for quantity

		// Setup shipping/error DIV ------
		document.forms[''+formname+''].elements[1].style.borderColor='';
		document.forms[''+formname+''].elements[1].style.borderStyle='';
		document.forms[''+formname+''].elements[1].style.color='';
		


		// Product does NOT have a DropDownList (ie: tools, miscellaneous)
		// ---------------------------------------------------------------
		var intQuantity = document.forms[''+formname+''].elements[1].value;
		// Show Message if trying to order more than 5 of an item
		if (parseFloat(intQuantity) > 5 )
		{
			divreplace(shippingdiv,'<span style="color: Red; font-size: 10pt; font-weight: bold;">* You can only order 5 of this item at a time.</span>');
			document.forms[''+formname+''].elements[1].style.borderColor='Red';
			document.forms[''+formname+''].elements[1].style.borderStyle='solid';
			document.forms[''+formname+''].elements[1].style.color='Red';
			submitgo=false;
		}


	if (checksize){
		if (selectedsize==0)
			{
			submitgo=false;
			divreplace(ajaxdiv,'<span style="font-size:13px; color:#ff0000; font-weight:bold;">'+replacewith+'</span>');
			}
		
		

		// Product DOES have a DropDownList - Check Stock
		// ----------------------------------------------
		if (checksize)
		{
			if (selectedsize!=0)
			{
		// Show Message if trying to order more than 5 of an item
			if (parseFloat(intQuantity) > 5 )
			{
				divreplace(ajaxdiv,'');
				divreplace(shippingdiv,'<span style="color: Red; font-size: 10pt; font-weight: bold;">* You can only order 5 of this item at a time.</span>');
				document.forms[''+formname+''].elements[1].style.borderColor='Red';
				document.forms[''+formname+''].elements[1].style.borderStyle='solid';
				document.forms[''+formname+''].elements[1].style.color='Red';
				submitgo=false;
			}
			else
			{
				var strString = document.forms[''+formname+''].elements[0][document.forms[''+formname+''].elements[0].selectedIndex].text;
				var intInStock = strString.indexOf('in stock');
		
				var strLength = 2;
				var strStart = (strString.length-11);
						// Make sure start and len are within proper bounds
						if (strStart < 0 || strLength < 0) return "";
						var iEnd, iLen = String(strString).length;
						if (strStart + strLength > iLen)
							  iEnd = iLen;
						else
							  iEnd = strStart + strLength;
						var myString = String(strString).substring(strStart,iEnd);
						
						
						// Are there more in stock than requested?
						 if (myString =="4+") 
							{myString="5";}
	
							// subtract In Stock from Quantity
							if (parseFloat(intQuantity)> parseFloat(myString) || (intInStock==-1) )
							{
						divreplace(ajaxdiv,'');
						divreplace(shippingdiv,'<span style="color: Red; font-size: 10pt; font-weight: bold;">* The Quantity Entered Exceeds Our Current Inventory.</span>');
						document.forms[''+formname+''].elements[1].style.borderColor='Red';
						document.forms[''+formname+''].elements[1].style.borderStyle='solid';
						document.forms[''+formname+''].elements[1].style.color='Red';
						submitgo=false;
							}
							else
							{
						divreplace(ajaxdiv,'');
						document.forms[''+formname+''].elements[1].style.borderColor='';
						document.forms[''+formname+''].elements[1].style.borderStyle='';
						document.forms[''+formname+''].elements[1].style.color='';
							}
				}
			}
}
// END check for quantity
		
	}
	if (submitgo){
		document.forms[''+formname+''].submit();
	}
}

var persisteduls=new Object()
var ddtreemenu=new Object()

////////// this is for 5 star rating system

var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;

// Rollover for image Stars //
function rating(num,set){
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
		s = num.id.replace("_", ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				if (set){
					document.getElementById("_"+i).className = "sel";
				} else {
					document.getElementById("_"+i).className = "on";
				}
				document.getElementById("rateStatus").innerHTML = num.title;	
				holder = a+1;
				a++;
			}else{
				document.getElementById("_"+i).className = "";
			}
		}
}

// For when you roll out of the the whole thing //
function off(me){
		if(!preSet){	
			for(i=1; i<=sMax; i++){		
				document.getElementById("_"+i).className = "";
				document.getElementById("rateStatus").innerHTML = me.parentNode.title;
			}
		}else{
			rating(preSet,true);
		}
}

// When you actually rate something //
function rateIt(me,set,myform){
	preSet = me;
	rating(me,true);
	if (set){
		document.forms[''+myform+''].rstars.value=me.id.replace("_", '')
	}
}

function getselectedbrand(bform,thisform,sitem){
	var bform = document.getElementById(bform);
 	var v = sitem.options[sitem.selectedIndex].value;
	aarray = bform.getAttribute("action").split("/");
	newaction = "/" + aarray[aarray.length-1];
		
	if (v!=''){
	
		varray = v.split('|');
		bform.setAttribute("action", "/"+varray[0]+"/"+varray[1]+newaction);
	
	} else {
		
		bform.setAttribute("action", newaction);
		
	}
	thisform.submit();
}


function Validate_String(string, return_invalid_chars)
         {
         valid_chars = '1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         invalid_chars = '';
         
         if(string == null || string == '')
            return(true);
         
         //For every character on the string.   
         for(index = 0; index < string.length; index++)
            {
            char = string.substr(index, 1);                        
            
            //Is it a valid character?
            if(valid_chars.indexOf(char) == -1)
              {
              //If not, is it already on the list of invalid characters?
              if(invalid_chars.indexOf(char) == -1)
                {
                //If it's not, add it.
                if(invalid_chars == '')
                   invalid_chars += char;
                else
                   invalid_chars += ', ' + char;
                }
              }
            }                     
            
         //If the string does not contain invalid characters, the function will return true.
         //If it does, it will either return false or a list of the invalid characters used
         //in the string, depending on the value of the second parameter.
         if(return_invalid_chars == true && invalid_chars != '')
           {
           last_comma = invalid_chars.lastIndexOf(',');
           
           if(last_comma != -1)
              invalid_chars = invalid_chars.substr(0, $last_comma) + 
              ' and ' + invalid_chars.substr(last_comma + 1, invalid_chars.length);
                      
           return(invalid_chars);
           }
         else
           return(invalid_chars == ''); 
         }


function Validate_Email_Address(email_address)
         {
         //Assumes that valid email addresses consist of user_name@domain.tld
         at = email_address.indexOf('@');
         dot = email_address.indexOf('.');
         
         if(at == -1 || 
            dot == -1 || 
            dot <= at + 1 ||
            dot == 0 || 
            dot == email_address.length - 1)
            return(false);
            
         user_name = email_address.substr(0, at);
         domain_name = email_address.substr(at + 1, email_address.length);                  
         
         if(Validate_String(user_name) === false || 
            Validate_String(domain_name) === false)
            return(false);                     
         
         return(true);
         }


//////////No need to edit beyond here///////////////////////////

ddtreemenu.createTree=function(treeid, enablepersist, persistdays){
var ultags=document.getElementById(treeid).getElementsByTagName("ul")
if (typeof persisteduls[treeid]=="undefined")
persisteduls[treeid]=(enablepersist==true && ddtreemenu.getCookie(treeid)!="")? ddtreemenu.getCookie(treeid).split(",") : ""
for (var i=0; i<ultags.length; i++)
ddtreemenu.buildSubTree(treeid, ultags[i], i)
if (enablepersist==true){ //if enable persist feature
var durationdays=(typeof persistdays=="undefined")? 1 : parseInt(persistdays)
ddtreemenu.dotask(window, function(){ddtreemenu.rememberstate(treeid, durationdays)}, "unload") //save opened UL indexes on body unload
}
}

ddtreemenu.buildSubTree=function(treeid, ulelement, index){
ulelement.parentNode.className="submenu"
if (typeof persisteduls[treeid]=="object"){ //if cookie exists (persisteduls[treeid] is an array versus "" string)
if (ddtreemenu.searcharray(persisteduls[treeid], index)){
ulelement.setAttribute("rel", "open")
ulelement.style.display="block"
ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
}
else
ulelement.setAttribute("rel", "closed")
} //end cookie persist code
else if (ulelement.getAttribute("rel")==null || ulelement.getAttribute("rel")==false) //if no cookie and UL has NO rel attribute explicted added by user
ulelement.setAttribute("rel", "closed")
else if (ulelement.getAttribute("rel")=="open") //else if no cookie and this UL has an explicit rel value of "open"
ddtreemenu.expandSubTree(treeid, ulelement) //expand this UL plus all parent ULs (so the most inner UL is revealed!)
ulelement.parentNode.onclick=function(e){
var submenu=this.getElementsByTagName("ul")[0]
if (submenu.getAttribute("rel")=="closed"){
submenu.style.display="block"
submenu.setAttribute("rel", "open")
ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
}
else if (submenu.getAttribute("rel")=="open"){
submenu.style.display="none"
submenu.setAttribute("rel", "closed")
ulelement.parentNode.style.backgroundImage="url("+ddtreemenu.closefolder+")"
}
ddtreemenu.preventpropagate(e)
}
ulelement.onclick=function(e){
ddtreemenu.preventpropagate(e)
}
}

ddtreemenu.expandSubTree=function(treeid, ulelement){ //expand a UL element and any of its parent ULs
var rootnode=document.getElementById(treeid)
var currentnode=ulelement
currentnode.style.display="block"
currentnode.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
while (currentnode!=rootnode){
if (currentnode.tagName=="UL"){ //if parent node is a UL, expand it too
currentnode.style.display="block"
currentnode.setAttribute("rel", "open") //indicate it's open
currentnode.parentNode.style.backgroundImage="url("+ddtreemenu.openfolder+")"
}
currentnode=currentnode.parentNode
}
}

ddtreemenu.flatten=function(treeid, action){ //expand or contract all UL elements
var ultags=document.getElementById(treeid).getElementsByTagName("ul")
for (var i=0; i<ultags.length; i++){
ultags[i].style.display=(action=="expand")? "block" : "none"
var relvalue=(action=="expand")? "open" : "closed"
ultags[i].setAttribute("rel", relvalue)
ultags[i].parentNode.style.backgroundImage=(action=="expand")? "url("+ddtreemenu.openfolder+")" : "url("+ddtreemenu.closefolder+")"
}
}

ddtreemenu.rememberstate=function(treeid, durationdays){ //store index of opened ULs relative to other ULs in Tree into cookie
var ultags=document.getElementById(treeid).getElementsByTagName("ul")
var openuls=new Array()
for (var i=0; i<ultags.length; i++){
if (ultags[i].getAttribute("rel")=="open")
openuls[openuls.length]=i //save the index of the opened UL (relative to the entire list of ULs) as an array element
}
if (openuls.length==0) //if there are no opened ULs to save/persist
openuls[0]="none open" //set array value to string to simply indicate all ULs should persist with state being closed
ddtreemenu.setCookie(treeid, openuls.join(","), durationdays) //populate cookie with value treeid=1,2,3 etc (where 1,2... are the indexes of the opened ULs)
}

////A few utility functions below//////////////////////

ddtreemenu.getCookie=function(Name){ //get cookie value
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

ddtreemenu.setCookie=function(name, value, days){ //set cookei value
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

ddtreemenu.searcharray=function(thearray, value){ //searches an array for the entered value. If found, delete value from array
var isfound=false
for (var i=0; i<thearray.length; i++){
if (thearray[i]==value){
isfound=true
thearray.shift() //delete this element from array for efficiency sake
break
}
}
return isfound
}

ddtreemenu.preventpropagate=function(e){ //prevent action from bubbling upwards
if (typeof e!="undefined")
e.stopPropagation()
else
event.cancelBubble=true
}

ddtreemenu.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}

/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();

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_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_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];}
}

// light box from flash script
function GroupDelegate(id) {
   Lightview.show(id)
}

function viewalldiv(id,to,from,overflow,display,js){
	var el = document.getElementById(id)
	if (el.style.height.replace("px","")==from || el.style.height==""){
		if (js=="hide"){
			return;
		}
		if (overflow){
			el.style.overflow="auto";
		}
		var attributes = { 
			height: { to: to } 
		}; 
		displaym="block";
		if (display){
		 el.style.display=displaym;
		}
	} else {
		if (js=="show"){
			return;
		}
		if (overflow){
			el.style.overflow="hidden";
		}
		var attributes = { 
			height: { to: from } 
		}; 
		displaym="none";
	}
	var viewall = new YAHOO.util.Anim(id, attributes, .5, YAHOO.util.Easing.easeOut); 
	var anifinished = function() { 
		if (display){
		 el.style.display=displaym;
		}
		el.scrollTop = 0;
		if (js!="" && js!="show" && js!="hide"){
			eval(js);
		}
	} 
	viewall.onComplete.subscribe(anifinished); 
	viewall.animate(); 
}
		
		
var animatebutton=true;
function scrolldiv(id,dir,to,dur,items){
	if (animatebutton){
		animatebutton=false;
		var curid = document.getElementById(id);
		//var container_width = document.getElementById(id+"_container").offsetWidth;
		//alert(container_width);
		curmargin = curid.style.marginLeft.replace("px","");

		var attributes = { 
		   marginLeft: { by: to }
		}; 
		var myAnim = new YAHOO.util.Anim(id, attributes); 
		var updateanibutton = function() { 
		   animatebutton=true
		} 
		myAnim.onComplete.subscribe(updateanibutton); 
		myAnim.duration = dur; 
		myAnim.method = YAHOO.util.Easing.easeOut;
		if ((dir=="left" && (curmargin=="" || curmargin==0 || Number(curmargin)>(items*to))) || (dir=="right" && curmargin<0)){
			myAnim.animate(); 
		} else {
			animatebutton=true
		}
	}
}

function sendemailfriend(){
	if (!Validate_Email_Address(document.frmEmailFriend.email.value)){ 
		alert('You must enter a valid email address');
		return false;
	}
}

function showajax(url){
	//alert(answerid);
	Lightview.show({
  href: '/functions/'+url,
  rel: 'ajax',
  options: {
	width: 800,
	height: 600,
	menubar: true
  }
});

}

function showpriceadjust(){
	//alert(answerid);
	Lightview.show({
  href: '/functions/ajax-priceadjust.asp',
  rel: 'ajax',
  options: {
	width: 800,
	height: 600,
	menubar: true
  }
});

}

function showgiftcards(user,section,orderitemid){
	//alert(answerid);
	Lightview.show({
  href: '/functions/ajax-giftcards.asp?id='+user+'&section='+section+'&itemid='+orderitemid,
  rel: 'ajax',
  options: {
	width: 700,
	height: 900,
	menubar: true,
	autosize: false
  }
});

}

function getbestanswer(answerid,pester){
	//alert(answerid);
	Lightview.show({
  href: '/functions/ajax-select-answers.asp?qid='+answerid+'&pester='+pester,
  rel: 'iframe',
  options: {
	width: 800,
	height: 600,
	menubar: false
  }
});

}

function fetchurl(url,memberid){
	if (memberid==2){
		Lightview.show({
		  href: '/includes/top-login.asp?nox=true',
		  rel: 'ajax',
		  options: {
			  topclose: true,
			width: 300,
			height: 170
		  }
		});
	} else {
		if (url!=""){
			document.location=url;
		}
	}
}

function fetchjavascript(js,memberid){
	if (memberid==2){
		Lightview.show({
		  href: '/includes/top-login.asp?nox=true',
		  rel: 'ajax',
		  options: {
			  topclose: true,
			width: 300,
			height: 170
		  }
		});
	} else {
		eval(js);
	}
}

document.onclick=checkd;
function checkd(e){
	var target = (e && e.target) || (event && event.srcElement);
	var obj = document.getElementById('brandsdropdownlist');
	var obj2 = document.getElementById('brandsdropdown');
	if (obj!=null && obj2!=null){
		checkParent(target)?obj.style.display='none':null;
		target==obj2?obj.style.display='block':null;
	}
}
function checkParent(t){
	while(t.parentNode){
		if(t==document.getElementById('brandsdropdownlist')){
			return false
		}
		t=t.parentNode
	}
return true
} 
function winOpener(theURL, winName, scrollbars, resizable, width, height) {

	winFeatures = 'left=' + (screen.availWidth-10-width)/2 + ',top=' + (screen.availHeight-30-height)/2 + ',scrollbars=' + scrollbars + ',resizable=' + resizable + ',width=' + width + ',height=' + height + ',toolbar=0,location=0,status=1,menubar=0'
  	window.open(theURL, winName, winFeatures);
}

function disableKeyPress(e)
{
     var key;
     if(window.event) {
          key = window.event.keyCode;     //IE
	 } else {
          key = e.which;     //firefox
	 }
     if(key == 13) {
          return false;
	 } else {
          return true;
	 }
}

function selectYuiSaleTab()
	{
		upselltabs.set('activeIndex', 0); // make tab at index 4 active (sale items)
		changeSimilarItems('on');
		document.getElementById('UpSellTabsAnchor').scrollIntoView(true);
	}
	
function selectphoto(pnumber) {
    thisMovie("photoplayer").selectphoto(pnumber);
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

	var mySimilarItemsOnOff;
	
	function changeSimilarItems(mySimilarItemsOnOff)
	{
		if(mySimilarItemsOnOff=="on")
		{
		document.getElementById('tabSalehref').style.color='#d31c1b';
		document.getElementById('tabSalehref').style.backgroundColor='#FFFFFF';
		}
		else
		{
		document.getElementById('tabSalehref').style.color='#FFFFFF';
		document.getElementById('tabSalehref').style.backgroundColor='#d31c1b';
		}
	}
	function changeTabs(page,tab1,tab2,tab3,tab4,tab5)
	{
		var tabArray = new Array(tab1,tab2,tab3,tab4,tab5)
		for(i=0;i<tabArray.length;i++){
			if(i==0){
				if(page=="addcart"){
					document.getElementById(tabArray[i]).style.color='#000000';
					document.getElementById(tabArray[i]).style.backgroundColor='#FFFFFF';
				}else{
					document.getElementById(tabArray[i]).style.color='#FFFFFF';
					document.getElementById(tabArray[i]).style.backgroundColor='#346699';
				}
			}else{
				document.getElementById(tabArray[i]).style.color='#346699';
				document.getElementById(tabArray[i]).style.backgroundColor='#d8d8d8';
			}
		}
		
	}
	
	function formData2QueryString(docForm,action,increment) {
	var strSubmitContent = '';
	var formElem;
	var strLastElemName = '';
	
		for (i = 0; i < docForm.elements.length; i++) {
			
			formElem = docForm.elements[i];

			switch (formElem.type) {
			// Text fields, hidden form elements
			case 'text':
				strSubmitContent = strSubmitContent + formElem.name + '=' + escape(formElem.value) + '&'
				break;
			case'hidden':
				strSubmitContent = strSubmitContent + formElem.name + '=' + escape(formElem.value) + '&'
				break;
			case'password':
				strSubmitContent = strSubmitContent + formElem.name + '=' + escape(formElem.value) + '&'
				break;
			case'textarea':
				strSubmitContent = strSubmitContent + formElem.name + '=' + escape(formElem.value) + '&'
				break;
			case'select-one':
				strSubmitContent = strSubmitContent + formElem.name + '=' + escape(formElem.value) + '&'
				break;
				
			// Radio buttons
			case 'radio':
				if (formElem.checked) {
					strSubmitContent = strSubmitContent + formElem.name + '=' + escape(formElem.value) + '&'
				}
				break;
				
			// Checkboxes
			case 'checkbox':
				if (formElem.checked) {
					// Continuing multiple, same-name checkboxes
					if (formElem.name == strLastElemName) {
						// Strip of end ampersand if there is one
						if (strSubmitContent.lastIndexOf('&') == strSubmitContent.length-1) {
							strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
						}
						// Append value as comma-delimited string
						strSubmitContent = strSubmitContent + ',' + escape(formElem.value);
					}
					else {
						strSubmitContent = strSubmitContent + formElem.name + '=' + escape(formElem.value); 
					}
					strSubmitContent = strSubmitContent + '&';
					strLastElemName = formElem.name;
				}
				break;			
			}
		}
		
		// Remove trailing separator
		strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
		
		if(action=="pmgrequest"){
			ajaxLoader('/functions/ajax-completePMG.asp?'+strSubmitContent,'pmg_return','GET','');
			docForm.reset();
		}else if(action=="csrequest"){
			ajaxLoader('/functions/ajax-csRequest.asp?'+strSubmitContent+'&action=help','help_email','GET','');
		}else if(action=="cs_mail"){
			ajaxLoader('/functions/ajax-csRequest.asp?'+strSubmitContent+'&action=cs','cs_email','GET','');				  
		}else if(action=="combinegifts"){
			Lightview.hide();
			ajaxLoader('/functions/ajax-combinegifts.asp?'+strSubmitContent,'add_card_fill','GET','','','','apply_gift()');
		}else if(action=="profilegifts"){
			ajaxLoader('/functions/ajax-combinegifts.asp?'+strSubmitContent,'add_card_fill','GET','','','','');
			window.location="profilepage_shopping.asp?active_tab=gift_cards";
		}else if(action=="priceadjustment"){
			//Lightview.hide();
			//ajaxLoader('/functions/ajax-combinegifts.asp?'+strSubmitContent,'add_card_fill','GET','','','','apply_gift()');
			Lightview.show({
			  href: '/functions/ajax-combinegifts.asp?section=priceadjustment&'+strSubmitContent,
			  rel: 'ajax',
			  options: {
				width: 400,
				height: 200,
				menubar: true,
				autosize: false
			  }
			});
		}else if(action=="confirmreturn"){
			if(!returnitemschecked){
				alert('You must first check at least one item that you wish to return');
			}else{
				Lightview.show({
				  href: '/functions/ajax-confirmreturn.asp?'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
			}
		}else if(action=="adminconfirmreturn"){
			loadconfirmreturn(strSubmitContent);
		}else if(action=="admincreatereturn"){
			admincreatereturn(strSubmitContent);
		}else if(action=="emailreturn"){
			ajaxLoader('/returns/email-label.asp?'+strSubmitContent,'emailstatus','GET','');	
		}else if(action=="resetthankyoupassword"){
			if (document.resetpass.password1.value==document.resetpass.password2.value && document.resetpass.password1.value!=""){
			ajaxLoader('/functions/reset-thankyou-password.asp?'+strSubmitContent,'resetpassword','GET','');
			}else{
				alert("Passwords must match");
			}
		}else if(action=="reviewreply"){
			ajaxLoader('/functions/ajax-reviewreply.asp?'+strSubmitContent,'reply_container'+increment+'','GET','');
		}else if(action=="previewreview_snowboard"){
			Lightview.show({
				  href: '/functions/ajax-reviewpreview.asp?type=snowboard&'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
		}else if(action=="previewreview_binding"){
			Lightview.show({
				  href: '/functions/ajax-reviewpreview.asp?type=binding&'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
		}else if(action=="previewreview_boot"){
			Lightview.show({
				  href: '/functions/ajax-reviewpreview.asp?type=boot&'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
		}else if(action=="previewreview_jacket"){
			Lightview.show({
				  href: '/functions/ajax-reviewpreview.asp?type=jacket&'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
		}else if(action=="previewreview_pant"){
			Lightview.show({
				  href: '/functions/ajax-reviewpreview.asp?type=pant&'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
		}else if(action=="previewreview_clothing"){
			Lightview.show({
				  href: '/functions/ajax-reviewpreview.asp?type=clothing&'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
		}else if(action=="previewreview_accessories"){
			Lightview.show({
				  href: '/functions/ajax-reviewpreview.asp?type=accessories&'+strSubmitContent,
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
				});
		}else{}
	}
	
function apply_gift(){
	card_num = document.getElementById('add_card_fill').innerHTML;
	ajaxLoader('/shopping/ajaxtax.asp?gift='+card_num+'&display=full', 'dfull', 'GET','');
	document.getElementById('strGiftcertificate').value=card_num;
}

function add_new_card(cardnum){
	document.getElementById('add_rows').innerHTML = document.getElementById('add_rows').innerHTML+"<div id='row_"+cardnum+"' name='row_"+cardnum+"'></div>";
	ajaxLoader('/functions/ajax-getgifts.asp?id='+cardnum,'row_'+cardnum,'GET','');
}

function email_verification(){
	email1 = document.shipping.strEmail.value;
	email2 = document.shipping.strEmail2.value;
	if(email1==email2){
		submitform();
	}else{
		alert("Email verification did not match");	
	}
	
}
function changecss(theClass,element,value,value2) {
	//Last Updated on May 21, 2008
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 var added = false;
	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    if(document.styleSheets[S][cssRules][R].style[element]){
			if (value2!=undefined && value2!="undefined" && value2!=""){
				if (document.styleSheets[S][cssRules][R].style[element] == value){
					document.styleSheets[S][cssRules][R].style[element] = value2;
				}else{
					document.styleSheets[S][cssRules][R].style[element] = value;
				}
			}else{
				document.styleSheets[S][cssRules][R].style[element] = value;
			}
	    added=true;
		break;
	    }
	   }
	  }

	  if(!added){
	  if(document.styleSheets[S].insertRule){
			  document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
	  }
	 }
	}
	
function switchactive(navid,itemid,activate,currstyle){
	
	var menu = document.getElementById(navid).getElementsByTagName("a");
	
	for(i=0;i<menu.length;i++){
		
		menu[i].className=currstyle;
		
		if(activate){
			
			active = itemid+'_content';
			inactive = menu[i].id+'_content';
			
			if(active!=inactive){
				document.getElementById(inactive).style.display='none';
			}
			
			viewalldiv(inactive,350,350,true,false);
			document.getElementById(menu[i].id+'_expand').innerHTML="+";
			
			if(document.getElementById(active).style.display=='block' && active==inactive){
				viewalldiv(inactive,350,213,true,false);
				viewalldiv(active,350,213,true,false);
				if(expanded){
					expanded=false;
				}else{
					expanded=true;	
				}
			}else if(document.getElementById(active).style.display!='block' && active==inactive){
				expanded=true;
			}else{
				
			}
			
			if(expanded){
				document.getElementById(itemid+'_expand').innerHTML="-";
			}else{
				document.getElementById(itemid+'_expand').innerHTML="+";
			}
		}
	}

	

	document.getElementById(itemid).className='active';
	if(activate){
		document.getElementById(itemid+'_content').style.display='block';
	}
}

function showhide(obj){
	var o = document.getElementById(obj);
	if(o.style.display == 'block')
		o.style.display = 'none';
	else
		o.style.display = 'block';
}

function showprodsub(divid){
	viewalldiv(divid,515,190,true,false);
}

function reviewcategory(id){
	for(i=0;i<5;i++){
		document.getElementById('use'+i+'_content').style.display='none';	
	}
	document.getElementById(id+'_content').style.display='block';
}

function checkdeliveryoptions(service){
	return false;
	if (service.indexOf("Second Day")==-1 && service.indexOf("Next Day")==-1){
		document.getElementById("sat").checked = false;
		document.getElementById("sat").disabled = true;
	} else {
		document.getElementById("sat").disabled = false;
	}
}

function checkoutfieldfocus(current,row){
//current.style.borderColor='Yellow'
current.style.borderStyle='solid';
current.style.borderColor='Black';
//current.style.borderStyle='normal';
document.getElementById(row).bgColor='#f3f4f8';
}

//var incompletefields=new Array();

function checkoutfieldblur(current,required,row){
//current.style.borderColor='Yellow'
//current.style.backgroundColor=''
if (row=='chkrow2' || row=='chkrow8'){
document.getElementById(row).bgColor='#EEEEEE';
}else{
document.getElementById(row).bgColor='#ffffff';
}
current.style.borderStyle='solid';
	if (current.value=='' && required){
		current.style.borderColor='Red'
		//incompletefields.push(current);
	}else{
		current.style.borderColor=''
		//removeByElement(incompletefields,current)
	}
}

function removeByElement(arrayName,arrayElement)
 {
    for(var i=0; i<arrayName.length;i++ )
     { 
        if(arrayName[i]==arrayElement)
            arrayName.splice(i,1); 
      } 
  }

function checkzipcode(type){
	var bc=document.shipping.strcountry;
	var sc=document.shipping.shipcountry;
	var bz=document.shipping.strpostcode;
	var sz=document.shipping.shipzip;
	if (type=='bill'){
		if (bc.options[bc.selectedIndex].value=='US'){
			if (bz.value.length!=5){
				bz.style.borderStyle='solid';
				bz.style.borderColor='Red'
				divreplace('errorrow2','US Zip code must be 5 digits');
			} else {
				bz.style.borderStyle='solid';
				bz.style.borderColor='Black'
				divreplace('errorrow2','');
			}
		} else {
			if (bz.value.length!=1){
				bz.style.borderStyle='solid';
				bz.style.borderColor='Black'
				divreplace('errorrow2','');
			}
		}
		document.getElementById('chkrow2').bgColor='#EEEEEE';
	} else {
		if (sc.options[sc.selectedIndex].value=='US'){
			if (sz.value.length!=5){
				sz.style.borderStyle='solid';
				sz.style.borderColor='Red'
				divreplace('errorrow7','US Zip code must be 5 digits');
			} else {
				sz.style.borderStyle='solid';
				sz.style.borderColor='Black'
				divreplace('errorrow7','');
			}
		} else {
			if (sz.value.length!=1){
				sz.style.borderStyle='solid';
				sz.style.borderColor='Black'
				divreplace('errorrow7','');
			}
		}
		document.getElementById('chkrow8').bgColor='#EEEEEE';
	}
}

function checkoutemail(){
	var ce1=document.shipping.strEmail;
	var ce2=document.shipping.strEmail2;
	if (ce1.value!=ce2.value && ce1.value!='' && ce2.value!=''){
		divreplace('errorrow5','Email addresses entered do not match');
		ce1.style.borderStyle='solid';
		ce1.style.borderColor='Red'
		ce2.style.borderStyle='solid';
		ce2.style.borderColor='Red'
	} else {
		divreplace('errorrow5','');
        divreplace('signup_email',ce2.value);
	}
}

function autoskip(field,num,next,event){
	var nxt = document.shipping[next]
	if (field.value.length==num && event.keyCode != 9 && event.keyCode != 16){
		nxt.focus();
	}
}

function checksecond(form){
	var selectvalue = document.forms[''+form+''].elements[0].options[document.forms[''+form+''].elements[0].selectedIndex].value;
	if(selectvalue=="whatsecond"){
		Lightview.show({
				  href: '/functions/whatsecond.asp',
				  rel: 'ajax',
				  options: {
					width: 760,
					height: 600,
					menubar: true,
					autosize: false
				  }
		});
	}
}

function showvideos(prodid,type,photo,caption,video){
	//alert(answerid);
	Lightview.show({
  href: '/videoplayer.asp?prodid='+prodid+"&vtype="+type+"&photo="+photo+"&caption="+caption+"&vid="+video,
  rel: 'iframe',
  options: {
	width: 1000,
	height: 900,
	menubar: false
  }
});

}

function loadprofile(id){
	opener.location.href='/forum/member_profile.asp?PF='+id;
}
function loadproduct(url){
	opener.location.href=url;
}
function privatechat(id){
	var windowName = window.open('','SierraChat_'+id,'width=400,height=335');
	if(!windowName){
		Lightview.show({
		  href: '/popupblocker.asp?user='+id,
		  rel: 'iframe',
		  options: {
			width: 1000,
			height: 900,
			menubar: false
		  }
		});
	}
	if(windowName.iscomplete){
		windowName.setTimeout('winActive()', 800)
	}else{
		//MM_openBrWindow('/privatechat.asp?user='+id,'SierraChat_'+id,'width=400,height=335,resizable=yes');
		windowName = window.open('/privatechat.asp?user='+id,'SierraChat_'+id,'width=400,height=335,resizable=yes');
	}
	
}
function popoutchat(chatmode,answeringchid,answeringprodid){
	var windowName = window.open('','SierraChat_'+chatmode,'width=800,height=335,resizable=yes');
	if(windowName.iscomplete){
	windowName.setTimeout('winActive()', 800)
	}else{
	MM_openBrWindow('/privatechat.asp?chatmode='+chatmode+'&answeringchid='+answeringchid+'&answeringprodid='+answeringprodid,'SierraChat_'+chatmode,'width=800,height=335,resizable=yes');
	}
	
}
function winActive(){
window.focus()
}

function checkpc(){
	var currentTime = new Date()
	ajaxLoader('/feeds/checkprivatechat.asp?t='+currentTime.getTime(), '', 'GET','',true,'','');
	//MM_openBrWindow('/privatechat.asp?user='+id,'SierraChat_'+id,'width=800,height=335')
}

var oldTitle = "";
var timeoutId = "";
var msg = "";
function newExcitingAlerts() {
	//alert('test1');
	if (oktoupdatetab){
		//alert('test2');
		oldTitle = document.title;
		msg = "New Message!";
		timeoutId = setInterval(function() {
			document.title = document.title == msg ? ' ' : msg;
		}, 1000);	
	};
}
function tellflashitsblurred(state) {
	productchat.callFlash(state);
}

function countdown_clock(year, month, day, hour, minute)
         {
         //I chose a div as the container for the timer, but
         //it can be an input tag inside a form, or anything
         //who's displayed content can be changed through
         //client-side scripting.
         
         countdown(year, month, day, hour, minute);                
}
         
function countdown(year, month, day, hour, minute)
         {
		 var clientTime = new Date();
		 var currentTime = new Date();
		 var timeOffset = -7 * 60 * 60 * 1000;
		 currentTime.setTime(clientTime.getTime() + timeOffset);	 
         Todays_Year = currentTime.getUTCFullYear() - 2000;
         Todays_Month = currentTime.getUTCMonth();                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, currentTime.getUTCDate(), 
                                 currentTime.getUTCHours(), currentTime.getUTCMinutes(), currentTime.getUTCSeconds())).getTime();                                 
         Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();                  
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
                    //More datailed.
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if(days == 1) dps ='';
                    if(hours == 1) hps ='';
                    if(minutes == 1) mps ='';
                    if(seconds == 1) sps ='';
					if(hours < 10) hours = '0' + hours;
					if(minutes < 10) minutes = '0' + minutes;
					if(seconds < 10) seconds = '0' + seconds;
                    
                    document.getElementById('countdown').innerHTML = '';
                    document.getElementById('countdown').innerHTML += hours + ':';
                    document.getElementById('countdown').innerHTML += minutes + ':';
                    document.getElementById('countdown').innerHTML += seconds;
 
               
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ');', 1000);
}


var ltop2;scrollSpeed2=20; //Screen refresh rate in msec.
var sticky=""
function checkScrolled2(){ //backTo Top link stays in lower right
	ShowContent('stickyEl');
	window.status=document.documentElement.scrollTop // show results
	document.getElementById('stickyEl').style.top =
	document.documentElement.scrollTop+ltop2+'px';
}
function stickyInit(prodid){
	var iscomplete = true;
	swfobject.embedSWF("/assets/flash/chat-product.swf", "productchat", "300", "300", "9.0.0", "/assets/flash/expressInstall.swf", {autostart:"true",pcid:"",isguest:"2",prodid:prodid,chatmode:"product"}, {wmode:"transparent",AllowScriptAccess:"always"});
	ltop2=parseInt(document.getElementById('stickyEl').style.top,10);
	sticky = window.setInterval(checkScrolled2,scrollSpeed2) ;
}

function subMenu() { //v3.0
  var i,p,v,obj,args=subMenu.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v='hide')?'none':v; }
    	obj.display=v;
	}
}

//-->