var step=0;
function backStep(){	
	if (step==3){
		document.getElementById('thirdCircle').innerHTML='<img src="/pg/contactus/img/circlehollow.png" />';	
		document.getElementById('bulkContent').innerHTML="";
		document.getElementById('contactdropDown').style.display="block";
		document.getElementById('contactformInfo').style.display="block";
		document.getElementById('contactInfo').style.display="block";
		document.getElementById('contactFAQ').style.display="none";

		
		
		
		
	}
	else if (step==2){
		document.getElementById('secondCircle').innerHTML='<img src="/pg/contactus/img/circlehollow.png" />';
		document.getElementById('contactdropDown').style.display="block";
		document.getElementById('bulkContent').innerHTML="";
		document.getElementById('step1Div').style.display="block";
		document.getElementById('step1Drop').selectedIndex=0;
		document.getElementById('leftSelect').style.visibility="hidden";
		document.getElementById('rightSelect').style.visibility="hidden";
		document.getElementById('contactformInfo').style.display="block";
		document.getElementById('contactButtons').style.visibility="hidden";
		document.getElementById('contactFAQ').style.display="none";
		document.getElementById('canadaDiv').style.display="none";
		document.getElementById('marketingDiv').style.display="block";
		
	}
	step--;

}

function firstChange(){
	step=2;
	document.getElementById('contactButtons').style.visibility="visible";
	
	document.getElementById('secondCircle').innerHTML='<img src="/pg/contactus/img/circlefull.png" />';
	
	choice=document.getElementById('step1Drop').value;
	switch (choice)
	{
		case "potential":
			//window.location = "/pg/locatearetailer/"
		
			document.getElementById('leftSelect').style.visibility="visible";
			document.getElementById('rightSelect').style.visibility="visible";
			potDrop();
			break;
		case "existing":	
			document.getElementById('leftSelect').style.visibility="visible";
			document.getElementById('rightSelect').style.visibility="visible";
			existDrop();
			break;
		case "becoming":
			window.location = "/pg/becomeadealer/";
			//becomeForm();
// 			document.getElementById('usDiv').style.display="none";
			//document.getElementById('canadaDiv').style.display="none";
			//document.getElementById('marketingDiv').style.display="block";			
			break;
		case "other":
			window.location = "/pg/locatearetailer/";
			/*document.getElementById('leftSelect').style.visibility="visible";
			document.getElementById('rightSelect').style.visibility="visible";
			otherDrop();*/
			break;
		default:
			document.getElementById('rightSelect').style.visibility="hidden";
			document.getElementById('leftSelect').style.visibility="hidden";			
			break;	
	}

} 


function secondChange(){
	step=3;
	
	firstChoice=document.getElementById('step1Drop').value;
	secondChoice=document.getElementById('step2Drop').value;

	if (secondChoice=="") return;

	document.getElementById('thirdCircle').innerHTML='<img src="/pg/contactus/img/circlefull.png" />';
	document.getElementById('contactInfo').style.display="none";
	

	document.getElementById('bulkContent').innerHTML="";	
// 	firstChoice=document.getElementById('step1Drop').value;
// 	secondChoice=document.getElementById('step2Drop').value;
	
	switch (firstChoice){
		case "potential":
			//firstPotChoice(secondChoice);

			document.getElementById('contactInfo').style.display="block"; //faq temp disabled, so still display generic contact info
			potForm();
			break;
		case "existing":
			//firstExistChoice(secondChoice); Temp Disabled

			document.getElementById('contactInfo').style.display="block"; //faq temp disabled, so still display generic contact info
			existForm();

			break;
		case "becoming":
			break;
		case "other":
			//firstOtherChoice(secondChoice);

			document.getElementById('contactInfo').style.display="block"; //faq temp disabled, so still display generic contact info
			otherForm();

			break;
		
	}

	
	
} 



