
function set_Model(passedMake){
	
	if (passedMake == "1") {
		checkMake = document.getElementById("Make1").value
		myModel = document.getElementById("Model1")
	}else if (passedMake == "2") {
		checkMake = document.getElementById("Make2").value
		myModel = document.getElementById("Model2")
	}
	
	deleteAll = myModel
	while (deleteAll.length > 1){
		deleteAll.remove(1)
	}
	
	myArray = eval("String"+checkMake)
	
	
	if (checkMake != ""){
		modelsArray = myArray.split("|")
		myLength = modelsArray.length-1 //the minus 1 is because the ASP function to create the string adds an extra | at the end that iseasier to remove this way
			
		for (i=0;i<myLength;i++){
			
			modelInfo = modelsArray[i].split(",")
			
			myNew = new Option(modelInfo[1],modelInfo[0],false,false)
			if (document.all){
				myModel.add(myNew,i+1)
			}else if (document.getElementById){
				myModel.add(myNew,null)
			}	
		}
	}
}

function set_GM_Model(x){
	if(x==1){
		var l_makeinfo = "makeInfo"
	}else if(x=2){
		var l_makeinfo = "makeInfo2"
	}
	if(x==1){
		var l_modelinfo = "modelInfo"
	}else if(x=2){
		var l_modelinfo = "modelInfo2"
	}
	
	deleteAll = document.getElementById(l_modelinfo)
	while (deleteAll.length > 1){
		deleteAll.remove(1)
	}
	checkMake = document.getElementById(l_makeinfo).value
	
	selectedMake = document.getElementById(l_makeinfo).value	
	
	myArray = eval("GMString"+selectedMake)
	
	if (checkMake != ""){
		modelsArray = myArray.split("|")
		myLength = modelsArray.length
			
		for (i=0;i<myLength;i++){
			
			modelInfo = modelsArray[i].split(",")
			
			myNew = new Option(modelInfo[1],modelInfo[0],false,false)
			if (document.all){
				document.getElementById(l_modelinfo).add(myNew,i+1)
			}else if (document.getElementById){
				document.getElementById(l_modelinfo).add(myNew,null)
			}	
		}
	}
}

function checkBack(){
	if (document.getElementById("Year1") != ""){setMake(1,"true")}
	if (document.getElementById("Year2") != ""){setMake(2,"true")}
}


function holdModel(P){
	document.getElementById("vehModel"+P+"Holder").value = document.getElementById("Model" + P).value
}


function setState(){
	myState = document.getElementById("StateHolder").value
	stateLength = document.getElementById("State").length
	if (myState != ""){
		for(i=0;i<=stateLength;i++){
			if (document.getElementById("State").options[i].value == myState){
				document.getElementById("State").options[i].selected = true
				break;
			}
		}
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_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];}
}

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_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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.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')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function displayunicode(e){
	if (e=='validate'){
			var l_Story = document.getElementById('Story').value
			var l_StoryArray = l_Story.split(' ')
			var l_totalWords = l_StoryArray.length
			//alert(l_totalWords)
			
			var l_wordCount = 250-l_totalWords
			
			if (l_wordCount >= 0){
				document.MM_returnValue = true; 
				setUpValidation('NomFirstName|name|R|txt,NomLastName|name|R|txt,NomCity|city|R|txt,NomEmail|email|NR|txt,SubFirstName|name|R|txt,SubLastName|name|R|txt,SubPhone|phone|R|txt,SubEmail|email|R|txt,Category|radio|R|txt,Story|general|R|txt');
			}else{
				document.MM_returnValue = false; 
				document.getElementById('wordCount').innerHTML = "<span style=\"color:#FF0000\">" + l_wordCount + "</span>"
				alert('Your submission must be 250 words or less.\nPlease edit your posting and resubmit.');
				
			}

	}else{
		var unicode=e.keyCode? e.keyCode : e.charCode
		var actualKey = String.fromCharCode(unicode)
	
		if (actualKey == ' '){
			actualKey = 'spacebar'
		}
		if (unicode == '8' || unicode == '46' || unicode == '32' || e=='load'){
			//alert(unicode + '::' + actualKey)
			var l_Story = document.getElementById('Story').value
			var l_StoryArray = l_Story.split(' ')
			var l_totalWords = l_StoryArray.length - 1
			//alert(l_totalWords)
			
			var l_wordCount = 250-l_totalWords
			
			if (l_wordCount > 0){
				document.getElementById('wordCount').innerHTML = l_wordCount
			}else{
				document.getElementById('wordCount').innerHTML = "<span style=\"color:#FF0000\">" + l_wordCount + "</span>"
			}
		}
	}
}

function displayunicode_Ecard(e){
	if (e=='validate'){
			var l_Story = document.getElementById('Message').value
			var l_StoryArray = l_Story.split(' ')
			var l_totalWords = l_StoryArray.length
			//alert(l_totalWords)
			
			var l_wordCount = 250-l_totalWords
			
			if (l_wordCount >= 0){
				document.MM_returnValue = true; 
				setUpValidation('RecName|name|R|txt,RecEmail|email|NR|txt,SubName|name|R|txt,SubEmail|email|R|txt,CardStyle|radio|R|txt,Message|general|R|txt');
			}else{
				document.MM_returnValue = false; 
				document.getElementById('wordCount').innerHTML = "<span style=\"color:#FF0000\">" + l_wordCount + "</span>"
				alert('Your submission must be 250 words or less.\nPlease edit your posting and resubmit.');
				
			}

	}else{
		var unicode=e.keyCode? e.keyCode : e.charCode
		var actualKey = String.fromCharCode(unicode)
	
		if (actualKey == ' '){
			actualKey = 'spacebar'
		}
		if (unicode == '8' || unicode == '46' || unicode == '32' || e=='load'){
			//alert(unicode + '::' + actualKey)
			var l_Story = document.getElementById('Message').value
			var l_StoryArray = l_Story.split(' ')
			var l_totalWords = l_StoryArray.length - 1
			//alert(l_totalWords)
			
			var l_wordCount = 250-l_totalWords
			
			if (l_wordCount > 0){
				document.getElementById('wordCount').innerHTML = l_wordCount
			}else{
				document.getElementById('wordCount').innerHTML = "<span style=\"color:#FF0000\">" + l_wordCount + "</span>"
			}
		}
	}
}
