	

	// -------------------------------------------------
	// to open a child window with no features
	// -------------------------------------------------
	function wino(strURL, strName, intWidth, intHeight, scrollBars)
	{
		scrollBars = (scrollBars != undefined && scrollBars != "undefined" && scrollBars == "scrollbars") ? '1' : '0';
		window.open(strURL, strName, "width="+intWidth+",height="+intHeight+",scrollbars="+scrollBars+",status=0,toolbar=0");
	}
	
  // -------------------------------------------------
	// to open a child window with all features (at least many)
	// -------------------------------------------------
	function wiall(strURL, strName, intWidth, intHeight, scrollBars)
	{
		window.open(strURL,'Lifeportalen','left=20,top=20,width=600,height=700,toolbar=1,resizable=1,menubar=1,scrollbars=1');
	}
  
	// -------------------------------------------------
	//  funtion to create a cookie
	//  returns: void
	//  arguments: 1. name of cookie to create
	//             2. value to set into cookie
	//             3. number of days that cookie will live
	// -------------------------------------------------
		function createCookie(name,value,days)
		{
			if (days)
			{
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}

	// -------------------------------------------------
	//  funtion to read a cookie
	//  returns: 1. value of requested cookie
	//           2. null (if requested cookie did not exist)
	//  arguments: 1. name of cookie to read value from
	// -------------------------------------------------
		function readCookie(name)
		{
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++)
			{
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}

	// -------------------------------------------------
	//  funtion to erase a cookie
	//  returns: void
	//  arguments: 1. name of cookie to erase
	// -------------------------------------------------
		function eraseCookie(name)
		{
			createCookie(name,"",-1);
		}
		
	// ----------------------------------------------
	// disable context menu
	// ----------------------------------------------
		/*document.oncontextmenu = function(){return false}
		if(document.layers)
		{
			window.captureEvents(Event.MOUSEDOWN);
			window.onmousedown = function(e)
			{
				if(e.target==document)return false;
			}
		}
		else 
		{
			document.onmousedown = function(){return false}
		}*/


		function fixRowSpanBug()
		{
			var sHeight = document.body.scrollHeight;
			sHeight = sHeight - 300;
			document.getElementById('boxSmall_setheight').style.height = sHeight;
		}
		
		
	function closePlayer()
	{
		if(document.getElementById('lockedLayer')) document.getElementById('lockedLayer').style.display = "none";
		if(document.getElementById('lifePlayer')) document.getElementById('lifePlayer').style.display = "none";
		if(document.getElementById('lifePlayer')) document.getElementById('lifePlayer').innerHTML = '';
	}	
	function openPlayer()
	{
		Opera = navigator.userAgent.indexOf("Opera") > -1;
		IE = navigator.userAgent.indexOf("MSIE") > -1;
			
		// scroll window to top
		window.scroll(10000, 0);
		
		// enable background fader
		if(document.getElementById('lockedLayer')) document.getElementById('lockedLayer').style.display = "block";
		
			// set fade height
			if(document.getElementById('lockedLayer')) setFadeHeight();
			
		// create player div
		if(!document.getElementById('lifePlayer'))
		{
			// create the player DIV
			var divElement = document.createElement("div");
			divElement.setAttribute('id', 'lifePlayer');
			
			// create parent object (that will contain the "read box"
			var divParent = document.getElementsByTagName("body");
			divParent = divParent[0];
			
			// append "lifePlayer" box into body
			divParent.appendChild(divElement);
			
			// set style attribute on this new div
			document.getElementById('lifePlayer').style.position = "absolute";
			document.getElementById('lifePlayer').style.left = "45px";
			document.getElementById('lifePlayer').style.top = "60px";
			document.getElementById('lifePlayer').style.width = IE ? "721px" : "701px";
			document.getElementById('lifePlayer').style.height = IE ? "495px" : "475px";
			document.getElementById('lifePlayer').style.border = "1px solid black";
			document.getElementById('lifePlayer').style.backgroundColor = "black";
			document.getElementById('lifePlayer').style.padding = "20px 0 0 20px";
			document.getElementById('lifePlayer').style.overflow = "hidden";
			document.getElementById('lifePlayer').style.zIndex = "101";
			document.getElementById('lifePlayer').style.backgroundImage = "URL(inc/gfx/lifetv_bg.gif)";
		}
		
		// display player
		document.getElementById('lifePlayer').style.display = "block";
		
		// load content of player div
		if(document.getElementById('lifePlayer')) document.getElementById('lifePlayer').innerHTML = '<iframe src="webbtv/index.php" style="width: '+(IE ? "721px" : "701px")+'; height: '+(IE ? "495px" : "475px")+';" frameborder="0" allowtransparency="true"></iframe>';
	}
  
	// -------------------------------------------------
	//  funtion to open life-tv player with given clip
	//  returns: void
	//  arguments:  1. name of clip top play
  //              2. true if open for non-vip members
	// -------------------------------------------------
	function openLinkedPlayer(clip, nonvip)
	{
		Opera = navigator.userAgent.indexOf("Opera") > -1;
		IE = navigator.userAgent.indexOf("MSIE") > -1;
		
    //alert(nonvip);
    if (nonvip != true) {
      // if current page contains an "vip element" clip is loked
      // to vip and admin members		
      if (document.getElementById('vip')) {
        var str = document.getElementById('vip').innerHTML;
        if (!str.match('vip')) {
          alert('Endast vip medlemmar kan se Life-Tv, bli vip medlem!');
          return 0;
        }
      }
    }

		// scroll window to top
		window.scroll(10000, 0);
		
		// enable background fader
		if(document.getElementById('lockedLayer')) document.getElementById('lockedLayer').style.display = "block";
		
			// set fade height
			if(document.getElementById('lockedLayer')) setFadeHeight();
			
		// create player div
		if(!document.getElementById('lifePlayer'))
		{
			// create the player DIV
			var divElement = document.createElement("div");
			divElement.setAttribute('id', 'lifePlayer');
			
			// create parent object (that will contain the "read box"
			var divParent = document.getElementsByTagName("body");
			divParent = divParent[0];
			
			// append "lifePlayer" box into body
			divParent.appendChild(divElement);
			
			// set style attribute on this new div
			document.getElementById('lifePlayer').style.position = "absolute";
			document.getElementById('lifePlayer').style.left = "45px";
			document.getElementById('lifePlayer').style.top = "200px";
			document.getElementById('lifePlayer').style.width = IE ? "721px" : "701px";
			document.getElementById('lifePlayer').style.height = IE ? "365px" : "345px";
			document.getElementById('lifePlayer').style.border = "1px solid black";
			document.getElementById('lifePlayer').style.backgroundColor = "black";
			document.getElementById('lifePlayer').style.padding = "20px 0 0 20px";
			document.getElementById('lifePlayer').style.overflow = "hidden";
			document.getElementById('lifePlayer').style.zIndex = "101";
			document.getElementById('lifePlayer').style.backgroundImage = "URL(inc/gfx/lifetv_bg.gif)";
		}
		
		// display player
		document.getElementById('lifePlayer').style.display = "block";
		
		// load content of player div
		if(document.getElementById('lifePlayer')) document.getElementById('lifePlayer').innerHTML = '<iframe src="webbtv/linktv.php?clip='+clip+'" style="width: '+(IE ? "721px" : "701px")+'; height: '+(IE ? "365px" : "345px")+';" frameborder="0" allowtransparency="true"></iframe>';
	}
  
	function setFadeHeight()
	{
		if(document.getElementById('lockedLayer'))
		{
			var header_height = 0;
			
			var height = document.body.offsetHeight > (screen.availHeight-header_height) ? document.body.offsetHeight : (screen.availHeight-header_height);
			height = height > document.body.scrollHeight ? height : document.body.scrollHeight;
			var raw_height = height;
			Opera = navigator.userAgent.indexOf("Opera") > -1;
			IE = navigator.userAgent.indexOf("MSIE") > -1;
			
			// remove header height
			height = height - header_height;
			
			//Checks if browser = Opera and sets 3 specific divs to site offsetHeight
			if(Opera)
			{
				// remove just a little bit more to avoid scrolling
				//height = height-12;
				
				if(document.getElementById('lockedLayer')) document.getElementById('lockedLayer').style.height = raw_height;
			}
			//If IE, set 3 specific divs to site offsetHeight minus height of header
			else if(IE)
			{
				// remove just a little bit more to avoid scrolling
				height = height-12;
				
				if(document.getElementById('lockedLayer')) document.getElementById('lockedLayer').style.height = raw_height;
			}
			//If not Opera or IE (hopefully Mozilla), set 3 specific divs to site offsetHeight minus height of header
			else
			{
				// remove just a little bit more to avoid scrolling
				height = height+100;
				
				if(document.getElementById('lockedLayer')) document.getElementById('lockedLayer').style.height = raw_height;
			}
		}
	}
  
  function ow(url,p) {
  /////////////////////////////////////////////////////////////////////
  // Function to open a Textalk Weblisher publication.               //
  // Parameter 'url' is the path to the view file, probably named    //
  // 'view.php'. It may be a local path (../pub/view.php) or a full  //
  // URL (http://my.server.com/view.php).                            //
  // Parameter 'p' MAY be set to the subdirectory of a specific      //
  // publication. If not set, it will show the default publication.  //
  /////////////////////////////////////////////////////////////////////
  var width = screen.availWidth;
  var height = screen.availHeight;
  var fullscreen = false;  // For future use
  var fullurl;
  var opts;
  if (url == '') url = 'view.php';
  fullurl = url;
  if (p != '') fullurl += '?p=' + escape(p);
  opts = 'titlebar=no,toolbar=no,location=no,status=yes';
  opts += ',personalbar=no,resizable=yes,menubar=no,scrollbars=yes';
  opts += ',width=' + width + ',height=' + height;
  opts += ',screenX=0,screenY=0,top=0,left=0';
  if (fullscreen) opts += ',fullscreen=yes';
  w = window.open(fullurl,'_blank',opts);
  w.focus();
  if(w.moveTo) w.moveTo(0, 0);
  if(w.resizeTo) w.resizeTo(width, height);
}
