function amILocal($needle){
	$haystack=window.location.href;
	if($haystack.search($needle)>=0){
		return true;
	} else {
		return false;
	}
}

if(amILocal("192.168.10.16")){
	$host="192.168.10.16";
	ROOT="http://"+$host+"/prometheus/";
	AJAXURLstop="prometheus";
} else {
	$host="www.prometheusmedical.co.uk";
	ROOT="http://"+$host+"/";
    TESTROOT = "http://"+$host+"/";
	AJAXURLstop="prometheus.orphanspress.co.uk";
}
function setOpacity($item, $opacity){
	if(document.all){
		$item.setStyle("filter","alpha(opacity="+$opacity+")");
	} else {
		$item.style.opacity=$opacity/100 ;
	}
}


function createCookie(name,value,days) {
	if(days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

URLparts=window.location.href.split("/");
addParts=true;
AJAXlink="";
for(i=URLparts.length-2; i>0; i--){
	if(URLparts[i]==AJAXURLstop){
		addParts=false;
	}
	if(addParts){
		AJAXlink+="../";
	}
}
AJAXlink+="ajax/ajax.php";

window.hovers=1;

window.addEvent("domready", function(){
     
	$$("ul.dropdown li").each(function(menuItem){
		menuItem.style.zIndex=1000+i;
		menuItem.onmouseover=function(){
			for(x=0; x<this.childNodes.length; x++){
				if(this.childNodes[x].tagName=="UL"){
					this.childNodes[x].style.display="block";
					this.childNodes[x].style.zIndex=1500+window.hovers;
					window.hovers++;
				}
			}
		}
		menuItem.onmouseout=function(){
			for(x=0; x<this.childNodes.length; x++){
				if(this.childNodes[x].tagName=="UL"){
					this.childNodes[x].style.display="none";	
				}
			}
		}
	});

	$$("ul.dropdown li ul li").each(function(submenuItem){
		submenuItem.onmouseover=function(){
			for(x=0; x<this.childNodes.length; x++){
				if(this.childNodes[x].tagName=="UL"){
					this.childNodes[x].style.display="block";	
				}
			}
		}
		submenuItem.onmouseout=function(){
			for(x=0; x<this.childNodes.length; x++){
				if(this.childNodes[x].tagName=="UL"){
					this.childNodes[x].style.display="none";	
				}
			}
		}
	});
	
   /*	if($("subscribeform")){
		$("subscribeform").onsubmit=function(){
			if($("subscribeemailaddress").value!=""){
				this.action=ROOT+"ajax/ajax.php";
				$("subscribeinner").fader=new Fx.Styles($("subscribeinner"), {duration: 500, transition:Fx.Transitions.Sine.easeInOut});
				$("subscribeinner").fader.start({opacity:[1, .1]});
				$("subscribebutton").disabled=true;
				this.send({
					evalScripts:true
				});
			}
			return false;
		}
	} */

	$$("img.sectorpic").each(function(element){

		element.onmouseover=function(){
			this.src=this.src.split("_f1.jpg")[0]+"_f2.jpg";
		}
		element.onmouseout=function(){
			this.src=this.src.split("_f2.jpg")[0]+"_f1.jpg";
		}

	});

});
