﻿// general fucntions used throught out web site
// showcity(pg) - for refreshing page with city lookup after country chosen
// cancelsub(k) - passes data to cm3.asp for a cencellation or a modification after Are you sure
// SubF_CM(g) - passes data to cm3.asp for a cencellation or a modification
// SubF_Main - form submit on home page
// daysInFebruary (year)
// makeArray(n)
// isEmpty(s)
// isDate (year, month, day)
// popUpWindow(URLStr, left, top, width, height)
// movedirection()
// WReload(i)
// onEnterpress(e)
// SubF_SR() 
// MM_reloadPage(init) - reloads the window for Netscape

var defaultEmptyOK = false;
var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29; // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;
var popUpWin=0;
var flgforward=false;

function myvoid() {}

function showcity(pg) 
{
	document.f1.action=pg;
	document.f1.target="_parent";
	document.f1.submit();
	return;
}

function cancelsub(k) 
{
	if (k==1) {
		document.f1.action="cm3.asp?msg_type=c&sure=Yes";
		document.f1.submit();
		return;
	}

	if (k==0) {
		document.f1.action="cm3.asp?msg_type=c&sure=No";
		document.f1.submit();
		return;
	}
}



function SubF_CM(g) 
{
	if (g=="c") {
		document.res.action="cm3.asp?msg_type=c&sure=";
		document.res.submit();
		return;
	}

	if (g=="m") {
		document.res.action="cm3.asp?msg_type=m&sure=";
		document.res.submit();
		return;
	}
}


function SubF_CA_HD() 
{
var myDate=new Date()

myDate.setFullYear(document.f1.CIY.value,document.f1.CIM.value-1,document.f1.CID.value)

var today = new Date()

if (myDate<today) {
	alert('Please select later date.')
	return;
}

if (document.f1.city.value=="") {
	alert('Please select a city for the search.')
	return;
}

if (document.f1.ctry.value=="") {
	alert('Please select a country.')
	return;
}

x=isDate(document.f1.CIY.value + ' ',document.f1.CIM.value + ' ',document.f1.CID.value + '');
if (x==false) {
	alert("Please select a valid date.");
	return false;
}
document.f1.action="wavailability.asp?c=" + document.f1.city.value.toUpperCase();
document.f1.target="WA";
document.all.WA.height="500px";
document.f1.submit();
return;

}

function SubF_Main() 
{
var myDate=new Date()
	
	myDate.setFullYear(document.f1.CIY.value,document.f1.CIM.value-1,document.f1.CID.value)
	
	var today = new Date()
	
	if (!myDate>today) {
		alert('Please select later date.')
		return;
	}
	
	if (document.f1.country.value=='Select Country') {
		alert('Please select a country.')
		return;
	}
	
	if (document.f1.city.value=='Select City') {
		alert('Please select a city.')
		return;
	}
	
	
	x=isDate(document.f1.CIY.value + ' ',document.f1.CIM.value + ' ',document.f1.CID.value + '');
	if (x==false) {
		alert("Please select a valid date.");
		return false;
	}
	document.f1.action="loading.asp?pg=wavailability.asp?city=" + document.f1.city.value.toUpperCase() + "%26country=" + document.f1.country.value  + "%26CIM=" + document.f1.CIM.value + "%26CID=" + document.f1.CID.value + "%26CIY=" + document.f1.CIY.value + "%26ad=" + document.f1.ad.value + "%26NN=" + document.f1.NN.value + "%26NR=" + document.f1.NR.value + "%26nc=" + document.f1.nc.value;
	document.f1.submit();
	return;
}


function SubA_Main() 
{
var myDate=new Date()
	
	myDate.setFullYear(document.f1.CIY.value,document.f1.CIM.value-1,document.f1.CID.value)
	
	var today = new Date()
	
	if (!myDate>today) {
		alert('Please select later date.')
		return;
	}
	
	if (document.f1.country.value=='Select Country') {
		alert('Please select a country.')
		return;
	}
	
	if (document.f1.city.value=='Select City') {
		alert('Please select a city.')
		return;
	}
	
	
	x=isDate(document.f1.CIY.value + ' ',document.f1.CIM.value + ' ',document.f1.CID.value + '');
	if (x==false) {
		alert("Please select a valid date.");
		return false;
	}
	document.f1.action="searchresults.asp?city=" + document.f1.city.value.toUpperCase() + "&country=" + document.f1.country.value  + "&CIM=" + document.f1.CIM.value + "&CID=" + document.f1.CID.value + "&CIY=" + document.f1.CIY.value + "&ad=" + document.f1.ad.value + "&NN=" + document.f1.NN.value + "&NR=" + document.f1.NR.value + "&nc=" + document.f1.nc.value;
	document.f1.submit();
	return;
}


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 makeArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 0
	} 
	return this
}

