String.prototype.trim = function () 
{
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

document.write('<script language="javascript" src="../Scripts/CSJSRequestObject.js"><\/script>');
document.write('<script language="javascript" src="../Scripts/thumbnailviewer.js"><\/script>');
document.write('<link rel="stylesheet" href="../css/thumbnailviewer.css" type="text/css" />');	
document.write('<link rel="stylesheet" href="../css/anylink.css" type="text/css" />');	
document.write('<script language="javascript" src="../Scripts/anylink.js"><\/script>');
document.write('<script language="javascript" src="../Scripts/AC_RunActiveContent.js"><\/script>');

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if(typeof window.onload != "function")
	{
		window.onload = func;
	}
	else
	{
		window.onload = function() 
		{
			if (oldonload) 
			{
				oldonload();
			}
			func();
		}
	}
}

function backURL(where)
{	
    if (where != null)
    {
        document.location ='/';
    }
    else if(Request.QueryString('back').Count > 0 && Request.QueryString('back') != null)
	{	
		document.location = Request.QueryString('back');
	}
	else if (document.referrer != null || document.referrer != "")
	{
		document.location=document.referrer;
	}
	else
	{
		document.location ='/';
	}
}

function StartCountDown()
{	
	if(document.getElementById("RedirectTbl"))
	{
		var timer = setInterval('CountDown('+timer+')', 1000);											
	}
}
function CountDown(timer)
{
	Display = document.getElementById("CountSec").innerText;
					
	cTicks = parseInt(Display,10); 					
	
	if( cTicks )
	{
		--cTicks;
		if(cTicks <10)
		{
			document.getElementById("CountSec").innerText = '0'+cTicks;
		}
		else
		{
			document.getElementById("CountSec").innerText = cTicks;
		}
	}
	else
	{
		clearInterval(timer);
		document.location ='/';
	}
}

function ClearForm()
{
	for (i = 0; (i < document.forms.length); i++) 
	{
		document.forms[i].reset();
	}	
	for(i=0;i< Page_Validators.length;i++) 
	{ 
		ValidatorValidate(Page_Validators[i]) ;
	}
}

/*** for referral ***/
function EnableNames(ControlNum)
{	

    document.getElementById('lblResult'+ControlNum).innerHTML = "";
    	
	if(document.getElementById('txtContactEmail'+ControlNum))
	{		
		ValidatorValidate(document.getElementById('revContactEmail'+ControlNum));
		/*alert(document.getElementById('txtContactEmail'+ControlNum).value.trim().length);
		alert(document.getElementById('revContactEmail'+ControlNum).isvalid);*/		
		if(document.getElementById('txtContactEmail'+ControlNum).value.trim().length != 0) 
		{			
			if(document.getElementById('revContactEmail'+ControlNum).isvalid)
			{
				document.getElementById('txtFirstName'+ControlNum).disabled = false;
				document.getElementById('txtLastName'+ControlNum).disabled = false;	
				document.getElementById('btnSubmit').disabled = false;						
				document.getElementById('txtFirstName'+ControlNum).focus();
				document.getElementById('txtFirstName'+ControlNum).select();
				ValidateNames(ControlNum);
				
			}
			else
			{
				document.getElementById('txtFirstName'+ControlNum).disabled = true;
				document.getElementById('txtLastName'+ControlNum).disabled = true;
				document.getElementById('btnSubmit').disabled = true;
				document.getElementById('lblStatus'+ControlNum).style.display = "none";
				document.getElementById('lblResult'+ControlNum).style.display = "";					
			}		
		}
		else
		{
			document.getElementById('txtFirstName'+ControlNum).disabled = true;
			document.getElementById('txtLastName'+ControlNum).disabled = true;
			document.getElementById('lblStatus'+ControlNum).style.display = "";
			document.getElementById('lblStatus'+ControlNum).innerHTML = "Please fill in your  friend's details"
			//document.getElementById('lblStatus'+ControlNum).style.display = "";	
			document.getElementById('lblResult'+ControlNum).style.display = "none";
			document.getElementById('btnSubmit').disabled = false;
			for(i=1;i<= Page_Validators.length;i++) 
			{ 				
				if((document.getElementById('txtContactEmail'+i).value.trim().length != 0) && 
				    (document.getElementById('lblStatus'+i).innerHTML != "Ready"))
				{
					document.getElementById('btnSubmit').disabled = true;
					break;					
				}
			}
		}
	}
}

