var preVal='';
var EqpText = '';
var start = 1;
var ind=start;
var XX=0;
var YY=0; 
var arr = new Array();
var BillData = new Array();
var JobData = new Array();
var adPath = '';
var currentFld = '';
var NewCategoryOptions='';
var currentDrop='';
var topRows = 1;
var rowcount =0;
var arr = new Array();
var start = 1;
var ind = start;
var topRows = 0;
var imageCapcha = '';
function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) { 
      var x = Math.round(num * Math.pow(10,dec));
	  if (x >= 0) n1=n2='';
	  var y = (''+Math.abs(x)).split('');
	  var z = y.length - dec; 
	  if (z<0) z--; 
	  
	  for(var i = z; i < 0; i++) y.unshift('0');
	  
	  y.splice(z, 0, pnt); 
	  if(y[0] == pnt) y.unshift('0'); 
	  while (z > 3) {
	      z-=3; 
		  y.splice(z,0,thou);
	 }
	 var r = curr1+n1+y.join('')+n2+curr2;
	 return r;
}

function DG(obj) {
	 return document.getElementById(obj);
 }
function addRowToTable(tbl,fname,val) { 
  var tbl1 =  tbl; 
  var tbl = document.getElementById(tbl);
  var lastRow = tbl.rows.length;
  
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  var cellVal = '';
  var cellLeft;
  var i=0;
     	cellLeft = row.insertCell(i++);
  		cellLeft.bgColor = '#FFFFFF';
		cellLeft.innerHTML = '<input type="text" name="_'+fname+'_' + (iteration-topRows) + '" id="_'+fname+'_' + (iteration-topRows) + '" onkeypress="chkNext(this,\''+tbl1+'\',\''+fname+'\',\''+escape(val)+'\')"; value="'+val+'" >';
		
		cellLeft = row.insertCell(i++);
  		cellLeft.bgColor = '#FFFFFF';
		cellLeft.vAlign = 'bottom';
		cellLeft.innerHTML = '';
		 
		document.getElementById('TotalLines_'+fname).value = iteration-topRows;
  //ind++;
}



function chkNext(obj,tbl,fname,val) {
	  
	  var getId = obj.name.split(/_/);
	  if (navigator.userAgent.indexOf('Firefox')== -1) {
	  	if (!DG('_'+getId[0]+'_'+(parseInt(getId[1])+1))) addRowToTable(tbl,fname,val);
	  }
	  else {
	  	if (!DG('_'+getId[1]+'_'+(parseInt(getId[2])+1))) addRowToTable(tbl,fname,val);
	  }
	}
	
function addRowToTableTwoFields(tbl,fname,val,val1) { 
  var tbl1 =  tbl; 
  var tbl = document.getElementById(tbl);
  var lastRow = tbl.rows.length;
  
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  var cellVal = '';
  var cellLeft;
  var i=0;
     	cellLeft = row.insertCell(i++);
  		cellLeft.bgColor = '#FFFFFF';
		cellLeft.innerHTML = '<input type="text" name="_'+fname+'_' + (iteration-topRows) + '" id="_'+fname+'_' + (iteration-topRows) + '" onkeypress="chkNextTwoFields(this,\''+tbl1+'\',\''+fname+'\',\''+val+'\',\''+val1+'\')"; value="'+val+'" >';
		
		cellLeft = row.insertCell(i++);
  		cellLeft.bgColor = '#FFFFFF';
		cellLeft.innerHTML = '&nbsp;&nbsp;&nbsp;'+Currency+'<input type="text" name="_'+fname+'_PRICE_' + (iteration-topRows) + '" id="_'+fname+'_PRICE_' + (iteration-topRows) + '" size="5" value="'+val1+'" >';
		
		 
		document.getElementById('TotalLines_'+fname).value = iteration-topRows;
  //ind++;
}
function chkNextTwoFields(obj,tbl,fname,val,val1) {
	  
	  var getId = obj.name.split(/_/);
	  if (navigator.userAgent.indexOf('Firefox')== -1) {
	  	if (!DG('_'+getId[0]+'_'+(parseInt(getId[1])+1))) addRowToTableTwoFields(tbl,fname,val,val1);
	  }
	  else {
	  	if (!DG('_'+getId[1]+'_'+(parseInt(getId[2])+1))) addRowToTableTwoFields(tbl,fname,val,val1);
	  }
	}


