function showform(mode){

	switch(mode)
	{
		case 'contact':
		document.getElementById("contactholder2").style.display ="block";
		document.getElementById("loading").style.display ="block";
		document.getElementById("loading").innerHTML ="<br><img src='images/ajax-loader.gif' border='0'/><br>";
		setTimeout(function(){
		  document.getElementById("contactholder2").style.display ="none";
          document.getElementById("contactholder").style.display ="block";
            },2000
    	 );
		break;
		case 'contact2':
		document.getElementById("contactholder2").style.display ="block";
		document.getElementById("loading").style.display ="block";
		document.getElementById("loading").innerHTML ="<br><img src='images/ajax-loader.gif' border='0'/><br>";
		setTimeout(function(){
		  document.getElementById("contactholder2").style.display ="none";
          document.getElementById("contactholdertwo").style.display ="block";
            },2000
    	 );
		break;
		case 'contact3':
		document.getElementById("contactholder2").style.display ="block";
		document.getElementById("loading").style.display ="block";
		document.getElementById("loading").innerHTML ="<br><img src='images/ajax-loader.gif' border='0'/><br>";
		setTimeout(function(){
		  document.getElementById("contactholder2").style.display ="none";
          document.getElementById("contactholderthree").style.display ="block";
            },2000
    	 );
		break;
	}


}
function closeform(idx){
document.getElementById(idx).style.display ="none";
}
function closeform2(){
document.getElementById("contactholder2").style.display ="none";
}
function clickclear(thisfield, defaulttext) {
  if (thisfield.value == defaulttext) {
  thisfield.value = "";
  }
}
function clickrecall(thisfield, defaulttext) {
  if (thisfield.value == "") {
  thisfield.value = defaulttext;
  }
}

     function AJAX_obj()
	{
		var ajaxRequest;
		try{

			ajaxRequest = new XMLHttpRequest();
			} catch (e){

			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Your browser broke!");
				return false;
			}
			}
		}
		return ajaxRequest;
	}

function formValidator(){

		var name = document.getElementById('nameone');
		var phone = document.getElementById('phoneone');
		var email = document.getElementById('emailone');
		var url = 'ajax_page.php?action=first&name='+name.value+'&email='+email.value+'&phone='+phone.value;
		//alert(url);

		var ajaxRequest = AJAX_obj();

 if(notEmpty(name, "Please enter  your name")){

	if(emailValidator(email, "Please enter a valid email address")){
			if(isNumericDash(phone, "Please enter a valid phone number")){

			ajaxRequest.onreadystatechange = function() {

						if(ajaxRequest.readyState == 4){
							document.getElementById("contactholder").style.display ="none";
							document.getElementById("contactholder2").style.display ="block";
							document.getElementById("loading").style.display ="block";
							document.getElementById("loading").innerHTML ="Please Wait..<br><img src='images/ajax-loader.gif' border='0'/><br>";
							setTimeout(function(){
										 document.getElementById("contactholder2").style.display ="block";
										 document.getElementById("loading").style.display ="block";
										 document.getElementById("loading").innerHTML ="<p>Thank you!..</p>";
										 window.location ="agents.php";

							setTimeout(function(){
										 document.getElementById("contactholder2").style.display ="none";
										},2000
									 );

										},5000
									 );

						}
			}
			ajaxRequest.open("GET", url, true);
    		ajaxRequest.send(null);

			}
		}
				
	}

	return false;

}


function formValidatortwo(){

		var name = document.getElementById('nametwo');
		var phone = document.getElementById('phonetwo');
		var email = document.getElementById('emailtwo');
		var url = 'ajax_page.php?action=second&name='+name.value+'&email='+email.value+'&phone='+phone.value;
		//alert(url);
    	var ajaxRequest = AJAX_obj();

 if(notEmpty(name, "Please enter  your name")){

	if(emailValidator(email, "Please enter a valid email address")){
			if(isNumericDash(phone, "Please enter a valid phone number")){

			ajaxRequest.onreadystatechange = function() {

						if(ajaxRequest.readyState == 4){
							document.getElementById("contactholder").style.display ="none";
							document.getElementById("contactholder2").style.display ="block";
							document.getElementById("loading").style.display ="block";
							document.getElementById("loading").innerHTML ="Please Wait..<br><img src='images/ajax-loader.gif' border='0'/><br>";
							setTimeout(function(){
										 document.getElementById("contactholder2").style.display ="block";
										 document.getElementById("loading").style.display ="block";
										 document.getElementById("loading").innerHTML ="<p>Thank you!..</p>";
										 window.location ="costcomparison.php";

							setTimeout(function(){
										 document.getElementById("contactholder2").style.display ="none";
										},2000
									 );

										},5000
									 );

						}
			}
			ajaxRequest.open("GET", url, true);
    		ajaxRequest.send(null);

			}
		}
				
	}

	return false;

}


