var nn4 = false;	// Netscape Navigator or Communicator
var ie4 = false;
var ie5 = false;
var ie6 = false;
var ie = false;		//IE 5 und IE6
var ns6 = false;    // Netscape 6
var ns7 = false;    // Netscape 7
var moz = false;	// Mozilla Engine
var dom1 = false;	// fully supports DOM1
var dom2 = false;	// fully supports (important bits of) DOM2
var op = false;  	//all opera
var op7 = false;  	//opera 7
var mac = false;	//mac
var safari = false;	//mac Safari

var old = false;	// very old browser

var browserWarn = false;
var strAgent = window.navigator.userAgent;



function browser_detect()
{
	op = (strAgent.indexOf("Opera") > -1);
	op7 = (strAgent.indexOf("Opera/7") > -1) || (strAgent.indexOf("Opera 7") > -1);	

    // do it the official W3C way
    if ( window.document.implementation != null)
    {
         dom1 = window.document.implementation.hasFeature("HTML","1.0");
         dom2 = window.document.implementation.hasFeature("HTML","2.0") &&
         	window.document.implementation.hasFeature("Events","2.0") &&
         	window.document.implementation.hasFeature("Core","2.0") &&
         	window.document.implementation.hasFeature("CSS2","2.0");
    }
    // Mozilla based browsers contain the Gecko rendering engine
    moz = (window.navigator != null )
		? (strAgent.indexOf("ecko") != -1 )
		: false;
    nn4 = (window.document.layers != null && !moz);
	ns6 = (moz && !dom2);
	ns7 = (moz && (strAgent.indexOf("Netscape/7") > 0));
	
    // IE has incremental support for the Document Object Model
    ie6 = (window.document.all && dom1);
    ie5 = (window.document.all && (strAgent.indexOf('MSIE 5')>0));		//&& window.document.getElementsByTagName()
	ie  = (ie5 || ie6 && !op);
    ie4 = (window.document.all && !ie6 && !ie5); 
	mac = (strAgent.indexOf('Mac')>0);
	safari = (strAgent.indexOf('Safari')>0)
    // something horrible and old
    old = (!ie && !dom1 && !moz);
	
	// set flag browserWarn true if IE<5 or Netscape < 6
	if (ie == true || moz== true){
		browserWarn = false;
	} 
	else {
		browserWarn = true;
	}
	//alert (browserWarn);
}

browser_detect();



function setClass (id, name) {
  document.getElementById(id).className=name; 
}

function closeMenus (Ereignis) {
  if (!Ereignis)
    Ereignis = window.event;
  if ((Ereignis.clientX >= 150) || (Ereignis.clientY >= 140)) {
    hide_root_menu();
  }
}

document.onmousemove = closeMenus;

/* Root Menu */

function show_root_menu() {

    document.getElementById('root_navigation_sub').style.display='block'; 
    document.getElementById('rlink').className='active'; 
}

function hide_root_menu() {

    document.getElementById('root_navigation_sub').style.display='none'; 
    document.getElementById('rlink').className='rlink';  
}

// Elemente ein- oder ausblenden

function toggleDisplay(id) {

 el = document.getElementById(id);
 
 var display = el.style.display ? '' : 'none';
 
 el.style.display = display; 
}

/* Produktdetails */

function close(id) {
    document.getElementById('overlay').style.display = "none";
    document.getElementById(id).style.display = "none";
}

function closeall(start,end) {

    for (var i = start; i <= end; i++) {
        document.getElementById("tab"+i).style.display = "none";
        document.getElementById("io_1_"+i).className = "product_detail_menu";
    }
}

function opentab(tab) {

    document.getElementById("tab"+tab).style.display = "block";
    document.getElementById("io_1_"+tab).className = "product_detail_menu_current";
}

function getPageSize(){
    
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {   
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) {    // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }   
    
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){   
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
    return arrayPageSize;
} 

function findPosX(obj)
{
        var curleft = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        }
        else if (obj.x)
                curleft += obj.x;
        return curleft+3;
}

function findPosY(obj)
{
        var curtop = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else if (obj.y)
                curtop += obj.y;
        return curtop+5;
}

function showbigpicture(sBigImage, sPicID, isFlash) {
                        var     sAbzugX = 2;
                        if(isFlash=='true') sAbzugX = 3;

                        var     sAbzugY = 5;

                        if (op7) {
                                sAbzugX = 3;
                                sAbzugY = 5;
                        }
                        else if (moz) {
                                sAbzugX = 1;
                                sAbzugY = 7;
                        }


                        var sSmallPicture = document.getElementById(sPicID);
                        var sSmallPictureXPos = findPosX(sSmallPicture) + sSmallPicture.width - sAbzugX;
                        var sSmallPictureYPos = findPosY(sSmallPicture) - sAbzugY;

                        if(isFlash!='true'){
                                var sPicDiv = document.getElementById("showbigpicture");
                                sPicDiv.style.left = sSmallPictureXPos - 675 + 'px';
                                sPicDiv.style.top = sSmallPictureYPos + 'px';

                                document.getElementById("showbigpicture_image").src = sBigImage;
                                sPicDiv.style.display = "inline";}
                        else {
                                var sFlashDiv = document.getElementById("showbigFlashDiv");
                                sFlashDiv.style.left = sSmallPictureXPos - 700 + 'px';
                                sFlashDiv.style.top = sSmallPictureYPos;

                                var tmp = '';
                                tmp+='  <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" height="150" width="664" border="0" NAME="flashstrip" ID="flashstrip" >';
                                tmp+='          <param name="FlashVars" value="produkt=&lang=1&type=1&close=1"></param>';
                                tmp+='          <param name="movie" value="'+sBigImage+'"></param>';
                                tmp+='          <param name="quality" value="high"></param>';
                                tmp+='          <param name="LOOP" value="true"></param>';
                                tmp+='          <embed src="'+sBigImage+'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi P1 Prod Version=ShockwaveFlash" type="application/x-shockwave-flash" height="150" width="664" loop="true" name="flash strip" border="0" swliveconnect="true"></embed>';
                                tmp+='  </object>';
                                document.getElementById("showbigFlash").innerHTML = tmp;
                                sFlashDiv.style.display = "inline";
                        }

                }
                function closebigflash() {
                        document.getElementById("showbigFlashDiv").style.display = "none";
                }

                function closebigpicture() {
                        document.getElementById("showbigpicture").style.display = "none";
                        document.getElementById("showbigpicture_image").src = "";
                }


function open_function(url,width,height,options) {
  self.msgWindow = open(url, "Window", "width=" + width + ",height=" + height
    + ",screenX=" + (screen.width-width)/2
    + ",screenY=" + (screen.height-height)/2
    + ",dependent=yes"
    + ",left=" + (screen.width-width)/2
    + ",top=" + (screen.height-height)/2
    + options
    );
  if (self.msgWindow) {
     self.msgWindow.focus();
    if (self.msgWindow.opener == null) self.msgWindow.opener = self;
  }
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

