// This file has some common javascript that is used anywhere...


	//v1.0
	///////////////////////////////////////////////////////////////////////////////////////////
	// Purpose	  : Move one list options to another list
	// leftListId : first list Id
	// rightListId: second list Id
	// dir		  : Direction (true/false)
	// Name		  : Noun of options
	// all		  : one/All (true/false)
	// written By : Shalin Singh
	///////////////////////////////////////////////////////////////////////////////////////////
	
	function moveOptions(leftListId,rightListId,dir,name,all){
		var DIRECTION_LEFT_2_RIGHT = true;
		var DIRECTION_RIGHT_2_LEFT = false;
		var leftList = document.getElementById(leftListId);
		var rightList = document.getElementById(rightListId);

		if(dir == DIRECTION_LEFT_2_RIGHT){
			moveOptionsFistList2Other(leftList,rightList,name,all);
		}else{
			moveOptionsFistList2Other(rightList,leftList,name,all);				
		}				
	}
	
	//
	function moveOptionsFistList2Other(leftList,rightList,name,all){
		if(all)selectAllOptions(leftList);
		if(!isAnyOptionSelected(leftList)){
			alert("Please select any "+name+" from list.");
			leftList.focus();
			return false;
		}else{
			var length = leftList.length-1;
			for(var i=length; i>-1 ; i--){
				if(leftList.options[i].selected==true){
					var op = leftList.options[i];
					leftList.remove(i);
					rightList.options[rightList.length]= new Option (op.text,op.value);
				}
			}
		}
	}
	
	//Check for any option is selected
	function isAnyOptionSelected(list){
		for(var j=0; j< list.length; j++){	
			if(list.options[j].selected==true){
				return true;
			}
		}
		return false;
	}
	
	//Select all option of List
	function selectAllOptions(list){
		for(var k=0; k< list.length; k++){
			list.options[k].selected=true;
		}
	}
			
	//v1.0
	///////////////////////////////////////////////////////////////////////////////////////////
	// Purpose	  : Select or Deselect all the chkBox depend on Main chkBox
	// eArray	  : Array of string names of all chkBox 
	// formName	  : Form Name
	// sAll		  : Name of selectall chkbox
	// chkBoxName : Name of this checkbox
	// written By : Shalin Singh
	///////////////////////////////////////////////////////////////////////////////////////////

	function selectAllById(eArray, sAll,chkBoxName){
            if(eArray.length < 1){
                //eval("document."+formName+"."+sAll).disabled = true;
                document.getElementById(sAll).disabled = true;                
                return;
            }

            if(sAll == chkBoxName){
                if(document.getElementById(sAll).checked == true){
                    //checked All checkk box
                    for(var i=0; i < eArray.length; i++ ){
                            document.getElementById(eArray[i]).checked = true;
                    }
                }else{
                    //Uncheck All checkk box
                    for(var i=0; i < eArray.length; i++ ){
                            document.getElementById(eArray[i]).checked = false;
                    }
                }
            }else{
                var allBox = true;
                for(var i=0; i < eArray.length; i++ ){
                    if(document.getElementById(eArray[i]).checked != true){
                        allBox = false;
                        break;
                    }
                }
                if(allBox){
                	document.getElementById(sAll).checked = true;
                }
                if(!allBox){
                    document.getElementById(sAll).checked = false;
                }
            }
	}
	 

	//Added by Shalin Singh dated on 12/03/2007
	//v1.0
	///////////////////////////////////////////////////////////////////////////////
	//Check for selected
	/////////////////////////
	
	///
	function anyOneSelected(formName,chkNames){
	    if(getSelectionCountById(formName,chkNames) > 0) return true; else false;
	}
	
	///
	function isOneSelected(formName,chkNames){
	    if(getSelectionCountById(formName,chkNames) == 1) return true; else false;
	}
	
	///
	function isMoreThenOneSelected(formName,chkNames){
	    if(getSelectionCountById(formName,chkNames) > 1) return true; else false;
	}
	
	///
	function getSelectionCountById(formName,chkNames){
	    var selected = false;
	    var selectionCount = 0;
	    for(var g=0; g < chkNames.length; g++){
	        if(document.getElementById(chkNames[g]).checked == true){
	            selectionCount++;
	        }
	    }
	    return selectionCount;
	}
	 
	/**
	 * Added by Shalin Singh dated on 12/03/2007
	 * Check for Date Equality
	 */
	function getCurrentDate(){
		var date = new Date();
		var dateStr = ""+(date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear();
		return dateStr;
	}

	/**
	 * Added by Shalin Singh dated on 12/03/2007
	 * Check for Date Greatness
	 */
	function isGreaterDate(date1, date2){
		if(date1>date2){
			return true;
		}else{
			return false;
		}
	}


	/**
	 * Added by Shalin Singh dated on 12/03/2007
	 * Check for Date Greater or Equal to current date
	 */
	function isGreaterOrEqualToCurrentDate(date){
		var cDate = new Date();
		var curDate =new Date(cDate.getFullYear(),cDate.getMonth(),cDate.getDate());
		if(date > curDate || isEqualToCurrentDate(date)){
			return true;
		}else{
			return false;
		}
	}

	/**
	 * Added by Shalin Singh dated on 12/03/2007
	 * Check for Date greater then current date
	 */
	function isGreaterThenCurrentDate(date){
		var cDate = new Date();
		var curDate =new Date(cDate.getFullYear(),cDate.getMonth(),cDate.getDate());
		if(date > curDate){
			return true;
		}else{
			return false;
		}
	}
	
	
	function compareDate(toDate,fromDate){
		if(toDate >fromDate||toDate==fromDate){
			return true;
		}else{
			return false;
		}
	}
	/**
	 * Added by Shalin Singh dated on 12/03/2007
	 * Check for Date equal to current date
	 */
	function isEqualToCurrentDate(date){
		var cDate = new Date();
		var curDate =new Date(cDate.getFullYear(),cDate.getMonth(),cDate.getDate());
		return isEqualDate(curDate, date);
	}
	
	/**
	 * Added by Shalin Singh dated on 12/03/2007
	 * Check for Date Equality
	 * This function only compares date part
	 */
	function isEqualDate(date1, date2){
		if(date1.getDate()==date2.getDate() && date1.getMonth()==date2.getMonth() && date1.getFullYear()==date2.getFullYear()){
			return true;
		}else{
			return false;
		}
	}
	
	
	/**
	 * The function validates the date given to it 
	 * returns False if The date is Not Valid    
	 */
	function isValidDate(dt, mn, yr){
		//Number validation aded by shalin
		if(!isValidNumber(dt) || !isValidNumber(mn) || !isValidNumber(yr)){
			return false;
		}
		// If user has not entered date, it's invalid
		if ( dt == 0 || mn == 0 || yr == "0000" ){
			return false;
		}
		// else ..
		var yr_1 = yr/4;
		var d_max = 28;
		m31= new Array (1, 3, 5, 7, 8, 10, 12);
		var flag_m=0;
		var i=0;
		
		// If the person is born in February check 
		if ( mn == 2)
		{
			if ( yr_1 == Math.round(yr_1))    d_max=29;
							
		}
		else
		{
			// Check to see if the month is of 31 days 
			for ( i =0; i<7; i++) {
			if (mn == m31[i]) flag_m = 1;
			}
			if ( flag_m ) {d_max=31 } else {d_max=30}
		}
		if ( dt > d_max ) return false;	
		return true;
			
	}

	/**
	 * Validate date 
	 */
	 function isValidDateStr(dateStr){
	 	if(isBlankField(dateStr))return false;
	 	if(dateStr.length!=10)return false;
	 	
	 	var m = dateStr.substr(0,2);
	 	var d = dateStr.substr(3,2);
	 	var y = dateStr.substr(6,4);
	 		 	
	 	return isValidDate(d,m,y);	 
	 }
	 
    /**
	 * Check Future Date
	 */		
	function isFutureDate(dd,mm,yy){
		var time = new Date();   
		var d = time.getDate();
		var m = time.getMonth()+1;
		var y = time.getYear();   
		var future = false;
	
		if(yy == y){
			if(mm == m){
				if(dd > d){
					future = true;
				}
			}else if(mm > m){
				future = true;
			}
		}else if(yy > y){
			future = true;
		}		
		return future;
	}

	/**
	 * Validate Time format. It should be (hh:mm) 24 Hour format
	 */
	function isValidTime(timeStr){
	 	if(isBlankField(timeStr))return false;
	 	if(timeStr.length!=5)return false;
		var h = timeStr.substr(0,2);
	 	var m = timeStr.substr(3,2);
		if(!isValidNumber(h) || !isValidNumber(m)){
			return false;
		}
		if(h<0 || h>23 || m<0 || m>59){
			return false;
		}
		return true;
	}
		 
	/** 
	 * Validate Date format
	 */
	function cal_prs_date1 (str_date)
	{
	     if(trim(str_date).length == 0)
	     {
	       return true;
	     }
	     var RE_NUM = /^\-?\d+$/;
	
			var arr_date = str_date.split('/');
	
			if (arr_date.length != 3) return false;		
			if (!arr_date[1]) return false;
	       
			if (!RE_NUM.exec(arr_date[0])) return false;
			if (!arr_date[1]) return false;		
			if (!RE_NUM.exec(arr_date[1])) return false;
			if (!arr_date[2]) return false;	
			if (!RE_NUM.exec(arr_date[2])) return false;
	
			var dt_date = new Date();
			dt_date.setDate(1);
	       
			if (arr_date[0] < 1 || arr_date[0] > 12) return false;	
			dt_date.setMonth(arr_date[0]-1);
	
			if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
			dt_date.setFullYear(arr_date[2]);
	
			var dt_numdays = new Date(arr_date[2], arr_date[0], 0);
			dt_date.setDate(arr_date[1]);
			
			if (dt_date.getMonth() != (arr_date[0]-1)) return false;
		
		return true;
	}

	/**
	 *	Added by Shalin Singh dated on 26/12/2006
	 *	Validate Float length
	 *  @param float value
	 *  @reurn boolean
	 */
	function validateFloat(obj,pDigit){
		var floatMaxLimit=999999.99;
			
		if(pDigit==2){
			floatMaxLimit=999999.99;
		}else if(pDigit==3){
			floatMaxLimit=99999.999;
		}else if(pDigit==4){
			floatMaxLimit=9999.9999;
		}else if(pDigit==5){
			floatMaxLimit=999.99999;
		}
		var val = parseFloat(obj.value);
		
		if(val >= floatMaxLimit){
			alert("Value should be less then '"+floatMaxLimit+"'.");
			obj.focus();
			return false;
		}
		return true;
	}


	/**
	 *	Added by Shalin Singh dated on 26/12/2006
	 *	Validate leading Zeo
	 *  @param field object
	 *  @reurn focus to object if found invalid
	 */
	function validateLadingZero(fieldObj){
		var reg =/^0/;
		if(parseFloat(fieldObj.value)>1.0 && reg.test(fieldObj.value)){
			alert("Leading zeros not allowed.");
			fieldObj.focus();
			return false;
		}
	}

	// Added by Shalin On 16/12/2006
	// This function use to reFetch Data of the form
    function isValidDecimalNumber(numStr){
    	numStr = trim(numStr);
        for(var i=0;i<numStr.length;i++){
	    	 var flag=0;
	    	if(!isValidDigit(parseInt(numStr.charAt(i))) && numStr.charAt(i)!='.'){
	            	flag=1;
	                break;
	        }
        }
        if(flag == 1)
            return (false);		
        else
            return (true);		
    }

	/**
	 *	Added by Shalin Singh dated on 26/12/2006
	 *	This function convert in to 4 digit after decimal
	 */
	 
	function convertValueInDecimalNumber(value,noOfDgit){
	
		value = trim(value);
		var decimal=".";
		dIndex = value.indexOf(decimal);
		var dAfterDec = eval(value.length-(dIndex+1));
		
	
		if(dIndex==-1){
			if(noOfDgit==2)
				value+=".00";
			if(noOfDgit==3)
				value+=".000";
			if(noOfDgit==4)
				value+=".0000";
			if(noOfDgit==5)
			{
			
				value+=".00000";	
			}		
		}else if(dAfterDec==1){
			if(noOfDgit==2)
				value+="0";
			if(noOfDgit==3)
				value+="00";
			if(noOfDgit==4)
				value+="000";
		}else if(dAfterDec==2){
			if(noOfDgit==3)
				value+="0";
			if(noOfDgit==4)
				value+="00";
		}else if(dAfterDec==3){
			if(noOfDgit==2)
				value = value.substring(0,dIndex+3);
			if(noOfDgit==4)
				value+="0";
		}else if(dAfterDec==4){
			if(noOfDgit==2)
				value = value.substring(0,dIndex+3);
			if(noOfDgit==3)
				value = value.substring(0,dIndex+4);
		}
		
		else if(dAfterDec==5){
				if(noOfDgit==5)
				value = value.substring(0,dIndex+6);
				
		}
		else if(dAfterDec>5){
	
			if(noOfDgit==2)
				value = value.substring(0,dIndex+3);
			if(noOfDgit==3)
				value = value.substring(0,dIndex+4);
			if(noOfDgit==4)
				value = value.substring(0,dIndex+5);
			if(noOfDgit==5)
				value = value.substring(0,dIndex+6);	
		}	
		return value;
	}
	
	/**
	 *	Added by Shalin Singh dated on 26/12/2006
	 *	This function convert in to 2 digit after decimal
	 */
	function convertInDecimalNumber(deiNumObj,noOfDgit){
		var value = deiNumObj.value;
		deiNumObj.value = convertValueInDecimalNumber(value,noOfDgit);
	}



	/**
	 *	Added by Shalin Singh dated on 26/12/2006
	 *	This function convert in to 2 digit after decimal
	 */
	function checkConvertInDecimalNumber(deiNumObj){
		deiNumObj.value = trim(deiNumObj.value);
		var value = deiNumObj.value;
		var decimal=".";
		dIndex = value.indexOf(decimal);
		var dAfterDec = eval(value.length-(dIndex+1));
		
		if(dIndex==-1){
			deiNumObj.value+=".00";
		}else if(dAfterDec==1){
			deiNumObj.value+="0";
		}else if(dAfterDec > 2){
			deiNumObj.value = value.substring(0,dIndex+3);
		}
	}
	
	/**
	 *	Added by Shalin Singh dated on 15/03/2006
	 *	Validate Zipcode
	 */
	function validateUSZip(zipCode) {
		var zipcodeValue=zipCode;
		if(zipcodeValue!=""){
			var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
			if(objRegExp.test(zipcodeValue)==true){
				if(zipcodeValue=="00000"){
					return false;
				}
			}else{
				return false;
			}
		}
		return true;
	}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}

	/**
	 *	Added by Shalin Singh dated on 26/12/2006
	 *	This function convert in to 2 digit after decimal
	 *  Password has not any spacial character && range : 8 to 30
	 */
	function checkCommonPasswordFormat(passObj){
	  var totolAlphaNumeric = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	  var tval =trim(passObj.value);
	  if(isBlankField(tval)){
     	alert("Password should not be empty and can not contains spaces.");
     	passObj.focus();
     	return false;
	  }
	  if((tval.length >= 8) && (tval.length <= 30)){
	  	for (i=0;i<tval.length;i++){
		var c = tval.charAt(i);
		//alert(" Char is >>"+c);
			if(c != null && c != ' '){
			//password can contain any character - as discussed with client
				/*if (totolAlphaNumeric.indexOf(c) == -1){
			   	   alert("Password should be alphanumeric.");
			   	   passObj.focus();
			   	   return false;
		        }*/
	         }else{
	         	alert("Spaces not allowed in password.");
	         	passObj.focus();
	         	return false;
	        }
	    }
	  }else{
		alert("The password is too short. Please type a password that is at least 8 characters long.");
		passObj.focus();
		return false;
	  }
	  return true;
	} 

	/**
	 *	Added by Shalin Singh dated on 23/04/2007
	 *	This function convert in to 2 digit after decimal
	 *  Password has not any spacial character length should be less then 8
	 */
	function checkCommonPasswordByPassLength(passObj){
	  var totolAlphaNumeric = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	  var tval =trim(passObj.value);
	  if(isBlankField(tval)){
     	alert("Password should not be empty and can not contains spaces.");
     	passObj.focus();
     	return false;
	  }
	  	for (i=0;i<tval.length;i++){
		var c = tval.charAt(i);
		//alert(" Char is >>"+c);
			if(c != null && c != ' '){
				if (totolAlphaNumeric.indexOf(c) == -1){
			   	   alert("Password should be alphanumeric.");
			   	   passObj.focus();
			   	   return false;
		        }
	         }else{
	         	alert("Spaces not allowed in password.");
	         	passObj.focus();
	         	return false;
	        }
	    }
		return true;
	} 

	/**
	 *	This function convert in to 2 digit after decimal
	 *  Password has not any spacial character && range : 8 to 30
	 */
	function checkPasswordFormat(passObj){
	  var totolAlphaNumeric = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	  var tval =trim(passObj.value);
	  if((tval.length >= 8) && (tval.length <= 30)){
	  	for (i=0;i<tval.length;i++){
		var c = tval.charAt(i);
			if(c != null && c != " "){
				if (totolAlphaNumeric.indexOf(c) == -1){
			   	   alert("Password should be alphanumeric.");
			   	   passObj.focus();
			   	   return false;
		        }
	         }else{
	         	alert("Spaces not allowed in password.");
	         	passObj.focus();
	         	return false;
	        }
	    }
	  }else{
		alert("The password is too short. Please type a password that is at least 8 characters long.");
		passObj.focus();
		return false;
	  }
	} 


