function fnTextSize(textSize) {											
	document.body.className = textSize;			
	var menuLinks = document.getElementById("menu").getElementsByTagName("A");
	for(i=0;i<menuLinks.length;i++) {
		menuLinks[i].href = menuLinks[i].href.split("?")[0]+"?tSize="+textSize;
	}			
} 

function fnPrint() {	
	window.print();			
}

function fnBodyId(newID) {	
	document.body.id = newID;		
}

// Popup
function fnPopUp(filePath,height,width,attributes){
	var sScreenX = screen.width
	var sScreenY = screen.height
	var x = sScreenX - width
	var y = sScreenY - height
	var winLeft = x/2
	var winTop =  y/2 
	window.open(filePath,"","width=" + width + ",height=" + height + "," + attributes + ",left=" + winLeft + ",top=" + winTop)
}


/** Generic popup **/

function RightContent(id)
{
	$(id).blur();
	
	if($(id).style.display != 'block' && $(id).style.display != '')
	{

		new Effect.BlindDown($(id), {duration: 0.55, queue: 'end'});	
	}
	else
	{

		new Effect.BlindUp($(id), {duration: 0.55, queue: 'front'});
	}
}



// Change tab function for TV page //

var activeLink = 'tab_news';
var activeDIV = 'ScrollNews';

function homeTabs(LinkId,AreaId) {
	
	if(AreaId != activeDIV)
	{
		new Effect.Fade($(activeDIV), { beforeStart: function() {
			
			$(LinkId).className = 'active';
			$(activeLink).className = '';
			activeLink = LinkId;
			activeDIV = AreaId;
		}, duration: 0.7, queue: 'front', afterFinish: function() {
			new Effect.Appear($(AreaId), { duration: 0.7, queue: 'front'});
		}
		});
	}
	$(LinkId).blur();
}

function isValidDate(dateStr, strAlertText) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat);  /*is the format ok?*/
	if (matchArray == null) {
		strAlertText += " Date is not in a valid format.";
		alert(strAlertText)
		return false;
	}
	month = matchArray[1];  /*parse date into variables*/
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) {  /*check month range*/
		strAlertText += "Month must be between 1 and 12.";
		alert(strAlertText);
		return false;
	}
	if (day < 1 || day > 31) {
		strAlertText += "Day must be between 1 and 31.";
		alert(strAlertText);
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn't have 31 days!")
		return false
	}
	if (month == 2) { /*check for february 29th*/
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn't have " + day + " days!");
			return false;
		}
	}
	return true;  /*date is valid*/
}

function Validate()
{
					var arrivalDate = new Date(document.getElementById('Arrive').value);
	var departureDate = new Date(document.getElementById('depart').value);
	if (arrivalDate >= departureDate)
	{
		alert('Departure Date cannot be before Arrival Date.');
		return false;
	}

	ns_onclick(this, '', 'hotel.montague.onclick.booking_check_availability', 'clickout');
	return true;
}

function SetDepartDate()
{
	var d = datePickerController.datePickers[0].date.valueOf();
	var day = 24*60*60*1000;
	var depart = new Date(d + day);

	document.getElementById('depart').value = depart.format('mm/dd/yyyy');
}

function SetLegalDepartureDate()
{
	var arrivalDate = document.getElementById('Arrive').value;
	var depDate = new Date(arrivalDate);
	depDate.setDate(depDate.getDate() + 1);
	document.getElementById('depart').value = depDate.format('mm/dd/yyyy');
}
