var xmlHttp_index

function GetXmlHttpObject_index()
{
var xmlHttp_index=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp_index=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp_index=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp_index=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp_index;
}


function getInitYears_index()
{ 
xmlHttp_index=GetXmlHttpObject_index();
if (xmlHttp_index==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url;
if(Get_Cookie_index('yearselect')) {
url="/getyears_static.aspx?year="+Get_Cookie_index('yearselect');
} else {
url="/getyears_static.aspx";
}
xmlHttp_index.onreadystatechange=stateChanged_index;
xmlHttp_index.open("GET",url,true);
xmlHttp_index.send(null);
}


function stateChanged_index() 
{ 
if (xmlHttp_index.readyState==4)
{ 
document.getElementById("txtYears_index").innerHTML=xmlHttp_index.responseText;
}
}



function getInitMakes_index()
{
xmlHttpMakes_index=GetXmlHttpObject_index();
if (xmlHttpMakes_index==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url;
if(Get_Cookie_index('yearselect')) {
url="/getmakes_static.aspx?year="+Get_Cookie_index('yearselect')+"&make="+Get_Cookie_index('makeselect');
} else {
url="/getmakes_static.aspx?year=";
}
xmlHttpMakes_index.onreadystatechange=stateChangedMakes_index;
xmlHttpMakes_index.open("GET",url,true);
xmlHttpMakes_index.send(null);
}

function getMakes_index()
{
cookiedelete_index();
document.getElementById('make_id').disabled = true;
document.getElementById('model_id').disabled = true;
//document.getElementById('color_id').disabled = true;
getInitModels_index();
getInitColors_index();
var selYearIndex = document.getElementById('year_id').selectedIndex;
var selYearValue = document.getElementById('year_id')[selYearIndex].value;

xmlHttpMakes_index=GetXmlHttpObject_index();
if (xmlHttpMakes_index==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/getmakes_static.aspx";
url=url+"?year="+selYearValue;
xmlHttpMakes_index.onreadystatechange=stateChangedMakes_index;
xmlHttpMakes_index.open("GET",url,true);
xmlHttpMakes_index.send(null);
}

function stateChangedMakes_index() 
{ 
if (xmlHttpMakes_index.readyState==4)
{ 
document.getElementById("txtMakes_index").innerHTML=xmlHttpMakes_index.responseText;
}
}



function getInitModels_index()
{
xmlHttpModels_index=GetXmlHttpObject_index();
if (xmlHttpModels_index==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url;
if(Get_Cookie_index('yearselect')) {
url="/getmodels_static.aspx?year="+Get_Cookie_index('yearselect')+"&make="+Get_Cookie_index('makeselect')+"&model="+Get_Cookie_index('modelselect');
} else {
url="/getmodels_static.aspx?year=&make=";
}
xmlHttpModels_index.onreadystatechange=stateChangedModels_index;
xmlHttpModels_index.open("GET",url,true);
xmlHttpModels_index.send(null);
}

function getModels_index()
{
cookiedelete_index();
//chooser_index.option[3].disabled = true;
getInitColors_index();
var selYearIndex = document.getElementById('year_id').selectedIndex;
var selYearValue = document.getElementById('year_id')[selYearIndex].value;
var selMakeIndex = document.getElementById('make_id').selectedIndex;
var selMakeValue = document.getElementById('make_id')[selMakeIndex].value;

xmlHttpModels_index=GetXmlHttpObject_index();
if (xmlHttpModels_index==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/getmodels_static.aspx";
url=url+"?year="+selYearValue;
url=url+"&make="+selMakeValue;
xmlHttpModels_index.onreadystatechange=stateChangedModels_index;
xmlHttpModels_index.open("GET",url,true);
xmlHttpModels_index.send(null);
}

function stateChangedModels_index() 
{ 
if (xmlHttpModels_index.readyState==4)
{ 
document.getElementById("txtModels_index").innerHTML=xmlHttpModels_index.responseText;
}
}






function getInitColors_index()
{
xmlHttpColors_index=GetXmlHttpObject_index();
if (xmlHttpColors_index==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url;
if(Get_Cookie_index('colorselect')) {
url="/getcolors_static.aspx?year="+Get_Cookie_index('yearselect')+"&make="+Get_Cookie_index('makeselect')+"&model="+Get_Cookie_index('modelselect')+"&color="+Get_Cookie_index('colorselect');
} else {
url="/getcolors_static.aspx?year=&make=&model=";
}
xmlHttpColors_index.onreadystatechange=stateChangedColors_index;
xmlHttpColors_index.open("GET",url,true);
xmlHttpColors_index.send(null);
}

function getColors_index()
{
cookiedelete_index();
var selYearIndex = document.getElementById('year_id').selectedIndex;
var selYearValue = document.getElementById('year_id')[selYearIndex].value;
var selMakeIndex = document.getElementById('make_id').selectedIndex;
var selMakeValue = document.getElementById('make_id')[selMakeIndex].value;
var selModelIndex = document.getElementById('model_id').selectedIndex;
var selModelValue = document.getElementById('model_id')[selModelIndex].value;

xmlHttpColors_index=GetXmlHttpObject_index();
if (xmlHttpColors_index==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/getcolors_static.aspx";
url=url+"?year="+selYearValue;
url=url+"&make="+selMakeValue;
url=url+"&model="+selModelValue;
xmlHttpColors_index.onreadystatechange=stateChangedColors_index;
xmlHttpColors_index.open("GET",url,true);
xmlHttpColors_index.send(null);
}

function stateChangedColors_index() 
{ 
if (xmlHttpColors_index.readyState==4)
{ 
document.getElementById("txtColors_index").innerHTML=xmlHttpColors_index.responseText;
}
}





function getOptions_index()
{
var selColorIndex = chooser_index.option[3].selectedIndex;
var selColorID = chooser_index.option[3].options[selColorIndex].id;
var selSize = chooser_index.description.value.toLowerCase();;

var ColorArray = selColorID.split(",");
var TriCoat = ColorArray[0];
var MultiTone = ColorArray[1];
var RexNum = ColorArray[2];

chooser_index.payloadURL.value = RexNum;

if (TriCoat=="Yes") {
	if (selSize.indexOf("pen") >= 0) {
		document.getElementById("dynprice").innerHTML='19.42'; 
		document.getElementById("dyntxt").innerHTML='<br><font face="Arial" size="1" color="#FF0000"><b>Note: Tri-coat color chosen.&nbsp;Both a groundcoat and a midcoat of the selected container will be shipped.</b></font><br>'; 
		chooser_index.price.value = 19.42;
	} else if (selSize.indexOf("1/2 oz") >= 0) {
		document.getElementById("dynprice").innerHTML='14.92'; 
		document.getElementById("dyntxt").innerHTML='<br><font face="Arial" size="1" color="#FF0000"><b>Note: Tri-coat color chosen.&nbsp;Both a groundcoat and a midcoat of the selected container will be shipped.</b></font><br>'; 
		chooser_index.price.value = 14.92;
	} else {
		document.getElementById("dynprice").innerHTML='22.43';
		document.getElementById("dyntxt").innerHTML='<br><font face="Arial" size="1" color="#FF0000"><b>Note: Tri-coat color chosen.&nbsp;Both a groundcoat and a midcoat of the selected container will be shipped.</b></font><br>';
		chooser_index.price.value = 22.43;
	}	
} else if (MultiTone=="Yes") {
	if (selSize.indexOf("pen") >= 0) {
		document.getElementById("dynprice").innerHTML='25.95'; 
		document.getElementById("dyntxt").innerHTML='<br><font face="Arial" size="1" color="#FF0000"><b>Note: The selected color is considered a Multi Tone paint which changes color depending on the angle and light. The rare pigments and toners used in this color drive up the cost of this paint significantly.</b></font><br>';
		chooser_index.price.value = 25.95;
	} else if (selSize.indexOf("1/2 oz") >= 0) {
		document.getElementById("dynprice").innerHTML='17.95'; 
		document.getElementById("dyntxt").innerHTML='<br><font face="Arial" size="1" color="#FF0000"><b>Note: The selected color is considered a Multi Tone paint which changes color depending on the angle and light. The rare pigments and toners used in this color drive up the cost of this paint significantly.</b></font><br>';
		chooser_index.price.value = 17.95;
	} else {
		document.getElementById("dynprice").innerHTML='27.95'; 
		document.getElementById("dyntxt").innerHTML='<br><font face="Arial" size="1" color="#FF0000"><b>Note: The selected color is considered a Multi Tone paint which changes color depending on the angle and light. The rare pigments and toners used in this color drive up the cost of this paint significantly.</b></font><br>';
		chooser_index.price.value = 27.95;
	}		
} else {
	if (selSize.indexOf("pen") >= 0) {
		document.getElementById("dynprice").innerHTML='12.95'; 
		document.getElementById("dyntxt").innerHTML='';
		chooser_index.price.value = 12.95;
	} else if (selSize.indexOf("1/2 oz") >= 0) {
		document.getElementById("dynprice").innerHTML='9.95'; 
		document.getElementById("dyntxt").innerHTML='';
		chooser_index.price.value = 9.95;
	} else {
		document.getElementById("dynprice").innerHTML='14.95'; 
		document.getElementById("dyntxt").innerHTML='';
		chooser_index.price.value = 14.95;
	}	
}
}









function ValidateMe_index(theForm)
{
  if (theForm.option[0].selectedIndex == 0)
  {
    alert("Please select a year");
    return (false);
  }   
  
  if (theForm.option[1].selectedIndex == 0)
  {
    alert("Please select a make");
    return (false);
  } 
  
  if (theForm.option[2].selectedIndex == 0)
  {
    alert("Please select a model");
    return (false);
  }  

  if (theForm.option[3].selectedIndex == 0)
  {
    alert("Please select a color");
    return (false);
  }  
  
  return(true);
}


function cookieme_index()
{
Set_Cookie('yearselect', chooser_index.option[0].value, '', '/', '', '' );
Set_Cookie('makeselect', chooser_index.option[1].value, '', '/', '', '' );
Set_Cookie('modelselect', chooser_index.option[2].value, '', '/', '', '' );
Set_Cookie('colorselect', chooser_index.option[3].value, '', '/', '', '' );

//alert(Get_Cookie_index('yearselect')+' '+Get_Cookie_index('makeselect')+' '+Get_Cookie_index('modelselect'))
}





function cookiedelete_index()
{
Delete_Cookie_index('yearselect', '/', '');
Delete_Cookie_index('makeselect', '/', '');
Delete_Cookie_index('modelselect', '/', '');
Delete_Cookie_index('colorselect', '/', '');
}

function Set_Cookie_index( 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;
}
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" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie_index( 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 ) );
}

// this deletes the cookie when called
function Delete_Cookie_index( name, path, domain ) {
if ( Get_Cookie_index( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