function removeRowFromTable(tbl)
{
  var tbl = document.getElementById(tbl);
  var lastRow = tbl.rows.length;
  if (lastRow > (topRows+1)) tbl.deleteRow(lastRow-topRows-1);
  else alert("Atleast One Field Will Remain!");
  return false;
}


function show_pwd_errors() {
      var LoginError, ErrorString;
	  trimForm();
	  ErrorString ="";
	  LoginError = "";
	  
	 if (document.forPassForm.login_name.value== "") {
		 ErrorString+="Error : Please Enter Your Login Name<br>";
      } else {
	    if (!isUserName(document.forPassForm.login_name.value)) {
		 ErrorString+="Error : Invalid Login Name <br>";
		}  	  
	  }
	  
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  return false;
	  } else {
			return true;
		  }
  }
function show_blog_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	  
      if (document.RegForm.postBy.value=="") {
        ErrorString+="Error : Enter Your Name (Posted by)<br>";
      }
	  
	  if (document.RegForm.blogTitle.value=="") {
        ErrorString+="Error : Enter Blog Title<br>";
      }
	  
	  if (document.RegForm.blogDesc.value=="") {
        ErrorString+="Error : Enter Blog Description<br>";
      }
	  
	  if (document.RegForm.email.value!="") {
         if (!isValidEmail(document.RegForm.email.value)) {
				ErrorString+="Error : Invalid Email Address <br>";
		}
	  }
	  if (document.RegForm.imageVerify.value=="") {
         ErrorString+="Error : Enter Image Verification Code<br>";
	  }
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  return false;
	  } 
	return true;  
  }	

function show_email_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	  
      if (document.RegForm.yourSubject.value=="") {
        ErrorString+="Error : Enter Subject\n";
      }
	  
	  if (document.RegForm.yourMessage.value=="") {
        ErrorString+="Error : Enter Your Message\n";
      }
	  
	  if (ErrorString!="") {
	  
	  alert(ErrorString);
	  return false;
	  } 
	return true;  
  }	

function show_contactus_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	  
      if (document.RegForm.yourName.value=="") {
        ErrorString+="Error : Enter Your Name<br>";
      }
	  
	  if (document.RegForm.yourEmail.value!="") {	  
		  if (!isValidEmail(document.RegForm.yourEmail.value)) {
				ErrorString+="Error : Invalid Email Address<br>";
	    	}
	  }
	  
	  if (document.RegForm.subject.value=="") {
        ErrorString+="Error : Enter Subject<br>";
      }
	  
	  if (document.RegForm.yourMessage.value=="") {
        ErrorString+="Error : Enter Your Message<br>";
      }
	  
	  
	  if (ErrorString!="") {
	  
	   ErrorString+="<br>"; 	  
	   document.getElementById("ErrorLable1").innerHTML= ErrorString;
	   return false;
	  } 
	return true;  
  }	


function show_tell_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	  
      if (document.RegForm.yourName.value=="") {
        ErrorString+="Error : Enter Your Name<br>";
      }
	  
	  if (document.RegForm.recip.value=="") {
        ErrorString+="Error : Enter Altleast One Recipient<br>";
      } else {
		  
		  if (!isValidEmail(document.RegForm.recip.value)) {
				ErrorString+="Error : Invalid Recipient Email Address<br>";
	    	}
	  }
	  
	  if (document.RegForm.subject.value=="") {
        ErrorString+="Error : Enter Subject<br>";
      }
	  
	  if (document.RegForm.yourMessage.value=="") {
        ErrorString+="Error : Enter Your Message<br>";
      }
	  
	  
	  if (ErrorString!="") {
	  
	   ErrorString+="<br>"; 	  
	   document.getElementById("ErrorLable1").innerHTML= ErrorString;
	   return false;
	  } 
	return true;  
  }	

