/*********************************************
* Client Side Validation & Screen Functionality Scripts Starts Here
* Last Updated On: 11 Jul 2002
**********************************************/
function validateCurrency( strValue)
{
  var objRegExp = /(^\$\d{1,3}(,\d{3})*\.\d{2}$)|(^\(\$\d{1,3}(,\d{3})*\.\d{2}\)$)/;
  return objRegExp.test( strValue );
}

function validateTime ( strValue )
{
/************************************************
REMARKS: Returns True for time formats such as:
  HH:MM or HH:MM:SS or HH:MM:SS.mmm (where the
  .mmm is milliseconds as used in SQL Server
  datetime datatype.  Also, the .mmm portion will
  accept 1 to 3 digits after the period)
*************************************************/
  var objRegExp = /^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;
  return objRegExp.test( strValue );
}

function validateState (strValue )
{
  var objRegExp = /^(AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NB|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i;
  return objRegExp.test(strValue);
}

function validateSSN( strValue )
{
  var objRegExp  = /^\d{3}\-\d{2}\-\d{4}$/;
  //check for valid SSN
  return objRegExp.test(strValue);
}


function validateEmail( strValue)
{
  var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
  //check for valid email
  var val = objRegExp.test(strValue);
  if (val == true)
  {
	for (var i = 0; i < strValue.length; i++)
	{
		if (strValue.charAt(i) == "@")
		{
			if (strValue.charAt(i+1) == ".")
				val = false;
		}
		if (strValue.charAt(i) == ".")
		{
			if (strValue.charAt(i+1) == ".")
				val = false;
		}
	}
  }
  return val;
}

function validateUSPhone( strValue )
{
/************************************************
 Validates that a string contains valid
  US phone pattern.
  Ex. (999) 999-9999 or (999)999-9999
*************************************************/
 //var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
  var objRegExp  = /(^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$)|(^\+((\d{1})|(\d{2})|(\d{3}))\([1-9]\d{2}\)\s?\d{3}\-\d{4}$)/;

  //check for valid us phone with or without space between
  //area code
  return objRegExp.test(strValue);
}

function  validateNumeric( strValue )
{
/*****************************************************************
DESCRIPTION: Validates that a string contains only valid numbers.
*****************************************************************/
  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
  //check for numeric characters
  return objRegExp.test(strValue);
}

function validateInteger( strValue )
{
/************************************************
DESCRIPTION: Validates that a string contains only
    valid integer number.
*************************************************/
  var objRegExp  = /(^-?\d\d*$)/;
  //check for integer characters
  return objRegExp.test(strValue);
}

function validateIntegerOnly( strValue )
{
/************************************************
DESCRIPTION: Validates that a string contains only
    valid integer number.
*************************************************/
  var objRegExp  = /(^\d\d*$)/;
  //check for integer characters
  return objRegExp.test(strValue);
}

function validatePositiveInteger( strValue )
{
/************************************************
DESCRIPTION: Validates that a string contains only
    valid positive integer or decimal.
*************************************************/
  var objRegExp  = /(^\d\d*$)|(^\d\d*\.\d*$)/;
  //check for positive integers
  return objRegExp.test(strValue);
}

function validateNotEmpty( strValue )
{
/************************************************
DESCRIPTION: Validates that a string is not all
  blank (whitespace) characters.
*************************************************/
   var strTemp = strValue;
   strTemp = trimAll1(strTemp);
   if(strTemp.length > 0){
     return true;
   }
   return false;
}

function validateUSZip( strValue )
{
/************************************************
DESCRIPTION: Validates that a string a United
  States zip code in 5 digit format or zip+4
  format. 99999 or 99999-9999
*************************************************/
var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;

  //check for valid US Zipcode
  return objRegExp.test(strValue);
}

function validateUSDate( strValue,flag )
{
/************************************************
DESCRIPTION: Validates that a string contains only
    valid dates with 2 digit month, 2 digit day,
    4 digit year. Date separator can be ., -, or /.
    Uses combination of regular expressions and
    string parsing to validate date.
    Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy
*************************************************/
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;

  //check to see if in correct format
  if(!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    var arrayDate = strValue.split(RegExp.$1); //split date into month, day, year
	var intDay = parseInt(arrayDate[1],10);
	var intYear = parseInt(arrayDate[2],10);
    	var intMonth = parseInt(arrayDate[0],10);
	var today = new Date();

var iMonth = today.getMonth() + 1;
var iDate = today.getDate();
var iYear = today.getYear();

	var curYear = today.getYear();

	if (document.layers)
		curYear = curYear + 1900;

	//check for valid month
	if((intMonth > 12) || (intMonth < 1))
	{
		return false;
	}

	//check if current year is greater then entered date
	if (flag != true) //gendral
	{

		var givenDate = new Date(intMonth + "/" + intDay + "/" + intYear);
		var thisDate =  new Date(iMonth + "/" + iDate + "/" + iYear);

		if (givenDate < thisDate)
		{
			return false;
		}
	}

    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}

    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] != null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
        return true; //found in lookup table, good date
    }

    //check for February
	var booLeapYear = (intYear % 4 == 0 && (intYear % 100 != 0 || intYear % 400 == 0));
    if( ((booLeapYear && intDay <= 29) || (!booLeapYear && intDay <=28)) && intDay !=0)
      return true; //Feb. had valid number of days
  }
  return false; //any other values, bad date
}

