
function resetmsg()
	{
		document.getElementById("msg_text").innerHTML="&nbsp;";
	}
function trimString (str)
{
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


function recreate(){
	document.getElementById("captcha_box").src="verification-code.php";
}
function check_phonenumber(phoneBox)
{
	var phoneVal = trimString(phoneBox.value.toString()); 
	phoneBox.value=trimString(phoneBox.value.toString());
	
	var valid;
	valid=true;
	var mstr=phoneVal.toString();
	var count=0;
	for (var i = 0;i < mstr.length;i++)
	{
		var oc = mstr.charAt(i);
		if ((oc < "0" ||oc > "9"))
		{
			count++;
		}
	}
	
	if(mstr.length>0)
	{
		var oc = mstr.charAt(0);
		if ((oc < "0" ||oc > "9")&& oc!="+")
		{
			valid=false;
		}
	}
	for (var i = 1;i < mstr.length;i++)
	{
		var oc = mstr.charAt(i);
		if ((oc < "0" ||oc > "9")&& oc!=" "&& oc!=","&& oc!="-"&& oc!="+" && oc!="(" && oc!=")")
		{
			valid=false;
		}
	}
	if (valid == false)
	{		
		return(false);
	}
	return(true);
}



////////////////  Contact US ////////////////////////////////////////

function submitForm()
  {
   var flage=true;
   var numcon=0;
   if(document.frm1.name.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "1";
   }
   if(document.frm1.email.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "2";
   } 
   if(document.frm1.email.value!="")
   {
     if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.frm1.email.value)) == false){
      flage=false;
      numcon=numcon+"^"+ "3";
      }
   }
   if(document.frm1.phone.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "4";
   }
   if(document.frm1.phone.value!="")
   {
	  if (check_phonenumber(document.frm1.phone)==false){
      flage=false;
      numcon=numcon+"^"+ "5";
      }
   }
   if(document.frm1.security_code.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "6";
   }
  if(flage==true){
       
       // document.frm.action="bookingformforprint.php";
		//document.frm.target="_blank";
		document.getElementById("msg_text").innerHTML="&nbsp;";
		document.getElementById("msg_text").innerHTML="Please wait, while processing...";
		document.frm1.submit();
		
    }else{
    ShowMsgBox(numcon);
    FocusOnControl(numcon);
    return false;
    }
  }
  
function ShowMsgBox(t)
{
var _StrMsg="";
	if(t.value!=0){
	    _StrMsg="---- Validation Summary(Contact Us) ----" + "\n";
		vmodelArr=t.split("^");
	  for(i=1;i<vmodelArr.length;i++)
	  {
	   if(vmodelArr[i]=="1"){
	        _StrMsg=_StrMsg+"- Please enter name."+ "\n";
	   }else if(vmodelArr[i]=="2"){
	        _StrMsg=_StrMsg+"- Please enter email address."+ "\n";
	   }else if(vmodelArr[i]=="3"){
	        _StrMsg=_StrMsg+"- Please enter valid email address."+ "\n";
	   }else if(vmodelArr[i]=="4"){
	        _StrMsg=_StrMsg+"- Please enter telephone no."+ "\n";
	   }else if(vmodelArr[i]=="5"){
	        _StrMsg=_StrMsg+"- Please enter valid telephone no."+ "\n";
	   }else if(vmodelArr[i]=="6"){
	        _StrMsg=_StrMsg+"- please enter security code."+ "\n";
	   }
	  }
	  alert(_StrMsg);
  }
}

function FocusOnControl(t)
{
    if(t.value!=0){
    vmodelArr=t.split("^");
    if(vmodelArr[1]=="1"){
        document.frm1.name.focus();
    }else if(vmodelArr[1]=="2"){
        document.frm1.email.focus();
    }else if(vmodelArr[1]=="3"){
        document.frm1.email.focus();
		document.frm1.email.select();
    }else if(vmodelArr[1]=="4"){
        document.frm1.phone.focus();
    }else if(vmodelArr[1]=="5"){
        document.frm1.phone.focus();
		document.frm1.phone.select();
    }else if(vmodelArr[1]=="6"){
        document.frm1.security_code.focus();
    }
    }
}




