// JavaScript Document

function loadImage()
{
 	document.getElementById('mainContentBox').innerHTML = "<br><br><div align='center'><img src='./images/loading_animated2.gif' ></div>";
}


function textSetFocus(id)
{
  
    document.getElementById(id).value="";
  
}

function textSetFocusLogin(id,spanid)
{
     document.getElementById(spanid).innerHTML ="";  
    document.getElementById(id).value="";
  
}


function textLostFocus(id, defaultValue)
{
  
    if (document.getElementById(id).value=="")
	{
	    document.getElementById(id).value=defaultValue;
	}
 
}


function echeck(str) {



		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 ID")

		   return false



		}



		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		   alert("Invalid E-mail ID")

		   return false

		}



		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		    alert("Invalid E-mail ID")

		    return false

		}



		 if (str.indexOf(at,(lat+1))!=-1){

		    alert("Invalid E-mail ID")

		    return false

		 }



		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		    alert("Invalid E-mail ID")

		    return false

		 }



		 if (str.indexOf(dot,(lat+2))==-1){

		    alert("Invalid E-mail ID")

		    return false

		 }

		

		 if (str.indexOf(" ")!=-1){

		    alert("Invalid E-mail ID")

		    return false

		 }



 		 return true					

	}



function checkForm()
{
  if((document.getElementById('fname').value.search(/\S/)==-1) || (document.getElementById('fname').value == 'First Name'))

     {

	   window.alert("Please enter the first name.");

	   document.getElementById('fname').focus();

	   return false;
	 } 
	 
	 else if((document.getElementById('lname').value.search(/\S/)==-1) || (document.getElementById('lname').value == 'Last Name'))

     {

	   window.alert("Please enter the last name.");

	   document.getElementById('lname').focus();

	   return false;
	 } 
	 
	  else if(document.getElementById('email').value.search(/\S/)==-1)
	  {
	     	window.alert("Please enter the email address.");

	        document.getElementById('email').focus();

	        return false;
	 } 
	else  if((document.getElementById('phone').value.search(/\S/)==-1) || (document.getElementById('phone').value == 'Phone [xxx-xxx-xxxx]'))

     {

	   window.alert("Please enter phone number.");

	   document.getElementById('phone').focus();

	   return false;
	 } 
	 
	else  if((document.getElementById('message').value.search(/\S/)==-1) || (document.getElementById('message').value == 'Message'))

     {

	   window.alert("Please enter message.");

	   document.getElementById('message').focus();

	   return false;
	 } 
	 
}

function changeInputType(oldObject, oType) {
	
  var newObject = document.createElement('input');
  newObject.type = oType;
  newObject.style.width = '137px';
  
 
  newObject.value = '';
  if(oldObject.size) newObject.size = oldObject.size;
  if(oldObject.name) newObject.name = oldObject.name;
  if(oldObject.id) newObject.id = oldObject.id;
  if(oldObject.className) newObject.className = oldObject.className;
  oldObject.parentNode.replaceChild(newObject,oldObject);
  return newObject;
}


function clearDivContent(divName)
{
 	document.getElementById(divName).innerHTML = "";
}


function changeAction(actionFlag)
{

	if(actionFlag==1)
	{
       document.getElementById('_LOGINPOST').action="./post/postLoginClient.php";
    }

	if(actionFlag==2)
	{
     
       document.getElementById('_LOGINPOST').action="./post/postLoginBroker.php";
	   //document.getElementById('_LOGINPOST').action="javascript:setSpanName('mainContentBox');javascript:getlogin(document.getElementById('_LOGINPOST'),'BROKERPOST');"
    }

	if(actionFlag==3)
	{
     
       document.getElementById('_LOGINPOST').action="./post/postLoginAutoDealers.php";
	   //document.getElementById('_LOGINPOST').action="javascript:setSpanName('mainContentBox');javascript:getlogin(document.getElementById('_LOGINPOST'),'BROKERPOST');"
    }


}


  