
/* ************** STANDARD SCRIPTS ****************** */

function doOver(_link,_name) {
	var img = _link.getElementsByTagName("img");
	img[0].src = "images/nav/" + _name + "_o.gif";
}

function doOut(_link,_name) {
	var img = _link.getElementsByTagName("img");
	img[0].src = "images/nav/" + _name + ".gif";
}





function doPic(imgName) {

	if (ns3up || ie4up) {

		imgOn = ("" + imgName);

		document.large.src = imgOn;

   }

}

/* ************ PROFILE PAGE SHOW/HIDE *************** */



function doProfile(id,selected) {

	

	if (document.getElementById) {

		// sort out the right thing to display

		for ( var i = 0; i < 3; i++ ) {

			// hide all

		//	document.getElementById('heading' + i).style.display = 'none';

			document.getElementById('content' + i).style.display = 'none';

		}

		// show one with ID

		//document.getElementById('heading' + id).style.display = 'block';

		document.getElementById('content' + id).style.display = 'block';

		

		// get all links inside the right column

		var nav_box = document.getElementById("menu-navigation");

		var links = nav_box.getElementsByTagName("a");	

		

		// set all the links classes to nothing

		for(var i=0; i<links.length; i++)

			links[i].className = "";

		

		// set selected link as selected

		selected.className = "selected";

		

		// purely cosmetic... (adjust right hand stripe and margins)

		 

		document.getElementById("menu-navigation").style.margin = '0px 0 0 13px';

		if (id > 0) {

		 
			document.getElementById("menu-navigation").style.margin = '0px 0 122px 13px';

		}

	} else

		alert('Please update your browser');

}



/* ----------- VALIDATION FUNCTIONS ------------------ */

/* Contact Us Form ------------------ */
function validContact(contactForm) {
	
	 	
	if (contactForm.firstName.value == '') {
		alert("Please enter your First Name");
		contactForm.firstName.focus();
		return false;
	}
	
	/*if (contactForm.surname.value == '') {
		alert("Please enter your Surname");
		contactForm.surname.focus();
		return false;
	}*/
	if (contactForm.emailAddr.value == '') {
		alert("Please enter your email address");
		contactForm.emailAddr.focus();
		return false;
	}
	
	if (!validEmail(contactForm.emailAddr.value)) {
		contactForm.emailAddr.focus();
		return false;
	}
	 
	 
	 if (contactForm.contactComments.value == '') {
		alert("Please enter your comments");
		contactForm.contactComments.focus();
		return false;
	}
	/*if ( !validNum(contactForm.tel.value) ) {
		//alert("Please enter a valid telephone number");
		contactForm.tel.focus();
		return false;
	}
		if ( !validNum(contactForm.cell.value) ) {
		alert("Please enter a valid cellphone number");
		contactForm.cell.focus();
		return false;
	}*/
	
	
	return true;
	
}

// checks for valid telephone characters

function validNum(telno) {

	

	var pattern = "0123456789+-)(. ";

	var i = 0;

	

	do {

		var pos = 0;

		for ( var j = 0 ; j < pattern.length ; j++ )

			if ( telno.charAt(i) == pattern.charAt(j) )

				pos = 1;

		i++;

	}

	while ( pos == 1 && i < telno.length )

	

	if ( pos == 0 ) return false;

	

	return true;

}







// check email address pattern

function validEmail(addr) {

	

	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

	

	if ( !regex.test(addr) ) {

		alert("Invalid email address");

		return false;

	}

	

	return true;

}
/* ---------popup gallery--------------------------- */
 ie = document.all?1:0
ns4 = document.layers?1:0
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);


function pop(url, name, w, h, rs, sb, mn, st, oth) {
	var resize = ((rs) ? "resizable="+rs+"," : "");
	var scroll = ((sb) ? "scrollbars="+sb+"," : "");
	var menu = ((mn) ? "toolbar="+mn+",location="+mn+",menubar="+mn+"," : "");
	var sts = ((st) ? "status="+st+"," : "");

	var popupWin = window.open(url, name, resize + scroll + menu + sts + "width=" + w + ",height=" + h + " " + oth);
	if (document.layers) {
		popupWin.focus();
	}
}

function loadImage(no,dir,no_img){
	arr = new Array("","1","2","3","4","5","6","7","8","9","10");

	for(x=1;x<=no_img;x++){
		//imgTemp = "i0" + x;
		imgString = 'imgTemp = document.getElementById("i0'+x+'")';
		eval(imgString);
		if(x == no){
			imgTemp.src = "/images/rooms/button_0" + arr[x] + "_on.gif";
		}else{
			imgTemp.src = "/images/rooms/button_0" + arr[x] + ".gif";
		}
	}
	imgString = 'imgTemp = document.getElementById("middle")';
	eval(imgString);
	imgTemp.src = "/images/"+dir+"small_0" + no + ".jpg";
}

function doPic(imgName) {
	if (ns3up || ie4up) {
		imgOn = ("" + imgName);
		document.large.src = imgOn;
   }
}

function preload() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preload.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function openLayer(id, onpos) {
	document.getElementById(id).style.left = onpos;
}

function closeLayer(id) {
	document.getElementById(id).style.left = "-1000px";
}




/* ------Add bookmark------------------------------ */

function addBookmark(title,url) {

	if (window.sidebar) {

		window.sidebar.addPanel(title, url,"");

	} else if ( document.all ) {

		window.external.AddFavorite( url, title);

	} else if ( window.opera && window.print ) {

		return true;

	}

}

/* -------------contact map----------------------- */

function doMap(state) {
	if (document.getElementById)
		document.getElementById("map").style.display = state;
}
