﻿
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}   
var blockload = false;

var lastoo=null;
var lasto=null;
function expand(o,oo,open){
    var ooo = document.getElementById(oo)
    
    if (open) {
    o= document.getElementById(open)
    o.className='expand';
    }
    
    if (o.className=='expand'){
    o.className='minimize'; ooo.style.display='';
    
    if (lasto!=null && lasto!=o){lastoo.style.display='none';lasto.className='expand';}
    lastoo=ooo; lasto=o;
    
    }else{
    o.className='expand';ooo.style.display='none';
    }
}
                

var IFrameObj; // our IFrame object
function callToServer() {
  if (!document.createElement) {return true};
  var IFrameDoc;
  var URL = 'server.html';
  if (!IFrameObj && document.createElement) {
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      if (document.frames) {
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
       iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    setTimeout('callToServer()',10);
    return false;
  }
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  IFrameDoc.location.replace(URL);
  return false;
}

// ///////////////////////////////////////////////////
// START UP
//

var ss_starters = new Array();
function ss_startup()
{  
    for(var i = 0;i < ss_starters.length;i++)    
    eval(ss_starters[i]);
}
function addstart(func){
    ss_starters[ss_starters.length] = func;
}
window.onload=ss_startup;

var ss_prestarters = new Array();
function ss_prestartup()
{  setfriends();
    for(var i = 0;i < ss_prestarters.length;i++)    
    eval(ss_prestarters[i]);
}
function addprestart(func){
    ss_prestarters[ss_prestarters.length] = func;
}


var ss_scrollers = new Array();
function ss_scroller()
{  
    for(var i = 0;i < ss_scrollers.length;i++)    
    eval(ss_scrollers[i]);
}
function addscroll(func){
    ss_scrollers[ss_scrollers.length] = func;
}
window.onscroll=ss_scroller;


// ///////////////////////////////////////////////////
// SET FRIEND START UP
//
function setfriends(){
var boxes = document.getElementsByName('setf');
//document.getElementById('').getAttribute('alias')
var boxLength = boxes.length;
for ( i=0; i < boxLength; i++ ) {
     // alert(boxes[i].id);
      if (myfriends.indexOf(boxes[i].id) > -1 ) {
        boxes[i].src ='/-/user/icon_removefriend.gif';
       // boxes[i].href='javascript:setfriend(this,' + boxes[i].id + ')';
        boxes[i].title='Ta bort vän';
        continue;
      }else{
       // boxes[i].href='javascript:setfriend(this,' + boxes[i].id + ')';
        boxes[i].title='Lägg till som vän';
      }
      
     }
}

function isfriend(ob, alias){
if (myfriends.indexOf(alias) > -1)
{ob.src='/-/user/icon_removefriend.gif'}
}

// ///////////////////////////////////////////////////
// SET FRIEND FUNCTIONS
//
function removeblock(s)
{
    var friendscript = document.createElement('script'); 
    friendscript.type = 'text/javascript'; 
    friendscript.src = '/medlem/blocklist/unfriend_remove.aspx?suid=' + s + '&tm=' + new String (Math.random()).substring (2, 11);  
document.getElementsByTagName('head')[0].appendChild(friendscript);
document.getElementById("frienditem" + s).style.display='none';
}

function removefriend(s)
{
    var friendscript = document.createElement('script'); 
    friendscript.type = 'text/javascript'; 
    friendscript.src = '/medlem/friends/friend_remove.aspx?suid=' + s + '&tm=' + new String (Math.random()).substring (2, 11);  
    document.getElementsByTagName('head')[0].appendChild(friendscript);
    document.getElementById("frienditem" + s).style.display='none';
}

function setfriend(s)
{
    if (s.src.indexOf('addfriend')>-1){
    var friendscript = document.createElement('script'); 
    friendscript.type = 'text/javascript'; 
    friendscript.src = '/medlem/friends/friend_add.aspx?suid=' + s.id + '&tm=' + new String (Math.random()).substring (2, 11);  
    
    document.getElementsByTagName('head')[0].appendChild(friendscript);
    s.src ='/-/user/icon_removefriend.gif';
    //s.src ='/-/user/icon_addingfriend.gif';
    
}else{
   var friendscript = document.createElement('script'); 
    friendscript.type = 'text/javascript'; 
    friendscript.src = '/medlem/friends/friend_remove.aspx?suid=' + s.id + '&tm=' + new String (Math.random()).substring (2, 11);  
    document.getElementsByTagName('head')[0].appendChild(friendscript);
    s.src ='/-/user/icon_addfriend.gif';
    //s.src ='/-/user/icon_addingfriend.gif';
}
}


// Detect client browser:
// Code origin: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
// ANDVÄNDS INTE LÄNGRE MEN LIGGER KVAR IFALL NÅGON GAMMAL KOD FORTFARANDE FINNS KVAR

// KVAR I BANNERS & NÅGOT I USERPANEL ? - 
var agt=navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie6 = (agt.indexOf("msie 6.")!=-1);

/*
var is_ie6 = Boolean(navigator.userAgent.toLowerCase.indexOf("msie 6.")!=-1)
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
//alert(agt);
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
			&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) ||
					  (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);

var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up = (is_ie && (is_major >= 4));
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var is_ie7 = (is_ie && (is_major == 4) && (agt.indexOf("msie 7.")!=-1) );

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5);
var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5 && !is_opera6);

var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
var is_win16 = ((agt.indexOf("win16")!=-1) || 
           (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
           (agt.indexOf("windows 16-bit")!=-1) );  
var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                (agt.indexOf("windows 16-bit")!=-1));
var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));
var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 || 
                ((is_major >= 4) && (navigator.platform == "Win32")) ||
                (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
var is_os2   = ((agt.indexOf("os/2")!=-1) || 
                (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                (agt.indexOf("ibm-webexplorer")!=-1));
var is_mac    = (agt.indexOf("mac")!=-1);
if (is_mac && is_ie5up) is_js = 1.4;
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 
                           (agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 
                            (agt.indexOf("powerpc")!=-1)));

*/

// ///////////////////////////////////////////////////
// FUNCTIONS
//
function IDget(oID)
{
return document.getElementById(oID)
}

// Positioning 
/****  VER 3 test ******/
function getposX(obj){
    var curleft = 0;
    if (obj.offsetParent){
        while(1){
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent){break}
            obj=obj.offsetParent;
        }
    }else if(obj.x){
    curleft+=obj.x
    }
return curleft;
}
function getposY(obj){
    var curtop = 0;
    if (obj.offsetParent){
        while(1){
        curtop+=obj.offsetTop;
        if (!obj.offsetParent){break}
         obj=obj.offsetParent;
        }
    }else if(obj.y){
    curtop+=obj.y
    }
return curtop;
}
function getPageScrollY() {
    return f_filterResults (
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    )    
}
function getPageScrollX() {
    return f_filterResults (
        window.pageXOffset ? window.pageXOffset : 0,
        document.documentElement ? document.documentElement.scrollLeft : 0,
        document.body ? document.body.scrollLeft : 0
    )    
}
function getWindowHeight() {
    return f_filterResults (
        window.innerHeight ? window.innerHeight : 0,
        document.documentElement ? document.documentElement.clientHeight : 0,
        document.body ? document.body.clientHeight : 0
    );
}

function getPageSize(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;

	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;

	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	//pageWidth=xScroll+windowWidth;
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function getWidth(ob){
    if (ob.getAttribute("width") && ob.getAttribute("width") > 0)
	return parseInt(ob.getAttribute("width"));
	else if (document.defaultView.getComputedStyle!=null)
	return parseInt(document.defaultView.getComputedStyle(ob, '').getPropertyValue("width"));
}
function getHeight(ob){
	if (ob.getAttribute("height") && ob.getAttribute("height") > 0)
	return parseInt(ob.getAttribute("height"));
	else if (document.defaultView.getComputedStyle!=null)
	return parseInt(document.defaultView.getComputedStyle(ob, '').getPropertyValue("height"));
}

 
/* 
 *****************************************
 ********* IMAGES POPUP HANDLING *********
*/
var popfader;
var popfadetmr;

function ip(ob)
{
var pop = document.getElementById("pop")
pop.innerHTML = "";
var popimg = document.createElement("img");

if (ob.getAttribute("rel")!=null){
	popimg.src=ob.getAttribute("rel");
	}else{popimg.src = ob.src;}

pop.appendChild(popimg);

    var w = getWidth(popimg);
 	var h = getHeight(popimg);
	var winH = getWindowHeight();
	var wScroll = getPageScrollY();

	if (w > 320)
	{
	h = ((320/w)* h);
	w = 320;
	if (h > 320)
	{
	w = ((320/h)* w);
	h = 320;
	}
	popimg.style.width= w + 'px';
	popimg.style.height= h + 'px';
	}
 
	var orgwidth = 45
	var targetX = getposX(ob);
	var targetY = getposY(ob)
	
 	if (ob.src){
	orgwidth=getWidth(ob)
    targetX = targetX + orgwidth + 15; 
    if(h){targetY = targetY - (h/5)}else{targetY=targetY-200;}
    
    }else{targetY=targetY +25}
     
  //  if (wScroll > targetY){targetY=wScroll+5;}
  //  if((wScroll + winH) < (targetY +h)){targetY= (wScroll + winH - 20) - h;}
    
    popendfade();
   
    pop.style.top = targetY +'px';
    pop.style.left = targetX +'px';
    ob.onmouseout = popout;
    pop.style.visibility = "visible";
}

function popout(){
popfadetmr= setInterval(popoutfadeout,20);
}

function popoutfadeout(){
        var pop = document.getElementById("pop");
        popfader=popfader-20;
        if (popfader > -1)
        {
            pop.style.opacity = popfader/100;
	        pop.style.filter = 'alpha(opacity=' + popfader + ')';
        }else{ 
        popendfade();
        }
}

function popendfade(){
    popfader = 100;
    if (popfadetmr){
    clearInterval(popfadetmr);
    popfadetmr=-1;
    }
    var pop = document.getElementById("pop");
    pop.style.opacity = 1;
    pop.style.filter = 'alpha(opacity=100)';
    pop.style.visibility = "hidden";
}

// HIDE BANNERS 

function hidebanners(){
var ban = document.getElementById('topbanner');
if (ban){ban.style.display='none';}
ban = document.getElementById('midban');
if (ban){ban.style.display='none';}
ban = document.getElementById('botbanner');
if (ban){ban.style.display='none';}
ban = document.getElementById('ban250');
if (ban){ban.style.display='none';}
ban = document.getElementById('snackbanner');
if (ban){ban.style.display='none';}
}

function showbanners(){
var ban = document.getElementById('topbanner');
if (ban){ban.style.display='';}
ban = document.getElementById('midban');
if (ban){ban.style.display='';}
ban = document.getElementById('botbanner');
if (ban){ban.style.display='';}
ban = document.getElementById('ban250');
if (ban){ban.style.display='';}
ban = document.getElementById('snackbanner');
if (ban){ban.style.display='';}
}

function unblockpage(){
showbanners();
document.body.style.overflow = '';
var bk = document.getElementById("block");
bk.style.display='none';
bk = document.getElementById("blockcontent");
bk.style.display='none';
}

// ///////////////////////////////////////////////////
// BLOCK CONTENT
//
function blockpage(html)
{
hidebanners();
var bk = document.createElement("div");
var ps = getPageSize();
bk.onmousedown = "return false;"
bk.onclick = "return false;"
bk.onmousemove = "return false;"
bk.onmouseup = "return false;"
bk.ondblclick = "return false;"
bk.style.position='absolute';
bk.style.left='0px';
bk.style.top='0px';
bk.style.width=ps[0] + 'px';
bk.style.height=ps[1] + 'px';
document.body.style.overflow = 'hidden';
bk.style.backgroundColor = '#ffffff';

bk.id="block";
 

var bc = document.createElement("div");
bc.innerHTML ='<br><br><br><center><img class="imgbut" onclick="unblockpage()" src="/-/content/closead.gif" ></center><br><center>' + html + '</center><br><center><img class="imgbut" onclick="unblockpage()" src="/-/content/closead.gif" ></center>';
bc.id="blockcontent";
bc.style.position='absolute';
bc.style.width=ps[0] + 'px';
bc.style.left='0px';
bc.style.top='0px';

var objBody = document.getElementsByTagName("body").item(0);
objBody.insertBefore(bk, objBody.firstChild);
objBody.insertBefore(bc, objBody.firstChild);


    if (document.all){
		document.body.onresize = resizeblock;
	} else {
  		if (window.addEventListener) {
      		window.addEventListener("resize", resizeblock, false);
   		} else {
      		window.attachEvent("resize", resizeblock);
		}
	}
}

function resizeblock(){
document.body.style.overflow = 'hidden';
var bk = document.getElementById("block");
var bc = document.getElementById("blockcontent");
    if (bk){
            var ps = getPageSize()
            bk.style.width=ps[0] + 'px';
            bk.style.height=ps[1] + 'px';
            bc.style.width=ps[0] + 'px';
            }
}



/* Login remember checkbox */ 
 function setrem(i)
{
var v = document.getElementById('remember')
if (v.value=='0')
{
    i.src='/-/_site/avp/remember_on.gif';
    v.value='1';
}else{
    i.src='/-/_site/avp/remember_off.gif';
    v.value='0';
}
}



/* 
 ***********************************
 ********* COOKIE HANDLING *********
*/
function cset(name, val)           
{
var dt = new Date();                               
dt.setTime(dt.getTime() + 31536000000);          
document.cookie=name+"="+escape(val)+"; expires="+dt.toGMTString();   
}
function cget(name)                                             
{
kakor=document.cookie;                                           
kakor_delar=kakor.split("; ");                                  
for (raknare_i=0;raknare_i<kakor_delar.length;raknare_i++)      
{
tva_delar=kakor_delar[raknare_i].split("=");                   
if (tva_delar[0]==name)                                         
{
return unescape(tva_delar[1]);                                   
}
}
return "";
}


function fbs_click(t) {
u=location.href;
if (t==null){t=document.title;}
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
function tips_click(did, t) {

window.open('/snacka/tipsa/' + did + '/' + encodeURIComponent(t) +'/','sharer','toolbar=0,status=0,width=600,height=400');
return false;
}


function play(url){
AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','560','height','120','align','middle','src','NOTNEEDED_TAKENFROM_MOVE_INSTEAD','quality','high','bgcolor','#ffffff','name','28','allowscriptaccess','sameDomain','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','/script/player.swf?surl=' + encodeURIComponent(url) );
}

function openwin(src){
NewWin=window.open(src ,'t','width=520,height=420,scrollbars=1,menubar=no,resizable=yes');
NewWin.focus();
return false;
}

function blockuser(bsuid,bcom)
{
NewWin=window.open('/medlem/administrera/pop_block.aspx?suid=' + bsuid + '&c=' + bcom ,'BWin','width=520,height=420,scrollbars=1,menubar=no,resizable=yes');
NewWin.focus();
}