// *************************************************************************
// * *
// * http://www.pentia.dk/ *
// * *
// * Author: Brian Pedersen, Pentia A/S *
// * *
// * E-Mail: dev@pentia.dk *
// * *
// * Copyright(C) Pentia, 1997 - 2003. All rights reserved (R). *
// * *
// * LEGAL NOTICE: This is unpublished proprietary source code of Pentia. *
// * The contents of this file are protected by copyright laws and *
// * international copyright treaties, as well as other intellectual *
// * property laws and treaties. These contents may not be extracted, *
// * copied, modified or redistributed either as a whole or part thereof *
// * in any form, and may not be used directly in, or to assist with, the *
// * creation of derivative works of any nature without prior written *
// * permission from Pentia. The above copyright notice does not *
// * evidence any actual or intended publication of this file. *
// * *
// *************************************************************************
// Purpose: General javascript helper functions
// Bugs:
// History:
// *************************************************************************

function setCookie(name, value, expire) 
{
	var duration = 7;
	var today = new Date()
	var defaultExpire = new Date()
	defaultExpire.setTime(today.getTime() + 1000*60*60*24*duration)
	var currentCookie = name + "=" +
		escape(value) +
		((expire == null) ?
			("; expires=" + defaultExpire.toGMTString()) : 
			("; expires=" + expire.toGMTString()));
	document.cookie = currentCookie;
}

function getCookie(name) 
{
	var prefix = name + "="
	var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1)
		return null
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

