/*

   JS FUNCTIONS FOR mouseOver, mouseOut, etc...

   Karsten R. Heidtke
   08 08 2005

*/

/*
  function tooltipOpen/3

  Arguments:
  1) event: is a variable set by the browser, to determine mouse coordinates
  2) divtag: the name of the DIV element within the document window
             define an appropriate class to style the tooltip
  3) txt: the text to be displayed in the tooltip

  Purpose:
   The function sets the text of the divtag, changes the coordinates of
   the tag to the event position and makes it visible.
   
   16 11 2005 : KRH The functions has been modified, so that the tooltip
   will always be in the visible area of the browser window
   
*/
function tooltipOpen(e, divtag, txt)
{
  var element, visibility

  var left, right, top, bottom
  // get window dimensions
  var winDim = getWinWH()
  winWidth  = winDim.w
  winHeight = winDim.h

  // remove scroll offset
  var scrollOffset = getScrollXY()
  xOffset = winWidth  > 0 ? winWidth  - scrollOffset.x : 0
  yOffset = winHeight > 0 ? winHeight - scrollOffset.y : 0

  if(document.layers)
  {
    document.layers[0].document.open();
    document.layers[0].document.write("<p>"+txt+"</p>");
    document.layers[0].document.close();
    element    = document.layers[0];
    visibility = "show"
  }
  else if (document.getElementById)
  {
    element = document.getElementById(divtag)
    visibility = "visible"
    if (navigator.appName == "Netscape")
    {
      left   = e.pageX
      top    = e.pageY+30
      bottom = winHeight-top +30
      right  = winWidth -left+10
    }
    else
    {
      left   = window.event.clientX  +document.body.scrollLeft
      top    = window.event.clientY  +document.body.scrollTop
      bottom = winHeight-window.event.clientY+30
      right  = winWidth -window.event.clientX+30
    }
  }
  else
    if(document.all)
    {
      element    = document.all.elements[divtag]
      visibility = "visible"
      left       = window.event.x-50
      top        = window.event.y+30
      bottom     = winHeight-top +30
      right      = winWidth -left+10
    }// end function popup}

  // now fill the element in whatever style
  if ( element ) // apply to all elements, but layers
  {
    if ( !document.layers ) element.innerHTML=txt
  //      "<NOBR><BR>L:"+left+" T:"+top+" R:"+right+" B:"+bottom +"</NOBR><BR><NOBR>W:"+winWidth+" H:"+winHeight+" sX:"+scrollOffset.x+" sY:"+scrollOffset.y+" "+(top-scrollOffset.y < parseInt(winHeight/2.0))+" SCT:"+document.body.scrollTop+"</NOBR>"

    element.style.visibility = visibility

    // put the tooltip in the right half left
    // and in the left half right from the mouse cursor
    if ( left-scrollOffset.x < winWidth*(1-1/2) )
    {
      element.style.left  = left
      element.style.right = ''
    }
    else
    {
      element.style.right = right
      element.style.left = ''
    }

    // put the tooltip in the upper window below
    // and in the lower window above the mouse cursor
    if ( top-scrollOffset.y < winHeight*(1-1/4) )
    {
      element.style.top  = top
      element.style.bottom = ''
    }
    else
    {
      element.style.bottom = bottom
      element.style.top  = ''
    }
  }
}// end function:


