// Circles animation
function startAnimation() {
  if(document.layers) {
    document.images["circles"].src = "../images/blue-circles-animation.gif";
  } else {
    document.all.circles.src = "../images/blue-circles-animation.gif";
  }
}

// Poll votes
function vote(pollId) {
	var poll = -1;
	for(i = 0; i < document.forms["webpoll" + pollId].elements.length; i++) {
		if(document.forms["webpoll" + pollId].elements[i].checked) {
			poll = i;
			break;
		}
	}
	if(poll >= 0) {
		results(pollId, '&poll=' + poll);
	} else {
		alert('Du måste välja ett av alternativen för att rösta.');
	}
}

// Show poll results (and vote, if requested)
function results(pollId, vote) {
	if(!vote) {
		vote = "";
	}
	window.open('../poll/poll_result.jsp?pollId=' + pollId + vote, 'poll', 'width=400,height=300');
}

// Open the comments window.
function viewComments(docId) {
	window.open('../forum/forum.jsp?docId=' + docId, 'forum', 'scrollbars=yes,status=no,width=480,height=500');
}

/***************  Tell a Friend  *************************/
// Skickar med url:en man står på.
function tellAFriend(country) {
  theCountry = (country == 1 ? "dk" : (country == 2 ? "no" : "se"));

  window.open('../popup_' + theCountry + '/tellafriend.jsp?url=' + escape(location.href), 'tell', 'width=500,height=250');
}
/***************  Stränghantering *****************/
function trimLeadingAndTrailing(strText) { 
    // tar bort leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
    // tar bort trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
   return strText;
} 
/******************* SLUT stränghantering **********************/

/*****************  Administrerar sitemap **********************/

/*** revised by Per Turestedt  2002-01-12   **/
function newWindow(file,window) {
    msgWindow=open(file,window,'resizable=no,width=500,height=500,scrollbars=yes');
    if (msgWindow.opener == null) msgWindow.opener = self;
}

function loadFileInOpener(file,target) {
    if (target != '')
        target.window.location.href = file;
    else
        window.location.href = file;
}

/**************  SLUT  administrerar sitemap *******************/


/*************   swappa bilder    ***************************************/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*********************************************************/
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function custom_print() {
    if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
            self.print();
        }
    } else {
        self.print();
    }
}


//*************  skrivutscript   ***************
//deprecated
/*
var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 


function printPage(frame, arg) {
  if (frame == window) {    
  link = arg; // för att sätta fokus 
    printFrame(frame);
//    printThis();
  } else {
    link = arg; // för att sätta fokus 
    printFrame(frame);
  }
    
  loadEmptyPrintFile(); 
  return false;
}

function printThis() {
  if (pr) { // NS4, IE5
    window.print();
  } else if (da && !mac) { // IE4 (Windows)
    vbPrintPage();
  } else { // andra löjliga browsers
    alert("Din browser stöder inte denna funktion.");
  }
}

function printFrame(frame, arg) {
	if (frame == window) {		
	   } else {
		link = arg; // parameter för att sätta focus till framen igen
	   }
  if (pr && da) { // IE5
    frame.focus();		  		
    window.print();
    link.focus();
  } else if (pr) { // NS4
    frame.print();
  } else if (da && !mac) { // IE4 (Windows)
    frame.focus();
    setTimeout("vbPrintPage(); link.focus();", 100);
  } else { // andra webbläsare
    alert("Din browser stöder inte denna funktion.");
  }
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');

}
*/
function loadEmptyPrintFile() {
parent.printing.location.replace('../empty.htm');
}

/**************************** Popup **********************************************/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}