function firstPotChoice(secondChoice){
	switch (secondChoice)
	{
		case "911":	
			getFaq("geos","911");			
			break;
		case "time":
			getFaq("time","zone");
			break;
		case "activate":
			getFaq("tech");
			break;
		case "buy":
			getFaq("ship");
			break;
		case "help":
			getFaq("check","help");
			break;
		case "share":
			getFaq("share");
			break;
		case "promocode":
			getFaq("code","promo");
			break;
		case "sms":
			getFaq("sms","text");
			break;
		case "other":
			getFaq("");
			break;
		default:
			break;
	}
	potForm();

}

function firstExistChoice(secondChoice){

	switch (secondChoice)
	{
		case "911":
			getFaq("geos","911");
			break;
		case "billing":
			getFaq("time","bill");
			break;
		case "time":
			getFaq("time","zone");
			break;
		case "lost":
			getFaq("lost","stolen","replace");
			break;
		case "profile":
			getFaq("profile");
			break;
		case "help":
			getFaq("checkin","help");
			break;
		case "sms":
			getFaq("sms","text");
			break;
		case "share":
			getFaq("share");
			break;
		case "web":
			getFaq("registration");
			break;
		case "other":;
			getFaq("");
			break;
		default:
			break;
	}

	existForm();

}

function firstOtherChoice(secondChoice){
	switch (secondChoice)
	{
		case "911":
			getFaq("geos","911");
			break;
		case "billing":
			getFaq("time","bill");
			break;
		case "time":
			getFaq("time","zone");
			break;
		case "activate":
			getFaq("tech");
			break;
		case "buy":
			getFaq("ship");
			break;
		case "help":
			getFaq("checkin","help");
			break;
		case "promocode":
			getFaq("code","promo");
			break;
		case "sms":
			getFaq("sms","text");
			break;
		case "share":
			getFaq("share");
			break;
		case "other":
			getFaq("");
			break;
		default:
			break;
	}
	otherForm();

}

function thirdChange(){
	step=4;
	document.getElementById('fourthCircle').innerHTML='<img src="/pg/contactus/img/circlefull.png" />';	
	document.getElementById('thirdCircle').innerHTML='<img src="/pg/contactus/img/circlefull.png" />';
	document.getElementById('secondCircle').innerHTML='<img src="/pg/contactus/img/circlefull.png" />';
	document.getElementById('contactdropDown').style.display="none";
	document.getElementById('contactformInfo').style.display="none";
	document.getElementById('contactButtons').style.visibility="visible";
	document.getElementById('contactBackButton').style.display="none";
	document.getElementById('checkMark').style.display="block";
	document.getElementById('bulkContent').innerHTML=''+
	'<div id="contactThanks"><b>Obrigado!</b> <br />'+
	'Seu questionamento  foi enviado &agrave; nossa Central de Atendimento que responder&aacute; suas perguntas assim  que poss&iacute;vel.<br />'+
	'Por favor, continue navegando em nosso site. </div>';
	
}

