function ShowContent(itemID) {

//alert(itemID);

	 if (itemID == 1) {
	    // alert('Show');
			document.getElementById("pr1").style.display = 'inline';
	 }
	 else {
	    // alert('Hide');
			document.getElementById("pr1").style.display = 'none';
	 }

/* Toggle visibility between none and inline 
     if ((document.getElementById(itemID).style.display == 'none'))
      {
        document.getElementById(itemID).style.display = 'inline';
      } else {
        document.getElementById(itemID).style.display = 'none';
      } 
			
*/			

}

function ShowTime(itemID) {

//alert(itemID);

	 if (itemID == 1) {
	    // alert('Show');
			document.getElementById("pr2").style.display = 'inline';
	 }
	 else {
	    // alert('Hide');
			document.getElementById("pr2").style.display = 'none';
	 }

/* Toggle visibility between none and inline 
     if ((document.getElementById(itemID).style.display == 'none'))
      {
        document.getElementById(itemID).style.display = 'inline';
      } else {
        document.getElementById(itemID).style.display = 'none';
      } 
			
*/			

}

function ShowCare(itemID) {

//alert(itemID);

	 if (itemID == 1) {
	    // alert('Show');
			document.getElementById("pr3").style.display = 'inline';
	 }
	 else {
	    // alert('Hide');
			document.getElementById("pr3").style.display = 'none';
	 }

/* Toggle visibility between none and inline 
     if ((document.getElementById(itemID).style.display == 'none'))
      {
        document.getElementById(itemID).style.display = 'inline';
      } else {
        document.getElementById(itemID).style.display = 'none';
      } 
			
*/			

}

function runConfirmScript() {

    // set var radio_choice to false
    var radio_choice = false;
		var radio_choice2 = false;
		var show_text_fields = true;
		var show_text_fields2 = true;
		//alert(document.form1.whiplashCase.length);
		
		
		for (counter = 0; counter < document.form1.whiplashCase.length; counter++)
		{
				if (document.form1.whiplashCase[counter].checked) {
				      radio_choice = true;
							radio_choice_value = document.form1.whiplashCase[counter].value;
				} 
		}	
		
		for (counter = 0; counter < document.form1.whiplashGuide.length; counter++)
		{
				if (document.form1.whiplashGuide[counter].checked) {
				      radio_choice2 = true;
							radio_choice_value2 = document.form1.whiplashGuide[counter].value;
				} 
		}				
		
		//alert(radio_choice);
    //alert(radio_choice2);
		
		if (!radio_choice)
		{
		 	 // If there were no selections made display an alert box 
			 alert("Please select if you wish to receive a FREE sample of a Whiplash Case.")
			 show_text_fields = false;
		} 
		
		if (!radio_choice2)
		{
		 	 // If there were no selections made display an alert box 
			 alert("Please select if you wish to receive a FREE Whiplash Guide.")
			 show_text_fields2 = false;
		} 		
		
		
		if ((radio_choice_value == '0') && (radio_choice_value2 == '0')) {
		       show_text_fields = false;
					 show_text_fields2 = false;
    			 alert("Sorry, we cannot proceed because you have chosen not to receive any special offers!");
		}		
		
		
		//alert(radio_choice_value);
		//alert(radio_choice_value2);		
		
		if ((show_text_fields) && (show_text_fields2)) {
		
    			 document.getElementById("td1").style.display = 'inline';
					 document.getElementById("s1").style.display = 'none';
					 document.getElementById("s2").style.display = 'inline';
		}

}


validNo=/^[0-9]$/;

function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	  var spaces = words.length;
	  for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");   
	 }
	 return words;
}




function runForm() {

// validate the whiplash form on client side

	if (document.form1.yourName.value == "")
	{
		alert('Name is a required field.');
		document.form1.yourName.select();
		return false;
	}
	
	var sFullName = document.form1.yourName.value;
	sFullName = stripCharacter(sFullName,' ');
	
	//alert('sFullName = ' + sFullName);
	
	if (sFullName.length <= 2)
	{
		alert('Your Full Name must be longer than 2 characters.');
		document.form1.yourName.select();
		return false;
	}		
	
	if (document.form1.yourPhone.value == "")
	{
		alert('Telephone is a required field.');
		document.form1.yourPhone.select();
		return false;
	}		
	
	var iTelephoneNo = document.form1.yourPhone.value;
	iTelephoneNo = stripCharacter(iTelephoneNo,' ');
	
	if (isNaN(iTelephoneNo)) 
	{
		alert(document.form1.yourPhone.value + ' is not a telephone number');
		document.form1.yourPhone.select();
		return false;
	}
		
	if (iTelephoneNo.length <= 5)
	{
		alert('Your Telephone number must be greater then 5 digits.');
		document.form1.yourPhone.select();
		return false;
	}		
	
	if (document.form1.yourMail.value == "")
	{
		alert('E-Mail is a required field.');
		document.form1.yourMail.select();
		return false;
	}	
	
	var str = document.form1.yourMail.value;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
		
	if (str.indexOf(at)==-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}
		
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}		
	
	if (document.form1.extentInjury.value == "NA")
	{
		alert('Please select the extent of your injury.');
		document.form1.extentInjury.focus();
		return false;
	}		
	
	if (document.form1.otherPartyAtFault.value == "NA")
	{
		alert('Please select the % that you feel the other party was at fault.');
		document.form1.otherPartyAtFault.focus();
		return false;
	}			

}

