function CheckDay(theForm)
{
  var MonthValue 
  var Day
  var Year
  
  MonthValue = theForm.month.options[theForm.month.selectedIndex].value
  Day = theForm.day.options[theForm.day.selectedIndex].value
  Year = theForm.year.options[theForm.year.selectedIndex].value 
  
  if(((MonthValue == 4 || MonthValue == 6 || MonthValue == 9 || MonthValue == 11) &&  (Day > 30)))
  {
    return(true)
  }
  
  if(MonthValue == 2)
   {
       if((((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0)))
       {
         if(Day > 29)
          return(true)
       }
       else
        {
          if(Day > 28)
            return(true)
        }
   }
 return(false)
} // end of function

function CheckNumber(Object,label)
{
  var checkOK = "-0123456789/\\ ";
  var checkStr = Object.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  if(alltrim(Object.value) == "") 
  {
    alert('Please Enter the Value For ' + label + ' Field !')
    Object.focus();
    Object.value=""
    return true;
   }
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digits in the " + label + " field.");
    Object.focus();
    return (true);
  }
  return (false);
}

function isUrl(url) 
{
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	if(!regexp.test(url))
	{
		alert('Please enter valid Company URL');
		return true;
	}
return false;
}
//Comment added by Navin on 13Aug 2007
/*function CheckEmail(content)
{
if (!(/^([^\@]{1,}@\w{2,}(\.\w{2,})+)$/.test(content.replace(new RegExp("\\s","g"),""))))
{
alert("Invalid email address please verify it");
return true;
}
return false;
}*/ // END OF CHECKEMAIL FUNCTION

<!--
//******This Code Is Used For Removing The Empty Spaces From The String******
//-->
function ltrim(ObjectValue)
{
ctr=0
for(i=0; i < ObjectValue.length;i++)
{
  if(ObjectValue.charAt(i) == " ")
    ctr = ctr + 1 
    else
    break
}
return ObjectValue.substr(ctr,ObjectValue.length)
} // end of function ltrim

function rtrim(ObjectValue)
{
ctr=0
for(i=ObjectValue.length -1; i >=0 ;i--)
{
  if(ObjectValue.charAt(i) == " ")
    ctr = ctr + 1 
    else
    break
}
return ObjectValue.substr(0,ObjectValue.length-ctr)
} // end of function rtrim


function alltrim(ObjectValue)
{
 return rtrim(ltrim(ObjectValue))
} // end of function alltrim
//****End Of Code For Removing The Spaces****

function IsPassword(Object)
{
var obj = new String()
obj = alltrim(Object.value)
if(obj.length < 4)
{
alert('Password Field should be atleast (4 Character), No Space')
return true
}
if(obj.length > 15)
{
alert('Password Field should be Less than equal to (15 Characters), No Space')
return true
}

return false
} // end of function IsPassword


function CheckEmpty(Object,Name)
{
	if(alltrim(Object.value) == "")
	{
		alert('Please Enter The Value For ' + Name + ' Field !');
		return true;
	}
	return false;
}

function IdenticalPasswordFields(password, rePassword) 
{
	if(password == rePassword) 
	{ return true; }
	alert("Both the password fields must be identical.");
	return false;
}

//To get Form Controls ID.
function GetControl(ctlname)
{
	var id   = ctlname ; 
	var name = ctlname ; 
	var ctl;
	if(document.getElementById )
	{
		ctl = document.getElementById(id);
	}
	else if(document.all )
	{

		ctl = document.all[id]; 
	}
	else if(document.layers )
	{
		ctl = document.Form1.elements[name];  
	}
	return ctl;
}


function changeValue(objControlName)
{
	objhideEmailID = GetControl(objControlName);
	if(objhideEmailID.checked)
		objhideEmailID.value=1;
	else
		objhideEmailID.value=0;
//		alert(objhideEmailID.value);
}


function chkresume() 
{
	var ext = getExtension(document.form1.userfile.value);
	if (document.form1.userfile.value == '' && ext != 'doc' && ext != 'txt') 
	{
	    return false;
	}
	return true;
}	

function getExtension(value) 
{
    
	var mytext = value.substring(value.lastIndexOf('.') + 1,value.length);
	return mytext.toLowerCase();
}

