			//CHECK PEN NUMBER VALIDITY , If SIZE==12
function penno(varObj)
{
	var theInput = varObj.value;
	var theLength = theInput.length;
	var goodZip = true;
	if (theLength <=11 )
	{
		goodZip = false;
	}
	if (theLength>12 )
	{
		goodZip=false;
	}
	if ( !(theLength <=11 ) && !(theLength>12 ))
	{
		var theTemp = (theInput.substring(0,5).toUpperCase());
		if (theTemp !='KITBL')
		{
			alert("Invalid Pen number");
			varObj.focus();
			return false;
		}
		else
		{
			for (var i=5; i<11; i++)
			{
				var theChar = theInput.substring(i,i+1);
				if (theChar >= "0" && theChar <= "9")
					goodZip = true;
				else
				{
					goodZip=false;
					break;
				}
			}
		}
	}
	if (goodZip == false )
	{
	alert ("\nThis does not appear to be a valid Pen No.\nPen No. Should be in 12 digit.");
		varObj.focus();
		return false;
	}
	return true;
}

			// COMPARE PASSWORDS


function ComparePassword(varObj1,varObj2)
{
	var tmpPassword1=varObj1.value;
	var tmpPassword2=varObj2.value;
	if (tmpPassword1 != tmpPassword2 )
	{
		alert("Password does'nt match. Please retype the password");
		varObj1.focus();
		return false;
	}
	return true;
}

			// CHECK FOR ZIPCODE EMPTINESS AND ITS VALIDITY


function zipCode(varObj)
	{
	var theInput = varObj.value
	var theLength = theInput.length
	var goodZip = true
	if (theLength <=5 )
	{
		goodZip = false
	}
	if (theLength>6 )
	{
		goodZip=false
	}
	if (theLength == 6)
	{
		for (var i=0; i<6; i++)
		{
			var theChar = theInput.substring(i,i+1)
			if (theChar >= "0" && theChar <= "9")
				goodZip = true
			else
			{
				goodZip=false
				break;
			}
		}
	}
	if (goodZip == false )
	{
		alert ("\nThis does not appear to be a valid Zip Code\nZipCode Should be in 6 digit.")
		varObj.focus()
	return false;
	}
	return true;
}

			// CHECK FOR e-MAIL EMPTINESS AND ITS VALIDITY


function isEmail(varObj) 
{
	txt=varObj.value
	if (txt == "")
	{
        	alert("\nThe E-Mail field is blank.\nPlease enter your e-mail.")
                varObj.focus()
                return false
        }
	if ((txt.indexOf(" ")!=-1))
	{
		alert("Sorry, but email address cannot contain spaces!")
		varObj.focus()
		return false
	}
	if ((txt.indexOf("@")==-1))
	{
		alert("Sorry, but email address should contain '@' character!");
		varObj.focus()
		return false
	}
	if (txt.indexOf("@")<2)
	{
		alert("Sorry, but this email address is incorrect!\nPlease verify the text before @' character")
		varObj.focus()
		return false
	}
	var theInput = varObj.value
	var theLength = theInput.length
	if ( (theLength - txt.indexOf(".")) <3 )
	{
		alert("Sorry! but this email address is incorrect! Domain name less than equal to 2 charcters")
		varObj.focus()
		return false
	}
	if ( (theLength - txt.indexOf(".")) >4 )
	{
		alert("Sorry! but this email address is incorrect! Domain name greater than 3 charcters")
		varObj.focus()
		return false
	}
	if (txt.charAt(txt.length-1) == "." )
	{
		alert("Sorry! but this email address is incorrect! dot cannot be the last character")
		varObj.focus()
		return false
	}
	return true
}

			// CHECK FOR BALANCE CHECKING


function CheckBalance(varObj1,varObj2)
{
var total=parseInt(varObj1.value);
var balance=parseInt(varObj2.value);
if(total==0)
{
alert("No Selection has been made.\nPlease Select something to Shop or Book Cinema Tickets")
return false;
}
if (balance < total)
{
alert("Balance is not enough in account\n"+"Current Balance is Rs. "+ balance);
return false;
}
else
return true;
}
		//checking Blank field