function validateString( strValue ) {

/********************************************
DESCRIPTION: Validates only for alphabets
*********************************************/
	//var objRegExp  =  /(^[\a-z]*$)|(^[\A-Z]*$)|(^[\A-Z][\a-z]*$)/;
	//return objRegExp.test(strValue);

   if (!strValue) return false;
   var iChars = "*|,\":<>[]{}`\';()@&$#%1234567890";

   for (var i = 0; i < strValue.length; i++) {
      if (iChars.indexOf(strValue.charAt(i)) != -1)
         return false;
   }
   return true;
}


//Same as trimAll, diffrence is that this is used in validateNotEmpty()
function trimAll1( strValue )
{
/************************************************
DESCRIPTION: Removes leading and trailing spaces.
*************************************************/
 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;
}
/* To limit the length of text area
pass the control name and maxlength */

function textCounter(field, maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);

}

/*****************************************************
DESCRIPTION: Validates Number datatypes with 2 decimals
Author: Rajesh Shet
Date: 17-July-2001
*****************************************************/

// function to round the value to 2 decimal places
function Rounder(val,decs)
{
	var multiplier = 10
	for (var i = 1;i < decs;++i)
		multiplier = (multiplier * 10) ;
	if (decs==0)
		return Math.round(val);
	else
		return PadDecimal((Math.round(val *multiplier))/multiplier, decs)  ;
}


function PadDecimal(val, decs)
{
//Function to pad a decimal for the Commission entry text boxes
	var strVal = val.toString()  ;
	var decimal = strVal.indexOf(".");
	if(decimal == -1)
	{
		wholeLength = strVal.length ;
		strVal += ".";
	}
	else
		wholeLength = decimal ;
	newLength = wholeLength + eval(decs) + 1;
	if (newLength > strVal.length)
	{
	var padTotal = newLength - strVal.length;
	for (var i = 1; i <= padTotal;i++);
	strVal += "0";
	}
	return strVal;
}

//This function trims the given string and checks for unnecessary spaces

function IsValidFee(ctrl)
{
	ctrl.value=	trim(ctrl.value);
	if	(isNaN(ctrl.value )||(ctrl.value==""))
	{
		alert("Invalid Entry! Please enter a positive value.");
		//ctrl.value ="";
		ctrl.focus();
		ctrl.select();
		return false;
	}
	return true;
}

function trim( inputStringTrim )
{
//function to trims the given string and checks for unnecessary spaces
	fixedTrim = "";
	lastCh = " ";
	for (x=0; x < inputStringTrim.length; x++)
	{
		ch = inputStringTrim.charAt(x);
		if ((ch != " ") || (lastCh != " "))
		{
			fixedTrim += ch;
		}
		lastCh = ch;
	}
		if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {
			fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1);
		}
		return fixedTrim;
}