function IsLogin(Object)
{
var obj = new String()
obj = alltrim(Object.value)
if(obj.length < 4)
{
alert('Username Field should be atleast (4 Characters), No Space')
return true
}

if(obj.length > 15)
{
alert('Username Field should be Less than equal to (15 Characters), No Space')
return true
}
if(obj.search(" ")>0)
{
alert('There should not be any space between the Username')
return true
}
return false
} // end of function IsLogin


function SetIndex(ObjectName,Value)
{
for(i=0;i < ObjectName.length;i++)
 { 
   if (ObjectName[i].value == Value)
      break
 }
 return(i)
}

function NotSelected(Object, Name)
{

if(Object.selectedIndex == 0)
{ 
 alert('Please Select ' + Name + ' Field !'); 
 return true;
}
 return false;
}

function valradiobutton(Object, Name) {

// validate radiobuttons
myOption = -1;
for (i=0; i<Object.length; i++) {
if (Object[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("You must select an option for " + Name);
Object[0].focus();
return true;
}
return false;
}

function CheckEmail(strmail, mailtype)
{
var checkTLD=1;
var knownDomsPat=/^(com|COM|net|NET|org|ORG|edu|EDU|int|INT|mil|MIL|gov|GOV|arpa|ARPA|biz|BIZ|aero|AERO|name|NAME|coop|COOP|info|INFO|pro|PRO|museum|MUSEUM)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=strmail.match(emailPat);

            if (matchArray==null)
            {
                        if (mailtype == 1) //Email
                                    {alert("The EMail address seems incorrect (check @ and .'s)");
                                    return false;}
                        else  //wap mail
                                    {alert("The WAP Mail address seems incorrect (check @ and .'s)");
                                    return false;}
            }
            var user=matchArray[1];
            var domain=matchArray[2];
            for (i=0; i<user.length; i++)
            {
                        if (user.charCodeAt(i)>127)
                        {
                                    if (mailtype == 1) //Email
                                                {alert("Ths Email field contains invalid characters.");
                                                return false;}
                                    else  // WAP Mail
                                                {alert("Ths WAP Mail field contains invalid characters.");
                                                return false;}
                        }
            }
            for (i=0; i<domain.length; i++)
            {
                        if (domain.charCodeAt(i)>127)
                        {
                                    if (mailtype == 1) //Email
                                                {alert("Ths Email domain name contains invalid characters.");
                                                return false;}
                                    else  // WAP Mail
                                                {alert("Ths WAP Mail domain name contains invalid characters.");
                                                return false;}
                        }
            }
            if (user.match(userPat)==null)
            {
                        if (mailtype == 1) //Email
                                    {alert("The Email field doesn't seem to be valid.");
                                    return false;}
                        else  // WAP Mail
                                    {alert("The WAP Mail field doesn't seem to be valid.");
                                    return false;}
            }

            var IPArray=domain.match(ipDomainPat);
            if (IPArray!=null)
            {
                        for (var i=1;i<=4;i++)
                        {
                                    if (IPArray[i]>255)
                                    {
                                                if (mailtype == 1) //Email
                                                            {alert("The Email destination IP address is invalid!");
                                                            return false;}
                                                else  // WAP Mail
                                                            {alert("The WAP Mail destination IP address is invalid!");
                                                            return false;}
                                    }          
                        }
                        return true;
            }
 
            var atomPat=new RegExp("^" + atom + "$");
            var domArr=domain.split(".");
            var len=domArr.length;
            for (i=0;i<len;i++)
            {
                        if (domArr[i].search(atomPat)==-1)
                        {
                                    if (mailtype == 1) //Email
                                                {alert("The Email domain name does not seem to be valid.");
                                                return false;}
                                    else  // WAP Mail
                                                {alert("The WAP Mail domain name does not seem to be valid.");
                                                return false;}
                        }
            }
            if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
            {
                        if (mailtype == 1) //Email
                                    {
                                    //alert("hi" +checkTLD )
                                    alert("The Email address must end in a well-known domain or two letter " + "country.");
                                    return false;}
                        else  // WAP Mail
                                    {alert("The WAP Mail address must end in a well-known domain or two letter " + "country.");
                                    return false;}

            }
            if (len<2)
            {
                        if (mailtype == 1) //Email
                                    {alert("This Email address is missing a hostname!");
                                    return false;}
                        else  // WAP Mail
                                    {alert("This WAP Mail address is missing a hostname!");
                                    return false;}
            }

            return true;

}


