function openWindow(theURL,winName,features) 
{
  window.open(theURL,winName, features);
  //height=600,width=600,scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no
}

function openWinCentered(url,w,h,features) {
	x = (document.all) ? 'left=' : 'screenX=';
	y = (document.all) ? 'top=' : 'screenY=';
	window.open(url,'popwin', features + ',width='+w+',height='+h+','+(x+(screen.width-w)/2)+','+(y+(screen.height-h)/2) + '');
}

function popup(height, width, url)
{
	var properties = 'height=' + height + ',width=' + width;
	window.open(url,'',properties);
}

function goToLink(form) {
	window.location = form.options[form.selectedIndex].value;
}

function goToLinkTop(form) {
	if(form.options[form.selectedIndex].value == "top.html")
	{
		parent.head.location.href = form.options[form.selectedIndex].value;
	}
	else
	{
	parent.main.location.href = form.options[form.selectedIndex].value;
	changeMenuAllWhite();
	}
}

function showUserAgent() {

	var agt=navigator.userAgent;
	var indexOfSafari = agt.indexOf('Safari');
	
	if(indexOfSafari != -1)
	{
		document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/safari.css\" />");

	}
}

var pics=new Array("topMenuPjaser","topMenuMedverkande","topMenuOmOss", "topMenuUng", "topMenuPress", "topMenuArkiv", "topMenuWebbtv");

function changeMenuRed(id)
{
	for(i = 0; i<=pics.length-1; i++)
	{
		if(pics[i] != id)
		{
			document.getElementById(pics[i]).src = "img/" + pics[i] + ".gif";
		}
		else
		{
			document.getElementById(id).src = "img/" + id + "Red.gif";
		}
	}
}

function changeMenuAllWhite()
{
	for(i = 0; i<=pics.length-1; i++)
	{
		document.getElementById(pics[i]).src = "img/" + pics[i] + ".gif";
	}
}


function displayHelpWindow(strHelpTextPath)
{
	//Open a new browser window and display the page defined from the provided path in the parameter strHelptextPath
	window.open(strHelpTextPath,'Stadsteatern','toolbar=no,width=400,height=300,left=500,top=200,status=no,scrollbars=yes,rezize=no');
	return true;
}


function escapeVal(textarea,replaceWith)
{
	textarea.value=escape(textarea.value)
	for(i=0; i<textarea.value.length; i++)
	{
	 	if(textarea.value.indexOf("%0D%0A") > -1)
		{
			// Windows encodes returns as \r\n hex
			textarea.value=textarea.value.replace("%0D%0A",replaceWith)
		}
		else if(textarea.value.indexOf("%0A") > -1)
		{
			// Unix encodes returns as \n hex
			textarea.value=textarea.value.replace("%0A",replaceWith)
		}
		else if(textarea.value.indexOf("%0D") > -1)
		{
			// Macintosh encodes returns as \r hex
			textarea.value=textarea.value.replace("%0D",replaceWith)
		}
	}
	textarea.value=unescape(textarea.value)
}

function setFieldFocus(sForm, sField) {
	if(document.forms[sForm][sField]) {
		document.forms[sForm][sField].focus();
	}
}

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