function show_send_email_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	  
      if (document.RegForm.subject.value=="") {
        ErrorString+="Error : Enter Subject<br>";
      }
	  
	  if (document.RegForm.yourMessage.value=="") {
        ErrorString+="Error : Enter Your Message<br>";
      }
	  
	  
	  if (ErrorString!="") {
	  
	   ErrorString+="<br>"; 	  
	   document.getElementById("ErrorLable1").innerHTML= ErrorString;
	   return false;
	  } 
	return true;  
  }	


function show_add_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	  
      if (document.RegForm.agentName.value=="") {
        ErrorString+="Error : Enter Agent Name<br>";
      }
	  
	  if (document.RegForm.email.value=="") {
         ErrorString+="Error : Enter Email Address<br>";
		 EmailError = 1; 
	  }
	  
	  if (document.RegForm.phone.value=="") {
        ErrorString+="Error : Enter Phone<br>";
      }
	  
	  if (EmailError!=1) {
		    if (!isValidEmail(document.RegForm.email.value)) {
				ErrorString+="Error : Invalid Email Address <br>";
				}
		  }
	  if (document.RegForm.imageVerify.value=="") {
         ErrorString+="Error : Enter Image Verification Code<br>";
	  }
	  
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  return false;
	  } 
	return true;  
  }	


function show_regedit_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	
	  
	  if (document.RegForm.userPreference.value=="") {
         ErrorString+="Error : Please Select a Preference<br>";
	  }
	  if (document.RegForm.agentName.value=="" && document.RegForm.anonymousName.value=="") {
         ErrorString+="Error : Enter Real Name OR Anonymous Name<br>";
	  }
	  
	  
	  if (document.RegForm.email.value=="") {
         ErrorString+="Error : Enter Email Address [Login ID]<br>";
		 EmailError = 1; 
	  }
	  
	 /* if (document.RegForm.password1.value=="") {
         ErrorString+="Error : Enter Password<br>";
	     PwdError=1;
      } */
	  /*if (document.RegForm.password2.value=="") {
         ErrorString+="Error : Enter Verify Password<br>";
	     PwdError=1;
	  }*/
	  
	  if (document.RegForm.age.value=="") {
         ErrorString+="Error : Enter your Age<br>";
	  }
	  
	  if (document.RegForm.country.value=="") {
         ErrorString+="Error : Please Select a Country<br>";
	  }
	  
	  /*if (document.RegForm.imageVerify.value=="") {
         ErrorString+="Error : Enter Image Verification Code<br>";
	  }*/
	  /*if (!document.RegForm.agree.checked) {
         ErrorString+="Error : Please read and agree to terms and conditions<br>";
	  }*/
	  
	  /*if (PwdError!=1) {
		  
		  if (document.RegForm.password1.value!=document.RegForm.password2.value) {
			    ErrorString+="Error : Passwords Missmatch<br>";
			  }
	  }*/
	  
	  
	  if (EmailError!=1) {
		    if (!isValidEmail(document.RegForm.email.value)) {
				ErrorString+="Error : Invalid Email Address <br>";
				}
		  }
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  scroll(0,0);
	  return false;
	  } 
	return true;  
  }	

function show_regpwd_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	
	  
	 if (document.RegForm.password.value=="") {
         ErrorString+="Error : Enter Current Password<br>";
	  } 
	  
	  if (document.RegForm.password1.value=="") {
         ErrorString+="Error : Enter New Password<br>";
	     PwdError=1;
      } 
	  if (document.RegForm.password2.value=="") {
         ErrorString+="Error : Enter Verify Password<br>";
	     PwdError=1;
	  }
	  
	  if (PwdError!=1) {
		  
		  if (document.RegForm.password1.value!=document.RegForm.password2.value) {
			    ErrorString+="Error : Passwords Missmatch<br>";
			  }
	  }
	  
	
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  scroll(0,0);
	  return false;
	  } 
	return true;  
  }	


