/*----------------------------Set Scrolling Area of every page according to screen resolution--------------*/

function checkSize() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight-164;
  } 
  else {
  	  if( document.documentElement &&
	    ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight-168;
    } 
	else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myHeight = document.body.clientHeight-142;
      }
    }
  }
  return myHeight;
}

/*----------------------------Set Scrolling Area Ends--------------------*/








/*-----------------------Validations------------------------------------------*/
errorMsg ="";
var fieldFocus;
function validateFields(formName){
	errors = "";
	fieldFocus = "";
	errorMsg += loopThroughElements(formName);
/*	inputs = div.getElementsByTagName('input')
	if(inputs)
		errorMsg += loopThroughElements(inputs);
	inputs = div.getElementsByTagName('select')
	if(inputs)
		errorMsg += loopThroughElements(inputs);
	inputs = div.getElementsByTagName('textarea')
	if(inputs)
		errorMsg += loopThroughElements(inputs);
		*/
	if(errorMsg == "")
		return true;
	else{
		return errorMsg;
	}
}


function loopThroughElements(frmName){
	inputs = eval('document.'+frmName+'.elements');
	errors = "";
	for(i=0;i<inputs.length;i++){
		if(inputs[i].type == 'text' || inputs[i].type == 'select-one'|| inputs[i].type == 'select-multiple'|| inputs[i].type == 'textarea'){
			if(!inputs[i].getAttribute('validate'))
				continue;
			name = inputs[i].getAttribute('validate').substring(0,inputs[i].getAttribute('validate').indexOf(','));
			type = inputs[i].getAttribute('validate').substring(inputs[i].getAttribute('validate').indexOf(',')+1,inputs[i].getAttribute('validate').lastIndexOf(','));
			mandatory =inputs[i].getAttribute('validate').substring((inputs[i].getAttribute('validate').lastIndexOf(',')+1)); 
			textValue = trimAll(inputs[i].value);		
			if(mandatory == "yes" & textValue == ""){
				errors += name + " cannot be blank.\n";
				if(fieldFocus=="")fieldFocus=inputs[i];
			}
			if(textValue!= "" & type == 'date'){
				if(!validateDate(textValue)){
					errors += name + " is not a valid date (dd/mm/yyyy).\n";
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			if(textValue!= "" & type == 'string'){
				if(!validateString(textValue)){
					errors += name + " is not valid.\n";
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'num'){
				
				if(!validateNumeric(textValue)){
					errors += name + " should be a number.\n";
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'int'){
				if(!validateInteger(textValue)){
					errors += name + " should be a number.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];	
				}
			}
			else if(textValue!= "" & type == 'email'){
				if(!validateEmail(textValue)){
					errors +="Email id entered is not valid.Please enter a valid email id.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}	
			else if(textValue!= "" & type == 'char'){
				if(!validateChar(textValue)){
					errors += name + " should contain characters only.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}			
			else if(textValue!= "" & type == 'passport'){
				if(!validateAlphaNumeric(textValue)){
					errors += "Enter a valid passport no.It can only contain alphabets and digits.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}	
			else if(textValue!= "" & type == 'pan'){
				if(!validateAlphaNumeric(textValue)){
					errors += "Enter a valid pan no.It can only contain alphabets and digits.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}	
			else if(textValue!= "" & type == 'float'){
				if(!validateFloat(textValue)){
					errors +=  name + " should contain decimal value only.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'marksInPercentage'){
				if(!validateMarksInPercentage(textValue)){
					errors += name + " should be greater than 33% or less than 100%.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'dateOfBirth'){
				if(!validateDateOfBirth(textValue))
				{
					date = new Date();
					year = date.getFullYear();
					
					errors += "Date of Birth should be after "+(year - 70)+" and before "+(year - 18)+".\n";
					if(fieldFocus=="")fieldFocus=inputs[i];						
				}
			}
			else if(textValue!= "" & type == 'EmpCode'){
				if(!validateEmpCode(textValue)){
					errors += "Please Enter Valid Employee Code\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'name'){
				if(!validateName(textValue)){
					errors += name + " is not valid.It can only contain alphabets.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'alphaspace'){
				if(!validateAlphaSpace(textValue)){
					errors += "Field " + name + " is not valid.It cannot start with no. and some special characters like ,.-and'.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'weight'){
				if(!validateWeight(textValue)){
					errors += "Please enter valid weight.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];					
				}
			}
			else if(textValue!= "" & type == 'phone'){
				if(!validatePhone(textValue)){
					errors += name + " can  only contain numbers and should be greater than 7 digits and less than 16.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			
			else if(textValue!= "" & type == 'fullName'){
				if(!validateFullName(textValue)){
					errors += name + " is not a valid name.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'company'){
				if(!validateCompany(textValue)){
					errors += name + " name cannot start with a dot(.) and can contain only alphabets,digits and a dot(.).\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];					
				}
			}
			
			else if(textValue!= "" & type == 'dateOfJoining'){
				if(!validateDateOfJoining(textValue)){
					errors += name + " is not valid.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			
			else if(textValue!= "" & type == 'dateOfInterview'){
				if(!validateDateOfInterview(textValue)){
					errors += name + " is not valid.\n";
					if(fieldFocus=="")fieldFocus=inputs[i];
				}						
			}
			
			else if(textValue!= "" & type == 'address'){
				if(!validateAddress(textValue)){
					errors += "Field " + name + " is not valid Address.It cannot start with some special characters like ,.-and'.\n";						
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'alphaAndSpace'){
				if(!validateAlphabetsAndSpace(textValue)){
					errors += name +" is not valid.It can only contain alphabets and spaces.\n";
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			else if(textValue!= "" & type == 'experience'){
				if(!validateExperience(textValue)){
					errors += name +" is not valid.\n";
					if(fieldFocus=="")fieldFocus=inputs[i];					
				}
			}
			else if(textValue!= "" & type == 'salary'){
				if(!validateSalary(textValue)){
					errors += name+" should be less than 99 and cannot start with a decimal and decimal value should be less than 9.\n";
					if(fieldFocus=="")fieldFocus=inputs[i];
				}
			}
			
		}
	}
	return errors;
}
function validateWeight( strValue ){
	if(validateInteger(strValue)){
		if(strValue <=0 || strValue >200)
			return false;
		return true;
	}
	else	
		return false;
	
}
function chkSpaces(strValue){
	for(j=0; j<strValue.length; j++){
		if(strValue[j]==" ")
			return false;
	}
	return true;
}

function validatePhone( strValue ) {
	if(strValue.length < 8 || strValue.length > 16)
 		return false;
   	else
  		return validateInteger(strValue);
}
	
function  validateName( strValue ) {
  var objRegExp = /[^a-z]/i;
 		return !objRegExp.test(strValue);
  return false;
  
}
function validateString( strValue ) {
	 
	var objRegExp  = /[^a-z*(\d\,\\\/\.\(\)\_\:\"\&\-\'\`\#\“\‘\n\r )]/i;
	if(strValue.substring(0,1)=="," || strValue.substring(0,1) == "." || strValue.substring(0,1) == "-" || strValue.substring(0,1) == "'" ){
			return false;
	}
	else{
		return !objRegExp.test(strValue);
	}
	return false;
}

function validateAddress( strValue ) {
	 
	var objRegExp  = /[^a-z*(\d\,\\\/\.\(\)\_\:\"\&\-\'\`\#\“\‘\n\r )]/i;
	if(strValue.substring(0,1)=="," || strValue.substring(0,1) == "." || strValue.substring(0,1) == "-" || strValue.substring(0,1) == "'" ){
			return false;
	}
	else{
		return !objRegExp.test(strValue);
	}
	return false;
}

function validateAlphaSpace( strValue ) {
	
	var objRegExp  = /[^a-z*(\d\,\\\/\.\(\)\_\:\"\&\-\'\`\#\“\‘\n\r )]/i;
	if(!(parseInt(strValue)>0)){
		if(strValue.substring(0,1)=="," || strValue.substring(0,1) == "." || strValue.substring(0,1) == "-" || strValue.substring(0,1) == "'" ){
			return false;
		}
		else{
			return !objRegExp.test(strValue);
		}
	}
  	return false;
}

function validateAlphabetsAndSpace( strValue ){
	var objRegExp  = /[^a-z ]/i;
		return !objRegExp.test(strValue);
}
function validateFullName( strValue ) {
	
	var objRegExp  = /[^a-z*(\.\d )]/i;
	if(parseInt(strValue)>0){
		return false;
	}
	else if(strValue.substring(0,1) == ".")
	{
			return false;
	}
	else{
			return !objRegExp.test(strValue);
	}
}

function validateCompany( strValue ) {
	var objRegExp  = /[^a-z*(\.\d )]/i;
	if(strValue.substring(0,1) == ".")
	{
			return false;
	}
	else{
			return !objRegExp.test(strValue);
	}
}

function validateAlphaNumeric( strValue ) {
	
	var objRegExp  = /[^a-z*(\d)]/i;
	return !objRegExp.test(strValue);
	
}

function  validateNumeric( strValue ) {
  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
  return objRegExp.test(strValue);
}

function validateInteger( strValue ) {
  var objRegExp  = /(^\d\d*$)/;
  return objRegExp.test(strValue);
}

function validateChar( strValue ) {
	var objRegExp  =  /[^a-z]/i;
  	return !objRegExp.test(strValue);
}
function validateFloat( strValue ) {
 	var objRegExp  =/^((\+|-)\d)?\d*(\.\d{2})?$/;
 	return objRegExp.test(strValue);
}
function validateMarksInPercentage( strValue ) {
  if(validateFloat)
  	if(strValue >= 33 && strValue <= 100)
  		return true;
  return false;
}

function validateExperience( strValue ) {
 
 	if(strValue.indexOf(".")!= -1) 
	{
 		var decimalvalue = strValue.substring(strValue.indexOf(".") + 1,strValue.length);
 		if(decimalvalue.length >= 3 || decimalvalue >= 12)
 		{
 			return false;
 		}
 	}
  if(validateFloat)
  	if(strValue >= 0 && strValue <= 58)
  		return true;
  return false;
}

function validateSalary( strValue ) {
 
 	if(strValue.indexOf(".")!= -1) 
	{
 		var decimalvalue = strValue.substring(strValue.indexOf(".") + 1,strValue.length);
 		if(decimalvalue.length >= 2 || decimalvalue > 9)
 		{
 			return false;
 		}
 	}
  if(validateFloat)
  	if(strValue >= 0 && strValue < 100)
  		return true;
  return false;
}

function validatePassport( strValue ) {
	if(strValue.length==8){
 		firstChar=strValue.substring(0,1);
 		rest=strValue.substring(1,8);
 		if(!validateChar(firstChar) || !validateInteger(rest)){
 			return false;
 		}
 		return true;
 	}
 	return false;
	
}

function validatePan( strValue ) {
	if(strValue.length==10)
	{
 		firstChar = strValue.substring(0,1);
 		rest = strValue.substring(1,10);
 		if(validateChar(firstChar))
 		{
 			if(validateAlphaNumeric(rest))
 			{
 				for(k = 0; k < rest.length; k++)
 				{
 					if(rest.charAt(k)>0 && rest.charAt(k)<9)
 					{
 						return true;
 					}	
 				} 
 			}
 		}
 		else
 			return false;
 	}
 	return false;
}


function validateDate( strValue ) {
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
	
  if(!objRegExp.test(strValue))
    return false; 
  else{
    var strSeparator = strValue.substring(2,3) 

    var arrayDate = strValue.split(strSeparator); 
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
	var intDay = parseInt(arrayDate[0],10);
		

    if(arrayLookup[arrayDate[1]] != null) {
      if(intDay <= arrayLookup[arrayDate[1]] && intDay != 0)
        return true; 
    }
	var intMonth = parseInt(arrayDate[1], 10);

    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0)
          return true;
       }
  }
  return false; 
}

function validateDateOfBirth(strValue) {
	
	var isValid=true;
	var dob=new Date(strValue.substring(6),(strValue.substring(3,5) - 1) ,strValue.substring(0,2));
	var nowDate=new Date();
	if(!validateDate( strValue )){
		isValid=false;
	}
	else if( ((dob.getFullYear()+19) > nowDate.getFullYear()) || ((dob.getFullYear() + 69) < nowDate.getFullYear())){
		isValid=false;
	}
	return isValid;
}
function validateDateOfJoining(strValue) {
	dateOfJoining = new Date(strValue.substring(6),(strValue.substring(3,5) - 1) ,strValue.substring(0,2));
 	currentDate = new Date();
	var month = currentDate.getMonth() + 1
	var day = currentDate.getDate()
	var year = currentDate.getFullYear()
	var seperator = "/"
	currentDate = new Date(month + seperator + day + seperator + year);
 	if(dateOfJoining >= currentDate)
 	{
		return true;
 	}
	 return false;
}

function validateDateOfInterview(strValue) {
	dateOfInterview = new Date(strValue.substring(6),(strValue.substring(3,5) - 1) ,strValue.substring(0,2));
 	currentDate = new Date();
 	var month = currentDate.getMonth() + 1
	var day = currentDate.getDate()
	var year = currentDate.getFullYear()
	var seperator = "/"
	currentDate = new Date(month + seperator + day + seperator + year);
 	if(dateOfInterview > currentDate){
		return false;
 	}
	 return true;
}




function validateEmail( strValue) {
var objRegExp  =
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  return objRegExp.test(strValue);
}

function validateEmpCode(strValue){
	if(strValue.length==6){
		if(!validateInteger(strValue)){
			return false;
		}
		else if(strValue.substring(0,1)!=0){
			alert("Employee Code Should Start with 0");
			return false;
		}	
		return true;
	}
	return false;	
}

function trimAll( strValue ) {
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)){
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function checkTextareaLength(obj){
	if(obj.getAttribute("maxlength")){
		if(obj.value.length > obj.getAttribute("maxlength")-1){
			return false;
		}
	}
}


 function checkMaxLength(obj){
        if(window.event){
            keyObj = window.event.keyCode
            if(keyObj == 9 || keyObj == 8 ||keyObj == 46 || keyObj == 16 || keyObj == 37 || keyObj == 36 || keyObj == 35 || window.event.ctrlKey )
                return true;
        }
        if(obj.getAttribute("maxlength")){
	        if(obj.value.length>obj.getAttribute("maxlength")-1){    
    	        return false;
        	}

        }
    }
    pasteFlag = false
    function checkOnPaste(obj){
	    pasteFlag = true;
     /*   txt =window.clipboardData.getData("Text", obj.value)
        if(obj.getAttribute("maxlength")){
	        if((txt.length+obj.value.length)>obj.getAttribute("maxlength")-1){
    	        obj.value = obj.value.substring(0,obj.getAttribute("maxlength"));
        	    return false;
        	}
        }*/
    }
    function checkMaxLengthMoz(obj){
        if(obj.getAttribute("maxlength")){
	        if(obj.value.length>obj.getAttribute("maxlength")-1){
	            obj.value = obj.value.substring(0,obj.getAttribute("maxlength"))
    	        return false;
        	}
        }
    }
    function finalCheck(obj){
	    if(obj.getAttribute("maxlength")){
           	if(pasteFlag){
        		obj.value = obj.value.substring(0,obj.getAttribute("maxlength"));
        		pasteFlag = false;
        	}
        }
    }

/*-----------------------Validation Ends---------------------------------------*/



/*--------------Hover on TR's for IE--------------------------------*/
function intializeHover(id, nodeName, className){
	navRoot = document.getElementById(id);
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName==nodeName) {
			node.onmouseover=function() {
				this.className+= className;
			}
			node.onmouseout=function() {
				this.className=this.className.replace(className, "");
			}
		}
	}
}


/*--------------Hover on TR's for IE Ends-----------------------------*/


/*-------------------Some General Functions---------------------------*/
function findDiv(obj){
	while(obj.nodeName != 'DIV'){
			obj = obj.nextSibling;
	}
	inps = obj.getElementsByTagName('INPUT');
	txt = obj.getElementsByTagName('TEXTAREA');
	if(inps.length>0){
		for(i=0;i<inps.length;i++){
			inps[i].value="";
		}
	}
	if(txt.length>0){
		for(i=0;i<txt.length;i++){
			txt[i].value="";
		}
	}
	
	return obj;
}
function findPrevElement(obj,tag){
	while(obj.nodeName != tag){
		obj = obj.parentNode
	}
	return obj;
}

window.onresize = function (){
	if(document.getElementById('content'))
		document.getElementById('content').style.height = checkSize()+"px";
}
/*-----------------Some General Functions Ends------------------------*/



/*-----------------Populate City------------------------*/
cityArr = new Array();

cityArr[1] = new Array();
cityArr[1][0] = "Select";
cityArr[1][1] = "Port Blair";

cityArr[2] = new Array();
cityArr[2][0] = "Select";
cityArr[2][1] = "Anantapur";
cityArr[2][2] = "Guntakal"
cityArr[2][3] = "Guntur"
cityArr[2][4] = "Hyderabad"
cityArr[2][5] = "Kurnool"
cityArr[2][6] = "Nellore"
cityArr[2][7] = "Nizamabad"
cityArr[2][8] = "Rajahmundry"
cityArr[2][9] = "Secunderabad"
cityArr[2][10] = "Tirupati"
cityArr[2][11] = "Vijayawada"
cityArr[2][12] = "Visakhapatnam"
cityArr[2][13] = "Warangal"

cityArr[3] = new Array();
cityArr[3][0] = "Select";
cityArr[3][1] = "Itanagar";

cityArr[4] = new Array();
cityArr[4][0] = "Select";
cityArr[4][1] = "Guwahati";
cityArr[4][2] = "Silchar";

cityArr[5] = new Array();
cityArr[5][0] = "Select";
cityArr[5][1] = "Bahgalpur";
cityArr[5][2] = "Patna";

cityArr[6] = new Array();
cityArr[6][0] = "Select";
cityArr[6][1] = "Chandigarh";

cityArr[7] = new Array();
cityArr[7][0] = "Select";
cityArr[7][1] = "Bhillai";
cityArr[7][2] = "Raipur";

cityArr[8] = new Array();
cityArr[8][0] = "Select";
cityArr[8][1] = "Dadra&Nagar Haveli";

cityArr[9] = new Array();
cityArr[9][0] = "Select";
cityArr[9][1] = "Daman&Diu";

cityArr[10] = new Array();
cityArr[10][0] = "Select";
cityArr[10][1] = "Delhi/NCR";

cityArr[11] = new Array();
cityArr[11][0] = "Select";
cityArr[11][1] = "Panaji";
cityArr[11][2] = "Panjim";
cityArr[11][3] = "Vasco Da Gama";

cityArr[12] = new Array();
cityArr[12][0] = "Select";
cityArr[12][1] = "Ahmedabad";
cityArr[12][2] = "Anand";
cityArr[12][3] = "Baroda";
cityArr[12][4] = "Bharuch";
cityArr[12][5] = "Bhavnagar";
cityArr[12][6] = "Bhuj";
cityArr[12][7] = "Gandhinagar";
cityArr[12][8] = "Gir";
cityArr[12][9] = "Jamnagar";
cityArr[12][10] = "Kandla";
cityArr[12][11] = "Porbandar";
cityArr[12][12] = "Rajkot";
cityArr[12][13] = "Surat";
cityArr[12][14] = "Vadodara";

cityArr[13] = new Array();
cityArr[13][0] = "Select";
cityArr[13][1] = "Ambala";
cityArr[13][2] = "Faridabad";
cityArr[13][3] = "Gurgaon";
cityArr[13][4] = "Karnal";
cityArr[13][5] = "Kurukshetra";
cityArr[13][6] = "Panipat";
cityArr[13][7] = "Rohtak";

cityArr[14] = new Array();
cityArr[14][0] = "Select";
cityArr[14][1] = "Dalhousie";
cityArr[14][2] = "Dharmsala";
cityArr[14][3] = "Kulu/Manali";
cityArr[14][4] = "Shimla";

cityArr[15] = new Array();
cityArr[15][0] = "Select";
cityArr[15][1] = "Jammu";
cityArr[15][2] = "Srinagar";

cityArr[16] = new Array();
cityArr[16][0] = "Select";
cityArr[16][1] = "Bokaro";
cityArr[16][2] = "Dhanbad";
cityArr[16][3] = "Jamshedpur";
cityArr[16][4] = "Ranchi";

cityArr[17] = new Array();
cityArr[17][0] = "Select";
cityArr[17][1] = "Bangalore";
cityArr[17][2] = "Belgaum";
cityArr[17][3] = "Bellary";
cityArr[17][4] = "Bidar";
cityArr[17][5] = "Dharwad";
cityArr[17][6] = "Gulbarga";
cityArr[17][7] = "Hubli";
cityArr[17][8] = "Kolar";
cityArr[17][9] = "Mangalore";
cityArr[17][10] = "Mysore";


cityArr[18] = new Array();
cityArr[18][0] = "Select";
cityArr[18][1] = "Calicut";
cityArr[18][2] = "Cochin";
cityArr[18][3] = "Kollam";
cityArr[18][4] = "Kottayam";
cityArr[18][5] = "Palakkad";
cityArr[18][6] = "Thrissur";
cityArr[18][7] = "Trivandrum";

cityArr[19] = new Array();
cityArr[19][0] = "Select";
cityArr[19][1] = "Kavaratti";

cityArr[20] = new Array();
cityArr[20][0] = "Select";
cityArr[20][1] = "Bhopal";
cityArr[20][2] = "Gwalior";
cityArr[20][3] = "Indore";
cityArr[20][4] = "Jabalpur";
cityArr[20][5] = "Ujjain";

cityArr[21] = new Array();
cityArr[21][0] = "Select";
cityArr[21][1] = "Ahmednagar";
cityArr[21][2] = "Aurangabad";
cityArr[21][3] = "Jalgaon";
cityArr[21][4] = "Kolhapur";
cityArr[21][5] = "Mumbai";
cityArr[21][6] = "Nagpur";
cityArr[21][7] = "Nasik";
cityArr[21][8] = "Pune";
cityArr[21][9] = "Sholapur";

cityArr[22] = new Array();
cityArr[22][0] = "Select";
cityArr[22][1] = "Imphal";

cityArr[23] = new Array();
cityArr[23][0] = "Select";
cityArr[23][1] = "Shillong";

cityArr[24] = new Array();
cityArr[24][0] = "Select";
cityArr[24][1] = "Aizawal";

cityArr[25] = new Array();
cityArr[25][0] = "Select";
cityArr[25][1] = "Kohima";

cityArr[26] = new Array();
cityArr[26][0] = "Select";
cityArr[26][1] = "Bhubaneshwar";
cityArr[26][2] = "Cuttack";
cityArr[26][3] = "Paradeep";
cityArr[26][4] = "Puri";
cityArr[26][5] = "Rourkela";

cityArr[27] = new Array();
cityArr[27][0] = "Select";
cityArr[27][1] = "Pondicherry";

cityArr[28] = new Array();
cityArr[28][0] = "Select";
cityArr[28][1] = "Amritsar";
cityArr[28][2] = "Jalandhar";
cityArr[28][3] = "Ludhiana";
cityArr[28][4] = "Mohali";
cityArr[28][5] = "Pathankot";
cityArr[28][6] = "Patiala";

cityArr[29] = new Array();
cityArr[29][0] = "Select";
cityArr[29][1] = "Ajmer";
cityArr[29][2] = "Jaipur";
cityArr[29][3] = "Jaisalmer";
cityArr[29][4] = "Jodhpur";
cityArr[29][5] = "Udaipur";

cityArr[30] = new Array();
cityArr[30][0] = "Select";
cityArr[30][1] = "Gangtok";

cityArr[31] = new Array();
cityArr[31][0] = "Select";
cityArr[31][1] = "Chennai";
cityArr[31][2] = "Coimbatore";
cityArr[31][3] = "Erode";
cityArr[31][4] = "Hosur";
cityArr[31][5] = "Madurai";
cityArr[31][6] = "Ooty";
cityArr[31][7] = "Salem";
cityArr[31][8] = "Tirunelveli";
cityArr[31][9] = "Trichy";
cityArr[31][10] = "Vellore";

cityArr[32] = new Array();
cityArr[32][0] = "Select";
cityArr[32][1] = "Agartala";

cityArr[33] = new Array();
cityArr[33][0] = "Select";
cityArr[33][1] = "Deharadun";

cityArr[34] = new Array();
cityArr[34][0] = "Select";
cityArr[34][1] = "Agra";
cityArr[34][2] = "Aligarh";
cityArr[34][3] = "Allahabad";
cityArr[34][4] = "Bareilly";
cityArr[34][5] = "Faizabad";
cityArr[34][6] = "Ghaziabad";
cityArr[34][7] = "Gorakhpur";
cityArr[34][8] = "Kanpur";
cityArr[34][9] = "Lucknow";
cityArr[34][10] = "Mathura";
cityArr[34][11] = "Meerut";
cityArr[34][12] = "Noida";
cityArr[34][13] = "Varanasi";

cityArr[35] = new Array();
cityArr[35][0] = "Select";
cityArr[35][1] = "Durgapur";
cityArr[35][2] = "Kharagpur";
cityArr[35][3] = "Kolkata";

function populateCity(num1){
		num1++;
		ob = document.getElementById('city')
		ob.length=0;
		ob.length = cityArr[num1].length+1;
		ob[0].value = "";
		ob[0].text = cityArr[num1][0]				
		for(i=1;i<cityArr[num1].length; i++){
				ob[i].value = cityArr[num1][i];
				ob[i].text = cityArr[num1][i]				
		}
		ob[i].value = "Other";
		ob[i].text = "Other";
}

function changeCity(obj){
		if(obj.value == "Other")			
			document.getElementById('othercity').style.display = 'block';
		else{
			document.getElementById('othercity').style.display = 'none';
			input=document.getElementById('othercity').getElementsByTagName('input');
			input[0].value="";
		}
	
}

function changeEducation(obj){
	if(obj.value == "Other")
		document.getElementById('otherEdu').style.display = 'block';
	else{
		input=document.getElementById('otherEdu').getElementsByTagName('input');
		input[0].value="";
		document.getElementById('otherEdu').style.display = 'none';
	}
}


function changeCountry(val,formName){
	
		obj = eval("document."+formName+".state");
		document.getElementById('othercity').style.display = 'none';		
		if(val=="India"){
				document.getElementById('statediv').innerHTML = '<SELECT NAME="state" id="state" onChange="populateCity(this.selectedIndex)" validate="State,string,yes"  class="select3"></SELECT>';
				populateCombo("state", state, formName);
				obj.value = "Delhi";
				document.getElementById('citydiv').innerHTML = '<select id="city" name="city" onChange="changeCity(this)" validate="City,string,yes"  class="select3"></select>'
				populateCity(9);
				document.getElementById('othercity').style.display = 'none';
			}
		else{
			document.getElementById('statediv').innerHTML = '<input type="text" name="state" id="state" value="" validate="State,alphaspace,yes" maxlength="30"/>'
			document.getElementById('citydiv').innerHTML =  '<input type="text" name="city"  id="city" value="" validate="City,alphaspace,yes" maxlength="30"/>'
		}	
		
}
			
/*-----------------Populate City Ends------------------------*/


function applyLeave(){
	frmobj = document.applyleave;
}
function surveyValidate(){
	count = 0;
	qCounter =1;
	errors = '';
	bool = false;
	questions = document.getElementsByTagName('input');	
	for(i=0;i<questions.length;i++){
		count++;
		if(questions[i].type == 'radio'){
			if(count<=5 &&  questions[i].checked)
				bool = true;	
			if(count == 5){
				if(!bool)
					errors += 'Question number ' + qCounter + ' is not answered.\n'
				count = 0;
				bool = false;	
				qCounter++;
			}
		}

	}
	if(errors != ""){
		alert(errors)
	}
	else
		document.saveQuestions.submit();
}

function submitForm(formName,div,action,extraFunction,extraFunction2,extraFunction3){
		errorMsg = "";
		ob1 = true;
		ob2 = true;
        obj = eval('document.'+formName)
        if(eval("window."+extraFunction))
        	ob1 =  eval(extraFunction+"()")
        if(eval("window."+extraFunction2))
        	ob2 = eval(extraFunction2+"()")
        if(eval("window."+extraFunction3))
        	ob3 = eval(extraFunction3+"()")        	
    	if(validateFields(formName)== true & ob1 & ob2){
        	obj.action = action;
		if(document.getElementById('messagebar'))
			document.getElementById('messagebar').innerHTML ='Sending Request, please wait...';
            obj.submit();
    	}
    	else{
	    	alert(errorMsg);
			if(fieldFocus!=""){
				fieldFocus.focus();
			}
	       	return false;	
	       	
    	}
}


function chkUploadError(){
	if(frames['uploadframe'].document.body.innerHTML.indexOf('footer') != -1){
		document.getElementById('uploaderror').innerHTML = "Error Uploadinf the file."
	}
	else if(frames['uploadframe'].document.body.innerHTML.indexOf('header') != -1){
		document.getElementById('uploaderror').innerHTML = "File Uploaded Successfully."
	}
}

/*----------------------------Add Employee ------------------------*/

country = new Array();
 country[0] = "Afghanistan";
 country[1] = "Albania";
 country[2] = "Algeria";
 country[3] = "American Samoa";
 country[4] = "Andorra";
 country[5] = "Angola";
 country[6] = "Anguilla";
 country[7] = "Antarctica";
 country[8] = "Antigua and Barbuda";
 country[9] = "Argentina";
 country[10]= "Armenia";
 country[11]= "Aruba";
 country[12]= "Australia";
 country[13]= "Austria";
 country[14]= "Azerbaijan";
 country[15]= "Bahamas";
 country[16]= "Bahrain";
 country[17]= "Bangladesh";
 country[18]= "Barbados";
 country[19]= "Belarus";
 country[20]= "Belgium";
 country[21]= "Belize";
 country[22]= "Benin";
 country[23]= "Bermuda";
 country[24]= "Bhutan";
 country[25]= "Bolivia";
 country[26]= "Bosnia and Herzegowina";
 country[27]= "Botswana";
 country[28]= "Bouvet Island";
 country[29]= "Brazil";
 country[30]= "British Indian Ocean Terr.";
 country[31]= "Brunei Darussalam";
 country[32]= "Bulgaria";
 country[33]= "Burkina Faso";
 country[34]= "Burundi";
 country[35]= "Cambodia";
 country[36]= "Cameroon";
 country[37]= "Canada";
 country[38]= "Cape Verde";
 country[39]= "Cayman Islands";
 country[40]= "Central African Republic";
 country[41]= "Chad";										   
 country[42]= "Chile";
 country[43]= "China";
 country[44]= "Christmas Island";
 country[45]= "Cocos (Keeling) Islands";
 country[46]= "Colombia";
 country[47]= "Comoros";
 country[48]= "Congo";
 country[49]= "Cook Islands";
 country[50]= "Costa Rica";
 country[51]= "Cote d'Ivoire";
 country[52]= "Croatia (Hrvatska)";
 country[53]= "Cuba";
 country[54]= "Cyprus";
 country[55]= "Czech Republic";
 country[56]= "Denmark";
 country[57]= "Djibouti";
 country[58]= "Dominica";
 country[59]= "Dominican Republic";
 country[60]= "East Timor";
 country[61]= "Ecuador";
 country[62]= "Egypt";
 country[63]= "El Salvador";
 country[64]= "Equatorial Guinea";
 country[65]= "Eritrea";
 country[66]= "Estonia";
 country[67]= "Ethiopia";
 country[68]= "Falkland Islands/Malvinas";
 country[69]= "Faroe Islands";
 country[70]= "Fiji";
 country[71]= "Finland";
 country[72]= "France";
 country[73]= "France, Metropolitan";
 country[74]= "French Guiana";
 country[75]= "French Polynesia";
 country[76]= "French Southern Terr.";
 country[77]= "Gabon";
 country[78]= "Gambia";
 country[79]= "Georgia";
 country[80]= "Germany";
 country[81]= "Ghana";
 country[82]= "Gibraltar";
 country[83]= "Greece";
 country[84]= "Greenland";
 country[85]= "Grenada";
 country[86]= "Guadeloupe";
 country[87]= "Guam";
 country[88]= "Guatemala";
 country[89]= "Guinea";
 country[90]= "Guinea-Bissau";
 country[91]= "Guyana";
 country[92]= "Haiti";
 country[93]= "Heard & McDonald Is.";
 country[94]= "Honduras";
 country[95]= "Hong Kong";
 country[96]= "Hungary";
 country[97]= "Iceland";
 country[98]= "India";
 country[99] = "Indonesia";
country[100] = "Iran";
country[101] = "Iraq";
country[102] = "Ireland";
country[103] = "Israel";
country[104] = "Italy";
country[105] = "Jamaica";
country[106] = "Japan";
country[107] = "Jordan";
country[108] = "Kazakhstan";
country[109] = "Kenya";
country[110] = "Kiribati";
country[111] = "Korea, North";
country[112] = "Korea, South";
country[113] = "Kuwait";
country[114] = "Kyrgyzstan";
country[115] = "Lao People's Dem. Rep.";
country[116] = "Latvia";
country[117] = "Lebanon";
country[118] = "Lesotho";
country[119] = "Liberia";
country[120] = "Libyan Arab Jamahiriya";
country[121] = "Liechtenstein";
country[122] = "Lithuania";
country[123] = "Luxembourg";
country[124] = "Macau";
country[125] = "Macedonia";
country[126] = "Madagascar";
country[127] = "Malawi";
country[128] = "Malaysia";
country[129] = "Maldives";
country[130] = "Mali";
country[131] = "Malta";
country[132] = "Marshall Islands";
country[133] = "Martinique";
country[134] = "Mauritania";
country[135] = "Mauritius";
country[136] = "Mayotte";
country[137] = "Mexico";
country[138] = "Micronesia";
country[139] = "Moldova";
country[140] = "Monaco";
country[141] = "Mongolia";
country[142] = "Montserrat";
country[143] = "Morocco";
country[144] = "Mozambique";
country[145] = "Myanmar";
country[146] = "Namibia";
country[147] = "Nauru";
country[148] = "Nepal";
country[149] = "Netherlands";
country[150] = "Netherlands Antilles";
country[151] = "New Caledonia";
country[152] = "New Zealand";
country[153] = "Nicaragua";
country[154] = "Niger";
country[155] = "Nigeria";
country[156] = "Niue";
country[157] = "Norfolk Island";
country[158] = "Northern Mariana Is.";
country[159] = "Norway";
country[160] = "Oman";
country[161] = "Pakistan";
country[162] = "Palau";
country[163] = "Panama";
country[164] = "Papua New Guinea";
country[165] = "Paraguay";
country[166] = "Peru";
country[167] = "Philippines";
country[168] = "Pitcairn";
country[169] = "Poland";
country[170] = "Portugal";
country[171] = "Puerto Rico";
country[172] = "Qatar";
country[173] = "Reunion";
country[174] = "Romania";
country[175] = "Russian Federation";
country[176] = "Rwanda";
country[177] = "Saint Kitts and Nevis";
country[178] = "Saint Lucia";
country[179] = "St. Vincent & Grenadines";
country[180] = "Samoa";
country[181] = "San Marino";
country[182] = "Sao Tome & Principe";
country[183] = "Saudi Arabia";
country[184] = "Senegal";
country[185] = "Seychelles";
country[186] = "Sierra Leone";
country[187] = "Singapore";
country[188] = "Slovakia (Slovak Republic)";
country[189] = "Slovenia";
country[190] = "Solomon Islands";
country[191] = "Somalia";
country[192] = "South Africa";
country[193] = "S.Georgia & S.Sandwich Is.";
country[194] = "Spain";
country[195] = "Sri Lanka";
country[196] = "St. Helena";
country[197] = "St. Pierre & Miquelon";
country[198] = "Sudan";
country[199] = "Suriname";
country[200] = "Svalbard & Jan Mayen Is.";
country[201] = "Swaziland";
country[202] = "Sweden";
country[203] = "Switzerland";
country[204] = "Syrian Arab Republic";
country[205] = "Taiwan";
country[206] = "Tajikistan";
country[207] = "Tanzania";
country[208] = "Thailand";
country[209] = "Togo";
country[210] = "Tokelau";
country[211] = "Tonga";
country[212] = "Trinidad and Tobago";
country[213] = "Tunisia";
country[214] = "Turkey";
country[215] = "Turkmenistan";
country[216] = "Turks & Caicos Islands";
country[217] = "Tuvalu";
country[218] = "Uganda";
country[219] = "Ukraine";
country[220] = "United Arab Emirates";
country[221] = "United Kingdom";
country[222] = "United States";
country[223] = "U.S. Minor Outlying Is.";
country[224] = "Uruguay";
country[225] = "Uzbekistan";
country[226] = "Vanuatu";
country[227] = "Vatican (Holy See)";
country[228] = "Venezuela";
country[229] = "Viet Nam";
country[230] = "Virgin Islands (British)";
country[231] = "Virgin Islands (U.S.)";
country[232] = "Wallis & Futuna Is.";
country[233] = "Western Sahara";
country[234] = "Yemen";
country[235] = "Yugoslavia";
country[236] = "Zaire";
country[237] = "Zambia";
country[238] = "Zimbabwe"; 


state = new Array();
state[0] = "Andaman and Nicobar"
state[1] = "Andhra Pradesh";
state[2] = "Arunachal Pradesh";
state[3] = "Assam";
state[4] = "Bihar";
state[5] = "Chandigarh"
state[6] = "Chattisgarh";
state[7] = "Dadra and Nagar Haveli";
state[8] = "Daman and Diu";
state[9] =  "Delhi";
state[10] = "Goa";
state[11] = "Gujarat";
state[12] = "Haryana";
state[13] = "Himachal Pradesh";
state[14] = "Jammu and Kashmir";
state[15] = "Jharkhand";
state[16] = "Karnataka";
state[17] = "Kerala";
state[18] = "Lakshadweep";
state[19] = "Madhya Pradesh";
state[20] = "Maharashtra";
state[21] = "Manipur";
state[22] = "Meghalaya";
state[23] = "Mizoram";
state[24] = "Nagaland";
state[25] = "Orissa";
state[26] = "Pondicherry";
state[27] = "Punjab";
state[28] = "Rajasthan";
state[29] = "Sikkim";
state[30] = "Tamil Nadu";
state[31] = "Tripura";
state[32] = "Uttaranchal";
state[33] = "Uttar Pradesh";
state[34] = "West Bengal";



graduation = new Array();
graduation[0] = "--Select Grad--"
graduation[1] = "B.Sc."
graduation[2] = "B.Com"
graduation[3] = "B.A."
graduation[4] = "BCA"
graduation[5] = "B.Tech"
graduation[6] = "BIT."
graduation[7] = "BBA"
graduation[8] = "B.E."
graduation[9] = "CA/CS/ICWA"
graduation[10] = "LLB"
graduation[12] = "MBBS"
graduation[13] = "Diploma"



pg = new Array();
pg[0] = "---Select PG---"
pg[1] = "M.Sc."
pg[2] = "MCA"
pg[3] = "MBA"
pg[4] = "M.Tech"
pg[5] = "PGDCA"
pg[6] = "PGDBM"
pg[7] = "M.E."
pg[8] = "M.A."
pg[9] = "M.Com."
pg[10] = "MIT"
pg[11] = "Hotel Mgmt"
pg[12] = "MD"
pg[13] = "CA/CS/ICWA"
pg[14] = "Diploma"

as = new Array();
as[0]="----Select-------"
as[1]="less than 1 lakhs"
as[2]="1 lakh to 2 lakhs" 
as[3]="2 lakh to 3 lakhs"
as[4]="3 lakh to 4 lakhs"
as[5]="4 lakh to 5 lakhs"
as[6]="5 lakh to 6 lakhs"
as[7]="6 lakh to 7 lakhs"
as[8]="7 lakh to 8 lakhs"
as[9]="8 lakh to 9 lakhs"
as[10]="9 lakh to 10 lakhs"
as[11]="10 lakh to 11 lakhs"
as[12]="11 lakh to 12 lakhs"
as[13]="over 12 lakhs"



function populateCombo(field, arr, formname){
	obj = eval("document."+formname+"."+field)
	obj.length = arr.length;
	obj.options[0].value='';
	obj.options[0].text= arr[0];	
	for(i=1;i<obj.length;i++){
		obj.options[i].value = arr[i];
		obj.options[i].text = arr[i];
	}
}

function validateGrid(formName, start, stop, fieldName1, fieldName2, fieldName3, fieldName4, fieldName5, fieldname6 ){
	for(i=start;i<=stop; i++){
		ob1 = eval("document.formName.fieldName1"+i)
		ob2 = eval("document.formName.fieldName2"+i)
		ob3 = eval("document.formName.fieldName3"+i)
		ob4 = eval("document.formName.fieldName4"+i)
		ob5 = eval("document.formName.fieldName5"+i)
		ob6 = eval("document.formName.fieldName6"+i)										
		if((ob1 && ob1.value!="")||(ob2 && ob2.value!="")||(ob3 && ob3.value!="")||(ob4 && ob4.value!="")||(ob5 && ob5.value!="")||(ob6 && ob6.value!="")){
			
		}
	}
	
}



/*-------------------------*/

function initTabButtons(){
	buttonObj = document.getElementsByTagName('input')
	if(buttonObj){
		for(i=0;i<buttonObj.length;i++){
			if(buttonObj[i].className=="button"){
				buttonObj[i].onfocus = setBorder;
				buttonObj[i].onblur = resetBorder;
			}
		}
	}
}
function setBorder(){
	this.style.border = "1px solid yellow"
}
function resetBorder(){
	this.style.border = "none"
}

function openNew(urlTo){
	window.open(urlTo);
}
