function sidebar(obj, state)
{
	if(state==0){obj.className="sidebar_link_normal";}
	else{obj.className="sidebar_link_hover";}
}

function adjust_sidebar(){
	if(typeof(sidebar_count)=="undefined"){return null;}
	
	cnt=sidebar_count;
	h=(cnt*30)+75;
	h_content=(cnt*30)+75+20;
	if(h>parseInt(document.getElementById("content").clientHeight))
	{
		document.getElementById("content").style.height=h_content+"px";
		document.getElementById("sidebar").style.height=h+"px";
	}
	else if(h<parseInt(document.getElementById("content").clientHeight))
	{
		h=parseInt(document.getElementById("content").clientHeight)-20;
		document.getElementById("sidebar").style.height=h+"px";
	}

}

function check_contact()
{
		
		first=document.getElementById("first");
		last=document.getElementById("last");
		
		phone_code=document.getElementById("phone_code");
		phone_area=document.getElementById("phone_area");
		phone_access=document.getElementById("phone_access");
		phone_local=document.getElementById("phone_local");
		
		if(checkForm(first) == false){alert("Invalid First Name"); ship_firstName.focus(); return false;}
		if(checkForm(last) == false){alert("Invalid Last Name"); ship_lastName.focus(); return false;}
		
		if(checkPhone(phone_area, 3) == false){alert("Invalid Area Code"); phone_area.focus(); return false;}
		if(checkPhone(phone_access, 3) == false){alert("Invalid Phone Number (Access Number)"); phone_access.focus(); return false;}
		if(checkPhone(phone_local, 4) == false){alert("Invalid Phone Number (Local Number)"); phone_local.focus(); return false;}
		
		return true;
}
	

// Screenshot Functions
var count=0; 
var animation=null;
var screenCount=0;

	/*function moveForward()
	{
		document.getElementById("screen").style.left=parseInt(document.getElementById("screen").style.left, 10)-10+"px";
		if(parseInt(document.getElementById("screen").style.left, 10) <= 310*count*-1){animationCount=0; clearInterval(animation); animation=null;}
	}
	
	function moveBackwards()
	{
		document.getElementById("screen").style.left=parseInt(document.getElementById("screen").style.left, 10)+10+"px";
		if(parseInt(document.getElementById("screen").style.left, 10) >= 310*count*-1){animationCount=0; clearInterval(animation); animation=null;}
	}*/
	
	function change(){
		document.getElementById("screen").style.left = 310*count*-1 +"px";
	}

	function changeScreen(direction)
	{
		if(animation == null)
		{
			if(direction == 1)
			{
				if(count < screenCount-1){count++; change();}
				else{count=0; change();}

				//if(count < screenCount-1){count++; animation=setInterval("moveForward()", 1); }
				//else{count=0; animation=setInterval("moveBackwards()", .001);}
			}
			else if(direction == -1)
			{
				if(count != 0){count--; change();}
				else{count=screenCount-1; change();}

				//if(count != 0){count--; animation=setInterval("moveBackwards()", 1); }
				//else{count=screenCount-1; animation=setInterval("moveForward()", .001);}
			}
			
			//if(count+1 == screenCount){document.getElementById("next").className="screen_next_inactive"}
			//else{document.getElementById("next").className="screen_next"}
			//if(count == 0){document.getElementById("previous").className="screen_previous_inactive"}
			//else{document.getElementById("previous").className="screen_previous"}
		}
	}

	function generateScreen()
	{
		
		while(count < screenCount)
		{
			document.getElementById("screen"+count).style.left=310*count+"px";
			count++;
		}
		
		count=0;
	}
	
	
var interval;
var count = 1;
var zcount = 1;
var fadeCount = 0;
var fade;

function initRotate(){setTimeout('rotate()', 6500);}

function rotate(){
	count++;
	zcount++;
	
	if(count >= 4){count=1;}
		fadeCount=0;
		document.getElementById('rotate'+count).style.zIndex=zcount+1;
		fade = setInterval('goFade()', 1);
}

function goFade(){
	if(fadeCount >= 110){
			initRotate();
			window.clearInterval(fade);		
	}
	else{
		document.getElementById('rotate'+count).style.opacity = fadeCount/100;
		document.getElementById('rotate'+count).filter="filter: alpha(opacity="+fadeCount+");";
		fadeCount+=10;
	}
}

var clearSubscribeVoid = false;

function doSearch(){
	document.location="index.php?page=shop&option=search&section="+document.getElementById("method").value+"&entry="+document.getElementById("search").value;
}

function clearSubscribe()
{
	if(clearSubscribeVoid==false)
	{
		document.getElementById("newsletter").value="";
		clearSubscribeVoid=true;
	}
	
}

function subscribe()
{
	var email = document.getElementById("newsletter");
		if(!checkEmail(email)){	
			alert("Invalid E-Mail Address");
		}
		else{
				window.location = "index.php?page=subscribe&email="+email.value;
		}	
}