function ValidateNames(ControlNum)
{	
	document.getElementById('lblResult'+ControlNum).style.display = "none";
	if((document.getElementById('txtFirstName'+ControlNum).value.trim().length == 0) && (document.getElementById('txtLastName'+ControlNum).value.trim().length == 0))
	{
		document.getElementById('btnSubmit').disabled = true;
		document.getElementById('lblStatus'+ControlNum).style.display = "";
		document.getElementById('lblStatus'+ControlNum).innerHTML = "Please fill in your friend's details"
		//document.getElementById('lblStatus'+ControlNum).style.display = "";	
	}
	else
	{
		document.getElementById('btnSubmit').disabled = false;		
		for(i=1;i<= Page_Validators.length;i++) 
		{ 			
			if((document.getElementById('txtContactEmail'+i).value.trim().length != 0) && (document.getElementById('lblStatus'+i).innerHTML != "Ready"))
			{
				document.getElementById('btnSubmit').disabled = true;
				break;					
			}
		}
		//document.getElementById('lblStatus'+ControlNum).style.display = "none";
		document.getElementById('lblStatus'+ControlNum).style.display = "";
		document.getElementById('lblStatus'+ControlNum).innerHTML = "Ready"
	}
}

function ClearRefFields()
{	
	ClearForm();	
	document.getElementById('txtContactEmail1').focus();
	if(document.getElementById('txtContactEmail1').value.trim().length != 0)
	{
		window.location = window.location;
	}
}
/*** end for referral ***/