function CheckBlank(PassedField)
{
	var tmpField=PassedField.value
	if ( tmpField.charAt(0)==" " )
	{
		alert("Please enter value in proper format.");
		PassedField.focus();
		return false;
	} 
	switch (PassedField.name)
	{
		case "name" :
			var msg="Please enter  name"
			break
		case "dob" :
			var msg="Please enter  your date of birth."
			break
		case "nname" :
			var msg="Please enter your nick name."
			break
		case "first" :
			var msg="Please enter first name."
			break
		case "last" :
			var msg="Please enter the last name."
			break
		case "address" :
			var msg="Please enter the address."
			break
		case "business" :	
			var msg="Please enter the Type of Business."
			break
		case "hotel" :
			var msg="Please enter the hotel name."
			break
		case "city" :
			var msg="Please enter the city name."
			break
		case "passwd" :
			var msg="Please enter the password."
		case "password" :
			var msg="Please enter the password."
			break
		case "prname" :
			var msg="Please enter the product name."
			break
		case "time" :
			var msg="Please enter the time."
			break
		case "occupation" :
			var msg="Please fill your occupation."
			break
		case "price" :
			var msg="Please enter the price."
			break
		case "state" :
			var msg="Please enter the state name."
			break
		case "from" :
		case "to"  :		
			var msg="Please enter date ."
			break
		case "no_room" :
			var msg="Please fill no.of rooms booking required."
			break
		case "username" :
			var msg="Please enter username."
			break
		case "password" :
			var msg="Please enter Password"
			break	
		case "voucherno" :
			var msg="Please enter VoucherNo."
			break
		case "zipcode" :
			var msg="Please enter the zip code."
			break
		case "cname" :
			var msg="Please enter the Company Name."
			break		
		case "desti" :
			var msg="Please enter the Designation."
			break
		case "cperson" :
			var msg="Please enter the contact person's name."
			break
		case "country" :
			var msg="Please enter your country"
			break
		case "phone" :
			var msg="Please enter phone number."
			break
			case "user" :
			var msg="Please enter the user ID."
			break
		case "login" :
			var msg="Please enter Login."
			break
		case "fname" :
			var msg="Please enter the fathers name."
			break
		case "jobcode" :
			var msg="Please enter the job code."
			break
		case "minquali" :
		case "academic" :
		case "prof" :
			var msg="Please enter qualification."
			break
		case "post" :
			var msg="Please enter no of posts."
			break
		case "minexp" :
			var msg="Please enter minimum experience required\nIf freshers then write Freshers."
			break
		case "age" :
			var msg="Please Fill age  field."
			break
		case "height" :
		case "ftheight" :
		case "inheight" :
			var msg="Please fill height."
			break
		case "toname" :
			var msg="Please Fill Receiver's name."
			break		
		case "fromname" :
			var msg="Please Fill Senders's name."
			break	
		case "file1" :
			var msg="Photograph is not attached\n Pl. attach a photograph"
			break

		case "month" :
			var msg="Please enter month in Numbers."
			break

		case "year" :
			var msg="Please enter year in Numbers."
			break
		case "fullname" :
			var msg="Please fill your full name."
			break
		case "question" :
			var msg="Please enter a question\nIt will help you to when you forget your password."
			break
		case "answer" :
			var msg="Please fill your question's answer."
			break
		default :
			var msg="Required field missing"
	}

	if ( tmpField == "" )
	{
		alert(msg)
		PassedField.focus()
		return false
	}
	else
		return true
}

		// Checking for "Only char value"