function validateFloat(ctrl,maxlen)
{

/*
The following functions are used internally.
1. function Rounder(val,decs)
2. function PadDecimal(val, decs)
3. function IsValidFee(ctrl)
4. function trim( inputStringTrim )

*/
	for (x=0; x < ctrl.value.length; x++)
	{
		ch = ctrl.value.charAt(x);
		//alert(ch);
		if (ch == ".")
			break;
	}
	maxlen=maxlen - 3;
	if(x > maxlen)
	{
		alert("The number entered should be less than or equal to "+ maxlen + " digits with 2 decimal places.");
		ctrl.focus();
		return false;
	}


	if (trim(ctrl.value) =="")
	{
		ctrl.value = 0;
	}
	else
	{
		//if(!isNaN(ctrl.value))
		//	ctrl.value= Rounder(ctrl.value,2)
		if (! IsValidFee(ctrl))
		{
			return false;
		}
		ctrl.value= Rounder(ctrl.value,2)
	}

	return true;
}

function ReturnLstSelectedIndex( lstName ) {
/************************************************
DESCRIPTION: Get the Index of the Combo Box.
*************************************************/
      var index;
      for(a=0;a < document.forms[0].elements.length; a++)
      {
              if (document.forms[0].elements[a].type == "select-one")
              {
                      if(document.forms[0].elements[a].name == lstName)
                      {
                              index = a;
                      }
              }
      }
      return index;
}

function ReturnCtrIndex(ctrName, ctrType) {
/************************************************
DESCRIPTION: Get the Index of the specified control
*************************************************/
      var index;
      for(a=0;a < document.forms[0].elements.length; a++)
      {
              if (document.forms[0].elements[a].type == ctrType)
              {
                      if(document.forms[0].elements[a].name == ctrName)
                      {
                              index = a;
                      }
              }
      }
      return index;
}

function ReturnLstSelectedText( lstName ) {
/************************************************
DESCRIPTION: Read The Text from List / Combo Box.
*************************************************/
      var selectedText = "";
      for(a=0;a < document.forms[0].elements.length; a++)
      {
              if (document.forms[0].elements[a].type == "select-one")
              {
                      if(document.forms[0].elements[a].name == lstName)
                      {
                              selectedText = document.forms[0].elements[a][document.forms[0].elements[a].selectedIndex].text;
                      }
              }
      }
      return selectedText;
}

function ReturnLstSelectedValue(lstName) {
/************************************************
DESCRIPTION: Read The Value from List / Combo Box.
*************************************************/
      var selection = "";
      for(a=0;a < document.forms[0].elements.length; a++)
      {
              if (document.forms[0].elements[a].type == "select-one")
              {
                      if(document.forms[0].elements[a].name == lstName)
                      {
                              selection = document.forms[0].elements[a][document.forms[0].elements[a].selectedIndex].value;
                      }
              }
      }
      return selection;
}

function ReturnTxtSelected(ctrName) {
/************************************************
DESCRIPTION: Read The Value from hidden type control
*************************************************/
      var selection = "";
      for(a=0;a < document.forms[0].elements.length;a++)
      {
              if (document.forms[0].elements[a].type == "hidden")
              {
                      if(document.forms[0].elements[a].name == ctrName)
                      {
                              selection = document.forms[0].elements[a].value;
                      }
              }
      }
      return selection;
}

function ReturnOptSelected(ctrName){
/************************************************
DESCRIPTION: Read The Value from Selected Radio Button
*************************************************/
      var selection = "";
      for(a=0; a < document.forms[0].elements.length; a++)
      {
              if (document.forms[0].elements[a].type == "radio")
              {
                      if(document.forms[0].elements[a].name == ctrName)
                      {
                              if (document.forms[0].elements[a].checked == true)
                              {
                                      selection = document.forms[0].elements[a].value;
                              }
                      }
              }
      }
      return selection;
}

function ConfirmAction(Message, causesValidation)
{
/************************************************
DESCRIPTION: Shows a confirm Message Pop Up Before Add Update Delete Operations.
*************************************************/	
	var returnValue = true;
	
	if (causesValidation){
		if (typeof(Page_ClientValidate) == 'function') 
		returnValue = Page_ClientValidate(); 	
		Page_ValidationActive = false;
	}

	if (returnValue)
		returnValue = window.confirm(Message);

	return returnValue;
	
/*	var returnValue = false;
	returnValue = window.confirm(Message);

	if (returnValue && causesValidation){
		if (typeof(Page_ClientValidate) == 'function') 
		returnValue = Page_ClientValidate(); 	
	}
	return returnValue;
*/
}