function tooltipOpen_deprecated(e, divtag, txt)
{
 if(document.layers)
 {
   document.layers[0].document.open();
   document.layers[0].document.write("<p>"+txt+"</p>");
   document.layers[0].document.close();
   document.layers[0].left = e.pageX-50;
   document.layers[0].top = e.pageY+30;
   document.layers[0].visibility = "show";
 }
 else if (document.getElementById)
 {
   document.getElementById(divtag).innerHTML=txt;
   if (navigator.appName == "Netscape")
   {
      document.getElementById(divtag).style.left = e.pageX;
      document.getElementById(divtag).style.top = e.pageY+30;
   }
   else
   {
      document.getElementById(divtag).style.left = window.event.clientX+document.body.scrollLeft;
      document.getElementById(divtag).style.top = window.event.clientY+30+document.body.scrollTop;
   }

   document.getElementById(divtag).style.visibility = "visible";
 }
 else if(document.all)
 {
   document.all.elements[divtag].innerHTML=txt;
   document.all.elements[divtag].style.left = window.event.x-50;
   document.all.elements[divtag].style.top = window.event.y+30;
   document.all.elements[divtag].style.visibility = "visible";
 }// end function popup}
}

/*
  function tooltipClose/1

  Arguments:
  1) divtag: the name of the DIV element within the document window
  
  Purpose:
   The function sets the given div html tag to invisible
*/
function tooltipClose(divtag)
{
  if(document.layers)
  {
    document.layers[divtag].visibility = "hide";
  }
  else if (document.getElementById(divtag))
  {
    document.getElementById(divtag).style.visibility = "hidden";
  }
  else if(document.all)
  {
    document.all.elements[divtag].style.visibility = "hidden";
  }
  move=0;
}// end function kll


/*
  function getScrollXY/0

  Purpose:
   The function gets the windows scrool offset for x and y.
*/
function getScrollXY()
{
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' )
  {
    scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;
  }
  else
    if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
    {
       scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;
    }
    else
      if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
      {
        scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;
      }

  return { x:scrOfX, y:scrOfY }
  //  window.alert( 'Horizontal scrolling = ' + scrOfX + '\nVertical scrolling = ' + scrOfY );
}// end function


/*
  function getWinWH/0

  Purpose:
   The function gets the windows dimensions, width and height
*/
function getWinWH()
{
  // determine window size
  var winWidth = 0, winHeight = 0;
  if( typeof( window.innerWidth ) == 'number' )
  {
    //Non-IE
    winWidth = window.innerWidth;
    winHeight = window.innerHeight;
  }
  else
    if(   document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
      //IE 6+ in 'standards compliant mode'
      winWidth = document.documentElement.clientWidth;
      winHeight = document.documentElement.clientHeight;
    }
    else
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
      {
        //IE 4 compatible
        winWidth = document.body.clientWidth;
        winHeight = document.body.clientHeight;
      }

  return { w:winWidth, h:winHeight }
}// end function

function change()
{
	alert('lalala');
}// end function

function showRank(zhal)
{
//	var group_set = zhal;
	alert('>>>'+zhal);
//document.forms['productset'].catagory.options[document.forms['productset'].catagory.selectedIndex].value
document.getElementById("setlist").value="----" + productgroups[group_set];
}


// Qing Dong 2009-09 for mouse over effect of top menu
if(window.navigator.systemLanguage && !window.navigator.language) {
  function hoverIE() {
    var LI = document.getElementById("top_menu").firstChild;
    do {
      if (sucheUL(LI.firstChild)) {
        LI.onmouseover=einblenden; LI.onmouseout=ausblenden;
      }
      LI = LI.nextSibling;
    }
    while(LI);
  }

  function sucheUL(UL) {
    do {
      if(UL) UL = UL.nextSibling;
      if(UL && UL.nodeName == "UL") return UL;
    }
    while(UL);
    return false;
  }

  function einblenden() {
    var UL = sucheUL(this.firstChild);
    UL.style.display = "block"; UL.style.backgroundColor = "silver";
  }
  function ausblenden() {
    sucheUL(this.firstChild).style.display = "none";
  }

  window.onload=hoverIE;
}

function newWindow(pageUrl) {
  window.open(pageUrl,"myWindow",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500'); 
   return false;
}

// simple form
function newWindow2(pageUrl) {
  var newWindow = window.open(pageUrl,"myWindow",'toolbar=no,location=no,resizable=yes,width=800,height=500,top=20,left=20'); 
   //return newWindow;
   return false;
}
