// JavaScript Document
function cLook()
{
	//alert("HI");
	event.srcElement.parentElement.className="l1";
}
function rLook()
{
	event.srcElement.parentElement.className="l0";
}

function checkNum()
 {
  var carCode = event.keyCode;
  if ((carCode < 48) || (carCode > 57))
  {
   alert('Please enter only numbers.');
   event.cancelBubble = true
   event.returnValue = false;
  }
 }

function checktxtemail()
 {
  a=new Array();
  s=document.prayer.txtemail.value;
  for(i=0; i<s.length; i++)
    {
     a[i]=s.charAt(i);
    }
   dot = s.indexOf(".");
   at   = s.indexOf("@");
   if (dot == -1 || at == -1)
    {
       document.prayer.txtemail.focus()
       alert ("Email id does not exist");
       return 1;
     }
       str1=s.substring(dot+1,s.length);
       str2=s.substring(at+1, dot);
       str3=s.substring(0,at);
       if((str1.length==0)||(str2.length==0)||(str3.length==0))
          {
             document.prayer.txtemail.focus()     
             alert ("Invalid email id");
             return 1;
          }
         return 0;
     }
	 
	 
function checkphone()
{
  s=document.prayer.txtphone.value;
var z;
z=new Array();
for(j=0;j<s.length;j++)
                {
                  z[j]=s.charAt(j);
                  if((z[j]>='0')&&(z[j]<='9')||(z[j]=='-')&&(j==s.length-7)&&(j==4)&&count!=1)
                     {
	     if (z[j]=='-')
	       {
	           counter=1;
	         }
	       continue;
	     }
	     else
	      {
	         document.prayer.txtphone.focus();
	         alert("Invalid Phone Number");
	         document.prayer.txtphone.value="";
	          return 1;
	         }
             }

return 0;
}

/*
function checknop() //no of persons
{
  s=document.prayer.txtnop.value;
var z;
z=new Array();
for(j=0;j<s.length;j++)
                {
                  z[j]=s.charAt(j);
                  if((z[j]>='0')&&(z[j]<='9')||(z[j]=='-')&&(j==s.length-7)&&(j==4)&&count!=1)
                     {
	     if (z[j]=='-')
	       {
	           counter=1;
	         }
	       continue;
	     }
	     else
	      {
	         document.prayer.txtnop.focus();
	         alert("Invalid Number of Persons");
	         document.prayer.txtnop.value="";
	          return 1;
	         }
             }

return 0;
}

*/

/*function checknoc() //no of children
{
  s=document.pkinfo.txtnochild.value;
var z;
z=new Array();
for(j=0;j<s.length;j++)
                {
                  z[j]=s.charAt(j);
                  if((z[j]>='0')&&(z[j]<='9')||(z[j]=='-')&&(j==s.length-7)&&(j==4)&&count!=1)
                     {
	     if (z[j]=='-')
	       {
	           counter=1;
	         }
	       continue;
	     }
	     else
	      {
	         document.pkinfo.txtnochild.focus();
	         alert("Invalid Number of Children");
	         document.pkinfo.txtnochild.value="";
	          return 1;
	         }
             }

return 0;
}*/

/*
function checkdot()
{
var z;
var s;
var ss;
    z=new Array();
    s=document.prayer.txtchkin.value
	ss=document.prayer.txtchkout.value
    if(s.value=="" || ss.value=="") //validity ?   TODO
      { 
           
           alert("Please fill in Date of Check in / Check Out!!");
           
           return 1;          
        }
        
return 0;
}

*/

function checknames()
{
var z;
var s;
    z=new Array();
    s=document.prayer.txtname.value
    for(j=0; j<s.length; j++)
      { 
        z[j]=s.charAt(j);
        if(!( ( (z[j]>='a')&&(z[j]<='z') ) || ( (z[j]>='A')&&(z[j]<='Z') ) ||  (z[j]==' ')  ) )
          {
           document.prayer.txtname.focus();
           alert("Invalid Name");
           document.prayer.txtname.value="";
           return 1;          
          }
        }
return 0;
}


function checkem()
{
	var e=0	
	var f = document.forms[0];
	
	if(f.txtname.value==""  || f.txtcity.value==""  ||  f.txtemail.value=="" ||  f.txtrequest.value=="" )
{
	alert("Please fill in the required information !!!");
	return;
}

if(checknames()==0  && checktxtemail()==0 && checkphone()==0) //date check pending
{
	
     document.prayer.submit();
	
}

}

function checkEmail(x)
{
	a=new Array();
	s=x.value;
	
	for(i=0; i<s.length; i++)
	{
		a[i]=s.charAt(i);
	}

	dot = s.indexOf(".");
	at = s.indexOf("@");
	
	if (dot == -1 || at == -1)
	{
		x.focus()

		return 1;
	}

	str1=s.substring(dot+1,s.length);
	str2=s.substring(at+1, dot);
	str3=s.substring(0,at);

	if((str1.length==0)||(str2.length==0)||(str3.length==0))
	{
		x.focus() 
             
		return 1;
	}

	return 0;
}


function check()
{
	var err=0;
	if(email.txtemail.value=="" || checkEmail(email.txtemail))
	{
		alert("please enter the email address");
		err=1;
	}
	else
	{
		document.email.submit()
	}
}

function checkSpace(box)
{
	var val = box.value
	var carCode = event.keyCode;
	
	if(val=="")
	{			
		if ( carCode == 32) 
		{			
			event.cancelBubble = true;
			event.returnValue = false;
			return;
		}
	}	
}

function checkNumDec()
{
	var carCode = event.keyCode;
		
	if ( ((carCode >= 48) && (carCode <= 57)) || (carCode == 46) )
	{
	}
	else
	{
		alert('Please enter only +ve numbers.');
		event.cancelBubble = true;
		event.returnValue = false;
		return;
	}
}

function email()
{

	var err=0;
		if(form1.txtfrom.value=="")
		{
			form1.txtfrom.focus();
			alert("Please fill in the required information !!!");
			err=1;
			return;
		}
		else
		{
			a=new Array();
			s=document.form1.txtfrom.value;
			for(var i=0; i<s.length; i++)
			{
				 a[i]=s.charAt(i);
			}
			dot = s.indexOf(".");
			at   = s.indexOf("@");
		   if (dot == -1 || at == -1)
			{
					document.form1.txtfrom.focus()
				   msg.innerText ="Email id does not exist";
				  // email.style.color="blue";
				   alert("check mail");
				   err=1;
				   return 1;
			 }
		   str1=s.substring(dot+1,s.length);
		   str2=s.substring(at+1, dot);
		   str3=s.substring(0,at);
		   if((str1.length==0)||(str2.length==0)||(str3.length==0))
			  {
				 document.form1.txtfrom.focus() 
				 msg.innerText ="Invalid email id";    
				alert("check mail"); 
				 err=1;
				 return 1;			   
			  }
		   //  return 0;
			//err=0;
		}
		if(err==0)
		{
			document.form1.submit();
		}
}
function CheckIfImageFile(path)
{
	if(path!="")
	{
		index=path.lastIndexOf(".");
		ext=path.substr(index);
		if(ext!='.jpg'&&ext!='.jpeg'&&ext!='.png'&&ext!='.JPG'&&ext!='.PNG')
		{
			alert("Please Put  Images with jpg or pnj extension only !! ");
			return 1;
		}
	}
	return 0;

}