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 disp(divName){
if(el = document.getElementById(divName)){
(el.style.display == "none") ? el.style.display='block':el.style.display='none';
}
}

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

function showDeliveryInstructionBox(){
box = document.getElementById('messagebox');
del_instructions = document.getElementById('message');
(box.style.display == "none") ? box.style.display='block':box.style.display='none';
(del_instructions.style.display == "none") ? del_instructions.style.display='block':del_instructions.style.display='none';
}


function check_length(txtarea, readout, limit)
{

if(readout){
readout = document.getElementById(readout);
}

if (txtarea.value.length > limit) {
// Alert message if maximum limit is reached.
// If required Alert can be removed.
var msg = "You have reached your maximum limit of characters allowed";
alert(msg);
// Reached the Maximum length so trim the textarea
txtarea.value = txtarea.substring(0, limit);
}
else{ // Maximum length not reached so update the value of my_text counter
readout.value = limit - txtarea.value.length;}
}

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

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


function showHideBox(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.com';
}

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');

}

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];}}
}


function bookmarksite(){
if (document.all)
window.external.AddFavorite(location.href, 'Floor Heating Ltd - '+document.title);
else if (window.sidebar)
window.sidebar.addPanel('Floor Heating Ltd - '+document.title, location.href, "")
}

function bookmarkquote(theUrl, numItems, theDate){
if (document.all)
window.external.AddFavorite(theUrl, 'Floor Heating Ltd Saved Order for '+numItems+' items on '+theDate);
else if (window.sidebar)
window.sidebar.addPanel('Floor Heating Ltd Saved Order for '+numItems+'items on '+theDate, theUrl, "");
}


// Postcoder functions

if(document.getElementById('addressPane')){
chooser = document.getElementById('addressPane');
}
function findaddress(pcode)
{
	if (pcode != ''){
		// disable the button
		toggleFormButton(true);
		// clear the form
		clearform();
	    document.S2SForm.postcode.value = pcode;
		document.S2SForm.submit();
chooser = document.getElementById('addressPane');
chooser.style.display = 'block';
//alert (chooser);
	}
else {
alert('Please enter a postcode to start search.');
}
}
function toggleFormButton(status) {
	var theform = document.address_details;
	if (document.all || document.getElementById) {
		var tempobj = theform.searchbutton;
		if (status == true)
			tempobj.value = 'Searching';
		else
			tempobj.value = 'Get Address';
		tempobj.disabled = status;
	}
}
function clearform(){
	var theform = document.address_details;
	//theform.ADD_ORG.value="";
	theform.ADD_BUILD.value="";
	theform.ADD_STREET.value="";
	theform.ADD_BUSPARK.value="";
	//theform.ADD4.value="";
	theform.ADD_CITY.value="";
	theform.ADD_REGION.value="";
	theform.ADD_POSTCODE_FIRST.value="";
	theform.ADD_POSTCODE_SECOND.value="";
}

// -- end of Postcoder functions


