

//uppdaterad 2002-05-05 av mattias
var DYNAMIC_TYPE=2, STATIC_TYPE=1;

// *** OBJEKT DEF. ***
function SubMenuItem(t_itemTex,t_itemUrl,t_altText)
{
this.itemText=t_itemTex;
this.itemUrl=t_itemUrl;
this.altText=t_altText;
}

function MenuItem(t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl, t_itemUrl)
//ERSATT 021113 M�lagt till Url-parametern
//function MenuItem(t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl)
{
	this.menuIndex = t_menuIndex;
	this.leftPosition = t_leftPosition;
	this.topPosition = t_topPosition;
	this.width = t_width;
	this.height = t_height;
	this.altText = t_altText;
	this.onMouseOverElementUrl = t_onMouseOverElementUrl;
	this.onMouseOutElementUrl = t_onMouseOutElementUrl;
	this.itemUrl = t_itemUrl; // NY EGENSKAP 021113 (M�
	
}

function SubMenu(t_menuIndex, t_topPosition, t_leftPosition, t_width)
{
	this.itemArray = new Array();
	this.numberOfItems = 0; //defaultv�de
	this.menuIndex = t_menuIndex;
	this.topPosition =  t_topPosition;
	this.leftPosition = t_leftPosition;
	this.width = t_width;

}
	
function P3Menu(t_zindex)
{
	
	this.menu1ItemArray = new Array();
	this.menu2ItemArray = new Array();
	this.subMenuArray = new Array();
	
	this.zindex=t_zindex;
	
	//medlemsfunktion
	this.addMenuItem=addMenuItem;
	this.addSubMenu=addSubMenu;
	this.addSubMenuItem=addSubMenuItem;
	//this.getMenuStyleClasses=getMenuStyleClasses;
	this.getMenu=getMenu;
	
}
// *** SLUT OBJEKT DEF. ***

