function myPopup2() {
window.open( "templates/quick_enquiry2.html", "myWindow1", "status = 1, height = 450, width = 450, resizable = 0" );
//alert("h");
}

function get_enq_form()
{
  {
content = "<table cellpadding='0' cellspacing='0' id='table2' width='193' ><tr><td height='10' width='191'></td></tr>  <tr><td width='191' class='header3' style='font-size:14px;'   >Quick Enquiry   </td>  </tr><tr><td height='10' width='191'></td></tr><tr><td width='191'><input type=text name='visitor2' id='visitor2' class='txt_1'  onfocus='blank(this)' onblur='unblank(this)' value='Full Name' /></td>  </tr><tr><td height='5' width='191'></td></tr><tr><td width='191'><input type=text  name='visitormail' id='visitormail' class='txt_1'  onFocus='blank(this)' onBlur='unblank(this)' value='Valid E-mail'></td>  </tr><tr><td height='5' width='191'></td></tr><tr><td width='191'><input type=text   name='contact' id='contact' class='txt_1'  onFocus='blank(this)' onBlur='unblank(this)' value='Contact Number'></td>  </tr><tr><td height='5' width='191'></td></tr><tr><td width='191'><input type=text value='subject'  name='location' id='location' class='txt_1' onFocus='blank(this)' onBlur='unblank(this)'></td>  </tr><tr><td height='5' width='191'></td></tr><tr><td width='191'><textarea name='notes' id='notes' class='txt_2'  onFocus='blank(this)' onBlur='unblank(this)'>Message</textarea></td>  </tr><tr><td height='5' width='191'></td></tr><tr><td width='191' height='24'><input type=button  onclick='bind_enq_data();' value='Call me' name='submit'  style='width:55px; height:22px'> <input type=button onclick=clean()  value='Reset' name='reset'   style='width:55px; height:22px'></td>  </tr></table>";

document.getElementById("small_box").innerHTML = content;}

}


function checkfield(small_box)
{
	ok=true
	alert("HAI");
	if(small_box.visitor.value=="")
	{
		alert("Please Enter Your Name.")
		small_box.visitor.focus()
		ok=false
	}
	else if (small_box.visitormail.value == "")
	{
		alert("Please enter a value for the email field.");
		small_box.visitormail.focus();
		ok=false
	}
	else if (!isEmailAddr(small_box.visitormail.value))
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		small_box.visitormail.focus();
		ok=false
	}
	else if(small_box.contact.value=="")
	{
		alert("Please Enter Phone Number.")
		small_box.contact.focus()
		ok=false
	}
	else if(small_box.location.value=="")
	{
		alert("Please Enter Country Name.")
		small_box.location.focus()
		ok=false
	}
	
	else if (small_box.notes.value == "")
	{
		alert("Please specify your requirements.");
		small_box.notes.focus();
		ok=false
	}
	return ok
}

function isEmailAddr(visitormail)
{
  var result = false
  var theStr = new String(visitormail)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
	var pindex = theStr.indexOf(".",index);
	if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function ValidateNum(input,event)
	{
			var keyCode = event.which ? event.which : event.keyCode;
			if(parseInt(keyCode)>=48 && parseInt(keyCode)<=57)
			{
				return true;
			}
			return false;
		}






function clean()
{
	document.getElementById("visitor").value = "Full Name";
	document.getElementById("visitormail").value = "Valid E-mail";
	document.getElementById("contact").value = "Contact Number";
	document.getElementById("location").value = "Select Location";
	document.getElementById("notes").value ="Message";
}




function isValidPhoneNumber(strPhone)
	{
		var phone = /^([0]{1}[1-9]{1}[0-9]{1}(-|\s)?\d{6,8})|([1-9]{1}\d{5,7})|([0]?([9]{1})([0-9]{9}))$/; 
		if (strPhone.match(phone)) {
			return true;
		} else {
			return false;
		}
	
	}
function bind_enq_data()
{
	name = document.getElementById("visitor").value;
	vmail = document.getElementById("visitormail").value;
	cont  = document.getElementById("contact").value;
	loc  = document.getElementById("location").value;
	note = document.getElementById("notes").value;
if(name=="")
	{
		alert("Please Enter Your Name.")		
		return false;
	}
if (vmail == "")
	{
		alert("Please enter a value for the email field.");
		return false;
		
	}
if (!isEmailAddr(vmail))
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		return false;
		
	}
if(cont=="")
	{
		alert("Please Enter Phone Number.");		
		return false;
	}
	
if(!isValidPhoneNumber(cont))
	{
		alert("Please Enter A Valid Phone Number.");	
		return false;
	}
	
if(loc=="")
	{
		alert("Please Enter A Intersted Location.")
		return false;
		
	}
	
if (note== "")
	{
		alert("Please specify your requirements.");
		return false;
		
	}
	
	var url="php/quick_enquiry.php";
	url=url+"?visitor="+name;
	url=url+"&visitormail="+vmail;
	url=url+"&notes="+note;
	url=url+"&contact="+cont;
	url=url+"&location="+loc;
	url=url+"&sid="+Math.random();

	Ajax(url,"small_box");
}



// Job Ast End

var xmlHttp
function Ajax(url,place)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	 } 

xmlHttp.onreadystatechange=function()
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById(place).innerHTML=xmlHttp.responseText;
}
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

