function dispmsg(id)
{
document.getElementById('msg').innerHTML=id;
	
}

function highlight(id)
{
		document.getElementById(id).className='menu1';
	
}
function ocss(id)
{
		document.getElementById(id).className='menu';
	
}
function display_error(ele,id,msg)
{
document.getElementById(id).innerHTML=msg;
//document.getElementById(ele).className='bg';
}
function display_error1(id,msg)
{
document.getElementById(id).innerHTML=msg;
}



function blank_msg()
{
	
		document.getElementById('securitycode_error').innerHTML='';

	
}

 var extea='';
 function verify_captcha(val)
{
	
   var url = "../code/verify_captcha.php?code="+val; 
 if (window.XMLHttpRequest)
   {
	    http=new XMLHttpRequest();
     http.open("GET",url,true);
      http.onreadystatechange=captchaprocess;
      http.send(null);
   }
   // code for IE
   else if (window.ActiveXObject)
   {
      http=new ActiveXObject("Microsoft.XMLHTTP");

      if (http)
      {
		  
         http.open("GET",url,true);
         http.onreadystatechange=captchaprocess;
         http.send();
      }
   } 
         
    } 
function captchaprocess() 
{ 
    if (http.readyState == 4 || http.readyState=="complete")
	 { 
    
        if(http.status==200) 
        { 
			//document.getElementById("s").innerHTML='';	
			if(http.responseText=='ok')
			{
			
		   document.form1.submit.disabled=false;
		   blank_msg();
			}
			else
			{ 
				document.form1.submit.disabled=true;
				//alert("Invalid Captcha Code");
				display_error('securitycode','securitycode_error','&nbsp;&nbsp;Invalid Captcha Code');
				document.form1.securitycode.focus();
				
			}
        } 
		
  } 
}





function altecheck(str) 
{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   display_error('p_email','p_email_error','&nbsp;&nbsp;Invalid E-mail ID');
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		    display_error('p_email','p_email_error','&nbsp;&nbsp;Invalid E-mail ID');
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		     display_error('p_email','p_email_error','&nbsp;&nbsp;Invalid E-mail ID');
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    display_error('p_email','p_email_error','&nbsp;&nbsp;Invalid E-mail ID');
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		     display_error('p_email','p_email_error','&nbsp;&nbsp;Invalid E-mail ID');
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		     display_error('p_email','p_email_error','&nbsp;&nbsp;Invalid E-mail ID');
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		     display_error('p_email','p_email_error','&nbsp;&nbsp;Invalid E-mail ID');
		    return false
		 }
	return true;
}




function checkExtension(val)
{
   var name = document.getElementById("file");
   var errmsg='';
  //checkIt = A();
   //alert(name.size);
   
  		 if(frmobj.merriage_photo.value=='')
		{
		display_error1('photo_error','&nbsp;&nbsp;please upload Merrage Photo.');
		 frmobj.merriage_photo.focus();
		  return false;
		}
		var photoPath = frmobj.merriage_photo.value;
		var pathLength = photoPath.length;
		var lastDot = photoPath.lastIndexOf(".");
		var fileType = photoPath.substring(lastDot,pathLength);
   		var flag=true;
	  	if((fileType == ".jpeg") || (fileType == ".gif") || (fileType == ".jpg") || (fileType == ".jpe") || (fileType == ".png")) 
							{
								return true
							} 
		  
	  if(flag==false)
	  {
	    alert(errmsg);
		//document.getElementById("file").value='';
		frmobj.file.value='';
	    document.getElementById("file").focus();
	  }
	  else
	  {
	    return true;
	  }
	   
}






  function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function Trim(TRIM_VALUE)

{
	
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
} 
function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";

	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} 
return strTemp;

}
function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} 
return strTemp;
} 
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	{field[i].checked = true ;
	}
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}
function mobile(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789-+";
   var strChar;
   var blnResult = true;

   if (strString.length < 10)
   {
	   return false;
   }
    if (strString.length > 14)
	{return false;
	}
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function IsNumericWithDash(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