// Phone validation 
function validatePhone(phoneValue) 
{
 if(phoneValue.value.length != 0)
 {
   if(checkPhone(phoneValue)== true)
   {                         
     alert("Invalid Phone Number");                         
     phoneValue.focus();   
   }
 }                        
} 
           
// Phone validation - For Masking
function convertPhoneMask(pStr)
{
 return(pStr.substring(0,3) + "-" + pStr.substring(3,6) + "-" + pStr.substring(6,10));
} 

// Phone validation - Check Phone Format              
function checkPhone(phoneStr)
{               
   var goodChars = "0123456789-";
   var allDigits = "0123456789";
   phoneNum = phoneStr.value;  
   if (phoneNum.length == 0)
   {  
     return false;  
   } 	

   for (i=0; i<phoneNum.length; i++)
   {
  	  var c = phoneNum.charAt(i);
	  if (goodChars.indexOf(c) == -1)
	  { 
	    return true;  
	  }
    }		 
  
   if (phoneNum.charAt(0) == "0")
   {	
     return true; 
   }		 
		
   if (phoneNum.length < 10)
   {
       return true; 
   }		 
	
   if ((phoneNum.length == 10) || (phoneNum.length == 11))
   {
	  for (i=0; i<phoneNum.length; i++)
	  {
	      var c = phoneNum.charAt(i);
	      if (allDigits.indexOf(c) == -1)
	      { 
	        return true; 
	      }
       }		 
      if (phoneNum.length == 10)
	  {
	     if (phoneNum.charAt(0) == "1")
	     {  return true;}
	     else
	     { phoneStr.value = convertPhoneMask(phoneNum);
	       return false;
	     }
	  }
	  else
	  {
	    if (phoneNum.charAt(0) != "1")
	    {  return true;}
	    else
        {
 		  phoneStr.value = convertPhoneMask(phoneNum.substring(1,11));
	      return false;
 	    }
      }
    }		 
    if (phoneNum.length == 12)
    {
	  j = phoneNum.indexOf("-");		 	
 	  if(j != 3)
	  {	 return true;}
 	  tempPhone = phoneNum.substring(j+1,12);
	  j = tempPhone.indexOf("-");
	  if (j != 3)
 	  {return true;	}
 	  tempPhone = tempPhone.substring(j+1,8);
      j = tempPhone.indexOf("-");
      if (j != -1)
	  { return true;}
     }
 }
 
 // password should be 8 or more charecters or numbers