function potForm(){
	firstChoice=document.getElementById('step1Drop').selectedIndex;
	firstText=document.getElementById('step1Drop').options[firstChoice].value;
	secondChoice=document.getElementById('step2Drop').selectedIndex;
	secondText=document.getElementById('step2Drop').options[secondChoice].text;
	//document.getElementById('step2Drop').blur();
	document.getElementById('contactdropDown').style.display="none";
	document.getElementById('contactformInfo').style.display="none";
	document.getElementById('bulkContent').innerHTML=''+
	'<form name="inputForm" action="/pg/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_la_pg">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<input type="hidden" name="note2" value="'+secondText+'">'+
	'<span style="font-size:12pt">Por favor complete o formulário abaixo:</span>'+
	'<span style="font-size:10pt;color:red"> (* Informação requerida)</span>'+
	'<table><tr>'+
	'<td nowrap >Endereço de e-mail:</td><td nowrap><input type="text" name="email" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td>Confirme o endereço de e-mail:</td><td nowrap><input type="text" name="emailConfirm" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td width="120px" nowrap >Nome de contato:</td><td nowrap><input type="text" name="firstname" maxLength="15" size="25" id="required2"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td colspan="2"><table><tr><td nowrap>Número do contato primário:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125">Número secundário:</td><td nowrap><input type="text" name="note3" id="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>Cidade:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td>País:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>&nbsp;</td>'+
	'</tr><tr>'+
	'<td colspan="2">Como você conheceu o SPOT? '+
	'<select name="note6[]" id="note6" onchange="otherSpecify()"><option>Revista</option><option>Anúncio em rádio</option><option>Anúncio em TV</option><option>Anúncio on-line</option><option>Outro</option></select></td>'+
	'<td><div id="otherText" style="visibility:hidden">PLEASE SPECIFY:</div></td><td><div id="otherBox" style="visibility:hidden"><input type="text" name="note6[]" id="otherTextBox" maxLength="50" size="20"></div></td>'+
	'</tr><tr>'+
	'<td>Pergunta:</td><td colspan="3"><textarea rows="4" cols="55" name="note4" ></textarea></td>'+
	'</tr></table>'+
	'<div id="bottomButt" align="right" style="margin-right:80px"><a onclick="document.inputForm.reset();return false;" href="#"><img alt="Clear" src="/pg/contactus/img/clear.png" /> </a> &nbsp; <input type="image" border="0" src="/pg/contactus/img/submit.png" /></div>'+
	'</form>';
	document.getElementById("required1").focus();

}

function becomeForm(){
	var regionArray=["Washington", "Oregon", "Idaho", "Montana", "Wyoming", "Colorado", "Utah", "Alaska","California", "Nevada", "Arizona", "New Mexico", "Hawaii","North Dakota", "South Dakota", "Nebraska", "Kansas", "Minnesota", "Iowa", "Missouri", "Illinois", "Tennessee", "Mississippi", "Alabama", "Georgia", "Florida", "South Carolina", "North Carolina","Wisconsin", "Michigan", "Indiana", "Kentucky", "Ohio", "West Virginia", "Virginia", "Maine", "Vermont", "New Hampshire", "Massachusetts", "Connecticut","Rhode Island", "New York", "Pennsylvania", "New Jersey", "Maryland", "Delaware","Washington DC", "Texas", "Louisiana", "Arkansas", "Oklahoma"];
	regionArray.sort();
	firstChoice=document.getElementById('step1Drop').selectedIndex;
 	firstText=document.getElementById('step1Drop').options[firstChoice].text;
//  	secondChoice=document.getElementById('step2Drop').selectedIndex;
// 	secondText=document.getElementById('step2Drop').options[secondChoice].text;
// 	document.getElementById('step2Drop').blur();
	document.getElementById('contactdropDown').style.display="none";
	document.getElementById('contactformInfo').style.display="none";
	document.getElementById('bulkContent').innerHTML=''+
	'<form name="inputForm" action="/pg/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_la_pg">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<span style="font-size:12pt">Por favor complete o formulário abaixo:</span>'+
	'<span style="font-size:10pt;color:red"> (* Informação requerida)</span>'+
	'<table><tr>'+
	'<td nowrap >Endereço de e-mail:</td><td nowrap><input type="text" name="email" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'<td style="text-align:center">Região:</td>'+
	'<td><select name="province" id="reqprovince">'+
	'<option value="">Select a Region</option></select><span style="color: red;">*</span></td>'+
	'</tr><tr>'+
	'<td>Confirme o endereço de e-mail:</td><td nowrap><input type="text" name="emailConfirm" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td width="120px" nowrap >Nome de contato:</td><td nowrap><input type="text" name="firstname" maxLength="15" size="25" id="required2"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td colspan="2"><table><tr><td nowrap>Número do contato primário:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125" style="text-align:center">Número secundário:</td><td nowrap><input type="text" name="note3" id="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>Cidade:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td style="text-align:center">País:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>&nbsp;</td>'+
	'</tr><tr>'+
	'<td colspan="2">Como você conheceu o SPOT? '+
	'<select name="note6[]" id="note6" onchange="otherSpecify()"><option>Revista</option><option>Anúncio em rádio</option><option>Anúncio em TV</option><option>Anúncio on-line</option><option>Outro</option></select></td>'+
	'<td><div id="otherText" style="visibility:hidden">PLEASE SPECIFY:</div></td><td><div id="otherBox" style="visibility:hidden"><input type="text" name="note6[]" id="otherTextBox" maxLength="50" size="20"></div></td>'+
	'</tr><tr>'+
	'<td>Pergunta:</td><td colspan="3"><textarea rows="4" cols="55" name="note4" ></textarea></td>'+
	'</tr></table>'+
	'<div id="bottomButt" align="right" style="margin-right:80px"><a onclick="document.inputForm.reset();return false;" href="#"><img alt="Clear" src="/pg/contactus/img/clear.png" /> </a> &nbsp; <input type="image" border="0" src="/pg/contactus/img/submit.png" /></div>'+
	'</form>';
	for(i=0; i<regionArray.length; i++) { 
		 var optn = document.createElement("OPTION");
		optn.text = regionArray[i];
		optn.value = regionArray[i];
		document.getElementById('reqprovince').options.add(optn);
		
		
	}
	document.getElementById("required1").focus();

}