function CheckOnlyChar(varObj)
 {
        var str1 = varObj.value
	switch (varObj.name)
	{
	case "cname":
		var msg="Company name should contain only letters & spaces."
		break
	case "business":
		var msg="Type of Business should contain only letters & spaces."
		break
	case "hotel":
		var msg="Hotel name should contain only letters & spaces."
		break
	case "fname":
		var msg="Name should contain only letters & spaces."
		break
	case "city":
		var msg="City name should contain only letters & spaces."
		break
	case "cperson":
		var msg="Contact Person name should contain only letters & spaces."
		break
	case "state":
		var msg="State name should contain only letters & spaces."
		break
	case "country":
		var msg="Country name should contain only letters & spaces."
		break
	} 

        for (var i = 0; i < str1.length; i++)
	 {
            var ch = str1.substring(i, i + 1);
            if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != '.' && ch != ' ') {
                   alert(msg);
                   varObj.focus();
                   return false;
             }
        }
   return true;
}

		//Checking for "only number value"

function CheckOnlyNum(varObj)
{ 
 	var str1=varObj.value
	switch (varObj.name)
	{
	case "voucherno" :
		str1= str1.substring(5,(str1.length))
		var msg="Invalid Voucher no.\nPlease enter valid voucher no." 
		break
	case "no_room":
		var msg="Hotel room should be in numbers."
		break
	case "age":
		var msg="Age should be in numbers."
		break
	case "phone":
		var msg="Phone number should be in digits only."
		break
	case "month":
		var msg="month should be in numbers."
		break
	case "year":
		var msg="year should be in numbers."
		break
	default :
		var msg="Fill here digits only."
	
	}
	for (var i = 0; i < str1.length; i++)
	 {
            var ch = str1.substring(i,i + 1);
            if (!(0 <= ch || ch <= 9 ))
            {
                  alert(msg);
                   varObj.focus();
                   return false;
            }
            if (ch==" ")
            {
                  alert(msg);
                   varObj.focus();
                   return false;
            }

         }
   return true;	 
}

		//Checking short characters in a field

function CheckShort(varObj)
{
	var temp=varObj.value;
	var theLength=temp.length;

	switch (varObj.name)
	{
	case "username" :
	   var msg="Username less than 4 characters not allowed.\nPlease enter a valid UserName."
	   var msg1="Invalid User Name\nUser Name should contain alphabets,digits and '_' only \n and can be of maximum 15 characters."		
	  	
		break
	case "repass" :
	case "pass1" :
	case "password" :	
	  var msg="password less than 4 characters not allowed.\nPlease enter a valid password."
	  var msg1="Invalid password\npassword should contain alphabets,digits and '_' only\n and can be of maximum 15 characters."				
 		break	
	default :
	var msg="Required Field missing\n(Enter value of more than 3 chars)"
	var msg1="Enter a value containing alphabets,digits and '_' only "
	}

	if (theLength<=3)
	{
		alert(msg);
		varObj.focus();
		return false;
	}
	else
	{
		
	  for(var i=0;i<theLength;i++)
	  {
	    var theChar=temp.substring(i,i+1);
	    if (! ( (theChar >= "a" && theChar <= "z" ) || (theChar >= "A" && theChar <= "Z") || (theChar >= "0" && theChar <= "9") || (theChar == "_") ) )
	    {
		alert(msg1);
		varObj.focus();
		return false;
	    }}}
	 
		return true;	
}

		// Checking if an item is selected from a combo box


function CheckComboBoxValue(PassedField)	
{
	
	switch (PassedField.name)
	{
	case "education" :
		var msg= "Please select your education level."
		break
	case "job" :
		var msg= "Please select your job status."
		break	
	}
	if ( PassedField.value > 0 )
		return true
	else
	{	
		alert(msg)
		PassedField.focus()
		return false
	}
}

	
function JobSelected(Value)
{
	if (Value==3)
	{
		document.form1.comp.value="Not Applicable";
		document.form1.post.value="Not Applicable";
		document.form1.inc.value="Not Applicable";
	}
	else
	{
		document.form1.comp.value="";
		document.form1.post.value="";
		document.form1.inc.value= 0;
	}
	return true;
}
