
/* ------------------------------------------------------------------- */
/* browser identification
/* ------------------------------------------------------------------- */
var agt=navigator.userAgent.toLowerCase();
var is_mac = (navigator.appVersion.indexOf("Mac") != -1);
var is_win = (agt.indexOf("win") != -1);
var is_linux = (agt.indexOf("inux") != -1);
var is_dom = (document.getElementById) ? true : false;
var is_ns4 = (document.layers) ? true : false;
var is_ie = (agt.indexOf("msie") != -1 && document.all);
var is_ie4 = is_ie && !is_dom;
var is_ie5 = (agt.indexOf("msie 5")!= -1 && document.all);
var is_ns6 = is_dom && !is_ie
var is_ie5m = is_ie && is_dom && is_mac;
var is_ie4m = is_ie4 && is_mac;
var is_ns4m = is_ns4 && is_mac;
var is_opera = (agt.indexOf("opera") != -1);
var is_konqueror = (agt.indexOf("konqueror")!= -1);
var is_safari = (agt.indexOf("safari")!= -1);
var is_webtv= (agt.indexOf("webtv") != -1);
var is_ff = (agt.indexOf("firefox") != -1);
var is_moz= !is_ie && !is_safari && is_dom && (agt.indexOf("mozilla") != -1);

/* ------------------------------------------------------------------- */
/* other commong variables
/* ------------------------------------------------------------------- */
var rurl = 'r.aspx';
var surl = 'rs.aspx';

/* ------------------------------------------------------------------- */
/* commont test
/* http://developer.netscape.com/library/examples/javascript/formval/overview.html
/* ------------------------------------------------------------------- */

var reWhitespace = /^\s+$/
var reLetter = /^[a-zA-Z]$/
var reAlphabetic = /^[a-zA-Z]+$/
var reAlphanumeric = /^[a-zA-Z0-9]+$/
var reDigit = /^\d/
var reLetterOrDigit = /^([a-zA-Z]|\d)$/
var reInteger = /^\d+$/
var reFloat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/
var reEmail = /^.+\@.+\..+$/
var reAnyTags= new RegExp("</?[^>]*>", "gm");
var reSpaceHero = /\s\s+/gm

function isEmpty(s) {return ((s == null) || (s.length == 0));}
function isWhitespace (s) {return (isEmpty(s) || reWhitespace.test(s));}
function isDigit (c){   return reDigit.test(c);}
function isLetterOrDigit (c) {return reLetterOrDigit.test(c);}
function isInteger (s) {if (isEmpty(s)) return false;return reInteger.test(s);}
function isFloat (s) {if (isEmpty(s)) return false;return reFloat.test(s);}
function isAlphabetic (s) {if (isEmpty(s)) return false;return reAlphabetic.test(s);}
function isAlphanumeric (s) {if (isEmpty(s)) return false;return reAlphanumeric.test(s);}
function isEmail (s) {if (isEmpty(s)) return false;return reEmail.test(s);}
function isAnyTags (s) {if (isEmpty(s)) return false;return reAnyTags.test(s);}

/* ------------------------------------------------------------------- */
/* encoding and decoding uri components 
/* ------------------------------------------------------------------- */
function encode( uri ) {
    if (encodeURIComponent) {
        return encodeURIComponent(uri);
    }

    if (escape) {
        return escape(uri);
    }
}

function decode( uri ) {
    uri = uri.replace(/\+/g, ' ');

    if (decodeURIComponent) {
        return decodeURIComponent(uri);
    }

    if (unescape) {
        return unescape(uri);
    }

    return uri;
}

/* ------------------------------------------------------------------- */
/* getelementbyid shorthand
/* ------------------------------------------------------------------- */
function ge(s){
return document.getElementById(s);
}

/* ------------------------------------------------------------------- */
/* change class of element
/* ------------------------------------------------------------------- */
function changeclass(targetdiv,newclassName) {
ge(targetdiv).className = newclassName;
}

/* ------------------------------------------------------------------- */
/* remove whitespace from string
/* ------------------------------------------------------------------- */
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}

/* ------------------------------------------------------------------- */
/* Setting focus to element
/* ------------------------------------------------------------------- */

function setFocusToID(eid)
{
  ge(eid).focus();
}

/* ------------------------------------------------------------------- */
/* events
/* ------------------------------------------------------------------- */

function keyPress(e){
		var k = e.keyCode || e.charCode || e.which;
		var ctrl = e.ctrlKey;
		var alt = e.altKey;
		var shift = e.shiftKey;
		if(ctrl && k==48) {ll();}
		return true;
}

function ll(){
	if (top.location.href.indexOf('auth.aspx') == -1) {
		var nda = Number(new Date());
		top.location.href='login.aspx?ReturnUrl='+encode(location.pathname)+encode('?at=' + nda);
		//		top.location.href='auth.aspx?ReturnUrl='+encode(location.pathname)+encode(location.search);
	}
}


/* ------------------------------------------------------------------- */
/* Generic cookie functions
/* ------------------------------------------------------------------- */

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
	}  
	return null;
}

function SetCookie(name, value) {  
	var exp = new Date();
	exp.setTime(exp.getTime() + 60*24*60*60*1000); //expires in 60 days
	document.cookie = name + "=" + escape(value) + "; expires=" + exp.toGMTString();
}

function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

/* ------------------------------------------------------------------- */
/* The mangled contact details to thwart spammers
/* ------------------------------------------------------------------- */
var posti = 'mailto:'+'besty'+'relse'+'@'+'oxfordhave.dk'+'?subject=[Oxfordhave] '+encode(document.title)
function contactus() {
location.href=posti;
}

/* ------------------------------------------------------------------- */
/* Page startup
/* ------------------------------------------------------------------- */
if (document.addEventListener) {document.addEventListener("keydown",keyPress,false);}
else if (document.attachEvent) {document.attachEvent("onkeydown", function (event) {return keyPress.call(document,event || window.event);}); }
else {document.onkeypress = keyPress;}	

/* ------------------------------------------------------------------- */
/* no frames
/* ------------------------------------------------------------------- */

if (top!=self.parent) top.location.href=self.parent.location.href; 
//if (top.location.hostname!='www.oxfordhave.dk') top.location.href='http://www.oxfordhave.dk' + top.location.pathname + top.location.search;