function isEmpty(s)
{ 
	return ((s == null) || (s.length == 0))
}


function isDate (year, month, day)
{ 
var intYear = parseInt(year);
var intMonth = parseInt(month);
var intDay = parseInt(day);

	if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
	
	if (intDay > daysInMonth[intMonth]) return false; 
	
	return true;
}

function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,title=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function movedirection() 
{
	if (flgforward==false)
	{
		document.location.href="../../supra.asp";
	}
}

function WReload(i) 
{
	document.changedate.cd.value=i;
	document.changedate.submit();
	
	return true;
}

function onEnterpress(e)
{
    var KeyPress  

	if(e && e.which)
    {
       e = e
	   KeyPress = e.which 
    }
    else
    {
        e = event
        KeyPress = e.keyCode
    }
  
    if(KeyPress == 13)
    {
        SubF_SR()
        return false     
    }
    else
    {
        return true
    }

}

function SubF_SR() 
{
var myDate=new Date()
var today = new Date()

	myDate.setFullYear(document.f1.CIY.value,document.f1.CIM.value-1,document.f1.CID.value)
	
	if (!myDate>today) {
		alert('Please select later date.')
		return;
	}

	x=isDate(document.f1.CIY.value + ' ',document.f1.CIM.value + ' ',document.f1.CID.value + '');
	if (x==false) {
		alert("Please select a valid date.");
		return false;
	}
	
	document.f1.action="http://www.snrhotels.com/hotelrates.asp";
	document.f1.target="showrates";
	document.getElementById("showrates").height="360px";
	document.f1.submit();
	document.getElementById("RRow").height="360";
	return;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var info=0;
var details=0;

function expandcollapseHIGroup(cc,hc)
{
	if (info==0) {
		document.getElementById("showinfo" + hc).height=150;
		document.getElementById("showinfo" + hc).src="hotelinfo.asp?cc=" + cc + "&hc=" + hc;
		document.getElementById("hotelx" + hc).src="/comfiles/images/general/minus.gif";
		info=1;
		return;
	}
	
	if (info==1) {
		document.getElementById("showinfo" + hc).height=0;
		document.getElementById("showinfo" + hc).src=""
		document.getElementById("hotelx" + hc).src="/comfiles/images/general/plus.gif";
		info=0;
		return;
	}
}

function expandcollapseRRGroup(id,cc,hc,ad,nc,cid,cim,ciy,nn)
{
	if (info==0) {
		document.getElementById("showrates" + id).height=250;
		document.getElementById("showrates" + id).src="displayall.asp?cc=" + cc + "&hc=" + hc + "&nn=" + nn + "&ad=" + ad + "&ciy=" + ciy + "&cim= " + cim + "&cid=" + cid + "&nc=" + nc;
		document.getElementById("detailx" + id).src="/comfiles/images/general/minus.gif";
		info=1;
		return;
	}
	
	if (info==1) {
		document.getElementById("showrates" + id).height=0;
		document.getElementById("showrates" + id).src=""
		document.getElementById("detailx" + id).src="/comfiles/images/general/plus.gif";
		info=0;
		return;
	}
}

function expandcollapseHI(cc,hc)
{
	if (info==0) {
		document.all.showinfo.height=130;
		document.all.showinfo.src="hotelinfo.asp?cc=" + cc + "&hc=" + hc;
		document.all.hotelx.src="/comfiles/images/general/minus.gif";
		info=1;
		return;
	}
	
	if (info==1) {
		document.all.showinfo.height=0;
		document.all.showinfo.src=""
		document.all.hotelx.src="/comfiles/images/general/plus.gif";
		info=0;
		return;
	}
}

function expandcollapseD(id)
{

	if (details==0) {
		document.getElementById("detailx" + id).src="/comfiles/images/general/minus.gif";
		document.getElementById("showdates" + id).height=150;
		document.getElementById("f" + id).action='savailability.asp';	
		document.getElementById("f" + id).submit();	
		details=1;
		return;
	}
	
	if (details==1) {
		document.getElementById("showdates" + id).height=0;
		document.getElementById("detailx" + id).src="/comfiles/images/general/plus.gif";
		details=0;
		return;
	}
}

function SubF_WA() 
{
var myDate=new Date()

	myDate.setFullYear(document.f1.CIY.value,document.f1.CIM.value-1,document.f1.CID.value)
	
	var today = new Date()
	
	if (myDate<today) {
		alert('Please select date after today')
		return false;
	}
	
	x=isDate(document.f1.CIY.value + ' ',document.f1.CIM.value + ' ',document.f1.CID.value + '');
	if (x==false) {
		alert("Please select a valid date");
		return false;
	}
	
	document.f1.action="wavailability.asp?re=0&city=" + document.f1.city.value.toUpperCase();
	document.f1.submit();
	return;
}