// Generell script for basic functions such as hiding/showing layers, popups, roll-overs.
// DHTML functions and values
var layerRef = "document[";
var layerRef2 = "]";
var showRef = "show";
var hideRef = "hide";
if(document.layers) {
	var layerRef = "document["; var layerRef2 = "]"; 
	var showRef = "show"; 
	var hideRef = "hide";
}
else if(document.all) {
	var layerRef = "document.all[";
	var layerRef2 = "].style";
	var showRef = "visible";
	var hideRef = "hidden";
}
else {
	var layerRef = "document.getElementById("; var layerRef2 = ").style";
	var showRef = "visible"; var hideRef = "hidden";
}

function hideLayer(layerName) {
	eval( layerRef + '"' + layerName + '"' + layerRef2 + '.visibility = ' + '"' + hideRef + '"' )
}

function showLayer(layerName) {
	eval( layerRef + '"' + layerName + '"' + layerRef2 + '.visibility = ' + '"' + showRef + '"' )
}

function toggleLayer(whichLayer) {
	if(eval( layerRef + '"' + whichLayer + '"' + layerRef2 + '.visibility == ' + '"' + showRef + '"' )) {	
		hideLayer(whichLayer);
	}
	else {
		showLayer(whichLayer);
	}
}

// RedSheriff standard ID
var rs_id = 0;

// Rollover funktion
function ro(where,which) {
	document.images[where].src = eval(which + ".src");
}

// Byt sida med dropdowner
function ddSwitch(where) {
	if(where.options[where.options.selectedIndex].value != "#") {
		window.location.href=(where.options[where.options.selectedIndex].value);
	}
}

// Popupfšnster
function popWin(whatUrl,bredd,hojd) {
	window.open(whatUrl,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width='+bredd+',height='+hojd);
}

function popWinExt(whatUrl,bredd,hojd,para) {
	window.open(whatUrl,'_blank',para + ',width='+bredd+',height='+hojd);
}

function popPrint(whatUrl,bredd,hojd) {
	window.open(whatUrl,'_blank','toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=0,copyhistory=0,width='+bredd+',height='+hojd);
}

//för att visa flashfiler
function popFlashWin(whatUrl,bredd,hojd) {
	window.open('/cgi-bin/sr_flash.asp?strFile=' +whatUrl+'&intWidth='+bredd+'&intHeight='+hojd,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width='+bredd+',height='+hojd);
}



function popPlayer(namn) {
	popNewPlayer(namn) 
}


function chkPlayerWindow(){
	if(webbradioWin==null || webbradioWin.closed){
		alert('Du måste tillåta extrafönster ("pop-up")')
	} else {
	webbradioWin.focus();
	}
}


function popNewPlayer(namn) {
 if (namn != null) {
  	webbradioWin = window.open('/webbradio/start.asp?' +namn,'webbradio','width=348,height=500,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,resizable=1');
  	chkPlayerWindow();
   }
   else {
	webbradioWin = window.open('/webbradio/start.asp','webbradio','width=348,height=500,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,resizable=1');
  	chkPlayerWindow();
   } 
}

 


function goDD(theForm) {
	window.location.href = document.forms[theForm].goSelect[document.forms[theForm].goSelect.options.selectedIndex].value;
}

function openVoteResult(choice,voteSessionID,numberOfChoice)
{
	var itemID;
	var URL;
	var checkChecked;
	var placeLeft;
	var placeHeight;
	var height;
	var formName;
	
	formName = "webVote"+ voteSessionID
	
	height = 155;
	
	for(i=1;i<numberOfChoice;i++)
	{
		height += 25; 
	}
	
	placeLeft = screen.width/2-410;
	placeHeight = screen.height/2-height;
	
	if (choice == 'vote')
	{
		checkChecked = false
		for (var x = 0 ; x<numberOfChoice ; x++){
			if(eval('document.'+formName+'.choice[x].checked')){
				itemID = eval('document.'+formName+'.choice[x].value;')
				checkChecked = true;
				break;
			}
		}
		
		if (checkChecked == true)
		{
			URL= '/cgi-bin/webvote/v2002resultat.asp?votesessionid=' + voteSessionID + '&alt=' + itemID;
		}
		else
		{
			URL= '/cgi-bin/webvote/v2002resultat.asp?votesessionid=' + voteSessionID;
		}
	
	}
	else if (choice == 'look')
	{
		URL= '/cgi-bin/webvote/v2002resultat.asp?votesessionid=' + voteSessionID;
	}
	else
	{
		URL= '/cgi-bin/webvote/v2002resultat.asp';
	}
	
	window.open(URL,"popup","resizable=no,scrollbars=no,width=410,height="+height+",left="+placeLeft+",top="+placeHeight+"screenX="+placeLeft+"screenY="+placeHeight+"");
}
