// JavaScript Document

var popUpWin=0;
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,menub ar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function LoadStuff(Path) {
	if (document.images) {
    	var Pics1 = new Array ("home_1", "home_2", "contact_1", "contact_2", "appart_1", "appart_2", "poolarea_1", "poolarea_2", "rates_1", "rates_2", "facilities_1", "facilities_2", "map_1", "map_2"); 
    	Liste1 = new Array();
    	for (i in Pics1) {		
    		Liste1[i] = new Image();
    		Liste1[i].src = Path + Pics1[i] + ".gif";
   		}
	}
}

function hiLite(imgID, picID) {
// imgID - Name des auszutauschenden Bildes 
// picID - Name des Bildes mit dem ausgetauscht wird 
	window.document.images[imgID].src = Liste1[picID].src;
}

function MessageBox(lang){
	if (lang == "deu")
		alert("Die Online-Reservierung ist leider derzeit nicht verfügbar!\n Bitte Email an:\n manny@highview.co.za");	
	else 
		alert("The online reservation is temporarily not available!\n Please use email - thank you:\n manny@highview.co.za"); 
}

function Link(){//link-in new window..
}


// Validation of reservation form ****************************************************

function Outline(id) {
 if(document.getElementById(id).style.display == 'none') {
 	document.getElementById(id).style.display = 'block';
 	document.forms.pickupFORM.checked
 	}
 else {
	document.getElementById(id).style.display = 'none';
	document.forms.pickupFORM.unchecked
 	}
}
 
// VALIDATION OF EMAIL ENTRY AND FLIGHTNUMBER 
function ValidateEntries(lang) {

if ((reservationFORM.emailFORM.value == "") || 
(reservationFORM.emailFORM.value.indexOf('@') == -1) || 
(reservationFORM.emailFORM.value.indexOf('.') == -1)) { 
	if (lang == "deu") 
		alert ("Bitte Emailadresse eintragen.") ;
	else 
		alert ("Please enter a valid email address.") ;
	return false; 
} 

if (reservationFORM.pickupFORM.checked) {
	if (reservationFORM.flightFORM.value == "") { 
		if (lang == "deu") 
			alert ("Bitte Flugnummer eintragen.") ;
		else 
			alert ("For the pick up service please enter your flightnumber.") ;
		return false; 
	}
	return document.reservationFORM.submit(); 
}
else return document.reservationFORM.submit(); 
} 
  
  
// Scrolling message in statusbar ****************************************************

var msg = " >>> Highview is lifetime you will never forget...! <<< "; // Scrolling Message 
var spacer = "            "; 
var pos = 0; // Message Starting Position 
var showmsg = true; // Message Flag Control
function ScrollMessage() { 
	if (!showmsg) { 
		window.setTimeout("ScrollMessage()",1500); 
		showmsg = true; 
		return; 
	} 
	window.status = msg.substring(pos, msg.length) + spacer + 
	msg.substring(0, pos); 
	pos++; 
	if (pos > msg.length) pos = 0; 
	window.setTimeout("ScrollMessage()",150); // TimeLapse Update 
} 
ScrollMessage(); // Start the scrolling message 


// Layerfunctionality for navigation *************************************************

// MENU MOUSE OVER 
function menuOver(itemName) {
 clearTimeout(timeOn)
 menuActive = 1
}

// MENU MOUSE OUT 
function menuOut(itemName) {
 if(document.layers) {
 	menuActive = 0 
 	timeOn = setTimeout("hideAllMenus()", 400)
  }
}

 // SET BACKGROUND COLOR 
function getImage(name) {
  if (document.layers) {
    return findImage(name, document);
  }
  return null;
}

function findImage(name, doc) {
  var i, img;
  for (i = 0; i < doc.images.length; i++)
    if (doc.images[i].name == name)
      return doc.images[i];
  for (i = 0; i < doc.layers.length; i++)
    if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  return null;
}

function getImagePageLeft(img) {
  var x, obj;
  if (document.layers) {
    if (img.container != null)
      return img.container.pageX + img.x;
    else
      return img.x;
  }
  return -1;
}

function getImagePageTop(img) {
  var y, obj;
  if (document.layers) {
    if (img.container != null)
      return img.container.pageY + img.y;
    else
      return img.y;
  }
  return -1;
}

//document.write('<style> .menu{position: absolute;}</style>');
var timeOn = null
numMenus = 1;
document.onmouseover = hideAllMenus;
document.onclick = hideAllMenus;
window.onerror = null;

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	//we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility


function showMenu(menuNumber, eventObj, labelID) {
    hideAllMenus();
	if(document.layers) {
	img = getImage("img" + menuNumber);
 	x = getImagePageLeft(img);
 	y = getImagePageTop(img);
 	menuTop = y + 10; // LAYER TOP POSITION
	eval('document.layers["menu'+menuNumber+'"].top="'+menuTop+'"');
 	eval('document.layers["menu'+menuNumber+'"].left="'+x+'"');
	}
	eventObj.cancelBubble = true;
    var menuId = 'menu' + menuNumber;
    if(changeObjectVisibility(menuId, 'visible')) {
	return true;
    } else {
	return false;
    }
}

function hideAllMenus() {
    for(counter = 1; counter <= numMenus; counter++) {
	changeObjectVisibility('menu' + counter, 'hidden');
    }
	// hiLite('appart',4); 
}

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject
