var browser;
var platform;
if (navigator.userAgent.indexOf("Mac")!=-1) platform="mac";
if (navigator.userAgent.indexOf("Windows")!=-1) platform="win";
if (navigator.userAgent.indexOf("MSIE")!=-1) browser="e";
if (navigator.userAgent.indexOf("Firefox")!=-1) browser="f";
if (navigator.userAgent.indexOf("Netscape")!=-1) browser="n";
if (navigator.userAgent.indexOf("Safari")!=-1) browser="s";


// ----------------------------------------------------------------------------------------
// scripts for opening window
// ----------------------------------------------------------------------------------------
function openNewWindow (url, name, width, height) {
  var urlstring="'" + url + "'";
  var namestring="'" + name + "'";
  var propstring="'status=no,resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + "'";  
  var ref=open(eval(urlstring), eval(namestring), eval(propstring));
  if (ref!= null) { 
    ref.focus();
  }
  return ref;
}

// ----------------------------------------------------------------------------------------
// workaround for the infamous Netscape CSS- and Layer-bug
// ----------------------------------------------------------------------------------------
// reloads the window on resize
if (document.layers) {
origWidth = innerWidth;
origHeight = innerHeight;}
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();}
//if (document.layers) onresize = reDo;

// ----------------------------------------------------------------------------------------
// scripts for the rollover-effect in the main navigation bar
// ----------------------------------------------------------------------------------------
var selectedid = "";
function setTopic(id,src) {
 if (document.images && id!="") {          
   selectedid = id;       
   eval("document." + id + ".src = '" + src + "'");
 }  
}
function setImage(id, src, set) {
 
 if (!document.images) return ;
 
 if (set==1 && id!=selectedid) {
   eval("document." + id + ".src = '" + src + "'");
 } else {
   if (selectedid != id) {
     eval("document." + id + ".src = '" + src + "'");  
   }
 }
}

function showMovie (movie) {
  
 var content="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='385' height='326' id='FLVPlayer'><param name='movie' value='/media/FLVPlayer_Progressive.swf' /><param name='salign' value='lt' /><param name='quality' value='high' /><param name='scale' value='noscale' /><param name='FlashVars' value='&MM_ComponentVersion=1&skinName=/media/Halo_Skin_1&streamName=/media/" + movie + "&autoPlay=true&autoRewind=true' /><embed src='/media/FLVPlayer_Progressive.swf' flashvars='&MM_ComponentVersion=1&skinName=/media/Halo_Skin_1&streamName=/media/" + movie + "&autoPlay=true&autoRewind=true' quality='high' scale='noscale' width='385' height='326' name='FLVPlayer' salign='LT' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
  
  document.getElementById('dMovieContainer').style.display='';
  document.getElementById('dMovieContainer').style.visibility='visible';
  document.getElementById('dMovieContainer').innerHTML=content;
  
  // this is only bec of safari
  // new Effect.Appear('dMovContainer');
    
}

function showWerbung (movie) {
var content="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='272' height='255' id='FLVPlayer'><param name='movie' value='/spots/streaming/FLVPlayer_Progressive.swf' /><param name='salign' value='lt' /><param name='quality' value='high' /><param name='scale' value='noscale' /><param name='FlashVars' value='&MM_ComponentVersion=1&skinName=/spots/streaming/Halo_Skin_1&streamName=/spots/" + movie + ".flv&autoPlay=false&autoRewind=false' /><embed src='/spots/streaming/FLVPlayer_Progressive.swf' flashvars='&MM_ComponentVersion=1&skinName=/spots/streaming/Halo_Skin_1&streamName=/spots/" + movie + ".flv&autoPlay=false&autoRewind=false' quality='high' scale='noscale' width='272' height='255' name='FLVPlayer' salign='LT' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
document.write(content);
}


// *********************
// ----------------------------------------------------------------------------------------
// Printing
// ---------------------------------------------------------------------------------------- 

var printParams="";
function makePrint(params, empty) {
   
  if (empty==1) printParams="";
  if (params) {
   
    if (printParams=="") printParams+="?"+params;
    else printParams+="&"+params;
 
  } 
}

function openWindow(url,winName,w,h)  {
 
 PopupWindow=null; 
 var LeftPos=20;
 var TopPos=20;
 features = 'width='+ w + ',height='+ h + ',top=' + TopPos + ',left=' + LeftPos + ',location=no,directories=no,menubar=yes,toolbar=yes,status=no,scrollbars=yes,resizable=yes,dependent=yes';
      PopupWindow = open(url + printParams,winName,features);
      if (PopupWindow != null) { 
          PopupWindow.focus();
     }
}

function printPage() {
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}

// ***************************

// set subnavigation shades

function setShades(subnavtotal) {
 
 if (subnavtotal != 0) {
   
 // multiply with 27 for mac and 28 otherwise
 // add space on top and bottom
 
 var multiplyer=28;
 if (platform=="mac") multiplyer=27;
    subnavtotal=(subnavtotal*multiplyer)+30;
    document.getElementById('dColSpacerLVImg').style.height=subnavtotal;
    document.getElementById('dColSpacerMVImg').style.height=subnavtotal;
  } else {
    document.getElementById('dColSpacerLVImg').style.height=1;
    document.getElementById('dColSpacerMVImg').style.height=1;
  }
}

// control subnavigation

function highlightSubNav(ourIndex) {

  if (!ourIndex || isNaN(ourIndex)) { }
  else {
    searchlink="'" + "navlink_" + ourIndex + "'";
    var obj=document.getElementById(eval(searchlink));
    if (obj) {
      obj.style.color="#FF0000";
    }
    // add title
    document.title=obj.title + " - " + document.title;
    // addTitle=obj.title;
    
    if (document.images) {
      searchlink="'" + "navimg_" + ourIndex + "'";
      var obj=document.getElementById(eval(searchlink));
      if (obj) {    
        obj.src = "/img/nav/nav_arrow_s.gif";
      }
    }  
  }
}

function setSubnavigation () {

 // set the shades
 setShades(subnavtotal);
 
 // highlight the entry
 if (window.location.href) {
   var searchlink=new String(window.location.href);
   // get the last ? and max two afterwards
   var ourIndex=searchlink.substr(searchlink.lastIndexOf('?')+1, 2);
   // second part could be NAN, eg. search for humidor ?1&type=dy
   if (isNaN(ourIndex.substr(1,1))) {
     ourIndex=ourIndex.substr(0,1);      
   }
   
   highlightSubNav(ourIndex);
 }
}

// make content as high as left column

function checkContent() {
  
  if (document.getElementById('dContBox') && document.getElementById('dLeftColumn')) {

    var correction=26;
    if (browser=="e") correction=7;

    var hyleft=document.getElementById('dLeftColumn').offsetHeight;
    var hyCont=document.getElementById('dContBox').offsetHeight;

    if (hyleft-correction>hyCont) {
      document.getElementById('dContBox').style.height = (hyleft - correction) + "px";
    }
  }
}

// empty defautl fields in box search

function checkBoxSearch (element, novalue) {
  if (element.value==novalue) element.value="";
}

// swap image for merkzettel
function swapImage (id, replace, opener) {
 
  var element=""; 
  if (opener) element=opener.document.getElementById(id);
  else element=document.getElementById(id);
  
  if (element) {
    element.src = replace;
  }  
}