function otherSpecify(){
	var w=document.getElementById('note6').selectedIndex;
	choice=document.getElementById('note6').options[w].text;
	if (choice=="Outro"){
		document.getElementById('otherText').style.visibility="visible";
		document.getElementById('otherBox').style.visibility="visible";
	}
	else{
		document.getElementById('otherText').style.visibility="hidden";
		document.getElementById('otherTextBox').value="";
		document.getElementById('otherBox').style.visibility="hidden";
	}

}

function existForm(){
	document.getElementById('contactdropDown').style.display="none";
	document.getElementById('contactformInfo').style.display="none";
	
	firstChoice=document.getElementById('step1Drop').selectedIndex;
	firstText=document.getElementById('step1Drop').options[firstChoice].value;
	secondChoice=document.getElementById('step2Drop').selectedIndex;
	secondText=document.getElementById('step2Drop').options[secondChoice].text;

	document.getElementById('bulkContent').innerHTML=''+
	'<form name="inputForm" action="/pg/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_la_pg">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<input type="hidden" name="note2" value="'+secondText+'">'+
	'<span style="font-size:12pt">Por favor complete o formulário abaixo:</span>'+
	'<span style="font-size:10pt;color:red"> (* Informação requerida)</span>'+
	'<table><tr>'+
	'<td width="120px" nowrap >SPOT ESN #:</td><td nowrap><input type="text" name="note5" maxLength="15" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td nowrap >Endereço de e-mail:</td><td nowrap><input type="text" name="email" maxLength="40" size="25" id="required2"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td>Confirme o endereço de e-mail:</td><td nowrap><input type="text" name="emailConfirm" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td nowrap>Nome de contato:</td><td nowrap><input type="text" name="firstname" maxLength="50" size="25" id="required3"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td colspan="2"><table><tr><td nowrap>Número do contato primário:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125">Número secundário:</td><td nowrap><input type="text" name="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>Cidade:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td>País:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>Pergunta:</td><td colspan="3"><textarea rows="4" cols="55" name="note4" ></textarea></td>'+
	'</tr></table>'+
	'<div id="bottomButt" align="right" style="margin-right:80px"><a onclick="document.inputForm.reset();return false;" href="#"><img alt="Clear" src="/pg/contactus/img/clear.png" /> </a> &nbsp;  <input type="image" border="0" src="/pg/contactus/img/submit.png" /></div>'+
	'</form>';
	document.getElementById("required1").focus();
}