function runQForm() {

	if (document.form1.yourName.value == "")
	{
		alert('Name is a required field.');
		document.form1.yourName.select();
		return false;
	}
	
	var sFullName = document.form1.yourName.value;
	sFullName = stripCharacter(sFullName,' ');
	
	//alert('sFullName = ' + sFullName);
	
	if (sFullName.length <= 2)
	{
		alert('Your Full Name must be longer than 2 characters.');
		document.form1.yourName.select();
		return false;
	}	
	
	if (document.form1.yourPhone.value == "")
	{
		alert('Telephone is a required field.');
		document.form1.yourPhone.select();
		return false;
	}		
	
	var iTelephoneNo = document.form1.yourPhone.value;
	iTelephoneNo = stripCharacter(iTelephoneNo,' ');
	
	if (isNaN(iTelephoneNo)) 
	{
		alert(document.form1.yourPhone.value + ' is not a telephone number');
		document.form1.yourPhone.select();
		return false;
	}
		
	if (iTelephoneNo.length <= 5)
	{
		alert('Your Telephone number must be greater then 5 digits.');
		document.form1.yourPhone.select();
		return false;
	}		
	
	if (document.form1.yourMail.value == "")
	{
		alert('E-Mail is a required field.');
		document.form1.yourMail.select();
		return false;
	}	
	
	var str = document.form1.yourMail.value;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
		
	if (str.indexOf(at)==-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}
		
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.yourMail.select();
		return false;
	}		
	
	if (document.form1.yourQuestion.value == "")
	{
		alert('Please enter a question to proceed.');
		document.form1.yourQuestion.select();
		return false;
	}	
		
}

function checkWhiplashForm() {

	if (document.form1.confirmEmail.value == "")
	{
		alert('E-Mail is a required field.');
		document.form1.confirmEmail.select();
		return false;
	}	
	
	var str = document.form1.confirmEmail.value;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
		
	if (str.indexOf(at)==-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.confirmEmail.select();
		return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid E-mail Address!");
		document.form1.confirmEmail.select();
		return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid E-mail Address!");
		document.form1.confirmEmail.select();
		return false;
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.confirmEmail.select();
		return false;
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Invalid E-mail Address!");
		document.form1.confirmEmail.select();
		return false;
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.confirmEmail.select();
		return false;
	}
		
	if (str.indexOf(" ")!=-1)
	{
		alert("Invalid E-mail Address!");
		document.form1.confirmEmail.select();
		return false;
	}		
	
	if (document.form1.confirmTelephone.value == "")
	{
		alert('Telephone is a required field.');
		document.form1.confirmTelephone.select();
		return false;
	}		
	
	var iTelephoneNo = document.form1.confirmTelephone.value;
	iTelephoneNo = stripCharacter(iTelephoneNo,' ');
	
	if (isNaN(iTelephoneNo)) 
	{
		alert(document.form1.confirmTelephone.value + ' is not a telephone number');
		document.form1.yourPhone.select();
		return false;
	}
		
	if (iTelephoneNo.length <= 5)
	{
		alert('Your Telephone number must be greater then 5 digits.');
		document.form1.confirmTelephone.select();
		return false;
	}		
	
		
}


function callMeFunction() {

	if (document.formCallMe.firstName.value == "")
	{
		alert('Please enter your first name.');
		document.formCallMe.firstName.select();
		return false;
	}	
	
	if (document.formCallMe.confirmTelephone.value == "")
	{
		alert('Telephone is a required field.');
		document.formCallMe.confirmTelephone.select();
		return false;
	}		
	
	var iTelephoneNo = document.formCallMe.confirmTelephone.value;
	iTelephoneNo = stripCharacter(iTelephoneNo,' ');
	
	if (isNaN(iTelephoneNo)) 
	{
		alert(document.formCallMe.confirmTelephone.value + ' is not a telephone number');
		document.formCallMe.yourPhone.select();
		return false;
	}
		
	if (iTelephoneNo.length <= 5)
	{
		alert('Your Telephone number must be greater then 5 digits.');
		document.formCallMe.confirmTelephone.select();
		return false;
	}		
	
		
}
