var currently_showing_answer;


if (navigator.userAgent.indexOf("Mac") != -1) {
	if (navigator.appVersion.indexOf('MSIE 5')>0) {
		brType = "ie";
	}
	else if (navigator.appVersion.indexOf('Safari')>0) {
		brType = "safari";
	}
	else brType = "other";
}
else if (navigator.userAgent.indexOf('Win') != -1) {
	if (navigator.appName.indexOf('Netscape') != -1) {
		brType = "other";
	}
	else brType = "ie";
}

function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) {
		//alert(el.offsetTop);
		ot += el.offsetTop;
	}

	return ot;
}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}

function getAnchorPosition(anchorname, sidemenu) {
	//alert('function');
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;

	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
	}
	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
		}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
		}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
	}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
	}
	if(sidemenu){
		if(brType=="ie"){
			coordinates.x=x+120;
			coordinates.y=y-3;
		}else{
			coordinates.x=x+118;
			coordinates.y=y-10;
		}
	}
	else{
		if(brType=="ie"){
			coordinates.x=x;
			coordinates.y=y+24;
		}
		else if(brType=="safari"){
			coordinates.x=x;
			coordinates.y=y+24;
		}
		else{
			coordinates.x=x;
			coordinates.y=y+14;
		}
	}

	//alert(coordinates.x);

	return coordinates;
}

/*
if(brType=="ie"){
document.write('<link rel="stylesheet" type="text/css" href="css/infocus_ie.css" />');
}
else{
document.write('<link rel="stylesheet" type="text/css" href="css/infocus_ns.css" />');
}

for(i=1;i<8;i++){
im = new Image();
im.src="<?=$imgPath?>0"+i+"_on.gif";
}
*/
function bookmarksite(){
if (document.all)
window.external.AddFavorite(location.href, 'Autumn Down - '+document.title);
else if (window.sidebar)
window.sidebar.addPanel('Autumn Down - '+document.title, location.href, "")
}


function disp(divName){
	el = document.getElementById(divName);
	(el.style.display == "none") ? el.style.display='block':el.style.display='none';
}

function showAnswer(divName)
{
	if (currently_showing_answer && currently_showing_answer!=divName) {
		document.getElementById(currently_showing_answer).style.display='none';
	}
	el = document.getElementById(divName);
	(el.style.display == "none") ? el.style.display='block':el.style.display='none';
	currently_showing_answer=divName;
}




function showHide(item)
{
	thisItem = document.getElementById(item);

	if(thisItem.style.display == "none")
	{
		thisItem.style.display="block";
	}
	else
	{
		thisItem.style.display="none";
	}
}

var currMenu;
var menuX;
var menuY;
document.overMenu = false;
document.overSub = false;

function menuShow(menuName, y,x) {

	for(i=0; i<menu_layers.length; i++){

		obj = document.getElementById(menu_layers[i]);
		obj = obj.style;

		if(menu_layers[i] == menuName){

			document.currMenu = menuName;
			document.menuX = x;
			document.menuY = y;

			obj.top = y;
			obj.left = x;
			obj.visibility='visible';
		}
		else{
			obj.visibility='hidden';
		}
	}
}

function subShow(menuName, y,x) {

	//alert('hello');

	for(i=0; i<sub_layers.length; i++){

		obj = document.getElementById(sub_layers[i]);
		obj = obj.style;


		if(sub_layers[i] == menuName){
			//alert(menuName);

			obj.top = y;
			obj.left = x;
			obj.visibility='visible';
		}
		else{
			obj.visibility='hidden';
		}
	}
}

function checkSelect(item){
	if(item=="") return false;
	return true;
}

function subDelay(){
	//alert("overSub = "+document.overSub+", overMenu= "+document.overMenu);
	if(document.overSub == false && document.overMenu == false){
		subShow();
		menuShow();
	}

	setTimeout("subDelay()",2000);
}

function openMail(){
	location.href='mailto:sales@floorheating.ltd.uk';
}

function openCustom(url, new_name, winWidth, winHeight, winTop, winLeft){

	if(!winWidth) {
		winWidth = 760;
	}

	if(!winHeight) {
		winHeight = 500;
	}

	if(!winTop) {
		winTop = 50;
	}

	if(!winLeft) {
		winLeft = 50;
	}

	//window.open(url, new_name, 'width='+winWidth+',height='+winHeight+',top='+winTop+', left='+winLeft+', resizable, scrollbars=yes');
	new_win = window.open(url, 'newWin', 'width='+winWidth+',height='+winHeight+',top='+winTop+', left='+winLeft+', resizable, scrollbars=yes');
	window.new_win.focus();

}

function menuHide(menuName) {
	obj = document.getElementById(menuName);
	if (obj) {
		if (obj.style)
		obj=obj.style;
		obj.visibility='hidden';
	}
}

var onSw = "/img/all/icon/lighton.gif";
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.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];}}
}

