/**********************
 * Common functions 
 **********************/

// Jquery Rollover Function

jQuery(function()
{
	var hide = false;
	
	jQuery(".hoverswap").hover
	(
		function (){jQuery(this).attr("src", jQuery(this).attr("src").replace(".png", "_ro.png"));},
		function (){jQuery(this).attr("src", jQuery(this).attr("src").replace("_ro.png", ".png"));}
	);

});



// ABC Testing Redirect
function ABCTest() 
{
	if(readCookie("tsscampaign") == null)
	createCookie("tsscampaign","code=INTHOME01&phone=8667268979&ltype=",90)
}

//faq content switch widget
function SwitchContent(obj)
{
	if(document.getElementById)
	{
		var el = document.getElementById(obj);
		var el2 = document.getElementById("content0");
		var ar = document.getElementById("rightcolumn").getElementsByTagName("div"); 
		if(el.style.display != "block")
		{ 
			for (var i=0; i<ar.length; i++)
			{
				if (ar[i].className=="content")
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}
		/*else
		{
			el.style.display = "none";
			el2.style.display = "block";
		}*/
	}
}

//popup window function
function openVW(linkName,SizeX,SizeY,PlaceX,PlaceY,useScroll)
{
	if((PlaceY == "")||(PlaceY == null))
		{PlaceY = 300;}
	if((PlaceX == "")||(PlaceX == null))
		{PlaceX = 400;}
	if((useScroll == "")||(useScroll == null))
		{useScroll = 1;}
	else
		{useScroll = 0;}
	window.open(linkName,null,"toolbar=0,scrollbars="+ useScroll +",status=0,resizable=0,menubar=0,location=0,width=" + SizeX + ",height=" + SizeY + ",top=" + PlaceY + ",left=" + PlaceX);
}
//autotab fields function
function autotab(original,destination)
{
	if (original.getAttribute && original.value.length == original.getAttribute("maxlength"))
	destination.focus();
}

function targetopener(mylink, closeme, closeonly)
{
	if (! (window.focus && window.opener))return true;
	window.opener.focus();
	if (! closeonly)window.opener.location.href=mylink.href;
	if (closeme)window.close();
	return false;
}


// Cookie functions
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/;domain=.thescooterstore.com";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


