

var mail1;
var mail2;
function writemail(mail1, mail2){
  document.open();
  document.writeln('<a href=mailto:' + mail1 + '@' + mail2 + '>');
  document.close();
}
function writesafemail(mail1, mail2){
  document.open();
  document.writeln(mail1 + '@' + mail2);
  document.close();
}


function expandcollapse (postid) {
	whichpost = document.getElementById(postid);
	if (whichpost.className=="postshown") { whichpost.className="posthidden"; }
	else { whichpost.className="postshown"; }
}

function expandcollapseMove (postid) {
	whichpost = document.getElementById(postid);
	if (whichpost.className=="postshown") { whichpost.className="posthidden"; }
	else { whichpost.className="postshown"; }
	window.location.href = window.location.href + ("#"+postid);

}

function toggle(o, cls) { //viser/skjuler programbeskrivelsen på forsidens tv-guide
	var disp = o.checked ? 'block' : 'none';
	var lis = document.getElementsByTagName('p');
	for(var i=0; i<lis.length; i++) {
		if(lis[i].className == cls) { lis[i].style.display = disp; }
	}
}

function toggleImageTools(id,flagit) {
	if (flagit=="1"){
			if (document.layers) document.layers[''+id+''].visibility = "show"
			else if (document.all) document.all[''+id+''].style.visibility = "visible"
			else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
		}
		else
			if (flagit=="0"){
			if (document.layers) document.layers[''+id+''].visibility = "hide"
			else if (document.all) document.all[''+id+''].style.visibility = "hidden"
			else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
	}
}
function printarticle() {
	window.print();
}

// Setter vannmerke på inputboksen ved klikk på Google-radio-button
function googleBackground(active) {
	if (active == '1') {
		document.getElementById("search_main").style.backgroundImage = 'url(http://gfx.dagbladet.no/g3/google-vannmerke.jpg)';
	}
	else {
		document.getElementById("search_main").style.backgroundImage = 'url(http://gfx.dagbladet.no/g3/input-bg.gif)';
	}
}
//<a href="#" onMouseOver="toggleImageTools('div1',1)" onMouseOut="toggleImageTools('div1',0)">Link 1</a>
//<div id="div1">...</div>


// Endrer bodys bakgrunnsfarge
function changeBG(color) {
	var chng_body = document.getElementsByTagName("body")[0];
	chng_body.style.background = "#"+color;
}
//function setBG(cookieName,cookieValue,nDays) {
function setBG(colorValue) {
	var today = new Date();
	var expire = new Date();
	nDays=400;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	if (colorValue.toUpperCase() ==  "EDEDED" || colorValue.toUpperCase() == "C6C2B3" || colorValue.toUpperCase() == "34749A" || colorValue.toUpperCase() == "777777") {
		document.cookie = "bgfarge="+escape(colorValue) + ";expires="+expire.toGMTString()+";path=/";
	}
	changeBG(colorValue);
}

function ReadBG() {
	var cookieName = "bgfarge"
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return ""; 
		var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length; 
	var colorToSet = theCookie.substring(ind+cookieName.length+1,ind1);
	if (colorToSet.toUpperCase() != "EDEDED" && colorToSet.toUpperCase() != "C6C2B3" && colorToSet.toUpperCase() != "34749A" && colorToSet.toUpperCase() != "777777") {
		colorToSet = "EDEDED";
	}
	changeBG(colorToSet);
}

// START-POLLS
var pollAltSelected = 0; 

 function pollAltSelect( id ) 
 {   
 if ( pollAltSelected != 0 ) 
 {     
 document.getElementById( "pollAltRadio_" + pollAltSelected ).checked = false;   
 }  
 
 pollAltSelected = id;   
 document.getElementById( "pollAltRadio_" + id ).checked = true; 
 
 } 
 function pollSubmit( pollid ) 
 {  
  pollPopup = window.open("http://stem.start.no/vote.php?id=" + pollid + "&alt=" + pollAltSelected,"","width=560,height=700");   
  pollPopup.focus();  
  } 
  
  function pollResult( pollid ) 
  {   
  pollPopup = window.open("http://stem.start.no/result.php?id=" + pollid,"","width=560,height=700");   
  pollPopup.focus();  
  }
  
  function changeTextSize(mode) {

        if (mode == "increase") {
            textSize = YAHOO.util.Dom.getStyle("article-text", "font-size");
            textSize = Number(textSize.substring(0,2));
            if (textSize < 18) {
                textSize = textSize+1;
                YAHOO.util.Dom.setStyle("article-text", "font-size", String(textSize) + "px");
            }
        }
        else if (mode == "decrease") {
            textSize = YAHOO.util.Dom.getStyle("article-text", "font-size");
            textSize = Number(textSize.substring(0,2));
            if (textSize > 10) {
                textSize = textSize-1;
                YAHOO.util.Dom.setStyle("article-text", "font-size", String(textSize) + "px");
            }
        }
        else {
            YAHOO.util.Dom.setStyle("article-text", "font-size", "12px");
        }
}

