// Including document must set these variables :

//

// var tmenu_color = "<?=$SITE->getSiteConfig('tmenu_color');?>";

// var tmenu_s_color = "<?=$SITE->getSiteConfig('tmenu_s_color');?>";

// var layerstartlevel = <?=$SITE->getSiteConfig('layerstartlevel');?>;



function printArticle( artUrl ){

    behind = window.open(artUrl ,'printwin','height=620,width=590,status=yes,toolbar=yes,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes');

}



function colCh(cellname,mOver) {

  if (document.all)

        document.all[cellname].style.background = (mOver)? tmenu_hover_color : tmenu_color;

  else if (document.getElementById)

    document.getElementById(cellname).style.background = (mOver)? tmenu_hover_color : tmenu_color;

}



function colChFocus(cellname,mOver) {

  if (document.all)

        document.all[cellname].style.background = (mOver)? tmenu_s_color : tmenu_color;

  else if (document.getElementById)

    document.getElementById(cellname).style.background = (mOver)? tmenu_s_color : tmenu_color;

}



function getAbsolutePos(el){

  for (var lx=0,ly=0;el!=null;

    lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);

  return {x:lx,y:ly}

}



function showMenuLayer(catID,level,parentID) {

  if (submenuLayers[catID]) {



    // position the layer using a hidden image...

    //submnuimg-catID

    if (document.getElementById && document.getElementById("submnuimg-"+catID))	{

      theImage = document.getElementById("submnuimg-"+catID);

      pos = getAbsolutePos(theImage);



      if (level == layerstartlevel) {

        initX = pos.x - 6;

        initY = pos.y + 6;

      } else {

        initX = pos.x + 16;

        initY = pos.y -8;

      }

      // alert("x er " + initX + ", y er " + initY);

      // initY = y;

    } else {

      // ns 4

      initX = x;

      initY = y;

    }



    // close active layer if exists

    closeActiveLayer(level);



    submenuLayers[catID].moveTo(initX,initY);



    submenuLayers[catID].show();



    // preserve parent showing...

    if (parentID > 0) {

      keepMenuLayerOpen(parentID);

    }



    // set active id on this level

    activeID[level] = catID;



  } else {

    // hide active layer on this level....

    closeActiveLayer(level);

  }

}





function hideMenuLayer(catID,level) {

  timerArray[catID] = setTimeout("submenuLayers["+catID+"].hide()",2000);

}



function closeActiveLayer(level) {

  if (activeID[level] > 0 ) {

    submenuLayers[activeID[level]].hide();

  }



  // close parents

  for (x=level;x < 12 ; x++) {

    if (activeID[x] > 0 ) {

      submenuLayers[activeID[x]].hide();

    }

  }

}



function closeAllActiveLayers() {

  closeActiveLayer(0);

}



function keepMenuLayerOpen(catID) {

  clearTimeout(timerArray[catID]);

}





function changeLinkColor(catID, mouseover) {

  if (document.getElementById && document.getElementById("link-"+catID))	{

       linkelement = document.getElementById("link-"+catID);

    if (mouseover == true) {

      linkelement.style.color = '#FFFFFF';

    } else {

      linkelement.style.color = '#FFFFFF';

    }



  }



}



function loginOpen(url) {

  var x = ((window.screenX + window.outerWidth)/2)-100;

  var y = ((window.screenY + window.outerHeight)/2)-75;

  var msg = window.open(url, "DisplayWindow", "HEIGHT=150,WIDTH=200,status=no,toolbar=no,scrollbars=no,directories=no,menubar=no,location=no,screenX="+x+",screenY="+y);

}



function closeWindow() {



        window.opener.location.reload();

        window.opener.focus();

        window.close();

}



function getFocus() {

  window.focus();

}



function feedbackOpen(url) {

  var x = ((window.screenX + window.outerWidth)/2)-200;

  var y = ((window.screenY + window.outerHeight)/2)-100;

  var msg = window.open(url, "DisplayWindow", "HEIGHT=200,WIDTH=400,status=no,toolbar=no,scrollbars=no,directories=no,menubar=no,location=no,screenX="+x+",screenY="+y);

}



function Pop(url,width,height,status,toolbar,scrollbars) {

    if (width == null) w = 600; else w = width;

    if (height == null) h = 400; else h = height;

    if (status == null) st = 0; else st = status;

    if (toolbar == null) tb = 0; else tb = toolbar;

    if (scrollbars == null)	sb = 1; else sb = scrollbars;

    open(url,"_blank","status="+st+",toolbar="+tb+",scrollbars="+sb+",resizable=1,width="+w+",height="+h+",screenX=30,screenY=30,left=30,top=30");

}



function printPage() {

  window.print();

}





/* Original:  Richard Cleaver (richard@cleaver.org.uk)

   Web Site:  http://www.cleaver.org.uk



  This script and many more are available free online at

  The JavaScript Source!! http://javascript.internet.com

*/

/*
// Commented out when we removed the floating bar in the bottom of the page.

function floatButton () {

    if (document.all) { document.all.topButton.style.pixelTop = document.body.scrollTop + document.body.clientHeight - document.all.topButton.offsetHeight;

    }

    else if (document.layers) {
    	document.topButton.top = window.pageYOffset + window.innerHeight - document.topButton.clip.height;
    }

    else if (document.getElementById) {
    	if (document.getElementById('topButton')) {
    		document.getElementById('topButton').style.top = (window.pageYOffset + window.innerHeight - 16) + 'px';
    	}
    }

}



if (document.all){

window.onscroll = floatButton;

window.onresize = floatButton;

}

else setInterval ('floatButton()', 100);



function initButton () {

    if (document.all) {

      document.all.topButton.style.pixelleft = 0;

      document.all.topButton.style.pixelTop = document.body.scrollTop + document.body.clientHeight - document.all.topButton.offsetHeight;

      document.all.topButton.style.visibility = 'visible';

    }

    else if (document.layers) {

      document.topButton.left = 0;

      document.topButton.top = window.innerHeight - document.topButton.clip.height;

      document.topButton.visibility = 'show';

    }

    else if (document.getElementById('topButton')) {

      document.getElementById('topButton').style.left = '0px';

      document.getElementById('topButton').style.top = (window.innerHeight - 416) + 'px';

      document.getElementById('topButton').style.visibility = 'visible';

    }

}
*/
function addToFavorites(urlAddress,pageName) {
   if (window.external)
   {
    window.external.AddFavorite(urlAddress,pageName)
    }
   else { alert("Sorry! Your browser doesn't support this function.");
   }
}

var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'Produktdetaljer','height=350,width=440');
	if (window.focus) {newwindow.focus()}
}

var avbetaling = new Array (20);

function update_downpayment(id) {
	element = document.getElementById('avbetaling_mnd' + id);
	update = document.getElementById('avbetaling_pris' + id);
	update.innerHTML = "<b>Terminbeløp:</b> " + avbetaling[id][element.value] + ",- <br /><a href='forklar.php?topic=avbetaling' onclick='javascript:poptastic(\"forklar.php?topic=avbetaling\"); return false;'>Betalingsbetingelser, avbetaling</a>";
} 