//cookie stuff
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate);
}
function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return null;
}




//Resizes the iframe to 100% height. 
function autofitIframe(id) 
{ 
	if (!window.opera && !document.mimeType && document.all && document.getElementById) 
		parent.document.getElementById(id).style.height=(this.document.body.clientHeight - 50)+"px";
    else if(document.getElementById)  
		parent.document.getElementById(id).style.height=(this.document.body.clientHeight - 50)+"px";
} 

//adds a cross-browser load onload event
function addLoadEvent(func) 
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') window.onload = func;
  else 
  {
    window.onload = function() 
    {
		if (oldonload) oldonload();  
		func();
	}
  }
}



function openModalWindow(url,width,height)
{
	var paramspassed = new Array();
	if(arguments.length>3)
		for(i=3;i<arguments.length;i++) paramspassed[paramspassed.length] = arguments[i];

	if(window.showModalDialog)
		var modalWin = window.showModalDialog(url,paramspassed,
		"dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;help:no;resizable:yes;scroll:yes;status:no;edge:sunken");
	else
	{
		var modalWin = window.open(url,"","width="+width+"px,height="+height+"px;");
		window.onfocus = function() {
			//if(modalWin && !modalWin.closed) modalWin.focus();
		}
		modalWin.paramspassed = paramspassed;
		modalWin=document.arr;
	}
	//alert(paramspassed);
	return modalWin;
}

function AttachEvent(elementObj, eventName, eventHandlerFunctionName)
{
  if (elementObj.addEventListener) 
  { // Non-IE browsers
    elementObj.addEventListener(eventName, eventHandlerFunctionName, false);		
  } 
  else if (elementObj.attachEvent) 
  { // IE 6+
    elementObj.attachEvent('on' + eventName, eventHandlerFunctionName);
  } 
  else 
  { // Older browsers 
    var currentEventHandler = elementObj['on' + eventName];
    if (currentEventHandler == null) 
    {
      elementObj['on' + eventName] = eventHandlerFunctionName;
    } 
    else 
    {
      elementObj['on' + eventName] = function(e) { currentEventHandler(e); eventHandlerFunctionName(e); }
    }
  }
}

if (navigator.product == "Gecko") {
Document.prototype.elementFromPoint = function(x, y) {
this.addEventListener("mousemove", this.elementFromPoint__handler, false);
var event = this.createEvent("MouseEvents");
var box = this.getBoxObjectFor(this.documentElement);
var screenDelta = { x: box.screenX, y: box.screenY };
event.initMouseEvent("mousemove", true, false, this.defaultView, 0,
x + screenDelta.x, y + screenDelta.y, x, y,
false, false, false, false, 0, null);
this.dispatchEvent(event);
this.removeEventListener("mousemove", this.elementFromPoint__handler, false);
return this.elementFromPoint__target;
}
Document.prototype.elementFromPoint__handler = function (event) {
this.elementFromPoint__target = event.explicitOriginalTarget;

// reparent target if it is a text node to emulate IE's behavior
if (this.elementFromPoint__target.nodeType == Node.TEXT_NODE)
this.elementFromPoint__target = this.elementFromPoint__target.parentNode;

// change an HTML target to a BODY target to emulate IE's behavior (if we are in an HTML document)
if (this.elementFromPoint__target.nodeName.toUpperCase() == "HTML" && this.documentElement.nodeName.toUpperCase() == "HTML")
this.elementFromPoint__target = this.getElementsByTagName("BODY").item(0);

event.preventDefault();
event.stopPropagation();
}
Document.prototype.elementFromPoint__target = null;
}