/*** for registeration ***/
function ShowEmail()
{
    document.getElementById("lblEmail").innerHTML=document.getElementById("txtContactEmail").value;
}
function CheckCardNoLength(RadioGroupObj, CardNoObj, Len)
{	
	CardNo = CardNoObj.value.trim();
	if(CardNo != "" && CardNo.length > Len)
	{
		if(confirm("Selecting this option will truncate your card number entered to " + Len + " digits.\n Click OK to truncate."))
		{
			CardNoObj.value = CardNo.substr(0,Len);			
		}
		else
		{		
			for(i=0; i< RadioGroupObj.length; i++)
			{				
				if(RadioGroupObj[i].getAttribute('wasChecked') == true)
				{
					RadioGroupObj[i].checked = true;
					break;
				}
				else if(RadioGroupObj[i].getAttribute('wasChecked') == null)
				{
					alert("Please select which Card Type to register.");
				}
			}
			return false;
		}
	}
	CardNoObj.maxLength = Len;
	for(i=0; i< RadioGroupObj.length; i++)
	{				
		RadioGroupObj[i].setAttribute('wasChecked', RadioGroupObj[i].checked);		
	}
	return true;
}
function IsValidUIN(UIN)
{
	if(UIN == '' || UIN.length != 9)
	{
		return false		
	}
	format = new RegExp("([STFG])([0-9]+)([A-Z])");	
	matchedformat = format.exec(UIN.toUpperCase());
	if((matchedformat == null) || (matchedformat.length != 4) || (matchedformat[2].length != 7))
	{		
		return false;
	}
	
	prefix = matchedformat[1];
	num = matchedformat[2];
	checkdigit = matchedformat[3];
	
	var UIDCheck;
	if((prefix == 'S') || (prefix == 'T'))
	{
		UIDCheck = new Array('J', 'Z', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A');
	}
	else // FIN ((prefix == 'F') || (prefix == 'G'))
	{
		UIDCheck = new Array('X', 'W', 'U', 'T', 'R', 'Q', 'P', 'N', 'M', 'L', 'K');			
	}
	if(UIDCheck.toString().indexOf(checkdigit) == -1)
	{
		return false;
	}		
	var weightage = new Array(2, 7, 6, 5, 4, 3, 2);
	var checksum = 0;
	for (i = 0; i < weightage.length; i++) 
	{
		checksum += weightage[i] * parseInt(num.charAt(i));
	}
	if((prefix == 'T') || (prefix == 'G'))
	{
		checksum += 4;
	}
	var check = checksum % 11;
	if((check > UIDCheck.length) || UIDCheck[check] != checkdigit)
	{		
		return false;
	}
	
	return true;
}
function AllowCard2()
{	
	if((document.getElementById("cbCardSubType").selectedIndex == 0) &&  (document.getElementById("txtCardNo").value.trim() == ""))
	{
				document.getElementById("cbCardSubType2").disabled = true;
				document.getElementById("txtCardNo2").disabled = true;
				ValidatorEnable(rfvCardSubType2,false);
				ValidatorEnable(rfvCardNo2,false);
				ValidatorEnable(revCardNo2,false);
	}
	else
	{
		document.getElementById("cbCardSubType2").disabled = false;
		document.getElementById("txtCardNo2").disabled = false;		
		if((document.getElementById("cbCardSubType2").selectedIndex == 0) &&  (document.getElementById("txtCardNo2").value.trim() == ""))
		{		
			ValidatorEnable(rfvCardSubType2,false);
			ValidatorEnable(rfvCardNo2,false);
			ValidatorEnable(revCardNo2,false);
		}
		else
		{					
			ValidatorEnable(rfvCardSubType2,true);
			ValidatorEnable(rfvCardNo2,true);
			ValidatorEnable(revCardNo2,true);
		}
	}
}
function CheckAgreement()
{
    if(document.getElementById("btnRegister") != null)
    {
	    if((document.getElementById("chkAccept").checked) && (document.getElementById("EmailCheck").checked)){
		    document.getElementById("btnRegister").disabled = false;		    
	    }else{
		    document.getElementById("btnRegister").disabled = true;		    
	    }
	}else if(document.getElementById("btnUpgrade") != null){
	    if((document.getElementById("chkAccept").checked) && (document.getElementById("EmailCheck").checked)){
		    document.getElementById("btnUpgrade").disabled = false;		    
	    }else{
		    document.getElementById("btnUpgrade").disabled = true;		    
	    }
	}
}
function CheckActivationCode()
{
    if(document.getElementById("btnActivate") != null)
    {
	    if(document.getElementById("txtActivateCode").value == ""){
		    document.getElementById("btnActivate").disabled = true;		    
	    }else{
		    document.getElementById("btnActivate").disabled = false;		    
	    }
	}
}
function DisplayIDFormat()
{
	if(document.getElementById("cbIDType").options[document.getElementById("cbIDType").selectedIndex].value == "3")
	{
		document.getElementById("LblIDFormat").style.display = "none";		
	}
	else
	{
		document.getElementById("LblIDFormat").style.display = "";		
	}
}
function DisplayAddress()
{	
	if(((document.getElementById("cbCountry"))&&document.getElementById("cbCountry").style.visibility != '')&&(document.getElementById("cbCountry").options.length > 0))
	{		
		var SelectedCountryOptionText = document.getElementById("cbCountry").options[document.getElementById("cbCountry").selectedIndex].text.toUpperCase();	
								
		if(SelectedCountryOptionText == "SINGAPORE")
		{
			if(document.getElementById("StateRow"))
			{
				document.getElementById("StateRow").style.display = "none";
				ValidatorEnable(rfvState,false);
			}
			if(document.getElementById("CityRow"))
			{
				document.getElementById("CityRow").style.display = "none";
				ValidatorEnable(rfvCity,false);
			}
		}					
		else
		{			
			ValidatorEnable(rfvState,false);
			ValidatorEnable(rfvCity,false);						
			document.getElementById("StateRow").style.display = "";
			document.getElementById("CityRow").style.display = "";
		}		
		if((SelectedCountryOptionText == "UNITED STATES") ||
			(SelectedCountryOptionText == "UNITED STATES MINOR OUTLYING ISLANDS"))
		{
			document.getElementById("lblZIPCodeTxt").style.display = "";
			ValidatorEnable(rfvZipCode,true);			
			document.getElementById("lblPostalCodeTxt").style.display = "none";
			ValidatorEnable(rfvPostalCode,false);
		}
		else
		{
			document.getElementById("lblZIPCodeTxt").style.display = "none";
			ValidatorEnable(rfvZipCode,false);
			document.getElementById("lblPostalCodeTxt").style.display = "";
			ValidatorEnable(rfvPostalCode,true);			
		}
	}
}
function ValidatePostalCodeFormat(sender, args)
{
	if(isNaN(args.Value)==true)
		{
			args.IsValid = false;
			return;
		}
	args.IsValid = true;
}
function LoadRegPage()
{
	if(document.getElementById('tblStep2'))
	{		
		SetValidDOB('years');
		LoadDOB('dmy');
		CheckAgreement();		
	}
}
function SaveDOB(format)
{
	SaveDate(document.getElementById('DOBYear'), document.getElementById('DOBMonth'), document.getElementById('DOBDay'), document.getElementById('txtDateOfBirth'), format);
	ValidatorValidate(rfvDOB);
}
function LoadDOB(format)
{
	LoadDate(100, document.getElementById('DOBYear'), document.getElementById('DOBMonth'), document.getElementById('DOBDay'), document.getElementById('txtDateOfBirth'), format);
}			
function SetValidDOB(type)
{
	if(type == 'years')
	{
		SetValidYears(100, document.getElementById('DOBYear'), document.getElementById('DOBMonth'), document.getElementById('DOBDay'));	
	}
	else if(type == 'months')
	{
		SetValidMonths(document.getElementById('DOBYear'), document.getElementById('DOBMonth'), document.getElementById('DOBDay'));	
	}
	else if (type == 'days')
	{
		SetValidDays(document.getElementById('DOBYear'), document.getElementById('DOBMonth'), document.getElementById('DOBDay'));	
	}
}
function MakeCompulsary()
{	
	if(document.getElementById('tblStep2'))
	{		
		document.getElementById('LblDOB').style.display = "";						
		document.getElementById('LblContact').style.display = "";
		document.getElementById('LblNationality').style.display = "";
		document.getElementById('LblPostalCode').style.display = "";
		document.getElementById('LblCountryResidence').style.display = "";
		ValidatorEnable(rfvDOB,true);
		ValidatorEnable(rfvMobile,true);
		ValidatorEnable(cvMobile,true);
		ValidatorEnable(rfvNationality,true);
		ValidatorEnable(rfvCountry,true);
		var SelectedCountryOptionText = document.getElementById("cbCountry").options[document.getElementById("cbCountry").selectedIndex].text.toUpperCase();
		if(( SelectedCountryOptionText == 'UNITED STATES') ||
			(SelectedCountryOptionText == 'UNITED STATES MINOR OUTLYING ISLANDS'))
		{
			document.getElementById('LblPostalCode').style.display = "none";			
			document.getElementById('LblZipCode').style.display = "";
			ValidatorEnable(rfvZipCode,true);
			ValidatorEnable(rfvPostalCode,false);
			ValidatorEnable(rfvState,true);
			ValidatorEnable(rfvCity,true);
		}
		else
		{
			ValidatorEnable(rfvPostalCode,true);
			ValidatorEnable(rfvZipCode,false);
			if(SelectedCountryOptionText == 'SINGAPORE')
			{								
				ValidatorEnable(rfvState,false);
				ValidatorEnable(rfvCity,false);
			}
		}					
	}				
	//document.getElementById('LblCountryResidence').innerText = document.getElementById('LblCountryResidence').innerText + '*';
}
function ValidateMobileFormat(sender, args)
{
	var phone = args.Value.replace(' ','').replace('-','');
	if(isNaN(phone)==true)
	{						
		args.IsValid = false;
		return;
	}
	else
	{									
		if((phone.length != 8) || ((phone.charAt(0) != '9') && (phone.charAt(0) != '8')))
		{
			args.IsValid = false;
			return;
		}
	}
	args.IsValid = true;
}
function ValidateUID(sender, args)
{				
	if(document.getElementById("cbIDType").options[document.getElementById("cbIDType").selectedIndex].value != "3")
	{
		UID = args.Value.replace(' ','');
		if(IsValidUIN(UID) == false)
		{
			args.IsValid = false;
			return;
		}
	}
	args.IsValid = true;
}

function ValidateCardAdded(sender, args)
{				
	if(document.getElementById("cblCards") == null)
	{
		args.IsValid = false;
		return;
	}
	args.IsValid = true;
}
/*** end for registration ***/



/*** HTMLSelect date picker ***/
function SaveDate(YearSelect, MonthSelect, DaySelect, HiddenTxt, Format)
{	
	HiddenTxt.value = '';
	if((YearSelect.selectedIndex!=0) && (MonthSelect.selectedIndex!=0) && (DaySelect.selectedIndex!=0))
	{
		if(Format.toUpperCase() == "DMY")
		{
			HiddenTxt.value = DaySelect.options[DaySelect.selectedIndex].value + '/' + MonthSelect.options[MonthSelect.selectedIndex].value + '/' + YearSelect.options[YearSelect.selectedIndex].value;
		}
		else if (Format.toUpperCase() == "MDY")
		{
			HiddenTxt.value = MonthSelect.options[MonthSelect.selectedIndex].value + '/' + DaySelect.options[DaySelect.selectedIndex].value + '/' + YearSelect.options[YearSelect.selectedIndex].value;
		}
		else if (Format.toUpperCase() == "YMD")
		{
			HiddenTxt.value = YearSelect.options[YearSelect.selectedIndex].value + '/' + MonthSelect.options[MonthSelect.selectedIndex].value + '/' + DaySelect.options[DaySelect.selectedIndex].value;	
		}
		else
		{
			HiddenTxt.value = DaySelect.options[DaySelect.selectedIndex].value + '/' + MonthSelect.options[MonthSelect.selectedIndex].value + '/' + YearSelect.options[YearSelect.selectedIndex].value;		
		}
	}				
}
function LoadDate(YearsPeriod, YearSelect, MonthSelect, DaySelect, HiddenTxt, Format)
{	
	if(HiddenTxt.value != '')
	{
		var Day=null,Month=null,Year=null;
		Dates = HiddenTxt.value.split('/');		
		if(Format.toUpperCase() == "DMY")
		{
			Day = String(Dates[0]);
			Month = String(Dates[1]);
			Year = String(Dates[2]);
		}
		else if (Format.toUpperCase() == "MDY")
		{
			Month = String(Dates[0]);
			Day = String(Dates[1]);
			Year = String(Dates[2]);		
		}
		else if (Format.toUpperCase() == "YMD")
		{
			Year = String(Dates[0]);
			Month = String(Dates[1]);
			Day = String(Dates[2]);		
		}
		else
		{
			if(String(Dates[1]) < 12)
			{
				Year = String(Dates[2]);
				Month = String(Dates[1]);
				Day = String(Dates[0]);
			}
			else
			{
				Year = String(Dates[2]);
				Month = String(Dates[0]);
				Day = String(Dates[1]);			
			}
		}	
		
		Month = parseInt(Month,10);
		Day = parseInt(Day,10);		
		if(Year.length == 2)
		{
			if(Year.substring(0,1)>4)
			{
				Year = '19' + Year;
			}
			else
			{	
				Year = '20' + Year;
			}
		}
		
		if(YearSelect.length < 2)
		{
			SetValidYears(YearsPeriod, YearSelect, MonthSelect, DaySelect);
		}		
		for(i=0;i<YearSelect.length;i++)
		{
			if(YearSelect.options[i].text==Year)
			{
				YearSelect.selectedIndex=i;
				break;
			}
		}		
		if(MonthSelect.length < 2)
		{
			SetValidMonths(YearSelect, MonthSelect, DaySelect);
		}				
		for(i=0;i<MonthSelect.length;i++)
		{
			if(MonthSelect.options[i].text==Month || MonthSelect.options[i].value==Month)
			{
				MonthSelect.selectedIndex=i;
				break;
			}
		}
		if(DaySelect.length < 2)
		{
			SetValidDays(YearSelect, MonthSelect, DaySelect);
		}		
		for(i=0;i<DaySelect.length;i++)
		{
			if(DaySelect.options[i].text==Day)
			{
				DaySelect.selectedIndex=i;
				break;
			}
		}				
	}
}
function SetValidYears(YearsPeriod, YearSelect, MonthSelect, DaySelect)
{				
	YearSelect.options[0] = new Option('Year','0');							
	var CurrentYear = new Date().getFullYear();
	if(isNaN(YearsPeriod))
	{
			YearsPeriod = 100;
	}				
	for(i=CurrentYear; i>(CurrentYear-100); i--)
	{				
		YearSelect.options[YearSelect.options.length] = new Option(i,i);
	}
	SetValidMonths(YearSelect, MonthSelect, DaySelect);
}
function SetValidMonths(YearSelect, MonthSelect, DaySelect)
{
	var MaxMonth = 12;
	var SelectedMonth = MonthSelect.selectedIndex;
	var CurrentYear = new Date().getFullYear();
	var CurrentMonth = new Date().getMonth()+1;
	var MonthName = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
	if(MonthSelect.length == 0)
	{
		MonthSelect.options[0] = new Option(MonthName[0],'0');
	}
	else if(YearSelect.options[YearSelect.selectedIndex].value == CurrentYear)
	{
		MaxMonth = CurrentMonth;					
		while(MonthSelect.length-1 > MaxMonth)
		{
			MonthSelect.options[MonthSelect.length-1] = null;					
		}
	}				
	while((MonthSelect.length-1)<MaxMonth)
	{					
		MonthSelect.options[MonthSelect.length] = new Option(MonthName[MonthSelect.length-1],MonthSelect.length);					
	}
	if(SelectedMonth <= MonthSelect.options.length)
	{
		MonthSelect.options[SelectedMonth].selected = true;
	}
	SetValidDays(YearSelect, MonthSelect, DaySelect);
}
function SetValidDays(YearSelect, MonthSelect, DaySelect)
{			
	var MaxDays = 31;				
	var SelectedDay = DaySelect.selectedIndex;				
	if(DaySelect.length == 0)
	{
		DaySelect.options[0] = new Option('Day','0');
	}
	else
	{	var CurrentYear = new Date().getFullYear();
		var CurrentMonth = new Date().getMonth()+1;
		
		if (MonthSelect.selectedIndex == 2)
		{
			MaxDays = 29;
		}
		else if((MonthSelect.selectedIndex == 4) 
		        || (MonthSelect.selectedIndex == 6) 
		        || (MonthSelect.selectedIndex == 9) 
		        || (MonthSelect.selectedIndex == 11))
		{
		    MaxDays = 30;
		}
		if((YearSelect.selectedIndex != 0) && (MonthSelect.selectedIndex != 0))
		{
			if((YearSelect.options[YearSelect.selectedIndex].value == CurrentYear) && 
			(MonthSelect.options[MonthSelect.selectedIndex].value == CurrentMonth))
			{
				MaxDays = new Date().getDate();					
			}
			else
			{
				MaxDays = GetDays(new Date(YearSelect.options[YearSelect.selectedIndex].value,MonthSelect.options[MonthSelect.selectedIndex].value-1,1));
			}
		}					
	}			
	
	while(DaySelect.length-1 > MaxDays)
	{
		DaySelect.options[DaySelect.length-1] = null;
	}
	while((DaySelect.length-1)<MaxDays)
	{					
		DaySelect.options[DaySelect.length] = new Option(DaySelect.length,DaySelect.length);
		
	}
	if(SelectedDay <= DaySelect.options.length)
	{
		DaySelect.options[SelectedDay].selected = true;
	}
}			
function GetDays(TargetDate) 
{
	var tmpDate, d, m;

	tmpDate = new Date(Date.parse(TargetDate));
	m = tmpDate.getMonth();
	d = 28;
	do {
		d++;
		tmpDate.setDate(d);
	} while (tmpDate.getMonth() == m);

	return d - 1;
}
/*** end HTMLSelect date picker ***/