//////////////////// Qutation Form /////////////////////////////





function submitFormQu()
  {
   var flage=true;
   var numcon=0;
   if(document.frm2.citem.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "1";
   }
    if(document.frm2.name.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "2";
   }
      if(document.frm2.cname.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "3";
   }
     if(document.frm2.contact.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "4";
   }
   if(document.frm2.email.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "5";
   } 
   if(document.frm2.email.value!="")
   {
     if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.frm2.email.value)) == false){
      flage=false;
      numcon=numcon+"^"+ "6";
      }
   }
   if(document.frm2.phone.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "7";
   }
   if(document.frm2.phone.value!="")
   {
	  if (check_phonenumber(document.frm2.phone)==false){
      flage=false;
      numcon=numcon+"^"+ "8";
      }
   } if(document.frm2.security_code.value=="")
   {
    flage=false;
    numcon=numcon+"^"+ "9";
   }
   
  if(flage==true){
       
       // document.frm.action="bookingformforprint.php";
		//document.frm.target="_blank";
		document.getElementById("msg_text").innerHTML="&nbsp;";
		document.getElementById("msg_text").innerHTML="Please wait, while processing...";
		document.frm2.submit();
		
    }else{
    ShowMsgBoxQu(numcon);
    FocusOnControlQu(numcon);
    return false;
    }
  }
  
function ShowMsgBoxQu(t)
{
var _StrMsg="";
	if(t.value!=0){
	    _StrMsg="---- Validation Summary(Online Quotation) ----" + "\n";
		vmodelArr=t.split("^");
	  for(i=1;i<vmodelArr.length;i++)
	  {
	   if(vmodelArr[i]=="1"){
	        _StrMsg=_StrMsg+"- Please enter item."+ "\n";
	   }else if(vmodelArr[i]=="2"){
	        _StrMsg=_StrMsg+"- Please enter name."+ "\n";
	   }else if(vmodelArr[i]=="3"){
	        _StrMsg=_StrMsg+"- Please enter company."+ "\n";
	   }else if(vmodelArr[i]=="4"){
	        _StrMsg=_StrMsg+"- Please enter contact."+ "\n";
	   }else if(vmodelArr[i]=="5"){
	        _StrMsg=_StrMsg+"- Please enter email address."+ "\n";
	   }else if(vmodelArr[i]=="6"){
	        _StrMsg=_StrMsg+"- Please enter valid email address."+ "\n";
	   }else if(vmodelArr[i]=="7"){
	        _StrMsg=_StrMsg+"- Please enter telephone no."+ "\n";
	   }else if(vmodelArr[i]=="8"){
	        _StrMsg=_StrMsg+"- Please enter valid telephone no."+ "\n";
	   }else if(vmodelArr[i]=="9"){
	        _StrMsg=_StrMsg+"- please enter security code."+ "\n";
	   }
	  }
	  alert(_StrMsg);
  }
}

function FocusOnControlQu(t)
{
    if(t.value!=0){
    vmodelArr=t.split("^");
    if(vmodelArr[1]=="1"){
        document.frm2.citem.focus();
    }else if(vmodelArr[1]=="2"){
        document.frm2.name.focus();
    }
	else if(vmodelArr[1]=="3"){
        document.frm2.cname.focus();
    }else if(vmodelArr[1]=="4"){
        document.frm2.contact.focus();
    }else if(vmodelArr[1]=="5"){
        document.frm2.email.focus();
    }else if(vmodelArr[1]=="6"){
        document.frm2.email.focus();
		document.frm2.email.select();
    }else if(vmodelArr[1]=="7"){
        document.frm2.phone.focus();
    }else if(vmodelArr[1]=="8"){
        document.frm2.phone.focus();
		document.frm2.phone.select();
    }else if(vmodelArr[1]=="9"){
        document.frm2.security_code.focus();
    }
    }
}