function show_freepost_errors_update() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	
	  if (document.RegForm.postTitle.value=="") {
         ErrorString+="Error : Enter Name of Package or Deal<br>";
	  }
	  if (document.RegForm.postDescription.value=="") {
         ErrorString+="Error : Enter Description<br>";
	  }
      if (document.RegForm.packageFrom.value=="" || document.RegForm.packageTo.value=="") {
         ErrorString+="Error : Enter Price Range for your package. Fill both fields with same figures for no range<br>";
	  }
	  if (document.RegForm.city.value=="") {
         ErrorString+="Error : Enter City Name<br>";
	  }
	  if (document.RegForm.country.value=="") {
         ErrorString+="Error : Select Country<br>";
	  }
	  if (document.RegForm.email.value=="") {
         ErrorString+="Error : Enter Contact Email Address<br>";
		 EmailError = 1; 
	  }
	  
	  if (EmailError!=1) {
		    if (!isValidEmail(document.RegForm.email.value)) {
				ErrorString+="Error : Invalid Contact Email Address <br>";
				}
		  }
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  scroll(0,0);
	  return false;
	  } 
	return true;  
	
  }


function show_freepost_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	
	  if (document.RegForm.postTitle.value=="") {
         ErrorString+="Error : Enter Name of Package or Deal<br>";
	  }
	  if (document.RegForm.postDescription.value=="") {
         ErrorString+="Error : Enter Description<br>";
	  }
      if (document.RegForm.packageFrom.value=="" || document.RegForm.packageTo.value=="") {
         ErrorString+="Error : Enter Price Range for your package. Fill both fields with same figures for no range<br>";
	  }
	  if (document.RegForm.city.value=="") {
         ErrorString+="Error : Enter City Name<br>";
	  }
	  if (document.RegForm.country.value=="") {
         ErrorString+="Error : Select Country<br>";
	  }
	  if (document.RegForm.email.value=="") {
         ErrorString+="Error : Enter Contact Email Address<br>";
		 EmailError = 1; 
	  }
	  if (document.RegForm.imageVerify.value=="") {
         ErrorString+="Error : Enter Image Verify Code<br>";
	  }
	  if (EmailError!=1) {
		    if (!isValidEmail(document.RegForm.email.value)) {
				ErrorString+="Error : Invalid Contact Email Address <br>";
				}
		  }
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  scroll(0,0);
	  return false;
	  } 
	return true;  
	
  }

