
var printparts = "";

function clearthisform(frm) {
	for(i=0; i<frm.length; i++) {
		if (frm[i].tagName=="SELECT") frm[i].selectedIndex=0;
		if (frm[i].tagName=="INPUT") {
			if (frm[i].type=="text") frm[i].value="";
			if (frm[i].type=="radio") frm[i].checked=false;
			if (frm[i].type=="checkbox") frm[i].checked=false;
		}
	}
}

function showtipsbox() {
	document.getElementById("tipslink").style.display = "none";
	document.getElementById("tipsbox").style.display = "";
}	

function printpage() {
	scroll(0,0);
	beforeprint();
	setTimeout("window.print()",10);
}

function beforeprint() {
	var html = ""; var div = '';
	if (printparts) {
		var parts = printparts.split(',');
		for (i=0; i<parts.length; i++) {
			if (document.getElementById(parts[i])) {
				html += document.getElementById(parts[i]).innerHTML + "<br/>";
			}
		}
	}
	else {
		if (document.getElementById("printbody")) {
			html = document.getElementById("printbody").innerHTML;
		}
	}
	if (html!="") {
		iActive = false;
		div += '<div class="printheader"><a href="javascript:document.location.reload()">Tilbake til versjon for skjerm</a></div>';		
		div += '<div class="printbody clearfix">';
		div += '<div class="printinfo"><img alt="SFT logo" src="/media/img/sft-logo-small.gif" class="logosmall" />' + document.location.href + '</div>';		
		div += html + '</div>';
		orgbody = document.body.innerHTML;
		document.body.className = 'print';
		document.body.innerHTML = div;		
	}
}

function afterprint() {
	alert("");
	document.body.innerHTML = orgbody;
	document.body.className = '';
}

function reloadSearchStatusImage() {
	document.getElementById("searchLoading").src = "/img/loading.gif";	
}

function showSearchStatus() {
	scroll(0,0);
	document.getElementById("searchStatus").style.display = "block";
	document.getElementById("mainsearch").style.display = "none";		
	document.getElementById("relatedSearch").style.visibility = "hidden";
	setTimeout("reloadSearchStatusImage()",1);
	return true;
}	


  // this function is need to work around 
  // a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

	    // avoid rows that have a class attribute
        // or backgroundColor style
	    if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
 
         // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
	        if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
        
		      mytd.style.backgroundColor = even ? evenColor : oddColor;
              
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }


function savePageAsPDF(url) {
    var myurl = escape(document.location.href);
    myurl = "http://www.sft.no";
    if (url) myurl = escape(url);
    var pURL = "http://www.web2pdfconvert.com/HTMLtoPDFTemplate.aspx?cURL=" + myurl + "&author=" + "&subj=" + "&title=" + "&app=";
    pURL+="&keywords="+"&allowcpy="+"&allowmodif="+"&allowprn="+"&keylen=";
    pURL+="&userpass="+"&ownerpass="+"&preservelinks="+"&compress=";
    pURL+="&marginleft="+"&marginright="+"&margintop="+"&marginbottom=";
    pURL+="&psize="+"&porient="+"&ctype="+"&allowscript="+"&wsize="+"&outputmode=link";
    window.open(pURL);
}