// *** P3Menu's metoder ****

		
function getMenu(typeOfMenu,intTopOffset,intLeftOffset,blnHideFirstItem,intHeight,intWidth)
{

	if (is_explorer4) { var explorer4fix = " style=\"cursor:hand;\""; }
	else { var explorer4fix = ""; }

	var tempstring=""; 
	var tempstringA="";
	var tempstringB="";
	var tempstringSUB="";
	var subMenuExists=false;
	var tableWidth = intWidth;
	
	if ( (is_explorer4up||is_netscape6up||is_opera7up) && typeOfMenu==DYNAMIC_TYPE)
	{
				
		//tempstringA += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\""+ tableWidth +"\"><tr>";
		//tempstringA += "<td style=\"background:black;\" height=\"26\" ></td>";
		//tempstringA += "</tr></table>";
		if(tableWidth != null && intHeight != null){
			tempstringA += "<div style=\"background:black; width:"+ tableWidth +"px; height:" + intHeight + "px;\"></div>";
		}
	
		CurrentMenuItemArray = eval('this.menu'+ 2 +'ItemArray');
		
		for (i=0;i<CurrentMenuItemArray.length;i++)
		{
			if(i != 0 || !blnHideFirstItem){
				tempstringB = "<span id=\"mks_" + CurrentMenuItemArray[i].menuIndex +"\" style=\"position: absolute; z-index:"+ (this.zindex+10) +"; top: " + (CurrentMenuItemArray[i].topPosition + intTopOffset)  + "px; left: "+ (CurrentMenuItemArray[i].leftPosition + intLeftOffset) +"px\">";
				subMenuExists=false;
				for (j=0;j<this.subMenuArray.length;j++)
				{
					if(this.subMenuArray[j].menuIndex == CurrentMenuItemArray[i].menuIndex )
					{
						tempstringSUB += "<div id=\"subMenu" + CurrentMenuItemArray[i].menuIndex + "\" style=\"position: absolute; z-index:" + (this.zindex+20) +"; left: " + (this.subMenuArray[j].leftPosition + intLeftOffset) +  "px; top: " + (this.subMenuArray[j].topPosition + intTopOffset) + "px; visibility: hidden;\" onmouseout=\"startHideCountDown('subMenu"+this.subMenuArray[j].menuIndex+"');\" onmouseover=\"stopHideCountDown('subMenu"+this.subMenuArray[j].menuIndex+"');\">  ";
						tempstringSUB += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\""+ this.subMenuArray[j].width +"\"><tr><td class=\"menuTdTop\">&nbsp;</td></tr>";
	
						for (k=0;k<this.subMenuArray[j].itemArray.length;k++)
						{
							if(this.subMenuArray[j].itemArray[k].itemUrl.indexOf("javascript:")== -1)
							{
								tempstringSUB += "<tr><td class=\"menuTdOut\" " + explorer4fix + " onMouseOver=\"this.className='menuTdOver';\"  onMouseOut=\"this.className='menuTdOut';\" onmouseup=\"window.location='"+ this.subMenuArray[j].itemArray[k].itemUrl +"'\" title=\""+this.subMenuArray[j].itemArray[k].altText+"\">"+this.subMenuArray[j].itemArray[k].itemText+"</td></tr>";
							}
							else
							{
									tempstringSUB += "<tr><td class=\"menuTdOut\" " + explorer4fix + " onMouseOver=\"this.className='menuTdOver';\" onMouseOut=\"this.className='menuTdOut';\" onmouseup=\""+ this.subMenuArray[j].itemArray[k].itemUrl +"\" title=\""+this.subMenuArray[j].itemArray[k].altText+"\">"+this.subMenuArray[j].itemArray[k].itemText+"</td></tr>";
							}				
						}
						
						tempstringSUB +="<tr><td class=\"menuTdBottom\">&nbsp;</td></tr></table>";
						tempstringSUB +="</div>";
						subMenuExists=true;
					}
				
				}
					
				if(subMenuExists){
					tempstringB += "<img onmouseover=\"this.src='" + CurrentMenuItemArray[i].onMouseOverElementUrl+ "'; showSubMenu('subMenu" + CurrentMenuItemArray[i].menuIndex +  "');\" onmouseout=\"this.src='"+ CurrentMenuItemArray[i].onMouseOutElementUrl +"'; startHideCountDown('subMenu"+CurrentMenuItemArray[i].menuIndex+"');\" src=\"" +CurrentMenuItemArray[i].onMouseOutElementUrl+ "\" width=\""+ CurrentMenuItemArray[i].width +"\" height=\""+CurrentMenuItemArray[i].height+"\" alt=\""+CurrentMenuItemArray[i].altText+"\" border=\"0\">";
					}
				else{
					tempstringB += "<a href=\"" + CurrentMenuItemArray[i].itemUrl + "\" title=\"" + CurrentMenuItemArray[i].altText  + "\"><img style=\"cursor:pointer;\" onmouseover=\"this.src='" + CurrentMenuItemArray[i].onMouseOverElementUrl+ "';\" onmouseout=\"this.src='"+ CurrentMenuItemArray[i].onMouseOutElementUrl +"';\" src=\"" +CurrentMenuItemArray[i].onMouseOutElementUrl+ "\" width=\""+ CurrentMenuItemArray[i].width +"\" height=\""+CurrentMenuItemArray[i].height+"\" alt=\""+CurrentMenuItemArray[i].altText+"\" border=\"0\"></a>";
					}
								
				tempstringB += "</span>";
				tempstringA += tempstringB;
			}
		}
		tempstringA +=tempstringSUB;
		return tempstringA;
		
	}
	else{
		
		CurrentMenuItemArray = eval('this.menu'+ 1 +'ItemArray');
		
	
		var aggCellWidth = 0;
		
		tempstringSUB += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\""+ tableWidth +"\"><tr>";
								
		for (i=0;i<CurrentMenuItemArray.length;i++)
		{
			aggCellWidth += CurrentMenuItemArray[i].width;
			tempstringSUB += "<td bgcolor=\"#000000\" width=\"" + CurrentMenuItemArray[i].width + "\"><a href=\"" + CurrentMenuItemArray[i].itemUrl + "\" title=\"" + CurrentMenuItemArray[i].altText  + "\" ><img  src=\"" +CurrentMenuItemArray[i].onMouseOutElementUrl+ "\" width=\""+ CurrentMenuItemArray[i].width +"\" height=\""+CurrentMenuItemArray[i].height+"\" alt=\""+CurrentMenuItemArray[i].altText+"\" border=\"0\"></a></td>";
		}
		
		if (aggCellWidth < tableWidth) {
			tempstringSUB += " <td  bgcolor=\"#000000\" width=\"" + (tableWidth - aggCellWidth) + "\">&nbsp;</td>";
		}
		
		tempstringSUB += "</tr></table>";
		return tempstringSUB;
	}
	
}	//slut getMenu









	
function addSubMenuItem(t_menuIndex,t_itemTex,t_itemUrl,t_altText)
{
	if(window.location.toString().indexOf("sr.se") == -1 || window.location.toString().indexOf("p3star.sr.se") > -1  ||  window.location.toString().indexOf("stage1.sr.se") > -1 ){
		if(t_itemUrl.indexOf("javascript:")== -1 && t_itemUrl.indexOf("http://")== -1){
			t_itemUrl = "http://www.sr.se" + t_itemUrl;
		}
	}
	for(i=0;i<this.subMenuArray.length;i++)
		{
		if(t_menuIndex == this.subMenuArray[i].menuIndex)
		{
			this.subMenuArray[i].itemArray[this.subMenuArray[i].numberOfItems] = new SubMenuItem(t_itemTex,t_itemUrl,t_altText);
			this.subMenuArray[i].numberOfItems ++;	
		}
	}
} //slut addSubMenuItem

