folder = new String('phuket');
destination = new String('Phuket');

function openWindow(myLink,windowName)
{
  if(! window.focus)return;
  var myWin=window.open("",windowName,"height=350,width=316,dependent=yes,scrollbars=yes,resizable");
  myWin.focus();
  myLink.target=windowName;
}
function openLargeWin(myLink,windowName)
{
  if(! window.focus) return;
  var myWin=window.open("",windowName,"height=400,width=600,dependent=yes,scrollbars=yes,resizable");
  myWin.focus();
  myLink.target=windowName;
}
function validateRestrictions(form,offerId)
{
	ratecount = new Number(form.rateloops.value);
	allsel = new Number(0); 
	cfactor = new Number(0);  gap = new Number(0);

	sDates = new Array();var j=Number(0);

	
	for (var i=0;i<ratecount ;i++ ) 
	{
		if (form.elements["book_"+i].checked) 
		{
			if (allsel==0)		cfactor=i;
			allsel++;	
			if ((i-allsel+1)!=cfactor)	gap++;
			sDates[j] = form.elements["book_"+i].value;j++;
		}
	}
	if(gap==0)
	{
		var nDays = sDates.length;
		if(offerRestrictions[offerId][sDates[0]][2]!=0)
		{
			var string = index_alert[8].replace("{date}",sDates[0]);
			alert(string);
			return(false);
		}
		for(i=0;i<sDates.length;i++)
		{
			if(offerRestrictions[offerId][sDates[i]][0]!=0 && offerRestrictions[offerId][sDates[i]][0]>nDays)
			{
				var string = index_alert[6].replace("{nights}",offerRestrictions[offerId][sDates[i]][0]);
				alert(string);
				return(false);
			}
			else if(offerRestrictions[offerId][sDates[i]][1]!=0 && offerRestrictions[offerId][sDates[i]][1]<nDays)
			{
				var string = index_alert[7].replace("{nights}",offerRestrictions[offerId][sDates[i]][1]);
				alert(string);
				return(false);
			}
		}
	}
	return(true);
}
function submitMe(formName) 
{
	var form = document.forms[formName];
	
	if(checkRestrictions==1)
	{
		var checkForm = validateRestrictions(form,form.offerId.value);
		if(checkForm==false){return(false);}
	}
	ratecount = new Number(form.rateloops.value);
	allsel = new Number(0); 
	cfactor = new Number(0);  gap = new Number(0);
	
	for (var i=0;i<ratecount ;i++ ) 
	{
		if (form.elements["book_"+i].checked) 
		{ 
			if (allsel==0)		cfactor=i;
			allsel++;	
			if ((i-allsel+1)!=cfactor)	gap++;

		} 
		
	}
	
	minstay = new Number(form.minNight.value);
	
	if (allsel==0) 
	{
		alert(index_alert[0]);
		return false;
	} 
	if (allsel > 1 && form.dayuse.value == 1)
	{
		alert(index_alert[1]);
		return false;
	}
	if (allsel<minstay) 
	{
		var string = index_alert[2].replace("{minstay}",minstay);
		alert(string);
		return false;
	} 
	if (gap>0)	
	{
		alert(index_alert[3]);
		return false;
	}
	promo = new Number(form.lpromoNight.value);

	
	// Apply Rule
	if (form.System.value == "Latestays")
	{
		applyRule = CheckRule(form);
		if (applyRule == 1)
		{
			alert(index_alert[4]);
			return false;
		}
		else if (form.dayuse.value != 1 && applyRule == 2)
		{
			alert(index_alert[5]);
			return false;	
		}
	}
	
	form.submit();
}
function setCookie (cookieName, cookieValue, expires, path, domain, secure) 
{
  document.cookie = 
    escape(cookieName) + '=' + escape(cookieValue) 
    + (expires ? '; EXPIRES=' + expires.toGMTString() : '')
    + (path ? '; PATH=' + path : '')
    + (domain ? '; DOMAIN=' + domain : '')
    + (secure ? '; SECURE' : '');
}

function getCookie (cookieName) 
{
  var cookieValue = null;
  var posName = document.cookie.indexOf(escape(cookieName) + '=');
  if (posName != -1) 
  {
    var posValue = posName + (escape(cookieName) + '=').length;
    var endPos = document.cookie.indexOf(';', posValue);
    if (endPos != -1)
      cookieValue = unescape(document.cookie.substring(posValue, endPos));
    else
      cookieValue = unescape(document.cookie.substring(posValue));
  }
  return cookieValue;
}

function showbox(boxname)
{
	leftpos = new Number(xMousePos+12);
	toppos = new Number(yMousePos+12);
	elebox = document.getElementById(boxname);
	currWidth = getWindowWidth() - 300;
	alert('currWidth');
	if (elebox)
	{
		// if (leftpos>600) { leftpos = leftpos-342; }
		if (leftpos > currWidth) { leftpos = leftpos - currWidth; }

		elebox.style.left=leftpos;
		elebox.style.top=toppos;
		elebox.style.display='block'
		
	}
}
function hidebox(boxname)
{
	elebox = document.getElementById(boxname);
	if (elebox)
	{
		elebox.style.display = 'none';
	}
}
function bookmarkThisPage()
{
 if (!((navigator.appName).indexOf("Netscape") == -1)) {
  alert("Please press ctrl-D - thank you!")
 } else if (!((navigator.appName).indexOf("Microsoft") == -1)) {
  window.external.AddFavorite(location.href, document.title)
 } else if (window.opera && window.print) {
  return true
 }
}