function formValidatorthree(){

		var name = document.getElementById('namethree');
		var phone = document.getElementById('phonethree');
		var email = document.getElementById('emailthree');
		var url = 'ajax_page.php?action=third&name='+name.value+'&email='+email.value+'&phone='+phone.value;
		//alert(url);

		var ajaxRequest = AJAX_obj();

 if(notEmpty(name, "Please enter  your name")){

	if(emailValidator(email, "Please enter a valid email address")){
			if(isNumericDash(phone, "Please enter a valid phone number")){

			ajaxRequest.onreadystatechange = function() {

						if(ajaxRequest.readyState == 4){
							document.getElementById("contactholder").style.display ="none";
							document.getElementById("contactholder2").style.display ="block";
							document.getElementById("loading").style.display ="block";
							document.getElementById("loading").innerHTML ="Please Wait..<br><img src='images/ajax-loader.gif' border='0'/><br>";
							setTimeout(function(){
										 document.getElementById("contactholder2").style.display ="block";
										 document.getElementById("loading").style.display ="block";
										 document.getElementById("loading").innerHTML ="<p>Thank you!..</p>";
										 window.location = "documents.php";

							setTimeout(function(){
										 document.getElementById("contactholder2").style.display ="none";
										},2000
									 );

										},5000
									 );

						}
			}
			ajaxRequest.open("GET", url, true);
    		ajaxRequest.send(null);

			}
		}
				
	}

	return false;

}


function recording(){
/*str = '<object height="65px" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fopal-1"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="65px" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fopal-1" type="application/x-shockwave-flash" width="100%"></embed> </object>';
str += '<BR/>';
str += 'LYN';
str += '<BR/>';*/
str = '<object height="65px" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fliza"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="65px" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fliza" type="application/x-shockwave-flash" width="100%"></embed> </object>';
str += '<BR/>';
str += 'LIZA';
str += '<BR/>';
str += '<object height="65" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fvernice"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="65" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fvernice" type="application/x-shockwave-flash" width="100%"></embed> </object>';
str += '<BR/>';
str += 'BERNICE';
str += '<BR/>';
str += '<object height="64" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fd"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="64" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fd" type="application/x-shockwave-flash" width="100%"></embed> </object> ';
str += 'DENNIS';
str += '<BR/>';
str += '<object height="64" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fmaica"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="64" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fdeveloper_zone%2Fmaica" type="application/x-shockwave-flash" width="100%"></embed> </object> ';
str += 'MAICA';
document.getElementById('future-box2').innerHTML= str;
}

/*
<OBJECT ID="MediaPlayer1" width=384 height=300 classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft Windows Media <strong class="highlight">Player</strong> components..." type="application/x-oleobject">
<PARAM NAME="fileName" VALUE="">
<PARAM NAME="showControls" VALUE="true">
<PARAM NAME="PlayCount" VALUE="0">

<PARAM NAME="transparentatStart" VALUE="true">
<PARAM NAME="autoStart" VALUE="false">
<EMBED type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="opal.wav" name="MediaPlayer1" width=300 height=75 AutoStart=false></EMBED></object>
*/

function formValidator2(){
	var name = document.getElementById('nameone');
	var phone = document.getElementById('phoneone');
	var email = document.getElementById('emailone');

	if(notEmpty(name, "Please enter  your name")){

					if(emailValidator(email, "Please enter a valid email address")){
							if(isNumericDash(phone, "Please enter a valid phone number")){
								return true;
							}
						}
				
			}

	return false;
}

function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	}
	return true;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isNumericDash(elem, helperMsg){
	var numericExpression= /^\d+$|\-/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Please enter between " +min+ " and " +max+ " characters");
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == "Please Choose"){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