function show_reg_errors() {
      var ErrorString,PwdError,EmailError,LoginError;
	  trimForm();
      ErrorString = "";
	  PwdError = "";
	  EmailError = "";
	  LoginError = "";
	
	  
	  if (document.RegForm.userPreference.value=="") {
         ErrorString+="Error : Please Select a Preference<br>";
	  }
	  if (document.RegForm.agentName.value=="" && document.RegForm.anonymousName.value=="") {
         ErrorString+="Error : Enter Real Name OR Anonymous Name<br>";
	  }
	  
	  
	  if (document.RegForm.email.value=="") {
         ErrorString+="Error : Enter Email Address [Login ID]<br>";
		 EmailError = 1; 
	  }
	  
	  if (document.RegForm.password1.value=="") {
         ErrorString+="Error : Enter Password<br>";
	     PwdError=1;
      }
	  if (document.RegForm.password2.value=="") {
         ErrorString+="Error : Enter Verify Password<br>";
	     PwdError=1;
	  }
	  
	  if (document.RegForm.age.value=="") {
         ErrorString+="Error : Enter your Age<br>";
	  }
	  
	  if (document.RegForm.country.value=="") {
         ErrorString+="Error : Please Select a Country<br>";
	  }
	 
	 
	  if (document.RegForm.imageVerify.value=="") {
         ErrorString+="Error : Enter Image Verification Code<br>";
	  } 
	  
	  if (!document.RegForm.agree.checked) {
         ErrorString+="Error : Please read and agree to terms and conditions<br>";
	  }
	  
	  if (PwdError!=1) {
		  
		  if (document.RegForm.password1.value!=document.RegForm.password2.value) {
			    ErrorString+="Error : Passwords Missmatch<br>";
			  }
	  }
	  
	  
	  if (EmailError!=1) {
		    if (!isEmail(document.RegForm.email.value)) {
				ErrorString+="Error : Invalid Email Address <br>";
				}
		  }
	  if (ErrorString!="") {
	  ErrorString+="<br>"; 	  
	  document.getElementById("ErrorLable1").innerHTML= ErrorString;
	  scroll(0,0);
	  return false;
	  } 
	return true;  
	
  }
  function show_finish_reg_errors() {
	var ErrorStr;
	trimForm();
	ErrorStr="";
	if (document.FForm.email.value=="") {
		 ErrorStr ="<br>&nbsp; &nbsp;Error : Email [Login ID] could not be empty<br>";
		  document.getElementById("ErrorLable").innerHTML= ErrorStr;
		  return false;
		} else {
	if (!isValidEmail(document.FForm.email.value)) {
				ErrorStr ="<br>&nbsp; &nbsp; Error : Invalid Email Address<br>";
				 document.getElementById("ErrorLable").innerHTML= ErrorStr;
				  return false;
				} else {
	          return true;
				}
		}
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
function addRow(){
  var tbl = document.getElementById('tblGrid');
  var lastRow = tbl.rows.length;
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  if (document.getElementById('tcat')) {
	   var conter = document.getElementById('tcat').value;
	   if (document.getElementById('tcat').value<2) {
		  var cellLeft = row.insertCell(0); 
	      document.getElementById('tcat').value = ++conter;
	   } else {
		     alert("Cannot Assign More then three categories");
			 return;
		   }
	  }else {
     var cellLeft = row.insertCell(0);	  
  }
  var textNode = cellLeft.innerHTML =  showCatDrop(iteration);
  document.getElementById('total').value = iteration;
 }
function removeRow()
{
  var tbl = document.getElementById('tblGrid');
  var lastRow = tbl.rows.length-1;
  if (lastRow>0) {
  tbl.deleteRow(lastRow);
 } 
 return false;
}
function Validate_pass() {
		var frm = document.getElementById('frmNewUser');
		var oldpass = Trim(frm.oldpass.value);
		var newpass = Trim(frm.newpass.value);
		var repass = Trim(frm.repass.value);
		var error_str = '';
		
		if (oldpass.length < 1)
		{
			error_str+="Error : Old Password is required<br>";
		}
		if (newpass.length < 1)
		{
			error_str+="Error : New Password is required<br>";
		}
		if (repass.length < 1)
		{
			error_str+="Error : Re-enter New Password<br>";
		}
		if (newpass != repass)
		{
			error_str+="Error : New Password and Re-entered Password doesnot match<br>";
		}
		if (error_str) {
			 document.getElementById("ERR_DISP").style.display = "block";
			 document.getElementById("Error_Label").innerHTML = error_str;
			 return false;
		} 
	return true;
}
 function show_login_form_errors() {
	
	var ErrorStr;
	trimForm();
	ErrorStr="";
	if (document.LoginFrm.LoginId.value=="") {
		 ErrorStr +="Error : Please Enter Login Name<br>";
		  
		}
	if (document.LoginFrm.Pwd.value=="") {
		 ErrorStr +="Error : Please Enter Password<br>";
		  
		}	
	if (ErrorStr!="") {
		ErrorStr += "<br>";	
		document.getElementById("ErrorLable").innerHTML= ErrorStr;
		return false;
		} 
	return true;
}
function trimStr(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function trimForm()
{
	for(field in document.getElementsByTagName("input"))
	{
		try{
		document.getElementById(field).value=trimStr(document.getElementById(field).value);
		}catch(e)
		{}
	}
	for(field in document.getElementsByTagName("textarea"))
	{
		try{
		document.getElementById(field).value=trimStr(document.getElementById(field).value);
		}catch(e)
		{}
	}
}

function Validate_upass() {
		var frm = document.getElementById('frmNewUser');
		
		var newpass = Trim(frm.newpass.value);
		var repass = Trim(frm.repass.value);
		var error_str = '';
		
		if (newpass.length < 1)
		{
			error_str+="Error : New Password is required<br>";
		}
		if (repass.length < 1)
		{
			error_str+="Error : Re-enter New Password<br>";
		}
		if (newpass != repass)
		{
			error_str+="Error : New Password and Re-entered Password doesnot match<br>";
		}
		if (error_str) {
			 document.getElementById("ERR_DISP").style.display = "block";
			 document.getElementById("Error_Label").innerHTML = error_str;
			 return false;
		} 
	return true;
}
function popup(src,wid,hei){
	    
	    winleft = screen.width/2 - wid/2;
		wintop = screen.height/2 - hei/2;
	    window.open(src,"","toolbar=no,scrollbars=no,resizable, status=yes,width="+wid+",height="+hei+",top="+wintop+",left="+winleft);
	}
function popupScroll(src,wid,hei){
	    winleft = screen.width/2 - wid/2;
		wintop = screen.height/2 - hei/2;
	    window.open(src,"","toolbar=no,scrollbars=yes,resizable, status=yes,width="+wid+",height="+hei+",top="+wintop+",left="+winleft);
	}
	
function Validate()
	{
		var frm = document.getElementById('frmNewUser');
		var usrName = Trim(frm.uname.value);
		var passwrd = Trim(frm.pwd.value);
		var repasswrd = Trim(frm.repwd.value);
		var emailad = Trim(frm.email.value);
		var adcat = Trim(frm.ad_cat.value);
		var error_str = '';
		
		
		if (usrName.length < 1)
		{
			error_str+="Error : User Name is required<br>";
		}
		if (passwrd.length < 1)
		{
			error_str+="Error : Password is required<br>";
		}
		if (passwrd != repasswrd)
		{
			error_str+="Error : Password and Confirm Password doesnot match<br>";
		}
		if (adcat == -1)
		{
			error_str+="Error : Please Choose a Permission Level for this User<br>";
		}
		if (emailad.length<1)
		{
			error_str+="Error : Email Address is required<br>";
		} else if (!isEmail(emailad)) {
			  error_str+="Error : Invalid Email Address<br>";
			} 
		if (error_str) {
			 document.getElementById("ERR_DISP").style.display = "block";
			 document.getElementById("Error_Label").innerHTML = error_str;
			 return false;
		}
		
		return true;
	}
function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
	var dom=new Array("au","com","net","org","edu","in","mil","gov","arpa","biz","aero","name","coop","info","pro","museum");
						var error="yes";
						for(var k=0;k<dom.length;k++)
						{
							if(string.indexOf('.' + dom[k])>0)
							{
								//alert(string.indexOf('.' + dom[k]))
								//alert('hello');
								k=dom.length
								error="no"
							}
						}
				if (error=="no") return true;		
				else return false;		
	}

else
return false;
}

