/* funktionen används bl.a. till nyheterna. Vid länkar i nyheterna ska det eventuellt länkas tillbaka till opener-fönstret*/
function linkBack(inURL)
{
	var strBaseURL;
	var strPath;
	var strHost;
	var strNewURL
	strBaseURL = 'http://www.uppsala.se/'
	strPath = inURL.pathname
	strHost = inURL.hostname
	
	if (strHost =='')
	{
		strNewURL = strBaseURL + strPath
		window.opener.location = strNewURL
	}
	else 
	{
		strNewURL = inURL
		window.open(strNewURL)
	}
	return false;
}

function initTwitter()
{
    new TWTR.Widget({
        version: 2,
        type: 'profile',
        rpp: 4,
        interval: 6000,
        width: 'auto',
        height: 300,
        theme: {
            shell: {
                background: '#ffffff',
                color: '#000000'
            },
            tweets: {
                background: '#ffffff',
                color: '#000000',
                links: '#0b61bd'
            }
        },
        features: {
            scrollbar: false,
            loop: false,
            live: false,
            hashtags: true,
            timestamp: true,
            avatars: false,
            behavior: 'all'
        }
    }).render().setUser('uppsalakommun').start();
}
function go2url(item)
{
  var url;
  url = item.options[item.selectedIndex].value;

  if (url != '0') location.href = url;
}

<!--

function changeImage(imgName,imgObj) 
{
		eval('document.images[\"' + imgName + '\"].src = \"' + imgObj + '\"')
}

function printPop(URL, nrOfColumns)
{
	var width;
	
	if (nrOfColumns == 1) {
		width = 510;
	}
	else {
		width = 620;
	}
	
	window.open(URL, 'Print', 'resizable=1,menubar=yes,scrollbars=1,location=no,toolbar=0,directories=no,width=' + width + ',height=500');
}

function tipFriendPop(URL)
{
	window.open(URL, 'TipFriend', 'resizable=1,menubar=no,scrollbars=0,location=no,toolbar=0,directories=no,width=350,height=450');
}


// Skapar ett nytt "strippat" fönster placerat i punkten x,y med bredden 'bredd',
// höjden 'hojd' och som ska startas upp med sidan 'sidlank'.
function newsPop(x,y,bredd,hojd,sidlank,winName)
{

	var link;
	
	link = sidlank + ''; //&news=YES'
/*	fonster = window.open(link,'' + winName + '', 'width=' + bredd + ",height=" + hojd + ",menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,status=no,dependent=yes,screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x);
	fonster.focus();*/
	
	fonster = window.open(link,winName,"width=" + bredd + ",height=" + hojd + ",menubar=yes,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,status=no,dependent=yes,screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x);
	fonster.focus();
}


function calendarPop(x,y,bredd,hojd,sidlank,winName)
{

	var link;
	
	link = sidlank + '&altView=calendar'
/*	fonster = window.open(link,'' + winName + '', 'width=' + bredd + ",height=" + hojd + ",menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,status=no,dependent=yes,screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x);
	fonster.focus();*/
	
	fonster = window.open(link,winName,"width=" + bredd + ",height=" + hojd + ",menubar=yes,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,status=no,dependent=yes,screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x);
	fonster.focus();
}

function driftInfoPop(x,y,bredd,hojd,sidlank,winName)
{

	var link;
	
	link = sidlank + '&driftInfo=YES'
	
	var fonster = window.open(link,winName,"width=" + bredd + ",height=" + hojd + ",menubar=yes,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,status=no,dependent=yes,screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x);
	fonster.focus();
}

// Skapar ett nytt "strippat" fönster placerat i punkten x,y med bredden 'bredd',
// höjden 'hojd' och som ska startas upp med sidan 'sidlank'.
function PopWindow(x,y,bredd,hojd,sidlank)
{
    var win = window.open(sidlank,"","width=" + bredd + ",height=" + hojd + ",menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,status=no,dependent=yes,screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x);
    win.focus();
}

function encode64 (str)
{
	var charBase64 = new Array(
		'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
		'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
		'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
		'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
	);

	var out = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	var len = str.length;

	do
	{
		chr1 = str.charCodeAt(i++);
		chr2 = str.charCodeAt(i++);
		chr3 = str.charCodeAt(i++);

		//enc1 = (chr1 & 0xFC) >> 2;
		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 0x03) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 0x0F) << 2) | (chr3 >> 6);
		enc4 = chr3 & 0x3F;

		out += charBase64[enc1] + charBase64[enc2];

		if (isNaN(chr2))
  		{
			out += '==';
		}
  		else if (isNaN(chr3))
  		{
			out += charBase64[enc3] + '=';
		}
		else
		{
			out += charBase64[enc3] + charBase64[enc4];
		}
	}
	while (i < len);

	return out;
}

function visa_karta(adress)
{
    if (adress)
    {
        window.open("http://kartan.uppsala.se/?page=content-locate&datasource=ds_extern_custom_search&buffer=200&command=customsearch&namn_base64="+encode64(adress));
    }    
}

// Funktionen öppnar ett nytt fönster för kartprogrammet
function openMap()
{
    var setup, url;
	if(navigator.appName.indexOf("Microsoft") != -1)
	{
		setup='toolbar=no,location=no,directories=no,status=no,menubar=no,width=286,height=128,scrollbars=no,resizable=no,titlebar=no';
		url = 'http://kartor.sbk.uppsala.se/jmapapplet/maprunner.htm';
	}
	else
	{
		setup='height=550,width=600,toolbar=no,status=yes,location=no,resizable=yes,scrollbars=yes';
		url = 'http://kartor.sbk.uppsala.se/SCRIPTS/hsrun.exe/Distributed/' + 'JMapApplet/MapXtreme.htx;start=CreateAppletPage?slump=' + Math.random();
	}
    window.open(url, 'InternKarta', setup);
}
 
function openMapExt()
{
    var setup;
	if(navigator.appName.indexOf("Microsoft") != -1)
	{
		setup = 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,width=800,height=550,scrollbars=yes,resizable=yes,titlebar=yes';
	}
	else
	{
		setup = 'height=550,width=800,toolbar=yes,status=yes,location=yes,resizable=yes,scrollbars=yes';
	}
    window.open('http://kartan.uppsala.se', 'ExternKarta', setup);
}

// Sätter width på diven som innehåller en bild. På detta sätt kommer inte eventuell bildtext att 
// fortsätta ut till höger om den är längre än bilden
function setImageCaptionWidth()
{
	if(document.getElementById("PageImage") != null && document.getElementById("ImageContainer") != null)
	{
		document.getElementById("ImageContainer").style.width = document.getElementById("PageImage").width + "px";
	}
}

// Tar hand om EPi-bugg
if (typeof(EPi) == "undefined") 
{
     var EPi = {};
}

//-->
