resortsOff = new Image(11,31);
resortsOff.src = "/images/template/resortsoff.gif";
resortsOn = new Image(11,31);
resortsOn.src = "/images/template/resortson.gif";
villasOff = new Image(11,31);
villasOff.src = "/images/template/villasoff.gif";
villasOn = new Image(11,31);
villasOn.src = "/images/template/villason.gif";
activeMenu = "";

document.onscroll = scrollFunc();

function phplive()
{
h=document.getElementsByTagName("head")[0];
a=Array();
default_img=Array();
default_link=Array();
extra_js=Array();
a[0]=Array("phpLiveDiv",1); // search box
a[1]=Array("englishPHP",4); // banner placement, <> index
a[2]=Array("spanishPHP",3); // banner placement spanish dept, <> index
a[3]=Array("homePHPLive",5); // banner placement, = index page
a[3]=Array("englishPHPweather",6); // banner placement, = index page

for(i=0;i<a.length;i++){
if(document.getElementById(a[i][0])){
s=document.createElement('script');
s.id='phpLiveScript';
s.type='text/javascript';
s.language='Javascript';
s.src='http://www.cabovillas.com/phplive/js/status_image.php?base_url=http://www.cabovillas.com/phplive&l=cabovillas_php&x=1&deptid=' + a[i][1];
h.appendChild(s);
if(a[i][2]) default_img[a[i][1]]=a[i][2];
if(a[i][3]) default_link[a[i][1]]=a[i][3];
if(a[i][4]) extra_js[a[i][1]]=a[i][4];
setTimeout("php_live_display_"+a[i][1]+"('"+a[i][0]+"')", 2000);
}
}
}

function Cabo()
{
	var randomNumber=Math.floor(Math.random()*4);
	if (randomNumber==0) document.write('<img src="/images/template/CaboSanLucas_family_03.jpg" style="margin-top:16px;" width="251" height="155">');
	else if (randomNumber==1) document.write('<img src="/images/template/CaboSanLucas_girl_03.jpg" style="margin-top:16px;" width="251" height="155">');
	else if (randomNumber==2) document.write('<img src="/images/template/CaboSanLucas_snorkeling_03.jpg" style="margin-top:16px;" width="251" height="155">');
	else document.write('<img src="/images/template/CaboSanLucas_villa_03.jpg" style="margin-top:16px;" width="251" height="155">');
}

function scrollFunc()
{
	if(objNotePad != null) objNotePad.OnScroll()
}

var notepad_page, paddir;
browser = navigator.appName;
appVer = parseInt(navigator.appVersion);
ie = "Microsoft Internet Explorer";
ns = "Netscape";
if (browser == ns && appVer < 5)
{
	notepad_page = "_ns";
}
else
{
	notepad_page = "_ie";
}
if(document.all || document.layers || document.getElementById)
{
	document.write('<' + 'SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="/js/notepad/notepad'+notepad_page+'.js""></' + 'SCRIPT>');
	document.write('<' + 'SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="/js/notepad/listing.js"></' + 'SCRIPT>');
}
var objNotePad = null, divSP = null, imgPreloads;
function loadNotePadObj()
{
	if(blnNotePadJSLoaded)
	{
		objNotePad = new jsNotePad('objNotePad', divSP);
	}
	else
	{
		setTimeout('loadNotePadObj()', 1111);
	}
}
function initNotePad()
{
	if(document.getElementById)
	{
		divSP = document.getElementById('divNotePad');
	}
	else if(document.all)
	{
		divSP = document.all('divNotePad');
	}
	else if(document.layers)
	{
		divSP = document.layers['divNotePad'];
	}
	if(divSP != null)
	{
		loadNotePadObj();
	}
}

