
function objBrowserCheck(){

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();
	//alert(agt + ' - ' + appVer)
    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1); // new 020128- abk
    this.opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1); // new 021205- dmr
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
    this.opera6up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4 && !this.opera5); // new020128
    this.opera7up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4 && !this.opera5 && !this.opera6); // new021205 -- dmr

    // Note: On IE, start of appVersion return 3 or 4
    // which supposedly is the version of Netscape it is compatible with.
    // So we look for the real version further on in the string

    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
       is_major = parseInt(is_minor);
    }

    // ditto Konqueror
                                      
    this.konqueror = false;
    var kqPos   = agt.indexOf('konqueror');
    if (kqPos !=-1) {                 
       this.konqueror  = true;
       is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
       is_major = parseInt(is_minor);
    }                                 

    var is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    var is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    this.safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
    var is_khtml  = (this.safari || this.konqueror);

    var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
    var is_gver  = 0;
    if (is_gecko) is_gver=navigator.productSub;

    var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                    (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                    (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                    (is_gecko) && 
                    ((navigator.vendor=="")||(navigator.vendor=="Mozilla")));
    if (is_moz) {
       var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
       if(!(is_moz_ver)) {
           is_moz_ver = agt.indexOf('rv:');
           is_moz_ver = agt.substring(is_moz_ver+3);
           is_paren   = is_moz_ver.indexOf(')');
           is_moz_ver = is_moz_ver.substring(0,is_paren);
       }
       is_minor = is_moz_ver;
       is_major = parseInt(is_moz_ver);
    }

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
                && (!is_khtml) && (!(is_moz)));
	
	this.nav = is_nav;
	
    // Netscape6 is mozilla/5 + Netscape6/6.0!!!
    // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    // Changed this to use navigator.vendor/vendorSub - dmr 060502   
    // var nav6Pos = agt.indexOf('netscape6');
    // if (nav6Pos !=-1) {
    if ((navigator.vendor)&&
        ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&
        (is_nav)) {
       is_major = parseInt(navigator.vendorSub);
       // here we need is_minor as a valid float for testing. We'll
       // revert to the actual content before printing the result. 
       is_minor = parseFloat(navigator.vendorSub);
    }

    this.nav2 = (is_nav && (is_major == 2));
    this.nav3 = (is_nav && (is_major == 3));
    this.nav4 = (is_nav && (is_major == 4));
	// This ensures backwards compatibilitet
  	this.ns4 = this.nav4;
    this.nav4up = (is_nav && is_minor >= 4);  // changed to is_minor for
                                                // consistency - dmr, 011001
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );

    this.nav6   = (is_nav && is_major==6);    // new 010118 mhp
	// This ensures backwards compatibilitet
	this.ns6 = this.nav6;

    this.nav6up = (is_nav && is_minor >= 6) // new 010118 mhp

    this.nav5   = (is_nav && is_major == 5 && !this.nav6); // checked for ns6
    this.nav5up = (is_nav && is_minor >= 5);

    this.nav7   = (is_nav && is_major == 7);
    this.nav7up = (is_nav && is_minor >= 7);

    this.ie   = ((iePos!=-1) && (!this.opera) && (!is_khtml));
    this.ie3  = (this.ie && (is_major < 4));

    this.ie4   = (this.ie && is_major == 4);
    this.ie4up = (this.ie && is_minor >= 4);
    this.ie5   = (this.ie && is_major == 5);
    this.ie5up = (this.ie && is_minor >= 2);

    this.ie5_2  = (this.ie && (agt.indexOf("msie 5.23") !=-1)); // 020128 new - abk
    this.ie5_2up =(this.ie5_2 && is_major >= 5);                // 020128 new - abk
    
    this.ie5_5  = (this.ie && (agt.indexOf("msie 5.5") !=-1)); // 020128 new - abk
    this.ie5_5up =(this.ie && is_minor >= 5.5);                // 020128 new - abk
	
    this.ie6   = (this.ie && is_major == 6);
    this.ie6up = (this.ie && is_minor >= 6);

	// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables this.aol, this.aol3, and this.aol4 aren't 100% reliable.

    this.aol   = (agt.indexOf("aol") != -1);
    this.aol3  = (this.aol && this.ie3);
    this.aol4  = (this.aol && this.ie4);
    this.aol5  = (agt.indexOf("aol 5") != -1);
    this.aol6  = (agt.indexOf("aol 6") != -1);
    this.aol7  = ((agt.indexOf("aol 7")!=-1) || (agt.indexOf("aol7")!=-1));
    this.aol8  = ((agt.indexOf("aol 8")!=-1) || (agt.indexOf("aol8")!=-1));

    var is_webtv = (agt.indexOf("webtv") != -1);
    
    // new 020128 - abk
    
    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    this.aolTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));

	//two methods
	this.ver = getBrowserVersion2;
	this.platform = getBrowserPlatform2;
}

function getBrowserVersion2(){
	ver = navigator.appVersion;
	return ver;
}
function getBrowserPlatform2(){
	  platform = navigator.userAgent;
	  platform.toUpperCase();
	  if(platform.indexOf('Win') != -1){
	  	platform = 'win';
	  	return platform;
	  }
	  if(platform.indexOf('Mac') != -1){
	  	platform = 'mac';
	  	return platform;
	  }
}

/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////