function showTv2Video(progId) {

        var url = "http://webtv.tv2.no/multimedia/webtv/sl_player/?progId=" + progId + "&autoplay=true&panelMode=disabled&referrer=dagbladet"
        var viewportwidth = 1024;;
        var viewportheight = 768;
        
        if (typeof window.innerWidth != 'undefined')
        {
          viewportwidth = window.innerWidth,
          viewportheight = window.innerHeight
        }
        else if (typeof document.documentElement != 'undefined'
         && typeof document.documentElement.clientWidth !=
         'undefined' && document.documentElement.clientWidth != 0)
        {
           viewportwidth = document.documentElement.clientWidth,
           viewportheight = document.documentElement.clientHeight
        }
        else
        {
           viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
           viewportheight = document.getElementsByTagName('body')[0].clientHeight
        }

        
        var popW = 968, popH = 651;
        
        var leftPos = (viewportwidth-popW)/2;
        var topPos = (viewportheight-popH)/2;
        
        
        window.open(url,'tv2player','channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,titlebar=0,toolbar=0,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);       
 }

var spring_site="test";var _cy_="undefined";if(!this.spring){var spring=function(){var F=_cy_;var D=spring_site;var O="tns-cs.net";var C=typeof spring_ms!=F?spring_ms:2048;var G=typeof spring_debug!=F?spring_debug:null;var E={"+":"%2B",",":"%2C",";":"%3B","=":"%3D","~":"%7E"};var K={};var N=null;var J={};function B(){if("https"==document.location.href.slice(0,5)){return"https://ssl-"}return"http://"}function P(S,Q){if(!Q){Q=S;S={r:document.referrer};J=Q}var R=Q.s?Q.s:S.s;if(!R){R=Q.site?Q.site:(S.site?S.site:D)}if(!K[R]){K[R]=[]}K[R].push([S,Q]);N=1;return this}function M(U){if(!N){P({})}var S;for(s in K){var T=K[s];while(T.length>0){var R=",",Q=[];while(T.length>0){R=R+A(I(T.shift(),Q),Q);if(R.length>C){break}if(T.length>0){R+="+"}}S=L(R+";",s,U)}}K={};return S}function L(T,R,U){var S=B()+(R?R:D)+"."+O+"/j0="+T;var Q=S+"?lt="+(new Date()).getTime().toString(36)+"&x="+screen.width+"x"+screen.height+"x"+screen.colorDepth;if(!U||U==1){document.write('<img src="'+Q+'"" width="1" height=""1">')}else{if(U==2){(new Image()).src=Q}}if(G){alert(Q)}return S}function A(Q,R){for(i in R){if(R[i]==Q){return"~"+i}}R.push(Q);return Q}function I(T,V){var R,U,S,Q,W=/[+&,;=~]/g,X;if(!V){V=[]}switch(typeof T){case"string":return W.test(T)?escape(T).replace(W,function(Y){var Z=E[Y];if(Z){return Z}return Y}):escape(T);case"number":return isFinite(T)?String(T):"null";case"boolean":case"null":return String(T);case"object":if(!T){return"null"}R=[];if(typeof T.length==="number"&&!(T.propertyIsEnumerable("length"))){Q=T.length;for(U=0;U<Q;U+=1){R.push(A(I(T[U],V),V)||"null")}return","+R.join("+")+";"}for(S in T){if(typeof S==="string"){if(S!="site"){X=I(T[S],V);if(X){R.push(A(I(S,V)+"="+X,V))}}}}return","+R.join("+")+";"}return""}function H(R,Q,S){P(R,Q);return M(S)}return{a:P,add:P,c:H,commit:H}}()};