function PopUpCalender(frmName)
{
	if(navigator.userAgent.indexOf("MSIE")>0)
	{
		var winLeft = window.event.screenX + (74 - window.event.offsetX)
		var winTop = window.event.screenY  - (window.event.offsetY + 3)
		var calendar_window=window.open(frmName,'calendar_window','width=230,height=195,top=' + winTop + ',left=' + winLeft);
	}
	else
		var calendar_window=window.open(frmName,'calendar_window','width=230,height=195');
	calendar_window.focus();
	return calendar_window ;
}

function GetWidth(){       
	var availWidth;
	
	if (document.all)               
	{                     		   
		availWidth = document.body.offsetWidth;					
	}
	else if (document.layers)
	{                     
		availWidth = window.outerWidth;     					
	}   
	
	//correction applied			
	if(availWidth < 955)
		return 955
	else
		availWidth -= 25;
	return availWidth;         
}

function GetHeight(){       

	var availHeight;
	
	if (document.all)               
	{                     		   
		availHeight = document.body.offsetHeight;					
	}
	else if (document.layers)
	{                     
		availHeight = window.outerHeight;
	}       
		
	//correction applied			
	availHeight -= 74;
	return availHeight;         
}	

function SetDivSize()
{	
	var obj;		
	obj = document.getElementById("mainDiv");	
	if (obj)
	{			
		obj.style.height = GetHeight();
		obj.style.width = GetWidth(); 		
	}
	return;
}		


function PopUpCalendar(frmName,sender)
{	
	if(event.srcElement.disabled == false)
	{
		if(event.shiftKey)
		{			
			var today = new Date();
			var date = (today.getMonth() + 1) + "/" + today.getDate() + "/" + today.getFullYear();
			var queryString = frmName.split("=");
			if(queryString.length == 2)
			{
				eval(queryString[1] + ".value = date");
			}
			
		}
		else
		{
			if(navigator.userAgent.indexOf("MSIE")>0)
			{
				var winLeft = window.event.screenX - (window.event.offsetX + 100)
				if((winLeft + 245) > window.screen.availWidth)
				{				
					winLeft	= window.screen.availWidth - 350;
				}			
				var winTop = window.event.screenY  - (window.event.offsetY + 100)
				var calendar_window=window.open(frmName,'calendar_window','width=245,height=225,top=' + winTop + ',left=' + winLeft);
			}
			else
				var calendar_window=window.open(frmName,'calendar_window','width=245,height=195');

			calendar_window.focus();	
			return calendar_window ;
		}
	}
}
/********* Function for checking and unchecking a checkbox depending upon a Master checkBox ********/
//Added by KIrti Patangia
//Kin ID : 17736

	function CheckUncheckAll(objHeaderChk)
		{
			   var objColl =  document.getElementsByTagName("INPUT");
				for(var i = 0; i < objColl.length; i++)
				{
					
							if(objColl[i].type == "checkbox")
							{
									if(objColl[i] != objHeaderChk)
									{
										if(objHeaderChk.checked == true)
										{
											objColl[i].checked = true;
										}
										else
										{
											objColl[i].checked = false;
										}
										objColl[i].onclick();
									}
							}	
				}
			}//End of Function
		

/********* End of Function for checking and unchecking a checkbox depending upon a Master checkBox ********/


///////////////////////////////////////////////////////////////////////////////
////////// Added By Ankit D Barot on 03-Mar-2006  START
//////////  	For Allowing Maximum typeable characters for the TextArea Field	
///////////////////////////////////////////////////////////////////////////////
function fnAllowMaxChars(controlName,maxLength)
{
	 if ( controlName.value.length >= maxLength )	   
	 {
			window.returnValue = false;
			event.keyCode = 0;
			return false;
	 }
		//alert(controlName.value.length);
}

function fnSetFocus(controlName)
{	
	//alert(typeof(controlName));
	//alert(controlName.type);
	//alert(controlName.value);
	if ( typeof(controlName) == "object" && controlName.type != "hidden" )
	{
		controlName.focus();
	}
}

function fnAllowOnly(allowedlist)
{
		var lsPressedKey;		
		var sAllowedChars = String(allowedlist);//'0123456789.';
		lsPressedKey	= String.fromCharCode(event.keyCode);			
		//alert(event.keyCode);
		//alert(lsPressedKey);
		//sAllowedChars	= String(allowedlist);		
		if ( sAllowedChars.indexOf( String( lsPressedKey )  ) != -1 )
		{ 
			//alert("Return true");
			return true ;	
		}
		else
		{
			window.returnValue		= false;
			event.keyCode			= 0;			
			//alert("Return false");
			return false ;	
		}
}//end of function fnAllowOnly(allowedlist)


