<!--

function UpdateDateList(objDate, numOfDays)
{
	var numOfDaysInDateObj = objDate.options.length-1;
	if (numOfDaysInDateObj > numOfDays)
	{
		difference = numOfDaysInDateObj - numOfDays;
		RemoveDateFromList(objDate, difference);		// removing dates from list
	}
	else
	{
		difference = numOfDays - numOfDaysInDateObj;
		AddDateInList(objDate, difference);		 		// adding dates in list
	}
}

function AddDateInList(objList, numOfItemsToAdd)
{
	var lstLength = objList.options.length;
	var lstLastValue = objList.options[lstLength - 1].value;	// last value of list
	for (i=1; i<= numOfItemsToAdd; i++)
	{		
		lstLastValue++;		
		objList.options[objList.options.length] = new Option(lstLastValue, lstLastValue);		
		//var oElement = document.createElement("OPTION");
		//oElement.innerText = lstLastValue;
		//oElement.value = lstLastValue;
	}	
}


function RemoveDateFromList(objList, numOfItemsToRemove)
{
	var lstLength = objList.options.length;
	var prevSelectedIndex = objList.options[objList.selectedIndex].value;
	for (i=1; i<= numOfItemsToRemove; i++)
	{
		//objList.options.remove(lstLength - i);
		objList.options[lstLength - i] = null;
	}
	// if selected date is not in range of selected dates then we select the last one date
	if (prevSelectedIndex >= objList.options.length)
	{
		objList.selectedIndex = objList.options.length - 1;	
	}
}


/*	
=========================================================================
List Biniding Functions
=========================================================================	
*/
// Forms Events Functions:
//------------------------
function onMonth_UpdateDate(objDate, objMonth, objYear)
{
	var numOfDays = null;
	var month = objMonth.options[objMonth.selectedIndex].value;
	if (month == 2)	// if month is Feb
	{
		year = objYear.options[objYear.selectedIndex].value;
		if (year.isLeapYear())
		{
			numOfDays = 29;
		}
		else
		{
			numOfDays = 28;
		}
	}
	else if ((month == 4 || month == 6 || month == 8 || month == 10 || month == 12))
	{
		numOfDays = 30;
	}
	else
	{
		numOfDays = 31;		
	}
	// subtract -1 value bcoz Month string is also reside in date combobox	
	// if date column have required date values then return
	if ((objDate.options.length-1) == numOfDays) return;	
	//UpdateDateList(objDate, numOfDays);
}

function onYear_UpdateDate(objDate, objMonth, objYear)
{
	if (objMonth.options[objMonth.selectedIndex].value != 2) return; 	// if month is not Feb then return
	var year = objYear.options[objYear.selectedIndex].value;
	if (year.isLeapYear())
	{
		//UpdateDateList(objDate, 29);			// num of days 29 in leap year for feb
	}
	else
	{
		//UpdateDateList(objDate, 28);			// normal days 28 in year which isn't leap year
	}	
}

function isValidDate( day, month, year ) {
	var dt = new Date( year, month-1, day );
	return ((day == dt.getDate()) && ( (month-1) == dt.getMonth()) && (year == dt.getFullYear()));
}

// List Binding Functions
//-----------------------
function BindMonthList(txtSelMonth)
{	
	var date = new Date();
	if (txtSelMonth != null && txtSelMonth == 'NA')
	{
		document.write ("<option selected='selected' value='NA'>Month</option>");
	}
	else
	{
		document.write ("<option value='NA'>Month</option>");
	}
	for (i=1; i<=12; i++)
	{
		if ((txtSelMonth != null) && (txtSelMonth.indexOf(i) > -1))
		{
			document.write ("<option selected value='"+ i + "'>" + i + "</option>");
		}
		//else if (i == date.getMonth())
		//{
		//	document.write ("<option selected value='"+ (i+1) + "'>" + (i+1) + "</option>");
		//}
		else
		{
			document.write ("<option value='" + i + "'>"+ i +"</option>");
		}
	}
}

function BindDateList(txtSelDate, maxDate)
{	
	var date = new Date();	
	if (maxDate == null) maxDate = 31;
	if (txtSelDate != null && txtSelDate == 'NA')
	{
		document.write ("<option selected='selected' value='NA'>Day</option>");
	}
	else
	{
		document.write ("<option value='NA'>Day</option>");
	}
	for (i=1; i<=maxDate; i++)
	{
		if ((txtSelDate != null) && (txtSelDate == i))
		{
			document.write ("<option selected value='"+ i  + "'>" + i + "</option>");
		}
		//else if (i == date.getDate())
		//{
		//	document.write ("<option selected value='"+ i + "'>" + i + "</option>");
		//}
		else
		{
			document.write ("<option value='"+ i + "'>"+ i +"</option>");
		}
	}
}