function isUserName(value)
{
	for(i=0;i<value.length;i++)
	{			
		ch = value.charAt(i);
		if ( ((ch <= "z") && (ch >= "a")) || ((ch <= "Z") && (ch >= "A")) || ((ch <= "9") && (ch >= "0")) || (ch == '_') || (ch == "-") ) {}
		else 
 			return false;
	}
 	return true;
}


function Message()
	{
		alert("Not implemented yet");
	}
function checkEmail(emailCntrl)
{
	if(emailCntrl.value=="")
	{
		return "Please enter e-mail address.";
	}
	else
	{
		mail=emailCntrl.value
		at_pos=mail.indexOf("@")
		dot_pos=mail.indexOf(".")
		if(at_pos<1 || dot_pos<1)
		{
			return "Please enter valid email address.";
		}
		else
		{
			mail=emailCntrl.value
			condition="yes"
			var at_count=0
			var dot_count=0
			var temp=0
			for(var i=0;i<mail.length;i++)
			{
				if((mail.charCodeAt(i)>0 && mail.charCodeAt(i)<48)||(mail.charCodeAt(i)>57 && mail.charCodeAt(i)<65)||(mail.charCodeAt(i)>91 && mail.charCodeAt(i)<97)||mail.charCodeAt(i)>122)
				{
					if(mail.charAt(i)=="@"||mail.charAt(i)==".")
					{
							if(mail.charAt(i)=="@"){at_count++}else{dot_count++} // counts the no. of times @ and . appears in email
							if(dot_count>=1)
							{
								dot_pos=i
								if((dot_pos>at_pos) && temp==0)
								{
									pos=dot_pos-at_pos
									temp++
								}								
							}
					}
					else
					{
						condition="no"
						i=mail.length
					}
				}
			}
			if(condition=="no")
			{
				alert("Your email contains a blank space or special character.")
				emailCntrl.focus()
				ok=false
			}
			else
			{
				if(at_count>1)
				{
					alert("E-mail contains extra @ ")
					emailCntrl.focus()
					ok=false
				}
				else
				{
					if(pos<2)
					{
						alert("Missing domain name between '@' and '.'")
						emailCntrl.focus()
						ok=false
						i=mail.length
					}
					else
					{	
						count=dot_pos+1
						domain=""
						for(count;count<mail.length;count++)
						{
							domain=domain+mail.charAt(count)		
						}
						dom=new Array("au","com","net","org","edu","in","mil","gov","arpa","biz","aero","name","coop","info","pro","museum")
						error="yes"
						for(var k=0;k<dom.length;k++)
						{
							if(domain==dom[k])
							{
								k=dom.length
								error="no"
							}
						}
						if((error=="yes" && (domain.length>2)) || (domain.length<2))
						{
							alert("Domain name must end with well known domains \n or 2-lettered country name. eg com,edu,in etc.")
							emailCntrl.focus()
							ok=false
						}								
					}
				}
			}
		}
	}
	return ok
}

function LTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

function RTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

function Trim(String)
{
	if (String == null)
		return (false);

	return RTrim(LTrim(String));
}

function isName(value)
{
	for(i=0;i<value.length;i++)
	{			
		ch = value.charAt(i);
		if ( ((ch <= "z") && (ch >= "a")) || ((ch <= "Z") && (ch >= "A")) || (ch == ' ') || (ch == " ") ) {}
		else 
 			return false;
	}
 	return true;
}
function isNumeric(e)
{
	if((e.keyCode> 47 && e.keyCode < 58) || e.keyCode==8 || e.keyCode==9 || e.keyCode==13 || e.keyCode==46 || (e.keyCode>= 37 && e.keyCode <= 40)) return true;
	else return false; 

}

function isDigit(value)
{
	var digit = Boolean(true);
    	for(var i=0;i<value.length;i++)
    	{
      	  var ch = value.charAt(i);
      	  if(!(ch == "0" || ch=="1" || ch=="2" || ch=="3" || ch=="4" || ch=="5" || ch=="6" || ch=="7" || ch=="8" || ch=="9"))
   	  	return false;
      	}
	return true;
}
function isFloat(field)
{
	var point=0;
	var i=0;
	var beforePoint=0;
	var afterPoint=0;
	for(var a=0;a<field.length;a++)
	{
    	if(!(field.charAt(a)=="." || field.charAt(a)=="0" || field.charAt(a)=="1" || field.charAt(a)=="2" || field.charAt(a)=="3" || field.charAt(a)=="4" || field.charAt(a)=="5" || field.charAt(a)=="6" || field.charAt(a)=="7" || field.charAt(a)=="8" || field.charAt(a)=="9"))
			return false;
		if(field.charAt(a)==".")
			point++;
	}
	if(point > 1)
		return false;
	if(point == 1)
	{
		while(field.charAt(i)!=".")
		{
			i++;
			beforePoint++;
		}
		afterPoint=field.length-(beforePoint+1);
		if(beforePoint > 3)
			return false;
		if(afterPoint > 4)
			return false;
		if(afterPoint==0 && beforePoint==0)
			return false;
	}
	return true;
}	
function show_hide (obj){
   if (document.getElementById(obj).style.display == "none"){
     	document.getElementById(obj).style.display = "block";
   } else {
     	document.getElementById(obj).style.display = "none" ;
   }
}
function showDiv(div,textVal) {
   var scrollTop = 0;
   
  if (document.documentElement && document.documentElement.scrollTop)
  {
    // IE6 +4.01 and user has scrolled
    scrollTop = document.documentElement.scrollTop;
  }
  else if (document.body && document.body.scrollTop)
  {
    // IE5 or DTD 3.2
    scrollTop = document.body.scrollTop;
  }

objDiv = document.getElementById(div);

var divWidth = objDiv.style.width.split("px")[0];
var divHeight = objDiv.style.height.split("px")[0];
var top = scrollTop + YY + 250;

	objDiv.style.top = top + "px";
   	objDiv.style.left = (screen.width/2 - divWidth/2) + "px";  
   	objDiv.style.display = "block";
   
}
function close_div(div){
 document.getElementById(div).style.display='none';
 
}
function showMessage(e){
          if(document.all)
		  {
		     e = event;
          }
		  XX = e.clientX;
		  YY = e.clientY;
          return false;
}
//document.documentElement.onmousemove =  showMessage;