function oSimpleBrowserCheck(){
	this.ns4 = (document.layers)?true:false;
	this.ns6 = (document.getElementById && !document.all)?true:false;
	this.ie4 = (!document.getElementById && document.all)?true:false;
	this.ie5 = (document.getElementById && document.all)?true:false;
	this.ie6 = this.ie5
	//two methods
	this.ver = getBrowserVersion;
	this.platform = getBrowserPlatform;
}

// automaticaly create ajrIs object 

//ajrIs = new oSimpleBrowserCheck;
ajrIs = new objBrowserCheck

function getBrowserVersion(){
	ver = navigator.appVersion;
	return ver;
}
function getBrowserPlatform(){
	  platform = navigator.userAgent;
	  platform.toUpperCase();
	  if(platform.indexOf('Win') != -1){
	  	platform = 'win';
	  	return platform;
	  }
	  if(platform.indexOf('Mac') != -1){
	  	platform = 'mac';
	  	return platform;
	  }
}

/*
	var expdate = new Date ();
	expdate.setTime (expdate.getTime() + ( 24 * 60 * 60 * 1000)); // 24 hrs from now 
*/

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
	    if ((!start) && (name != document.cookie.substring(0,name.length))){
			 return null;
		}
    	if (start == -1){
			 return null;
    	}
	var end = document.cookie.indexOf(";",len);
    	if (end == -1){
			end = document.cookie.length;
		}
		//cookieString = unescape(document.cookie.substring(len,end));
   return unescape(document.cookie.substring(len,end));
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)){
	 	document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}

var userCookieArray
function objCSCookie(cookieName){
	this.cookieName = cookieName;
	this.getPropertyValue = getPropertyValue;
	this.userCookieArray;
	tmp = Get_Cookie(cookieName)
	if(tmp!=null){
		userCookieArray = tmp.split('&');
			for(i=0;i<userCookieArray.length;i++){
				userCookieArray[i] = userCookieArray[i].split('=');
				//alert('navn '+ userCookieArray[i][0])
				//alert('prop '+ userCookieArray[i][1])
			}
	}
	
}
function getPropertyValue(prop){
	for(i=0;i<userCookieArray.length;i++){
		if(userCookieArray[i][0] == prop){
			return userCookieArray[i][1];
			break;
		}
	}
}

/*###############################################*/
//create global object  "CSuserInfo"
var CSuserInfo = new objCSCookie('User');
/*###############################################*/


function fncConfirmIt(sMsg,sLocation) { 
	if (confirm(sMsg)) {
	location.href = sLocation;
	document.returnValue = false;
	} 
}

/*###############################################*/
// function to submit a form widt Keypress
// write this in inputField: "onKeypress="SubmitFormWithKeypress(event,this)""
/*###############################################*/


function SubmitFormWithKeypress(e,formy){
	var theformName = formy.form.name
	if(ajrIs.ns4){
	    if (e.which == 13){
	        document.forms[theformName].submit()
		}
	}
	if(ajrIs.ie4 || ajrIs.ie5 || ajrIs.ie6){
		if (window.event.keyCode == 13){
    			document.forms[theformName].submit()
		}
	}
	if(ajrIs.ns6){
	    if (e.which == 0){
	        document.forms[theformName].submit()
		}
	}
}

/*###############################################*/
// function to open page in new window 
// width=500, heigh=400
// This is an old function that will be replaced later
/*###############################################*/
function OpenNewWindow(sUrl,sWindowName){
	window.open(sUrl,sWindowName,'resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,width=500,height=400');
} 


//************************//
//** BACKEND JUMP START **//

var objBej;

function fncBEJInit(){
	var objCookieMdl = new CookieModule();
			
	if(objCookieMdl.getValueByCookieAndKey('User','bej')=='true'){
		for(i=0;i<document.all.length;i++){
			if(document.all[i].bej=='true'){
				//document.all[i].attachEvent('onmouseover', fncBEJOnMouseOver)
				document.all[i].attachEvent('onmouseout', fncBEJOnMouseOut)
				document.all[i].attachEvent('ondblclick', fncBEJDblClick, true)
				document.all[i].style.cursor = 'hand';
			}
		}
	}
}
	
function fncBEJDblClick(){
	if(objBej.bej=='true'){
	var objCookieMdl = new CookieModule();
	//window.open('http://' + objCookieMdl.getValueByCookieAndKey('User','LicenseId') + '.back-end.dk/BackEndJump.asp?' + objBej.type + '=' + objBej.id + '&NodeId=' + objCookieMdl.getValueByCookieAndKey('User','NodeId'), 'backend');
	document.location ='http://' + objCookieMdl.getValueByCookieAndKey('User','LicenseId') + '.back-end.dk/BackEndJump.asp?' + objBej.type + '=' + objBej.id + '&NodeId=' + objCookieMdl.getValueByCookieAndKey('User','NodeId') + '&ref='+ document.location;
	}
}

function fncBEJOnMouseOver(me){
	var objCookieMdl = new CookieModule();
	if(objCookieMdl.getValueByCookieAndKey('User','bej')=='true'){
		objBej = me;
		if(objBej.bej=='true'){
		objBej.style.background='#DDDDDD';
		}
	}
}

function fncBEJOnMouseOut(){
	if(objBej.bej=='true'){
		objBej.style.background='none';
	}
}
//** BACKEND JUMP STOP  **//
//************************//
