// JavaScript Document
function productinit(){
lhcolh=document.getElementById("lhcol").offsetHeight;
bodyconth=prodboxesh+maximageheight+document.getElementById("bodycontent").offsetHeight;
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img4").style.display="none";
 lhcolh=lhcolh-84;
}
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img3").style.display="none";
 lhcolh=lhcolh-84
}
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img2").style.display="none";
 lhcolh=lhcolh-84
}
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img1").style.display="none";
 document.getElementById("innerlhcol").style.display="none";
 lhcolh=lhcolh-84
}

if (lhcolh<bodyconth)
{
 lhcolh=bodyconth;
}
lhcolh=lhcolh+5;
if (lhcolh<440)
{
 lhcolh=440;
} 
document.getElementById("lhcol").style.height=lhcolh + "px";

findAccessKeys();
externalLinks();
}

function init(){
lhcolh=document.getElementById("lhcol").offsetHeight;
bodyconth=document.getElementById("bodycontent").offsetHeight;
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img4").style.display="none";
 lhcolh=lhcolh-84;
}
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img3").style.display="none";
 lhcolh=lhcolh-84
}
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img2").style.display="none";
 lhcolh=lhcolh-84
}
if (bodyconth < lhcolh && lhcolh > 450)
{
 document.getElementById("img1").style.display="none";
 document.getElementById("innerlhcol").style.display="none";
 lhcolh=lhcolh-84
}
if (lhcolh<440)
{
 lhcolh=440;
}
document.getElementById("lhcol").style.height=lhcolh + "px";

findAccessKeys();
externalLinks();
}

function prodimagealt(imagename, imagedisp, imagesrc, width, height){
if (imagedisp=="block"){
 document[imagename].src="productimages/"+imagesrc;
 document.getElementById(imagename).style.width=width+"px";
 document.getElementById(imagename).style.height=height+"px";
}
document.getElementById(imagename).style.display=imagedisp; 
}

function callMe(){
if (document.getElementById('callmeform').style.display == "block")
{
 if (document.CheckoutForm.name.value=="" || document.CheckoutForm.telephone.value=="")
 {
  alert ("Please enter your Name and Telephone Number");
  return;
 }
 else
 {
  document.CheckoutForm.action = "callme.php";
  document.CheckoutForm.submit();
 }
}
else
{
 document.getElementById('callmeform').style.display="block";
 document.getElementById('callmeoption').style.display="none";
}
}

function sendEnquiry(){
 if (document.EnquiryForm.email.value=="" && document.EnquiryForm.telephone.value=="")
 {
  alert ("Please enter your telephone number or email address");
  return;
 }
 else
 {
  document.EnquiryForm.action = "thanks.php";
  document.EnquiryForm.submit();
 }
}

function subsubshow(thisnav){
 subID="s"+thisnav;
 if (document.getElementById(subID)){
  document.getElementById(subID).style.display="block";
 }
}
function subsubhide(thisnav){
 subID="s"+thisnav;
 if (document.getElementById(subID)){
  document.getElementById(subID).style.display="none";
 }
}



function externalLinks() { 
 if (!document.getElementsByTagName) return;
 var fieldspecs = document.getElementsByTagName("a"); 
 for (var i=0; i<fieldspecs.length; i++) { 
   var fieldspec = fieldspecs[i]; 
   if (fieldspec.getAttribute("href") && 
       fieldspec.getAttribute("rel") == "external") 
       fieldspec.target = "_blank"; 
 } 
}
function externalLinksOff() { 
 if (!document.getElementsByTagName) return;
 var fieldspecs = document.getElementsByTagName("a"); 
 for (var i=0; i<fieldspecs.length; i++) { 
   var fieldspec = fieldspecs[i]; 
   if (fieldspec.getAttribute("href") && 
       fieldspec.getAttribute("rel") == "external") 
       fieldspec.target = "_self"; 
 }
 var images = document.getElementsByTagName("img");
 for (var i=0; i<images.length; i++) { 
   var image = images[i];
   var firstchar = image.getAttribute("src").lastIndexOf("/") + 1;
   var filename = image.getAttribute("src").substring(firstchar,firstchar+6);
   if (filename == "newwin")
     image.style.display = "none";
 }  
} 


function findAccessKeys() { 
var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
  var anchor = anchors[i]; 
  if (anchor.getAttribute("accesskey")) {
     highlightAccessKey(anchor, anchor.getAttribute("accesskey"));
   }
 }
} 
function highlightAccessKey(e, accessKey) {
    if (e.hasChildNodes()) {
        var childNode, txt;
        //find the first text node that contains the access character
        for (var i = 0; i < e.childNodes.length; i++) {
            txt = e.childNodes[i].nodeValue;
            if (e.childNodes[i].nodeType == 3 &&
                txt.toLowerCase().indexOf(accessKey.toLowerCase()) != -1) {
            
                childNode = e.childNodes[i];
                break;
            }
        }
        
        if (!childNode) {
            //access character was not found
            return;
        }

        var pos = txt.toLowerCase().indexOf(accessKey.toLowerCase());
        var span = document.createElement('em');
        var spanText = document.createTextNode(txt.substr(pos, 1));
        span.className = 'accesskey';
        span.appendChild(spanText);

        //the text before the access key
        var text1 = document.createTextNode(txt.substr(0, pos));
        //the text after the access key
        var text2 = document.createTextNode(txt.substr(pos + 1));
        
        if (text1.length > 0) e.insertBefore(text1, childNode);
        e.insertBefore(span, childNode);
        if (text2.length > 0) e.insertBefore(text2, childNode);

        e.removeChild(childNode);
    }
}


function confirmDelete(question, where)
{
    temp = window.confirm(question);
    if (temp) //delete
    {
        window.location=where;
    }
}
function logout(){
document.ControlForm.action = "index.php?logout=Yes";
document.ControlForm.submit();
}
function indexlogout(){
document.ControlForm.action = "index.php?index=Yes";
document.ControlForm.submit();
}
function sitemaplogout(){
document.ControlForm.action = "index.php?sitemap=Yes";
document.ControlForm.submit();
}
function changelogin(){
document.ControlForm.action = "index.php?changelogin=Yes";
document.ControlForm.submit();
}