function Goto(windowname,url){
window.open(url, windowname, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=460,height=504")
}
var br
if(navigator.appName == "Netscape" && navigator.appVersion.charAt(0)=="4"){br="N";}
else if(navigator.appName == "Microsoft Internet Explorer" && document.all != null){br="IE";}
else if(navigator.appName == "Netscape" && document.getElementById != null && navigator.appVersion.charAt(0)=="5"){br="N5";}
else{br=null}

function go(box) {
		var val = box.options[box.selectedIndex].value;
		if (val != "") {
					window.location.href = val;
				}
			}
			
function OpenWindow(page){ var cal = window.open(systranURL(page), "popup", "directories=no,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=1,width=600"); 
} 

function OpenCalendar(page){ var cal = window.open(systranURL(page), "AvailCal", "directories=no,height=600,location=no,menubar=no,scrollbars=yes,status=yes,resizable=1,width=785,left=0,top=0"); 
} 

function addbookmark()
{
	var bookmarkurl= window.location
	var bookmarktitle = "Cabo San Lucas Mexico Vacations"
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

var locations	=	Array();
var numLoc		=	0;

function showVilla()
{
	document.getElementById('ResortTab').style.backgroundColor 	= '#F3F5D6'; 
	document.getElementById('VillaTab').style.backgroundColor 	= '#DFD9C4';
	document.getElementById('tabImage').style.borderBottom 		= '1px solid white';
	document.getElementById('ResortTab').style.borderBottom 	= '1px solid white';
	document.getElementById('VillaTab').style.borderBottom 		= '1px solid #DFD9C4'
	document.getElementById('SearchBedrooms').style.display 	= 'block';
	document.images['tabImage'].src = resortsOff.src;
	document.images['tabImage2'].src = villasOn.src;
	for(i = 0; i < numLoc; i++)
	{
		var newOpt = new Option(locations[i][1], locations[i][0]);
		document.searchForm.Location.options[i] = newOpt;
	}
}
function showResort()
{
	document.getElementById('VillaTab').style.backgroundColor 	= '#F3F5D6';
	document.getElementById('ResortTab').style.backgroundColor 	= '#DFD9C4'; 
	document.getElementById('tabImage').style.borderBottom 		= '1px solid #DFD9C4';
	document.getElementById('ResortTab').style.borderBottom 	= '1px solid #DFD9C4';
	document.getElementById('VillaTab').style.borderBottom 		= '1px solid white'
	document.getElementById('SearchBedrooms').style.display 	= 'none';
	document.images['tabImage'].src = resortsOn.src;
	document.images['tabImage2'].src = villasOff.src;
	for(i = 0, n = document.searchForm.Location.options.length; i < n; i++)
	{
		locations[i]	=	Array();
		locations[i][0]	=	document.searchForm.Location.options[i].value;
		locations[i][1]	=	document.searchForm.Location.options[i].text;
	}
	numLoc = i;
	
	document.searchForm.Location.options[4] = null;
}

function PopUp(URL,Window,w,h,x,y) {
	var popupwin = window.open(URL,Window,"toolbar=yes,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+w+",height="+h+",left="+x+",top="+y);
}
function openPDF() {
	var msg = "We recommend a high-speed Internet connection of 100k or above to view this PDF. If you are on a 56k Modem we recommend against downloading this document.\n\nClick OK to download the Los Cabos Insider Guide PDF.\nClick Cancel to abort download.";
	if (confirm(msg)) {
		var PDFwin = window.open("/PDF/LC_InsiderGuide.pdf","pdfwindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=900,height=700,left=0,top=0");
	}
}
function mapPopUp(URL,Window,w,h,x,y) {
	theHeight = screen.height;
	if (theHeight > 800) theHeight = 850;
	var popupwin = window.open(URL,Window,"toolbar=no,location=no,directories=no,status=no,statusbar=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+theHeight+",left="+x+",top="+y);
	popupwin.focus();
}
function NLPopUp() {
	PopUp(systranURL('/newsletter_signup.asp'),'NL','450','360','25','25');
}
function OpenOwner() {
	var Ownerpopupwin = window.open("https://caboserver.com/owner/owner_login.asp","PWN3d","toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600,left=0,top=0");
}
function OpenFair() {
	PopUp('http://www.nextfares.com/nf/mask.asp?dn=6740528','Test','780','650','100','100');
}
function OpenRes() {
	window.open(systranURL('https://cabosecure.com'),'Res');
}

function OpenVideo() {
	ViewingVideo(systranURL('mms://wn71.reliablehosting.com/customer01/intro.asf'));
}
function Jump(Location) {
	opener.location.href = Location;window.close()
}
function ViewingVideo(sURL) {
        var msg = ("You must have an Internet Connection of 100k or above to view this Streaming Video. If you are on a 56k Modem you will not be able to view this Video..\n\nClick OK to View Video\nClick Cancel to abort viewing")
        if (confirm(msg)==true)
		location.href = sURL;
	
}
// image flip
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


// style sheets info
browser = navigator.appName;
  version = navigator.appVersion;
  os = navigator.platform;
  ie = "Microsoft Internet Explorer";
  nn = "Netscape";
    // sniff for netscape
  if (browser == nn) {
  	// sniff for Mac and give them the default stylesheet
    if (os == "MacPPC") {
  	  document.write('<link href="/css/default.css" rel="stylesheet" type="text/css" title="master">');
	}
	// sniff for anything greater than version 4 of Netscape and give them the default stylesheet
	if (version.charAt(0) > 4) {
	  document.write('<link href="/css/default.css" rel="stylesheet" type="text/css" title="master">');
	}
	// give Netscape 4.x users the netscape stylesheet
	else {
	  document.write('<link href="/css/netscape.css" rel="stylesheet" type="text/css" title="master">');
  	}
  }
  // give everyone else (IE) the default stylesheet
  else {
    document.write('<link href="/css/default.css" rel="stylesheet" type="text/css" title="master">');
  }
// reload the window upon resize to fix a bug in Netscape 4.x
var br
if(navigator.appName == 'Netscape') {
	if(document.layers) {br="N"}
	else if(document.getElementById) {br="NS6"}
} else{br="IE";}
function reDo(){window.location.reload()}
function setResize(){setTimeout("window.onresize=reDo",500);}
	if(br=="N"){
	window.onload = setResize;
}
//if (browser == nn) {
//	document.write('<link rel=stylesheet type="text/css" href="/css/netscape.css" title=master>');
//} 
//else {
//	document.write('<link rel=stylesheet type="text/css" href="/css/default.css" title=master>');
//}
//js library
function OpenScrollingPopup(URL, width, height) {
	window.self.name = "main";
	var now = new Date();
	var remote = window.open(systranURL(URL), "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=yes");
}
// ----- END: FOR OPENING GENERAL POPUP WINDOWS -----
// ----- BEGIN: FOR HIDING/SHOWING LAYERS -----
function showLayer(strLayerName) {
	if(document.all)
		document.all[strLayerName].style.display = 'block';
	else if(document.layers)
		document.layers[strLayerName].display = 'block';
}
function hideLayer(strLayerName) {
	if(document.all)
		document.all[strLayerName].style.display = 'none';
	else if(document.layers)
		document.layers[strLayerName].display = 'none';
}
// ----- END: FOR HIDING/SHOWING LAYERS -----
function swapImage(strImgName, strImgSrc) {
	if(document.images)
		document.images[strImgName].src = strImgSrc;
}

// ----- BEGIN: FOR GETTING COOKIES -----
function getCookie(strName) {
	var strCookie = document.cookie;
	if(strCookie.length == 0) return '';
	var strValue = '';
	var intStart = strCookie.indexOf(strName + '=');
	if(intStart > -1) {
		intStart += strName.length + 1;
		var intEnd = strCookie.indexOf(';', intStart + 1);
		if(intEnd == -1) intEnd = strCookie.length;
		strValue = strCookie.substring(intStart, intEnd);
	}
	return strValue;
}
function setCookie(strName, strValue, strExp) {
	document.cookie = strName + '=' + strValue
			+ (document.location.hostname == 'www.cabovillas.com' ? '' : '')
			+ (strExp == '' ? '' : ';expires=' + strExp);
}
function setCookieWithPath(strName, strValue, strPath, strExp) {
	document.cookie = strName + '=' + strValue
			+ (document.location.hostname == 'www.cabovillas.com' ? '' : '')
			//+ (strPath == '' ? '' : ';path=' + strPath)
			+ (strExp == '' ? '' : ';expires=' + strExp);
}
function deleteCookie(strName) {
	var dtmExp = new Date();
	dtmExp.setTime(dtmExp.getTime() - 3600000); // 1 hr ago
	setCookieWithPath(strName, '', '/', dtmExp.toGMTString())
}
// ----- END: FOR GETTING COOKIES -----

// ----- BEGIN: FOR STRING/NUMBER CONVERSIONS -----
function isNumericString(strOrig) {
	if(strOrig.length==0) return false;
	var strChar;
	var strValidChars = "1234567890$,";
	for (var i = 0; i < strOrig.length; i++) {
		strChar = strOrig.substring(i, i+1);
		if (strValidChars.indexOf(strChar, 0) == -1)
			return false;
	}
	return true;
}
function isValidEmail(strEmail) {
	var strBadChars, strChar, strSuffix, intNumBadChars, intCount, intPos, intPosPeriod
	// --- CHECKING FOR BAD CHARACTERS ---
	strBadChars = ' /:,#\'"`$~!%^&*();<>?\\|{}[]';
	intNumBadChars = strBadChars.length
	for(intCount = 0;  intCount < intNumBadChars;  ++intCount) {
		strChar = strBadChars.substring(intCount, 1);
		if(strEmail.indexOf(strChar) > 0)
			return false;
	}
	// --- CHECKING FOR THE @ SIGN ---
	intPos = strEmail.indexOf('@')
	if(intPos == -1)
		return false;
	// --- CHECKING FOR A . AFTER THE @ SIGN ---
	intPosPeriod = strEmail.indexOf('.', intPos);
	if(intPosPeriod == -1)
		return false;
	// --- CHECKING FOR AT LEAST 2 AFTER THE PERIOD ---
	if(strEmail.length - intPosPeriod < 3)
		return false;
	// --- ALL CHECKS OUT - MUST BE OKAY ---
	return true;
}
// ----- END: FOR STRING/NUMBER CONVERSIONS -----



function PrintTemp() { //Prints CaboWeather Temp
	var i = 0;
	var t = document.getElementsByTagName('font');
	for(i = 0; i < t.length; i++) {
		if(t[i].className == 'TRVLHobs1') {
			document.write(t[i].innerHTML.replace(/F/,""));
		}
	}
}
function PrintWind() { //Prints CaboWeather Temp
	var i = 0;
	var t = document.getElementsByTagName('font');
	for(i = 0; i < t.length; i++) {
		if(t[i].className == 'TRVLHobsWx') {
			document.write(t[i].innerHTML);
		}
	}
}
function PrintSunny() { //Prints CaboWeather Temp
	var i = 0;
	var t = document.getElementsByTagName('font');
	for(i = 0; i < t.length; i++) {
		if(t[i].className == 'TRVLHobs2') {
			document.write(t[i].innerHTML);
		}
	}
}