/*Function for Contact Page  START here*/

function check()
		{
		var a;
		a=document.getElementById('txt_Login_Name').value;
		if(isEmpty(a))
		{
			alert("Please enter the login name.");
			document.getElementById('txt_Login_Name').focus();
			return false;
		}
		a=document.getElementById('txt_Login_Name').value;
		if(!checkmail(a))
		{
			alert("Invalid login name. Please enter the valid.");
			document.getElementById('txt_Login_Name').focus();
			return false;
		}
		a=document.getElementById('txt_Password').value;
		if(isEmpty(a))
		{
			alert("Please enter login password.");
			document.getElementById('txt_Password').focus();
			return false;
		}
		}
		function Focus_text()
		{
			document.getElementById("txt_Login_Name").accessKey = "n";
			document.getElementById("txt_Password").accessKey = "p";
			document.getElementById("btn_Login").accessKey = "l";
		}
/*Function for Contact Page  END here*/

/*Function for Contact Page  START here*/
function check1()
		{
			var a;
			a=document.getElementById('txt_YourName').value;
			if(isEmpty(a))
			{
				alert("Please specify your name ! ");
				document.getElementById('txt_YourName').focus();
				return false;
			}
			a=document.getElementById('txt_City').value;
			if(isEmpty(a))
			{
				alert("Please specify your city ! ");
				document.getElementById('txt_City').focus();
				return false;
			}
			a=document.getElementById('txt_Contact_no').value;
			if(isEmpty(a))
			{
				alert("Please specify your contact number ! ");
				document.getElementById('txt_Contact_no').focus();
				return false;
			}
			a=document.getElementById('txt_Email_id').value;
			if(isEmpty(a))
			{
				alert("Please specify your email-Id ! ");
				document.getElementById('txt_Email_id').focus();
				return false;
			}
			a=document.getElementById('txt_Email_id').value;
			if(!checkmail(a))
			{
				alert("Invalid email-Id. Please enter the correct email-Id ! ");
				document.getElementById('txt_Email_id').focus();
				return false;
			}
			if (document.forms[0]['txt_Comments'].value.length >= 1488)
				{
				alert('Comment text can not be more than 1500 characters');
				return false;
				}
		}
		function reset()
		{
			document.getElementById('txt_YourName').value="";
			document.getElementById('txt_City').value="";
			document.getElementById('txt_Contact_no').value="";
			document.getElementById('txt_Email_id').value="";
			document.getElementById('txt_Comments').value="";
		}
		
		
		function on_focus()
		{
			document.getElementById('txt_YourName').focus();
		}
		
/*--- Function for Contact Page  END here ---*/
/* function for page load control focus in add user page*/
		function add_usr_focus()
		{
			document.getElementById('txt_email').focus();
		}
/*--- Checking numeric values & empty on all pages START here--*/
   function isNumeric(text)
   {
		var validchars="0123456789";
		var isnumber=true;
		var Char;
		for(i=0;i<text.length && isnumber==true;i++)
		{
			Char=text.charAt(i);
			if(validchars.indexOf(Char)==-1)
			{
				isnumber=false;
			}
		}
		return isnumber;
   }
   
  function isEmpty(text)
   {
	if((text.length==0)||(text==null))
	{
		return true;
	}   
	else
	{
		return false;
	}
   }
   function isSelect(text)
   {
	if((text.length==0)||(text=="-- Click here to Select the Company --"))
	{
		return true;
	}   
	else
	{
		return false;
	}
   }
   
   function dropdownlist(choice)
   {
		if(choice==0)
		{
			return true;		
		}
		else
		{
			return false;
		}
   }
   
   function dropdownlist1(choice)
   {
		if(choice==-1)
		{
			return true;		
		}
		else
		{
			return false;
		}
   }
   
   function checkmail(email)
   {
		var len=email.length;
		if(len<5)
		{ 
			
			return false;
		}
		else
		{
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{ 
			return true;
		}
			return false;
		}
	}
	
	
	function range(text,min,max)
	{
		if((parseFloat(text)<parseFloat(min))||(parseFloat(text)>parseFloat(max)))
		{
			alert("Range must be between 1 and 100");
			return false;
		}
		else
		{
			return true;
		}
	}
	
	
	function validdate(text)
	{
		var datepat=/^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;	
		var matcharry=text.match(datepat);	
		if(matcharry==null)
		{
			alert("Date is not in valid Format");
			return true;
		}
		month=matcharry[1];
		day=matcharry[3];
		year=matcharry[4];
		if(month<1||month>12)
		{
			alert("Month must be between 1 and 12");
			return true;
		}
		if(day<1||day>31)
		{
			alert("Day must be between 1 and 31");
			return true;
		}
		if((month==4 || month==6 || month==9 || month==11) && day==31)
		{
			alert("Month"+month+" does'nt have 31 days");
			return true;
		}
		if(month==2)
		{
			var isleap=(year%4 == 0 &&(year%100!=0 || year%400 == 0));
			if(day>29 || (day==29 && !isleap))
			{
				alert("February"+year+"does'nt have"+day+"days");
				return true;
			}
		}
	
		return false;
	}
	
	
	function compare(text1,text2)
	{
		var datepat=/^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
		var matcharry1=text1.match(datepat);
		var matcharry2=text2.match(datepat);

		month1=matcharry1[1];
		day1=matcharry1[3];
		year1=matcharry1[4];

		month2=matcharry2[1];
		day2=matcharry2[3];
		year2=matcharry2[4];
      	
		if(year2<year1)
		{
			alert("end date shud b grtr than start date");	
			return false;
		}
		else if(year2<=year1&&month2<month1)
		{
			alert("end date shud b grtr than start date");
			return false;
		}
		else if(year2<=year1&&month2<=month1&&day2<=day1)
		{ 
			alert("end date shud b grtr than start date");
		return false;
		}
		else
		{
			return true;
		}
	}
	
	
	
	
	function isZipcode(strZip)
	{
		var s = new String(strZip);
		if (s.length != 5 && s.length != 10)
		// inappropriate length
		return true;
		for (var i=0; i < s.length; i++)
		{
		if ((s.charAt(i) < '0' || s.charAt(s) > '9') && s.charAt(i) != '-')
		return true;
		}
		return false;
	}
	
	
	
	function ForceLength(objField, nLength)
	{
	var strField = new String(objField);

	if (strField.length != nLength) 
	{
	return true;
	} 
	else
	{
	return false;
	}

	}



function isInteger(b)
{
var i;
for (i = 4; i <8; i++)
{
// Check that current character is number.
var c = b.charAt(i);
if (((c < "0") || (c > "9"))) 
{
return true;
}
}
// All characters are numbers.
return false;
}

//function for triming the textbox value.
function TrimMe(a)
{
var txtObj = document.getElementById(a);
txtObj.value = txtObj.value.replace(/^\s+/,"");
txtObj.value = txtObj.value.replace(/\s+$/,"");
}


	
	
	
