//************* DENNE DELEN ER GENEREL BAKGRUNNSPRINTING *************************//
//Generel funksjon for å printe en gitt side(url) i bakgrunn
function printHidden(url) {
	if(url.indexOf("https") > -1)
	{
		document.body.insertAdjacentHTML("beforeEnd", 
			"<iframe name=printHiddenFrame src=url width=0 height=0></iframe>");
	}
	else
	{
		document.body.insertAdjacentHTML("beforeEnd", 
			"<iframe name=printHiddenFrame width=0 height=0></iframe>");
	}
	
  
  doc = printHiddenFrame.document;
  doc.open();
  doc.write(
    "<frameset onload='parent.onprintHiddenFrame()' rows=\"100%\">" +
    "<frame name=printMe src=\""+url+"\">" +
    "</frameset>");
  doc.close();

}

//Onprint event handler for den generelle bakgrunns printing funksjonen
function onprintHiddenFrame() {
  function onfinish() {
    printHiddenFrame.outerHTML = "";
    if ( window.onprintcomplete ) window.onprintcomplete();
  }
  printFrame(printHiddenFrame.printMe, onfinish);
}

//************* END GENEREL BAKGRUNNSPRINTING *************************************//


function printHiddenKonfig(url) {

  document.body.insertAdjacentHTML("beforeEnd", 
    "<iframe name=printHiddenFrame width=0 height=0></iframe>");
  doc = printHiddenFrame.document;
  doc.open();

	var i, start;
	if (document.configurator.Comp0.value == 0) {
		start = 1;
	} else {
		start = 0;
	}

  var indexes = '';
  var comp;

	for (i=start; i<=document.configurator.compCount.value; i++) {
		comp = eval("document.configurator.component" + i); 
		indexes += i + '|' + comp.selectedIndex + ';';
	}
  url = url + '&indexes=' + indexes;
 
  doc.write(
    "<frameset onload='parent.onprintHiddenFrame()' rows=\"100%\">" +
    "<frame name=printMe src=\""+url+"\">" +
    "</frameset>");
  doc.close();

}



//************* DENNE DELEN ER SPESSIFIK FOR CONFIG INFO BAKGRUNNSPRINTING ********//
//Konfig bakgrunnsprinting er ikke 100% testet, må sjekke hva som skjer med droppdown valgene (29.1.2004, Odd-Henrik)
//Spessiel funksjon for bakgruns printing av konfig produkt
function printConfig() {
  document.body.insertAdjacentHTML("beforeEnd", 
    "<iframe name=printHiddenFrame width=0 height=0></iframe>");
  doc = printHiddenFrame.document;
  doc.open();
  doc.write(
    "<frameset onload='parent.onprintHiddenFrameConfig()' rows=\"100%\">" +
    "<frame name=printMe>" +
    "</frameset>");
    
  document.configurator.target = 'printMe'; 
	document.configurator.action.value='printcfg';
    
  doc.close();
}

//Onprint event handler for den spessifike bakgrunns printing funksjonen for konfig
function onprintHiddenFrameConfig() {
  function onfinish() {
    printHiddenFrame.outerHTML = "";
    if ( window.onprintcomplete ) window.onprintcomplete();
  }
  printFrame(printHiddenFrame.printMe, onfinish);
  
  document.configurator.target = 'self'; 
  document.configurator.action.value='';
  document.configurator.submit();
}
//************* END SPESSIFIK FOR CONFIG INFO BAKGRUNNSPRINTING ********//


