//animated slide script
var sliderIntervalId = 0;
var sliderHeight = 355;
var sliding = false;
var slideSpeed = 20;
	
function SlideU(){
   if(sliding)
      return;
   sliding = true;
   sliderIntervalId = setInterval('SlideUpRun()', 20);
}
	
function SlideD(){
   if(sliding)
      return;
   sliding = true;
   sliderIntervalId = setInterval('SlideDownRun()', 20);
}
	
function SlideUpRun(){
	
	document.getElementById('productStateOn').style.display='none';
	document.getElementById('productStateOff').style.display='block';
	if ( state > 0) {
	document.getElementById('step2Off').style.display='none';	
	document.getElementById('step2On').style.display='block';
	}
   slider = document.getElementById('productSelectorFlash');
   if(sliderHeight <= 65)
   {
      sliding = false;
      sliderHeight = 65;
      slider.style.height = '65px';
      clearInterval(sliderIntervalId);
   }
   else
   {
      sliderHeight -= slideSpeed;
      if(sliderHeight <65)
    	sliderHeight = 65;
      	slider.style.height = sliderHeight + 'px';
   }
}
	
function SlideDownRun(){
	
	document.getElementById('productStateOn').style.display='block';
	document.getElementById('productStateOff').style.display='none';
	document.getElementById('step2Off').style.display='block';	
	document.getElementById('step2On').style.display='none';
	slider = document.getElementById('productSelectorFlash');
	if(sliderHeight>= 200){
	  sliding = false;
	  sliderHeight = 200;
	  slider.style.height = '200px';
	  clearInterval(sliderIntervalId);
	}
	else
	{
	sliderHeight += slideSpeed;
	if(sliderHeight> 200)
	sliderHeight = 200;
	slider.style.height = sliderHeight + 'px';
	}
}
	
//slide script without animation
function slideDown() {
	 //document.getElementById('topFlash').style.marginTop='-25px';
	 document.getElementById('productSelectorFlash').style.height='200px';			 	
	 document.getElementById('step2On').style.display='none';	
	 document.getElementById('step2Off').style.display='block';		 	 		 
}
function slideUp() {
	 //make layer visible
	 document.getElementById('productSelectorFlash').style.height='65px';
	 document.getElementById('step2Off').style.display='none';	
	 document.getElementById('step2On').style.display='block';
}

function showThirdDiv () {
	document.getElementById('step2Off').style.display='none';
	document.getElementById('step2On').style.display='block';
}	

function hideThirdDiv () {	
	document.getElementById('step2Off').style.display='block';
	document.getElementById('step2On').style.display='none';	
}


//Flash Embed - contact us page with cookie read
if (document.cookie != "") {
	//Product Name Cookie
	/*var aCookie = document.cookie.split("; ");
	  for (var i=0; i < aCookie.length; i++) {
	    // a name/value pair (a crumb) is separated by an equal sign
	    var aCrumb = aCookie[i].split("=");
	    if (aCrumb[0] == "prs_user") {
	    var finalCrumb = aCrumb[1].split("|");
	    var finalProduct = finalCrumb[0];
	    var finalYear = finalCrumb[1];
	   }
	  }*/
	var countbeginb = (document.cookie.indexOf("prodProblem") + 12);
	var countendb = document.cookie.indexOf(";");
	sValueb = document.cookie.substring( countbeginb, countendb );
	var myPropertyValuePairs = "prodName=" + ppr + "&prodYear=" + ppy + "&prodProblem=" + sValueb;
	} else {
	var myPropertyValuePairs = "";
}
var c=">"; // I will use the closing tag more than once
var oC="<OBJECT classid=\'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\' ";
var cB=" codebase=\'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\' ";
var pN=" <PARAM NAME=movie  VALUE=" 
var pQ=" <PARAM NAME=quality VALUE=best> ";
var pW=" <PARAM NAME=wmode VALUE=transparent> ";
var pB=" <PARAM NAME=bgcolor VALUE="; 
var bG="#FFFFFF";
var eS=" <EMBED src=";
var eQ=" quality=best ";
var eW=" wmode=transparent ";
var eB=" bgcolor=";
var eT=" TYPE=\'application/x-shockwave-flash\' ";
var eP= "PLUGINSPAGE=\'http://get.adobe.com/flashplayer/\'> ";
var eO=" </EMBED> </OBJECT> ";
// the last step
var line01=oC+cB;
var lineM = pN;
var line02=c+pQ+pW+pB+bG+c+eS;
var line03=eQ+eW+eB+bG;
var lineM2 = eT+eP+eO;



function setPTSCookie(input){
	var splitInput = input.split(",");
	//document.cookie = ""+splitInput[0]+"="+splitInput[1]+""
	var expiryDays = 365*24*60*60*1000;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expiryDays));
	var expiry =  exp.toGMTString();
	document.cookie = ""+splitInput[0]+"="+splitInput[1]+"" + ";expires=" + expiry + ";path=/" 
	//document.cookie = 
	//document.cookie = ";domain=" + domain ;
}

if (document.cookie != "") {
	var sValuePTS = "";
	//Product State Cookie
	var countbeginb = (document.cookie.indexOf("ptsState")+ 9);
	var countendb = (document.cookie.indexOf("ptsState") + 11);
	//alert(document.cookie)
	sValuePTS0 = document.cookie.substring( countbeginb, countendb );
	
	statesArrayShortCookie = new Array(
	                   "AL","AK","AZ","AR","CA","CO","CT","DE", "DC", "FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","ND","NC","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","IR","SS"
	               );

	for (var i = 0; i < statesArrayShortCookie.length; i++){ 
		if (statesArrayShortCookie[i] == sValuePTS0) {
					sValuePTS = sValuePTS0
					//alert (sValuePTS)
				}

				else  {
					//sValuePTS = "";
					//alert ("empty")
					
				}
		} 
	
	
	
	
}

$(document).ready(function() {


	if (ppr > 0) {
		document.getElementById('productStateOn').style.display='none';	
		document.getElementById('productStateOff').style.display='block';  
		slideUp();
	 }
	else {
		document.getElementById('productStateOn').style.display='block';	
		document.getElementById('productStateOff').style.display='none';  
	}
	
	if (sValuePTS == "ES" || sValuePTS == "null" || sValuePTS == "" || sValuePTS == null) {
		myPTSState = "";
		document.getElementById('step2Off').style.display='block';	
		document.getElementById('step2On').style.display='none';
	} else if (sValuePTS == "IR") {
		myPTSState = "IRS";
		$('#ptsStep2Top').css('background-image', 'url(/support/images/backgrounds/ptsStep2Blue.gif)');
		document.getElementById('step2Off').style.display='none';	
		document.getElementById('step2On').style.display='block';
		stateHandler (myPTSState);
	} else if (sValuePTS == "SS") {
		myPTSState = "SSA";
		$('#ptsStep2Top').css('background-image', 'url(/support/images/backgrounds/ptsStep2Blue.gif)');
		document.getElementById('step2Off').style.display='none';	
		document.getElementById('step2On').style.display='block';
		stateHandler (myPTSState);
	}
	else {
		myPTSState = sValuePTS;
		$('#ptsStep2Top').css('background-image', 'url(/support/images/backgrounds/ptsStep2Blue.gif)');
		document.getElementById('step2Off').style.display='none';	
		document.getElementById('step2On').style.display='block';
		stateHandler (sValuePTS);
	}
	//alert (myPTSState) 
});
// Selected State Cookie Handling
function pageRefresh (addThis){
	
	window.location = window.location.protocol + "//" + window.location.host + addThis;
}