// txtSelYear: year that is need to be selected
// argStartYear: year start from
// argEndYear: where to end years if null then current year
function BindYearList(txtSelYear, subtractYears, addYears)
{	
	var date = new Date();
	if (subtractYears == null)
	{
		subtractYears = 65;
	}	
	if (addYears == null)
	{
		addYears = 0;
	}
	var fromYear = date.getFullYear() - subtractYears;
	var toYear = date.getFullYear() + addYears;

	if (txtSelYear != null && txtSelYear == 'NA')
	{
		document.write ("<option selected='selected' value='NA'>Year</option>");
	}
	else
	{
		document.write ("<option value='NA'>Year</option>");
	}
	for (var i=fromYear; i <= toYear; i++)	
	{
		if ((txtSelYear != null) && (txtSelYear == i))
		{
			document.write ("<option selected='selected' value='"+ i + "'>" + i + "</option>");
		}
		//else if (i == fromYear)
		//{
		//	document.write ("<option selected='selected' value='"+ i + "'>" + i + "</option>");
		//}
		else
		{
			document.write ("<option value='"+ i + "'>"+ i +"</option>");
		}
	}
}

function getRadioButtonValue( radioButtonName ) 
{	
	if (!radioButtonName) return false;		
	var inputTags = document.getElementsByTagName  ('input');	  
	if ( inputTags ) 
	{
		for (var i=0; i < inputTags.length; i++) 
		{
	   		if ( inputTags[i].type == 'radio' && inputTags[i].name == radioButtonName )
	   		{
		 		if (inputTags[i].checked)
		  		{
					return (inputTags[i].value);
		  		}		   	
			}
		}
  	}
	return false;
}

function AddPersonTitles( selPersonTitle )
{	
	var titles = new Array();
	titles[0] = new Array("NA", "Select Title");
	titles[1] = new Array("Dr.", "Dr.");
	titles[2] = new Array("Mr.", "Mr.");
	titles[3] = new Array("Mrs.", "Mrs.");
	titles[4] = new Array("Miss.", "Miss.");
	titles[5] = new Array("Ms.", "Ms.");
	titles[6] = new Array("other", "other");	
	for (i=0; i<titles.length; i++)
	{
		if (titles[i][0] == selPersonTitle)
			document.write ('<option selected="selected" value="'+ titles[i][0] +'">'+ titles[i][1] +'</option>');		
		else		
			document.write ('<option value="'+ titles[i][0] +'">'+ titles[i][1] +'</option>');				
	}
}

function SetCookie(sKey, sValue, expireInHours)	// expire time
{
	var objDate = new Date();		
	var expiryTime = objDate.getTime() + (expireInHours * 60 * 60 * 1000);
	objDate.setTime(expiryTime);
	document.cookie = sKey + "=" + sValue + "; expires=" + objDate.toGMTString();
}	

function GetCookie(sKey)
{	
	var key_length = sKey.length;	
	var cookieData = document.cookie;	
	var cookie_length = cookieData.length;
	var cookie_end = null;
	var i = 0;		
	while (i < cookie_length) 
	{
		var j = i + key_length;
		if (cookieData.substring(i,j) == sKey) 
		{
			cookie_end = cookieData.indexOf(";",j)
			if (cookie_end == -1)
			{
				cookie_end = cookie_length;
			}
			return unescape(cookieData.substring( j + 1, cookie_end));
		}		
		i++;
	}
	return null;
}

// multiple selection for some list
function SelectListOptions(comaSeprateVal, objSelect)
{
	if (!comaSeprateVal) return;	
	var arr = comaSeprateVal.split(",");
	for (i=0; i<arr.length; i++)
	{
		for (j=0; j < objSelect.length; j++)
		{
			if (arr[i] == objSelect[j].value)
			{
				objSelect[j].selected = true;
			}
		}
	}	
}

function IsAnyItemSelected(txtCheckBoxInitial, minValue, maxValue)
{
	for (var i = minValue; i <= maxValue; i++)
	{
		var objCheck = document.getElementById(txtCheckBoxInitial + i);
		if (objCheck)
		{
			if (objCheck.checked) return true;
		}
	}	
	return false;
}

function TextBox_AllowOnlyNumbers(evt) 
{	
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))  return false;
    return true
}
-->