//<script>
// Browser detection
	isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	NS4 = (document.layers) ? true : false;
	IEmac = ((document.all)&&(isMac)) ? true : false;
	IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
	IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
	IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
	IE = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)) ? true : false;
	NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1) ? true : false;
	MOZ = (document.getElementById && navigator.appName == "Netscape" || navigator.appName == "Mozilla") ? true : false;
	OPERA = (navigator.userAgent.indexOf('Opera') != -1) ? true : false; 
	

//Function to manage options
function divShowHide(divID) {
	if(document.getElementById(divID).style.display == 'none') {
		divShow(divID);
	} else {
		divHide(divID);
	}
}

//Function to change opne/close img
function imgChange(obj) {
	
	//alert(obj.src.indexOf('blt_open'));
	var b_open = (obj.src.indexOf('blt_close')>0) ? true : false;
	//alert(b_open);
	if(b_open) {
		obj.src='images/blt_open.gif';
	} else {
		obj.src='images/blt_close.gif';
	}
}


//Function for showing div and hidding default
function divShow(divID) {
		
	if(MOZ || NS6)
	{
		document.getElementById(divID).style.visibility = "visible";
		document.getElementById(divID).style.display = 'block';
	} else {
		document.all[divID].style.visibility = "visible";
		document.all[divID].style.display = 'block';
	}
}

//Function for hiding div amd displaying default
function divHide(divID) {

	if(MOZ || NS6)
	{
		document.getElementById(divID).style.visibility = "hidden";
		document.getElementById(divID).style.display = 'none';
	} else {
		document.getElementById(divID).style.visibility = "hidden";
		document.getElementById(divID).style.display = 'none';
	}
}

//Function for hiding div amd displaying default
function divObjShow(obj) {
	//alert(obj.nextSibling.style.visibility);
	
	obj.style.visibility = 'visible';
	obj.style.display = 'block';

}

//Function for hiding div amd displaying default
function divObjHide(obj) {
	
	obj.style.visibility = 'hidden';
	obj.style.display = 'none';

}

//Image rollovers
function rollover(imgid,imgsrc) {
	eval("document.images['"+imgid+"'].src='"+imgsrc+"'")
}

//Function to class
function classChange(o,classX) {
	//alert("changing");
	o.className = classX;
}

//Function to class
function classChangeIn(o) {

	o.className = 'submenuOn';
}

//Function to class
function classChangeOut(o) {

	o.className = 'submenuOff';
}

//Function to change window
function winGo(url) {
	window.location.href = url;
}




//Function to change a class
function classChangeVal(Val,className) {
	o = document.getElementById(Val)
	classChangeObj(o,className)
}


//Function to change a class
function classChangeObj(obj,className) {
	
	obj.className = className;
}


//New window Function for centering
function newWin(url,name,w,h,scroll) {
	var xPos = (screen.width - w) / 2; 
	var yPos = 20; 
	winprops = 'height=' + h + ',width=' + w + ',top=' + yPos + ',left=' + xPos + ',scrollbars=' + scroll + ',menubar=no,status=no,toolbar=no,resizable';

	win = window.open(url, name, winprops);
}

//Validate booking form
function validateForm(o) {
	bValid = false;
	
	if(o.name.value=="") {
		alert("Please give us your name.");
		o.name.focus();
	}
	else if(o.email.value=="") {
		alert("Please give us your email.");
		o.email.focus();
	}
	else if(!checkEmail(o.email.value)) {
		alert("Please give us a valid email address.");
		o.email.focus();
	}
	else if(o.number.value=="") {
		alert("Please give us a contact telephone number.");
		o.number.focus();
	}
	else if(o.security.value=="") {
		alert("Please fill in the security value.");
		o.security.focus();
	}
	else {
		bValid = true;
	}
	return bValid;	
}

//Populate form with previous values
function populateForm(bTypes,sDate,sTime,sFirstVisit) {
	
	//Bookings
	var myBookings = bTypes.split(",");
	var iArr = 0;
	var myBookingCats = new Array('Hair','Colour','Beauty','Male Grooming','Facials','Nails','Massage');
	var iArrCat = 0;
	var myBookingCatDivs = new Array('OptHair','OptColour','OptBeauty','OptMaleGrooming','OptFacials','OptNails','OptMassage');
	var iArrCatDiv = 0;
	
	//Other selects
	var myOthers = new Array('date','time','firstvisit');
	var iArrOthers = 0;
	
	var oForm = document.forms.item(0);
	var sValues;
	
	for (var i = 0; i < oForm.elements.length; i++ )
	{
		if (oForm.elements[i].type == 'checkbox')
		{	 
			//strSample = strSample + ',' + oForm.elements[i].value;
			
			if (oForm.elements[i].value == myBookings[iArr])
		 	{
				//Is it a category
				for (var n=0; n<myBookingCats.length; n++)
				{
					if (oForm.elements[i].value == myBookingCats[n]) 
					{
						divShowHide(myBookingCatDivs[n]);
						break;
					}
				}
				oForm.elements[i].checked = true;
				iArr++;
		 	}
		}
    }
	
	
	
	var oSel;
	var n;
	
	if (sDate != "")
	{
		oSel = document.getElementById('selDate');
		for (n = 0; n < oSel.length; n++ )
		{
			if(oSel[n].value==sDate) {oSel[n].selected = true;}
		}
	}
	
	if (sTime != "")
	{
		oSel = document.getElementById('selTime');
		for (n = 0; n < oSel.length; n++ )
		{
			if(oSel[n].value==sTime) {oSel[n].selected = true;}
		}
	}
	
	if (sFirstVisit != "")
	{
		oSel = document.getElementById('selVisit');
		for (n = 0; n < oSel.length; n++ )
		{
			if(oSel[n].value==sFirstVisit) {oSel[n].selected = true;}
		}
	}
}

function checkEmail(email) {
	var filter = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
	return filter.test(email);
}

//Manage IPL Price List
function IPLRollover(obj,sex,action) {

	var sID = sID_IPLTable+sex;
	//alert(IPL_Active);
	if(sex!=IPL_Active) {
		if(action=='over') {
			obj.childNodes[1].setAttribute('class','style1');
			obj.style.cursor='hand';
		} else {
			obj.childNodes[1].setAttribute('class','style2');
			obj.style.cursor='pointer';
		}
	}
}

function IPLchange(sex,obj) {

	if(sex!=IPL_Active) {
		
		//Change class of active tab
		document.getElementById('IPLPrices_'+IPL_Active).setAttribute('class','IPLPrice_tab_inactive');
		document.getElementById('IPLPrices_'+IPL_Active).setAttribute('style','border-bottom:solid 1px #cccccc;');
		document.getElementById('IPLTabDivSpan_'+IPL_Active).setAttribute('class','style2');
		
		
		//Hide active prices
		divHide(sID_IPLTable+IPL_Active);
		
		//Show inactive prices
		divShow(sID_IPLTable+sex);
		
		
		
		//Change class of now inactive tab
		document.getElementById('IPLPrices_'+sex).setAttribute('class','IPLPrice_tab_active');
		document.getElementById('IPLPrices_'+sex).setAttribute('style','border-bottom:solid 1px #ebebeb;');
		document.getElementById('IPLTabDivSpan_'+sex).setAttribute('class','style1');
		
		
		//Set active
		IPL_Active = sex;
		
	}

}


//</script>

