function loadXMLDoc(lid,nm,ph,em,q) {
	var url="/asktheexpert.aspx";
	var currentTime = new Date();
	var vTicks = currentTime.valueOf();
	var strURL=url+'?r='+vTicks;
	var data="lid="+lid+"&sendername=" + nm + "&email="+em+"&phone="+ph + "&question="+q;
	//// branch for native XMLHttpRequest object
//	if (window.XMLHttpRequest) {
//		req = new XMLHttpRequest();
//		req.onreadystatechange = processReqChange;
//		req.open("GET", strURL, true);
//		req.send(null);
//	
//		
//	// branch for IE/Windows ActiveX version
//	} else if (window.ActiveXObject) {
//		req = new ActiveXObject("Microsoft.XMLHTTP");
//
//		if (req) {
//			req.onreadystatechange = processReqChange;
//			req.open("GET", strURL, true);
//			req.send();
//		
//		}
//	}
//	//setTimeout('loadXMLDoc()', 30000);
	
	
	
	
	if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open('POST', strURL, true);
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.send(data);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject('Microsoft.XMLHTTP')
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open('POST', strURL, true);
            req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            req.send(data);
        }
    }


}
function processReqChange() {
	// only if req shows "loaded"
	
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {	
			//document.getElementById("ttr").value=req.responseText;
			//document.getElementById("wait").innerHTML=req.responseText;
			toggleLayer('wait','none');
			alert("Thank you. Your question has been submitted.");
			return true
		} else {
			return false
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}


function SubmitForm() {
  var verify;
  verify="";
  if (document.asktheexpert.sendername.value==""){
  verify+="Name is required!\n";
  }
  
  if (document.asktheexpert.phone.value==""){
  verify+="Phone is required!\n";
  }
  
  
  if (document.asktheexpert.email.value==""){
  verify+="Email is required!\n";
  } else {
   if (valEmail(document.asktheexpert.email)==false){
    verify+="A Valid email is required!\n";
   }
  }
   if (document.asktheexpert.question.value==""){
  verify+="Question is required!\n";
  }
  
  if (verify==""){
 
   toggleLayer('dropin','none');
   toggleLayer('wait','block');
	loadXMLDoc(document.asktheexpert.lid.value,document.asktheexpert.sendername.value,document.asktheexpert.phone.value,document.asktheexpert.email.value,document.asktheexpert.question.value)
	//document.asktheexpert.submit();
  }else{
   alert(verify);
  }
 }
 
 
function valEmail(field)
{
 pattern = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9_]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;
 if(field.value.match(pattern) == null) {
  return false;
 } else {
  return true;
 }
} 


function toggleLayer(whichLayer,displ)

{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":displ;
		//style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	
}

var html;

html="<DIV id='dropin' style=' WIDTH: 200px;  HEIGHT: 320px; POSITION: relative;  LEFT: 0px;TOP: 0px;"
html+="font-family:Arial; font-size:10px; border:2px solid #000000; background-color:#E5E5E5;'>"
html+="<form action='/asktheexpert.aspx' method='POST' name='asktheexpert'>"
html+="<input name='lid' type='hidden' value='7'>"
html+="<table id=tbl border='0' width='100%' cellspacing='0' cellpadding='0' >"
html+="<tr>"
html+="<td width='100%' bgcolor='#1A3C5C' align='right'>"
html+="<A "
html+="href=\"Javascript:toggleLayer('dropin','none');\" style='color:#FFFFFF; font-weight:bold; font-size:14px; text-decoration:none;'>[<U>X</U>] </A></td>"
html+="</tr>"
html+="<tr>"
html+="<td width='100%' valign='top' align='center' style='font-size:12px;'><b>Ask the expert</b><br>"
html+="Name:<br>  "
html+="<input name='sendername' type='text' maxlength='50'><br>  "
html+="Phone:<br>  "
html+="<input name='phone' type='text' maxlength='50'><br>  "
html+="Email:<br> "
html+="<input name='email' type='text' maxlength='50'><br>&nbsp;<br> " 
html+="Your Question:<br> "
html+="<textarea name='question' cols='20' rows='5'></textarea><br>&nbsp;<br> " 
html+="<input name='submitbtn' type='button' value='Submit' onclick='SubmitForm();'>"
html+="</td>"
html+="</tr>"
html+="</table>"
html+="</form>"
html+="</DIV>"

html+="<DIV id='wait' style=' WIDTH: 200px;   POSITION: relative;  LEFT: 0px;TOP: 0px;"
html+="font-family:Arial; font-size:14px; border:2px solid #000000; background-color:#E5E5E5; text-align:center;  font-weight:bold; '>"
html+="<p>&nbsp;<br>Please wait...<br>&nbsp;</p>"
html+="</DIV>"

document.write(html);
toggleLayer('dropin','none');
toggleLayer('wait','none');
function ask()
{
	toggleLayer('dropin','block');
}