function addSubMenu(t_menuIndex, t_leftPosition, t_topPosition, t_width)
{
	this.subMenuArray[this.subMenuArray.length] = new SubMenu(t_menuIndex, t_topPosition, t_leftPosition, t_width);
} //slut addSubMenu

/* UTBYTT 021113 mot nedan (M�
function addMenuItem(t_menuNumber, t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl)
{
	if(t_menuNumber==1)
		this.menu1ItemArray[this.menu1ItemArray.length] = new MenuItem(t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl);
	else if(t_menuNumber==2)
		this.menu2ItemArray[this.menu2ItemArray.length] = new MenuItem(t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl);
} //slut addMenuItem
*/
// NY 021113 mot nedan (M� kopletterat med Url-parameter
function addMenuItem(t_menuNumber, t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl, t_itemUrl)
{
	if(window.location.toString().indexOf("p3star.com") > -1 || window.location.toString().indexOf("p3star.se") > -1 || window.location.toString().indexOf("p3star.sr.se") > -1 || window.location.toString().indexOf("stage1.sr.se") > -1 ){
		if(t_itemUrl.indexOf("javascript:")== -1 && t_itemUrl.indexOf("http://")== -1){
			t_itemUrl = "http://www.sr.se" + t_itemUrl;
		}
		t_onMouseOutElementUrl  = "http://www.sr.se" + t_onMouseOutElementUrl;
		t_onMouseOverElementUrl = "http://www.sr.se" + t_onMouseOverElementUrl;
	}
	
	if(t_menuNumber==1)
		this.menu1ItemArray[this.menu1ItemArray.length] = new MenuItem(t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl, t_itemUrl);
	else if(t_menuNumber==2)
		this.menu2ItemArray[this.menu2ItemArray.length] = new MenuItem(t_menuIndex, t_leftPosition, t_topPosition, t_width, t_height, t_altText, t_onMouseOverElementUrl, t_onMouseOutElementUrl, t_itemUrl);
} //slut addMenuItem


// *** slut P3Menu's metoder ****

//*** globala hj�pfunktioner f� IE4 ***
function Ie4RollOver(object)
{
	object.style.background="white";
	object.style.color="black";
	object.style.cursor="hand";
}
function Ie4RollOut(object)
{
	object.style.background="black";
	object.style.color="white";
	object.style.cursor="default";
}
//*** slut globala hj�pfunktioner f� IE4 ***

// ** menyfunktionalitet **

//****** DEALY TIME ********
var delayTime = 100;
//****** DEALY TIME ********

var countDown = false;
var globalElement = "nada";
var globaDoneDelay = false;

function showSubMenu(element)
{
	if(countDown)
	{
		stopHideCountDown();
		hide(globalElement);
	}
	show(element);
}
function startHideCountDown(element){
	if (!countDown)
	{ 
		globalDoneDelay=false;
		globalElement=element;
		HideCountDown();
		countDown=true;
	}
}
function stopHideCountDown()
{
	if (countDown)
	{
		window.clearTimeout(countDownTimer);
		countDown=false;
	}
}
function HideCountDown()
{
	if (globalDoneDelay)
	{
		hide(globalElement);
		countDown=false;
	}
	else
	{
		countDownTimer=window.setTimeout("HideCountDown();",delayTime);
		globalDoneDelay=true; //n�tan
	}
}


/**
 * Global g�/visa funktion
 **/

function show(element){
	if(is_explorer4){eval('document.all.'+element+'.style.visibility="visible"');}
	else {eval('document.getElementById("'+element+'").style.visibility="visible"');}
	//visibilityByElement("object", "embed", "form", "hidden");
}

function hide(element){
	if(is_explorer4){eval('document.all.'+element+'.style.visibility="hidden"');}
	else {eval('document.getElementById("'+element+'").style.visibility="hidden"');}
	//visibilityByElement("object", "embed", "form", "visible");
}

function visibilityByElement() {
	if (arguments.length < 2) return;
	var vis = arguments[arguments.length - 1];
	if (vis != "visible" && vis != "hidden") return;

	for (var i = 0; i < arguments.length - 1; i++) {
		if (arguments[i] == "form") {
			for (var fi = 0; fi < document.forms.length; fi++) {
				for (var ei = 0; ei < document.forms[fi].elements.length; ei++)
					document.forms[fi].elements[ei].style.visibility = vis;
			}
		} else {
			var elms = document.getElementsByTagName(arguments[i]);
			for (var ei = 0; ei < elms.length; ei++)
				elms[ei].style.visibility = vis;
		}
	}
}

/**
 * Slut menyfunktionalitet
 **/

// ** popup **
	
	function oppna(url,namn,para){
		window.open(url,namn,para)
		}
		
// ** slut popup **