function otherForm(){
	firstChoice=document.getElementById('step1Drop').selectedIndex;
	firstText=document.getElementById('step1Drop').options[firstChoice].value;
	secondChoice=document.getElementById('step2Drop').selectedIndex;
	secondText=document.getElementById('step2Drop').options[secondChoice].text;

	document.getElementById('contactdropDown').style.display="none";
	document.getElementById('contactformInfo').style.display="none";
	document.getElementById('bulkContent').innerHTML=''+
	'<form name="inputForm" action="/pg/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_la_pg">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<input type="hidden" name="note2" value="'+secondText+'">'+
	'<span style="font-size:12pt">Por favor complete o formulário abaixo:</span>'+
	'<span style="font-size:10pt;color:red"> (* Informação requerida)</span>'+
	'<table><tr>'+
	'<td width="120px" nowrap >SPOT ESN #:</td><td nowrap><input type="text" name="note5" maxLength="15" size="25"></td>'+
	'</tr><tr>'+
	'<td nowrap >Endereço de e-mail:</td><td nowrap><input type="text" name="email" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td>Confirme o endereço de e-mail:</td><td nowrap><input type="text" name="emailConfirm" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td width="120px" nowrap >Nome de contato:</td><td nowrap><input type="text" name="firstname" maxLength="15" size="25" id="required2"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td colspan="2"><table><tr><td nowrap>Número do contato primário:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125">Número secundário:</td><td nowrap><input type="text" name="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>Cidade:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td>País:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>&nbsp;</td>'+
	'</tr><tr>'+
	'<td colspan="2">Como você conheceu o SPOT? '+
	'<select name="note6[]" id="note6" onchange="otherSpecify()"><option>Revista</option><option>Anúncio em rádio</option><option>Anúncio em TV</option><option>Anúncio on-line</option><option>Outro</option></select></td>'+
	'<td><div id="otherText" style="visibility:hidden">PLEASE SPECIFY:</div></td><td><div id="otherBox" style="visibility:hidden"><input type="text" name="note6[]" maxLength="50" size="20"></div></td>'+
	'</tr><tr>'+
	'<td>Pergunta:</td><td colspan="3"><textarea rows="4" cols="55" name="note4" ></textarea></td>'+
	'</tr></table>'+
	'<div id="bottomButt" align="right" style="margin-right:80px"><a onclick="document.inputForm.reset();return false;" href="#"><img alt="Clear" src="/pg/contactus/img/clear.png" /> </a> &nbsp;<input type="image" border="0" src="/pg/contactus/img/submit.png" /></div>'+
	'</form>';
	document.getElementById("required1").focus();

}





var http_request = false;
function makeRequest(url, parameters) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
        	if (http_request.overrideMimeType) {
            		http_request.overrideMimeType('text/html');
         	}
      		} else if (window.ActiveXObject) { // IE
         		try {
            			http_request = new ActiveXObject("Msxml2.XMLHTTP");
         		} catch (e) {
            			try {
               				http_request = new ActiveXObject("Microsoft.XMLHTTP");
            			} catch (e) {}
       		}
    	}
    	if (!http_request) {
        	alert('Cannot create XMLHTTP instance');
         	return false;
      	}
      	http_request.onreadystatechange = alertContents;
      	http_request.open('GET', url + parameters, true);
      	http_request.send(null);
}

function getFaq(searchVal,searchVal2,searchVal3){
	if (searchVal3)
		makeRequest("/pg/contactus/backend/getfaq.php","?faq="+searchVal+"&faq2="+searchVal2+"&faq3="+searchVal3);
	else if (searchVal2)
		makeRequest("/pg/contactus/backend/getfaq.php","?faq="+searchVal+"&faq2="+searchVal2);
	else
		makeRequest("/pg/contactus/backend/getfaq.php","?faq="+searchVal);
}

function alertContents(){
	if (http_request.readyState == 4 && http_request.status == 200) {
        	var recdoc = http_request.responseText;	
		//alert ("::"+recdoc+"::");
			document.getElementById('contactInfo').style.display="none";
			document.getElementById('contactFAQ').style.display="block";
			document.getElementById('contactFAQ').innerHTML=recdoc;

	} 

}

function readCookie(name) {

	var cookiename = 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(cookiename) == 0) 
			return c.substring(cookiename.length,c.length);
	}
	return null;
}

function killCookie(cookieName) {
	  document.cookie = cookieName + 
                    '=; expires=-1;' +
                    "path=/; domain=." +
                    window.location.hostname;
  	return true;
}