function fnPasswordMatchCheck(password1,password2)
{
 var passwordvalue1 = trim(password1.value);
 var passwordvalue2 = trim(password2.value);
 
  if(passwordvalue1.length !=0)
  { 
	  if(passwordvalue1 != passwordvalue2)
	  {
		   alert("Password and PasswordAgain does not match.");	   
		   if(password1.name == 'adminPassword')
		   {
		      document.forms[0].txtNewPassword.focus();
		   }else if(password1.name == 'adminPasswordAgain')
		   {
		     document.forms[0].txtPasswordAgain.focus();
		   }
	    
	   return false;
	  }
   } 
   return true;
}
 
 	// Added by Shalin On 16/12/2006
	// This function use to reFetch Data of the form
	
    function reBuildForm(context,formName,url){
		var context=context+'/';
		url = context+url;
        var o = "document.forms['"+formName+"'].action='"+url+"'";
		eval(o);
        o = "document.forms['"+formName+"'].submit()";
		eval(o);
    }
    
	// Added by Shalin On 16/12/2006
	// This function use to reFetch Data of the form
	function isBlankField(str){
        var mVal = str;
        var isBlank = true;
        if(mVal == null || mVal == "")
        	return isBlank;
        for(i=0; i < mVal.length; i++){
            if(mVal.charAt(i) != ' '){
               isBlank = false;
               break;
            }
        }
        return isBlank;
	}
	
	
	// Added by Shalin On 16/12/2006
	// This function use to reFetch Data of the form
    function isValidNumber(numStr){
        for(var i=0;i<numStr.length;i++){
    	 var flag=0;
        	if(!isValidDigit(parseInt(numStr.charAt(i)))){
                	flag=1;
                        break;
            }
        }
        if(flag == 1)
            return (false);		
        else
            return (true);		
    }
    
	// Added by Shalin On 16/12/2006
	// This function use to reFetch Data of the form
    function isValidDigit(digit){
        switch(digit){
            case 0 : return (true);
            case 1 : return (true);
            case 2 : return (true);
            case 3 : return (true);
            case 4 : return (true);
            case 5 : return (true);
            case 6 : return (true);
            case 7 : return (true);
            case 8 : return (true);
            case 9 : return (true);
            default : return (false);								
        }
    }
	
	
	//Added By Jatin
	function validPhone(field)
	{
		if(trim(field.value)!="")	
		{
			  if(checkPhone(field)== true)
	          {                         
	             if(field.value.charAt(0) == "1" || field.value.charAt(0) == "0")
		         {
		             alert("Number cannot start with 0 or 1");
		             field.focus();	 
		             return false;		                    
		         }//inner if ends
		         else
		         {	                         
	             	alert("Please enter valid Number i.e XXX-XXX-XXXX");
		            field.focus();
   	                return false;		            
		         }                
	          }
	          else
	          {
	             if(field.value.charAt(0) == "1" || field.value.charAt(0) == "0")
		         {
		             alert("Number cannot start with 0 or 1");
		             field.focus();
	                 return false;
		         }//inner if ends
	          }
        }
        return true;
	}	
	
	/*****Added by Jatin**************/
	/*****Validating the charaters being entered in textbox. Only valid characters will be accepted********************/
	function validateData(e,index)
	{
		//alert("in validedata keycode:"+window.event.keyCode);
		var key,keychar,str;
			
		if (window.event)
			key = window.event.keyCode;
		else
		{
			if (e)
				key = e.which;
			else
			   return true;
		}
		 
		keychar = String.fromCharCode(key);
			
		// control keys
		if ((key==null) || (key==0) || (key==8) ||
			(key==9) || (key==13) || (key==27) || (key==32) )
			return true;
		else 
		{
			str = getValidateStr(index)
			if (((str).indexOf(keychar) > -1))
			   return true;
			else
			{
				
			   return false;
			}
		}
	
	}//func ends
	
	
	function getValidateStr(index)
	{
		//alert("in getValidatestr");
		var str = "";
		
		switch(index)
		{
						
			case 1:		//for validating telephone no
				//alert("index:"+index);
				str = "1234567890-";
				break;
			case 2: 
				
				str = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";
				break;	
			case 3: 
				
				str = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,/";
				break;	
			case 4: 
				
				str = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
				break;	
			
			case 5:		//for validating year
				//alert("index:"+index);
				str = "1234567890";
				break;
				
			case 6:		//for validating year
				//alert("index:"+index);
				str = "1234567890.";
				break;	
				
			case 7:		//for validating year
				//alert("index:"+index);
				str = "1234567890/";
				break;					
							
		}	//end of Switch statement
		return str;
	}//1
    
	var	xPos4Mouse = 100;
	var	yPos4Mouse = 100;
	
    //Added By Shalin for AutoLogoutWhenClickX
	function autoLogoutWhenClickX(){
		var logoutWindow="tempWin";
		var childParam="Logout.do?autoLogoutWhenClickX=true";
		var cwin = null;
		if ((xPos4Mouse == 0) && (xPos4Mouse == 0)){
			if(window.childWinID){childParam="&childWin="+childWinID;}
			cwin = open(childParam,logoutWindow,"width=1px,height=1px,left="+screen.width+",top="+screen.height);
			//cwin = open(childParam,logoutWindow,"width=1000px,height=1000px,left=200,top=200");
		}
	}
    	
	// Trak Mouse posititon from browser window	
	function trakMouseMove(out){
		if(out){
			xPos4Mouse = 0;
			yPos4Mouse = 0;
		}else{
			xPos4Mouse = 100;
			yPos4Mouse = 100;		
		}
		//alert("xPos >> "+xPos4Mouse+", yPos >> "+yPos4Mouse);
	}    
	
	/********Date Validation********************/
	function isInteger(s){
		var i;
	    for (i = 0; i < s.length; i++){   
	        // Check that current character is number.
	        var c = s.charAt(i);
	        if (((c < "0") || (c > "9"))) return false;
	    }
	    // All characters are numbers.
	    return true;
	}
	
	function stripCharsInBag(s, bag){
		var i;
	    var returnString = "";
	    // Search through string's characters one by one.
	    // If character is not in bag, append to returnString.
	    for (i = 0; i < s.length; i++){   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) returnString += c;
	    }
	    return returnString;
	}
	
	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
	    // EXCEPT for centurial years which are not also divisible by 400.
	    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
	   } 
	   return this
	}
	
	function isDate(dtStr){
		//alert("isDate");
		var dtCh= "/";
		var minYear=1900;
		var maxYear=2100;
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strMonth=dtStr.substring(0,pos1)
		var strDay=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			alert("The date format should be : mm/dd/yyyy")
			return false
		}
		if (strMonth.length<1 || month<1 || month>12){
			alert("Please enter a valid month")
			return false
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			alert("Please enter a valid day")
			return false
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
			return false
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			alert("Please enter a valid date")
			return false
		}
		return true
	}
	
	function checkDateValidation(dtObj){
		//var dt=document.frmSample.txtDate
		//alert("date--"+dtObj.value);
		if (isDate(dtObj.value)==false){
			dtObj.focus()
			return false
		}
	    return true
	 }
	
	/********Date Validation Ends********************/
	
	/************Function to open link for Electricity & Natural Gas*********************/
	function openDirectEnergy(linkName)
	{
		if(linkName=="planLink")
		{
			window.open("http://www.directenergy.com/EN/Pages/default.aspx");
		}
		else if(linkName=="clickHereLink")
		{
			window.open("https://www.directenergy.com/EN/PriceEnergy/Pages/NYEnrollment.aspx?OFFERCODE=PRICEENERGY");
		}
	}