function fnAllowMaxCharsPaste(control,maxLength)
{
    //alert(window.clipboardData.getData( "text" ).length);
    //alert(control.value.length);
    if (window.clipboardData.getData( "text" ).length + control.value.length > maxLength )
    {
		//alert('fail');
		window.clipboardData.setData("text","");
    }
}//end of function fnAllowMaxCharsPaste(control,maxLength)


function fnAllowOnlyDrop(controlName)
{
	return false;
}//end of function fnAllowOnlyDrop(controlName)

	function fnAllowOnlyPaste(controlName)
	{
//		window.event.cancelBubble = true;
//		window.returnValue = false;
		var lPreviousValue = controlName.value;
		var lsData;
		var lbRetVal;
		var liCharCode;

		psAllowChars = '0123456789.' ;
		//get the data in the clipboard
		lsData		= String( window.clipboardData.getData( "text" ) );
		lbRetVal = false; 

		for ( var iCtrj=0; iCtrj < String( lsData ).length; iCtrj++ )
		{
			liCharCode		= String( String( lsData ).substr( iCtrj, 1) ).charCodeAt(0);

			if ( liCharCode == 13 || liCharCode == 10)
			{
				continue;
			}

			if ( psAllowChars.indexOf( String( lsData ).substr( iCtrj, 1 ) ) != -1 )
			{
				lbRetVal	= true;
			}
			else
			{
				lbRetVal	= false;
				/*window.returnValue = false;
				window.keyCode =0;
				window.event.cancelBubble = true;*/				
				break ;
			}		
		}

		if ( lbRetVal == false )
		{
		  window.clipboardData.setData("text","");		
		  //controlName.value = lPreviousValue;
		}
	}//end of function 
	
	
	
	
	function fnAllowMaxChars(controlName,maxLength)
	{
		//if ( controlName.value.length >= 5 )
	   if ( controlName.value.length >= maxLength )	   
	   {
			window.returnValue = false;
			event.keyCode = 0;
			return false;
	   }
		//alert(controlName.value.length);
	}
	
	function fnIsMemberSelected()
	{
		//alert(window.document.all.memberXComboBox.selectedIndex);	
		if ( typeof(window.document.all.memberXComboBox) == "object" )
		{
				if ( window.document.all.memberXComboBox.selectedIndex == 0 )
				{
					if ( typeof(window.document.all.trPaymentsLabel) == "object" )
					{
						  window.document.all.trPaymentsLabel.style.display = "none";
						  window.document.all.trNewPaymentBar.style.display = "none";	
					}
					
				}
				else if ( window.document.all.memberXComboBox.selectedIndex > 0 )
				{
						if ( typeof(window.document.all.trPaymentsLabel) == "object" )
						{
								window.document.all.trPaymentsLabel.style.display = "block";
								window.document.all.trNewPaymentBar.style.display = "block";		  
						}
				}
		}
	}
