dolog=0;

function init(){

 dolog++;
 if (dolog==1)
 {
  myheight=document.getElementById("mybody").offsetHeight;
  mywidth=document.getElementById("mybody").offsetWidth;
  writeLog(myheight,mywidth);
 }


document.body.style.cursor = "default";
findAccessKeys();
externalLinks();

if (document.getElementById('navbox')){
navheight = document.getElementById('navbox').offsetHeight;
catlogopos= navheight-65;
logoheight=0;
 if (document.getElementById('catlogo')){
  logoheight=document.getElementById('catlogo').offsetHeight;
  document.getElementById('catlogo').style.top = catlogopos + "px";
 }
}

if (document.getElementById('innermain')){
innerheight = document.getElementById('innermain').offsetHeight;
 if (innerheight-navheight<logoheight-40){
  newheight=navheight+logoheight-40;
  document.getElementById('innerprop').style.height = newheight + "px";
 }
}

}

function browser(){
brheight=(document.getElementById('mybody').offsetHeight);
var shift="";
if (brheight<600){
shift="#PostNavigation";
}
return(shift);
}


function bye(){
document.body.style.cursor = "wait";
}

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('span');
        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 externalLinks() { 
 if (!document.getElementsByTagName) return;
  if (document.getElementById("newwindowlinks")){
   document.getElementById("newwindowlinks").style.display="inline"; 
  }
  if (document.getElementById("newwindowlinks1")){
   document.getElementById("newwindowlinks1").style.display="inline"; 
  }
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
       anchor.target = "_blank"; 
 } 
}
function externalLinksOff() { 
 if (!document.getElementsByTagName) return;
  if (document.getElementById("newwindowlinks")){
   document.getElementById("newwindowlinks").style.display="none"; 
  }
  if (document.getElementById("newwindowlinks1")){
   document.getElementById("newwindowlinks1").style.display="none"; 
  }
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
       anchor.target = "_self"; 
 } 
} 

function showPicture(path,w,h,alt){
document.getElementById('largeimage').src = path;
document.getElementById('largeimage').alt = alt;
document.getElementById('largeimage').style.width = w +"px";
document.getElementById('largeimage').style.height = h + "px";
document.getElementById('showhideprim').style.display = "none";
document.getElementById('showhidealt').style.display = "inline";
}

function hidePicture()	{
document.getElementById('largeimage').src = "imagesr/bit.jpg";
document.getElementById('largeimage').alt = "";
document.getElementById('largeimage').style.width = "1px";
document.getElementById('largeimage').style.height = "1px";
document.getElementById('showhidealt').style.display = "none";
document.getElementById('showhideprim').style.display = "inline";
}

function prodimagealt(imagesrc){
document["prodimage"].src="products_pictures/"+imagesrc;
}

var logObject;
function writeLog(h, w){
 if (logObject) 
 {
  document.body.removeChild(logObject);
 }
 logObject = document.createElement("script");
 logObject.src = "writelog.php?width="+w+"&height="+h;
 logObject.type = "text/javascript";
 document.body.appendChild(logObject);
}
