var step=0;
function backStep(){	
	if (step==3){
		document.getElementById('thirdCircle').innerHTML='<img src="/en/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="/en/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="/en/contactus/img/circlefull.png" />';
	
	choice=document.getElementById('step1Drop').value;
	switch (choice)
	{
		case "potential":
			window.location = "http://www.findmespot.eu/en/locatearetailer/"
		//redirect
			/*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":
			becomeForm();
// 			document.getElementById('usDiv').style.display="none";
			document.getElementById('canadaDiv').style.display="none";
			document.getElementById('marketingDiv').style.display="block";			
			break;
		case "other":
			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="/en/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="/en/contactus/img/circlefull.png" />';	
	document.getElementById('thirdCircle').innerHTML='<img src="/en/contactus/img/circlefull.png" />';
	document.getElementById('secondCircle').innerHTML='<img src="/en/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>THANK YOU!</b> <br />'+
	'Your inquiry has been sent to our Customer Service team who will reply to your questions as soon as possible.<br />'+
	'Please continue with your visit. </div>';
	
}

function potForm(){
	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="/en/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_eu_en">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<input type="hidden" name="note2" value="'+secondText+'">'+
	'<span style="font-size:12pt">Please complete the form below: </span>'+
	'<span style="font-size:10pt;color:red">(* Required Information)</span>'+
	'<table><tr>'+
	'<td nowrap >EMAIL ADDRESS:</td><td nowrap><input type="text" name="email" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td>CONFIRM EMAIL ADDRESS:</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 >CONTACT NAME:</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>PRIMARY CONTACT NUMBER:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125">SECONDARY NUMBER:</td><td nowrap><input type="text" name="note3" id="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>CITY:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td>COUNTRY:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>&nbsp;</td>'+
	'</tr><tr>'+
	'<td colspan="2">HOW DID YOU HEAR ABOUT SPOT? '+
	'<select name="note6[]" id="note6" onchange="otherSpecify()"><option>Magazine</option><option>Radio Ad</option><option>Tv ad</option><option>Online Ad</option><option>Other</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>QUESTION:</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="/en/contactus/img/clear.png" /> </a> &nbsp; <input type="image" border="0" src="/en/contactus/img/submit.png" /></div>'+
	'</form>';
	document.getElementById("required1").focus();

}

function becomeForm(){
	var regionArray=["Algeria", "Belgium", "Benedicte Le Blanc de Choisay", "Czech Republic", "Denmark", "Faroe Islands", "Finland", "France", "Gary King", "Iceland", "Ireland", "Morocco", "Norway", "Poland", "Portugal", "Spain", "Sweden", "The Netherlands", "United Kingdom", "Vlada Krasojevic"];
	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="/en/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_eu_en">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<span style="font-size:12pt">Please complete the form below: </span>'+
	'<span style="font-size:10pt;color:red">(* Required Information)</span>'+
	'<table><tr>'+
	'<td nowrap >EMAIL ADDRESS:</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">Region</td>'+
	'<td><select name="province" id="reqprovince">'+
	'<option value="">Select a Region</option></select><span style="color: red;">*</span></td>'+
	'</tr><tr>'+
	'<td>CONFIRM EMAIL ADDRESS:</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 >CONTACT NAME:</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>PRIMARY CONTACT NUMBER:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125" style="text-align:center">SECONDARY NUMBER:</td><td nowrap><input type="text" name="note3" id="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>CITY:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td style="text-align:center">COUNTRY:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>&nbsp;</td>'+
	'</tr><tr>'+
	'<td colspan="2">HOW DID YOU HEAR ABOUT SPOT? '+
	'<select name="note6[]" id="note6" onchange="otherSpecify()"><option>Magazine</option><option>Radio Ad</option><option>Tv ad</option><option>Online Ad</option><option>Other</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>QUESTION:</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="/en/contactus/img/clear.png" /> </a> &nbsp; <input type="image" border="0" src="/en/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=="Other"){
		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].text;
	secondChoice=document.getElementById('step2Drop').selectedIndex;
	secondText=document.getElementById('step2Drop').options[secondChoice].text;

	document.getElementById('bulkContent').innerHTML=''+
	'<form name="inputForm" action="/en/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_eu_en">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<input type="hidden" name="note2" value="'+secondText+'">'+
	'<span style="font-size:12pt">Please complete the form below: </span>'+
	'<span style="font-size:10pt;color:red">(* Required Information)</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 >EMAIL ADDRESS:</td><td nowrap><input type="text" name="email" maxLength="40" size="25" id="required2"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td>CONFIRM EMAIL ADDRESS:</td><td nowrap><input type="text" name="emailConfirm" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td nowrap>CONTACT NAME:</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>PRIMARY CONTACT NUMBER:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125">SECONDARY NUMBER:</td><td nowrap><input type="text" name="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>CITY:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td>COUNTRY:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>QUESTION:</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="/en/contactus/img/clear.png" /> </a> &nbsp;  <input type="image" border="0" src="/en/contactus/img/submit.png" /></div>'+
	'</form>';
	document.getElementById("required1").focus();
}

function otherForm(){
	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('contactdropDown').style.display="none";
	document.getElementById('contactformInfo').style.display="none";
	document.getElementById('bulkContent').innerHTML=''+
	'<form name="inputForm" action="/en/contactus/backend/submitForm.php" method="POST" onSubmit="return checkrequired(this)">'+
	'<input type="hidden" name="source" value="contact_revamp_eu_en">'+
	'<input type="hidden" name="note1" value="'+firstText+'">'+
	'<input type="hidden" name="note2" value="'+secondText+'">'+
	'<span style="font-size:12pt">Please complete the form below: </span>'+
	'<span style="font-size:10pt;color:red">(* Required Information)</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 >EMAIL ADDRESS:</td><td nowrap><input type="text" name="email" maxLength="40" size="25" id="required1"><span style="color:red"> *</span></td>'+
	'</tr><tr>'+
	'<td>CONFIRM EMAIL ADDRESS:</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 >CONTACT NAME:</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>PRIMARY CONTACT NUMBER:</td><td nowrap><input type="text" name="phone" maxLength="20" size="16" ></td></tr></table></td>'+
	'<td width="125">SECONDARY NUMBER:</td><td nowrap><input type="text" name="note3" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>CITY:</td><td nowrap><input type="text" name="city" maxLength="20" size="25"></td>'+
	'<td>COUNTRY:</td><td nowrap><input type="text" name="country" maxLength="50" size="20"></td>'+
	'</tr><tr>'+
	'<td>&nbsp;</td>'+
	'</tr><tr>'+
	'<td colspan="2">HOW DID YOU HEAR ABOUT SPOT? '+
	'<select name="note6[]" id="note6" onchange="otherSpecify()"><option>Magazine</option><option>Radio Ad</option><option>Tv ad</option><option>Online Ad</option><option>Other</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>QUESTION:</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="/en/contactus/img/clear.png" /> </a> &nbsp;<input type="image" border="0" src="/en/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("/en/contactus/backend/getfaq.php","?faq="+searchVal+"&faq2="+searchVal2+"&faq3="+searchVal3);
	else if (searchVal2)
		makeRequest("/en/contactus/backend/getfaq.php","?faq="+searchVal+"&faq2="+searchVal2);
	else
		makeRequest("/en/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;
}