//The function can used when user checks/unchecks checkbox and we want enable/disable particular control	
function EnableDisableNoOfGuestAllowedTxtBx(checkBox,targetControlName)	
{	
	if ( "undefined" != typeof(checkBox) ) 
	{
		if ( checkBox.checked )
		{
			if ( "undefined" != typeof(document.getElementById(targetControlName)) )
			{
				document.getElementById(targetControlName).disabled = false;
				//document.getElementById(targetControlName).onkeypress = "fnAllowOnly('0123456789')";
			}
		}
		else
		{
			if ( "undefined" != typeof(document.getElementById(targetControlName)) )
			{
				document.getElementById(targetControlName).disabled = true;
			}	
		}
	}
}
function fnReg_WantToAddValidations()
{
	var objwantToAddTablesRBtn = document.getElementById("wantToAddTablesRBtn");
	var objwantToAddGuestRBtn = document.getElementById("wantToAddGuestRBtn");
	var objaddTableTextBx = document.getElementById("addTableTextBx");
	var objaddGuestTextBx = document.getElementById("addGuestTextBx");
	
	if ( objwantToAddTablesRBtn.checked )
	{
			if ( typeof(objaddTableTextBx) == "object" )
			{
				if ( objaddTableTextBx.value == "" || objaddTableTextBx.value <= 0 )
				{
					document.getElementById("divForWantToAddTable").style.display = 'block';
					return false;			
				}
				else
				{
					document.getElementById("divForWantToAddTable").style.display = 'none';
					return true;			
				}
			}
		}//end of if ( objwantToAddTablesRBtn.checked )
		else
		{
			if ( typeof(objaddGuestTextBx) == "object" )
			{
				if ( objaddGuestTextBx.value == "" || objaddGuestTextBx.value <= 0 )
				{
					//alert('dd');
					document.getElementById("divForWantToAddGuest").style.display = 'block';
					return false;			
				}
				else
				{
					document.getElementById("divForWantToAddGuest").style.display = 'none';
					return true;			
				}
			}
		}
		//document.getElementById("divForWantToAddTable").style.display = 'none';
	
	
/*<SPAN id=reqValAddGuestTextBx style="COLOR: red" initialvalue="" 
display="Dynamic" errormessage="Please enter numeric value (1 to 99).<BR>" 
controltovalidate="addGuestTextBx" isvalid="false">Please enter numeric value (1 
to 99).	 */
}
///////////////////////////////////////////////////////////////////////////////
////////// Added By Ankit D Barot on 03-Mar-2006  END	
///////////////////////////////////////////////////////////////////////////////


/************************************************************/

function RegisterSubmitButton(buttonClientID){
	// Code to submit the page when the enter key is pressed
	Page.RegisterHiddenField("__EVENTTARGET", buttonClientID); 
}

