// browser version object
function fnBrowserInfo() 
{ 
    this.version = navigator.appVersion; 
    this.ver = this.version; 
    this.agent = navigator.userAgent; 
    this.dom = (document.getElementById) ? 1 : 0; 
    this.opera5 = this.agent.indexOf("Opera 5") > -1; 
    this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom && !(this.opera5)) ? 1 : 0; 
    this.ie6 = (this.ver.indexOf("MSIE 6") > -1 && this.dom && !(this.opera5)) ? 1 : 0; 
    this.ie4 = (document.all && !(this.dom) && !(this.opera5)) ? 1 : 0; 
    this.ie = this.ie4 || this.ie5 || this.ie6; 
    this.mac = this.agent.indexOf("Mac") > -1; 
    this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0; 
    this.ns4 = (document.layers && !(this.dom)) ? 1 : 0; 
    this.ns = (this.ns4 || this.ns6)
    this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5); 
    return this; 
} 
var bi = new fnBrowserInfo(); 

function fnCheckForAdminFrameSet()
{
	if (window == top)
	{
		top.document.location = "/admin/";
	}
}

function date_time()
{
	var setTime, setDate;
	now = new Date();
	
	hours = now.getHours();
	minutes = now.getMinutes();
	seconds = now.getSeconds();
	setTime = (((hours < 10) ? "0" : "") + hours);
	setTime += (((minutes < 10) ? ":0" : ":") + minutes);
	setTime += (((seconds < 10) ? ":0" : ":") + seconds);
	
	date = now.getDate();
	month = now.getMonth()+1;
	year = now.getYear();
	setDate = ((date < 10) ? "0" : "") + date;
	setDate += "/" + month;
	setDate += "/" + year;
	
	//navigator.appName.indexOf("Netscape") != -1)
	document.getElementById("DateTime").innerHTML = "<P STYLE='FONT-SIZE=10;COLOR=#000000'><B>Date:</B> <FONT COLOR=#FFFFFF>" + setDate + "<B></FONT>&nbsp;<FONT COLOR=#336666>---</FONT>&nbsp;<B>Time:</B> <FONT COLOR=#FFFFFF>" + setTime + "</FONT>&nbsp;</P>";
	Timer = setTimeout("date_time()", 1000);
}

function trim(str)
{
	return (str && typeof(str == "string")) ? str.replace(/^\s*/, "").replace(/\s*$/, "") : str;
}
/*
var reNonBlank=/[\S]/;
var reHexColor=/^#[0-9a-fA-F]{6}$/;
var reInt=/^\d+$/;
var reSignedInt=/^(\+|-)?\d+$/;
var reFloat=/^\d+(\.\d+)?$/;
var reSignedFloat=/^(\+|-)?\d+(\.\d+)?$/;
var reChar=/^[\w\-]+$/;
var reEMail=/^\w[\w\-\.]+\@\w[\w\-]+(\.\w[\w\-]+)+$/;
var reIP=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
var rePostalCA=/^(\w\d){3}$/;
var reURL=/^http(s)?\:\/\/\w[\w\-]+(\.\w[\w\-]+)+([\/\%\?\&\+\#\.\w\-\=]+)*$/;
*/
function Validate(frm)
{
	var sError="", ctrlValue, required;
	var frmElements = frm.elements;
	if (frmElements)
	{
		for (var index = 0; index < frmElements.length; index ++)
		{
			ctrlValue = trim(frmElements[index].value);
			// Check if the field should be validated.
			var required = frmElements[index].getAttribute("required");
			if (required && !ctrlValue)
			{
				sError += '  *  ' + frmElements[index].getAttribute("errmsg").toString() + '\n';
			}
			else if (frmElements[index].name.toLowerCase() == "email")
			{
				var invalid_email_errmsg = frmElements[index].getAttribute("invalid_email_errmsg")
				if (invalid_email_errmsg)
				{
					ctrlValue = ctrlValue.search(/^[\w\.-]+@([\w-]+\.)+[a-z]{2,4}$/i);
					if (ctrlValue == "-1")
					{
						sError += '  *  ' + invalid_email_errmsg.toString() + '\n';
					}
				}
			}
		}
	}
	if (sError)
	{
		window.alert("Fejl: \n---------------------------------------------------------------------------\n" + sError);
		return false;
	}
	return true;
}
function ToggleShipment(chkBox)
{
	var r1 = GetDOMObject('R1');
	var r2 = GetDOMObject('R2');
	r1.disabled = !chkBox.checked;
	r2.disabled = !chkBox.checked;
}
function GetDOMObject(sID)
{
	if (document.getElementById)
	{
		return document.getElementById(sID);
	}
	else if (document.layers)
	{
		return document.layers[sID];
	}
	else if (document.all)
	{
		return document.all(sID);
	}
}

function GetStyleObject(sID)
{
	if (document.getElementById)
	{
		return document.getElementById(sID).style;
	}
	else if (document.layers)
	{
		return document.layers[sID];
	}
	else if (document.all)
	{
		return document.all(sID).style;
	}
}

function addEvent(oTarget, sType, fpDest)
{
	var oOldEvent = oTarget[sType];
	if (typeof oOldEvent != 'function')
	{
		oTarget.attachEvent(sType, fpDest);
	}
	else
	{
		oTarget.attachEvent(sType, function()
									{
										fpDest();
										oOldEvent();
									}
							);
	}
}

function getAbsoluteLeft(oNode)
{
	var oCurrentNode = oNode;
	var iLeft = 0;
	do
	{
		iLeft += oCurrentNode.offsetLeft;
		oCurrentNode = oCurrentNode.offsetParent;
		if (oCurrentNode.tagName.toLowerCase() != "html")
		{
			break;
		}
	}
	while(oCurrentNode.tagName.toLowerCase() != "body")
	return iLeft;
}

function getAbsoluteTop(oNode)
{
	var oCurrentNode = oNode;
	var iTop = 0;
	do
	{
		iTop += oCurrentNode.offsetTop;
		oCurrentNode = oCurrentNode.offsetParent;
		if (oCurrentNode.tagName.toLowerCase() != "html")
		{
			break;
		}
	}
	while(oCurrentNode.tagName.toLowerCase() != "body")
	return iTop;
}

// ============= General functions =============//
function mouseEvent(action, ctrl)
{
	var src = ctrl.getAttribute("src")
	var index = (src.lastIndexOf("/") + 1);
	var path = src.substring(0, index);
	var name = src.substring(index);
	if(action.toLowerCase() == "over")
	{
		var firstPart = name.substring(0, name.lastIndexOf("."))
		var lastPart = name.substring(name.lastIndexOf("."))
		ctrl.setAttribute("src", path + firstPart + "_over" + lastPart);
	}
	else if(action.toLowerCase() == "out")
	{
		ctrl.setAttribute("src", path + name.replace("_over", ""));
	}
}
// ============= General functions =============//