///////////////////////////////////////////////////////////////////////////////
////////// Added By Kirti patangia on 12-Apr-2006  
///////////////////////////////////////////////////////////////////////////////

	function ABC()
	{
		var selPriSponser =  document.getElementById("primarySponsorHidden");
		var lblPriSponser = document.getElementById("primarySponsorLabel");
		var hidPriSponser = document.getElementById("primarySponsorIDXTextBox");
		var sepData = selPriSponser.value.split("|");
		lblPriSponser.innerText = sepData[1];
		hidPriSponser.value = sepData[0];
	}
	
	function PostbackForMember()
	{
		
		__doPostBack('donothing', null);
		
	}
	function WindowOpen()
	{
		window.open("candidateHelp.aspx","Candidate","height=650,width=800,status=yes,toolbar=No,menubar=no,location=no,top=0,left=0,scrollbars=yes");
		return false;
	}	
	function BioDataFilenotUploaded(sender, args)
	{		
		if (document.CandidateUploadDocumentForm.bioDataFileUpload.value.length ==0 )
		{
			args.IsValid = false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function Sponsor1FilenotUploaded(sender, args)
	{		
		if (document.CandidateUploadDocumentForm.sponsor1FileUpload.value.length ==0 )
		{
			args.IsValid = false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function Sponsor2FilenotUploaded(sender, args)
	{		
		if (document.CandidateUploadDocumentForm.sponsor2FileUpload.value.length ==0 )
		{
			args.IsValid = false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function document1FilenotUploaded(sender, args)
	{		
		if (document.CandidateUploadDocumentForm.document1FileUpload.value.length ==0 )
		{
			args.IsValid = false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function document2FilenotUploaded(sender, args)
	{		
		if (document.CandidateUploadDocumentForm.document2FileUpload.value.length ==0 )
		{
			args.IsValid = false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	
	/*start of code for validators*/
	function ValidateLength500(sender, args)
	{
	 	//alert(args.length);
		if (args.Value.length > 500 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}	
	function ValidateLength300(sender, args)
	{
	 	//alert(args.length);
		if (args.Value.length > 300 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function ValidateLength4000(sender, args)
	{
	 	//alert(args.length);
		if (args.Value.length > 4000 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function ValidateLength6000(sender, args)
	{
	 	//alert(args.length);
		if (args.Value.length > 6000 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function ValidateLength1000(sender, args)
	{
	 	if (args.Value.length > 1000 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	
	function ValidateLength5000(sender, args)
	{
		if (args.Value.length > 5000 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	
	//Added By Ankit Bansal On 02-Sep-2008 To Validate Special Instruction and Parking Information In Private Dinner Screen 
	function ValidateLength2000(sender, args)
	{
	 	//alert(args.length);
		if (args.Value.length > 2000 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	//End of Addition By Ankit Bansal As on 02-Sep-2008
	
	function ValidateLength200(sender, args)
	{
	 	//alert(args.length);
		if (args.Value.length > 200 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	function ValidateLength400(sender, args)
	{
	 	
			//alert(args.length);
		if (args.Value.length > 400 )
		{
			args.IsValid=false;
		}
		else
		{
			args.IsValid = true;
		}
	}
	
	/// Code Added for Committee Member
		//Validates End date
	function ValidateTenureDate(sender, args)
	{
	 	var stDate = new Date(document.committeeMemberForm.tenureStartDateTextBox.value);
		var endDate = new Date(document.committeeMemberForm.tenureEndDateTextBox.value);
		
		if ( stDate > endDate )
		{
			args.IsValid = false;
		}
		else
		{
			args.IsValid = true;
		}
	}	
	    function MoveOption(objSourceElement, objTargetElement)
	    {
        var aryTempSourceOptions = new Array();
        var x = 0;
        
        //looping through source element to find selected options
        for (var i = 0; i < objSourceElement.length; i++) {
            if (objSourceElement.options[i].selected) {
                //need to move this option to target element
                var intTargetLen = objTargetElement.length++;
                objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
                objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
            }
            else {
                //storing options that stay to recreate select element
                var objTempValues = new Object();
                objTempValues.text = objSourceElement.options[i].text;
                objTempValues.value = objSourceElement.options[i].value;
                aryTempSourceOptions[x] = objTempValues;
                x++;
            }
        }
        
        //resetting length of source
        objSourceElement.length = aryTempSourceOptions.length;
        //looping through temp array to recreate source select element
        for (var i = 0; i < aryTempSourceOptions.length; i++) {
            objSourceElement.options[i].text = aryTempSourceOptions[i].text;
            objSourceElement.options[i].value = aryTempSourceOptions[i].value;
            objSourceElement.options[i].selected = false;
        }
    }
    
    function MoveAll(objSourceElement, objTargetElement)
    {
        var aryTempSourceOptions = new Array();
        var x = 0;
        
        //looping through source element to find selected options
       for (var i = 0; i < objSourceElement.length; i++) 
       {
                //need to move this option to target element
                var intTargetLen = objTargetElement.length++;
                objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
                objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
       
        }
        
        //resetting length of source
        objSourceElement.length = aryTempSourceOptions.length;
        //looping through temp array to recreate source select element
        for (var i = 0; i < aryTempSourceOptions.length; i++) {
            objSourceElement.options[i].text = aryTempSourceOptions[i].text;
            objSourceElement.options[i].value = aryTempSourceOptions[i].value;
            objSourceElement.options[i].selected = false;
        }
    }

	//End of coded for Committee Members
	
/*End of code for validators*/


/* Code for Products */

		function TranscriptFilenotUploaded(sender, args)
		{		
			if (document.AddProductTranscriptForm.transcriptFileUpload.value.length ==0 )
			{
				args.IsValid = false;
			}
			else
			{
				args.IsValid = true;
			}
		}
		//function specified below will enable\disable
		//the quantity checkbox depending upon the checkbox clicked.
		
		function funEnableProductControls(ctrl)
		{	
			var obj = document.getElementById(ctrl);
			if(obj.disabled==true)
			{
				obj.disabled = false;
				obj.className = "form_label";
			}
			else
			{
				obj.value = "0";
				obj.disabled = true;
				obj.className = "disabled_input";
		}
	
	
	
}
/* End of Code for Products */

	
///////////////////////////////////////////////////////////////////////////////
////////// End of Code added by Kirti patangia on 12-Apr-2006  
///////////////////////////////////////////////////////////////////////////////
	
///////////////////////////////////////////////////////////////////////////////
////////// Start of code Added By Sheetal Desai on 12-Apr-2006  
////////// To call the member popup
///////////////////////////////////////////////////////////////////////////////

function callmemberpopup(navURL)
{
	var popupWindowName = window.open(navURL,null,'left=100, top=100, height=550, width= 900, status=no, resizable=no, scrollbars=yes, toolbar=no,location=no, menubar=no');
	popupWindowName.focus(); //Added By Ankit D Barot on 23-Aug-06, as we want the window to be highlighted.
}

//Added By Ankit D Barot on 29 Aug 06 For "Reconcile" link START
function callmemberpopupForReconcile(navURL)
{
	//navURL = navURL + "&ReconcileFirstName=" + document.getElementById("firstNameTxtBx").Text;
	navURL = navURL + "&ReconcileFirstName=" + document.all["firstNameTxtBx"].value;
	//alert(navURL);
	var popupWindowName = window.open(navURL,null,'left=100, top=100, height=550, width= 900, status=no, resizable=no, scrollbars=yes, toolbar=no,location=no, menubar=no');
	popupWindowName.focus(); //Added By Ankit D Barot on 23-Aug-06, as we want the window to be highlighted.
}
//Added By Ankit D Barot on 29 Aug 06 For "Reconcile" link END
	
///////////////////////////////////////////////////////////////////////////////
////////// End of Code added By Sheetal Desai on 12-Apr-2006   
///////////////////////////////////////////////////////////////////////////////

function ListBoxValidation(obj,args)
{		
	selectedColumns = document.forms[0].selectedColumnsXListBox.selectedIndex;
	availableColumns = document.forms[0].availableColumnsXListBox.selectedIndex;
	if(selectedColumns == -1 && availableColumns == -1)
	{
		args.IsValid=false;
		
	}	
}

///Added by Thiruma on 15 Apr 2006
///Purpose: Checks ShowOnWebCheck box when Online reigistration check box is checked
function ShowOnWebCheck()
{
	if ( document.MeetingForm.onlineRegXCheckBox.checked )
	{
		document.MeetingForm.showOnWebXCheckBox.checked = true;
	}
}

/****************************************************
* Client Side Validation & Screen Functionality Scripts Ends Here
*****************************************************/

function SetControlFocus(ctrlID){
	
	if(document.getElementById('" + ctrlID + "') != null){

		var isObjectVisible = false;		
		
		var obj = eval("document.getElementById('" + ctrlID + "')"); 
		if (obj.style){
			isObjectVisible = (obj.style.visibility == "");
		}else if (obj.visibility){
			isObjectVisible = (obj.visibility == "");
		}
		if (isObjectVisible){
			obj.scrollIntoView(true);
			obj.focus();
		}
	}
}

//This is used to display the combo box item based on the text selected in a text box
function autoComplete (field, select, property, forcematch) 
{
	var found = false;
	for (var i = 0; i < select.options.length; i++) 
	{
		if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { select.selectedIndex = i; }
	else { select.selectedIndex = -1; }
	if (field.createTextRange) {
	if (forcematch && !found) {
		field.value=field.value.substring(0,field.value.length-1); 
		return;
	}
	var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
	if (cursorKeys.indexOf(event.keyCode+";") == -1) {
		var r1 = field.createTextRange();
		var oldValue = r1.text;
		var newValue = found ? select.options[i][property] : oldValue;
		if (newValue != field.value) {
			field.value = newValue;
			var rNew = field.createTextRange();
			rNew.moveStart('character', oldValue.length) ;
			rNew.select();
		}
	}
 }
}
function clearText(txtFld)
{
	
}

// Code to disable the CTRL+N Key combination
function disableCtrlKeyCombination(e)
{
        //list all CTRL + key combinations you want to disable
        var forbiddenKeys = new Array('n');
        var key;
        var isCtrl;
        if(window.event)
        {
                key = window.event.keyCode;     //IE
                if(window.event.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }
        else
        {
                key = e.which;     //firefox
                if(e.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }
        
        //if ctrl is pressed check if other key is in forbidenKeys array
        if(isCtrl)
        {
                for(i=0; i<forbiddenKeys.length; i++)
                {
                        //case-insensitive comparation
                        if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
                        {
                                alert("Key combination CTRL + "
                                        +String.fromCharCode(key)
                                        +" has been disabled.");
                                return false;
                        }
                }
        }
        return true;
}


function printContent()
{
	var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
	var content_vlue = document.getElementById("print_content").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>ECC Web Application</title>'); 
   docprint.document.write('<link rel="stylesheet" href="../style/print.css"  TYPE="text/css" />');   
   docprint.document.write('</head><body onLoad="self.print()"><center>');  
   docprint.document.write('<table width="100%" border="0"><tr id="white"><td class="form_label"  align="right"><a href="javascript:window.close();">Close</a></td></tr></table>');
   docprint.document.write(content_vlue);
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}
