function changeLanguage(strLangCode) {
	document.frmChangeLanguage.ToLanguage.value = strLangCode;
	document.frmChangeLanguage.submit();
}

function compileURL(remove, add) {
	var arrRemoves = remove.split(",");
	var strUrl = document.location.href;
	var arrUrl = strUrl.split("?");
	var strFile = arrUrl[0].substring(arrUrl[0].lastIndexOf("/")+1, arrUrl[0].Length);
	var strQs = arrUrl[1];
	var strSep = "?";
	var strFinal = "";
	
	if (strQs != null) {
		strQs = strQs.replace(/\./gi, "\\.");
		strQs = strQs.replace(/\*/gi, "\\*");
		strQs = strQs.replace(/\?/gi, "\\?");
		strQs = strQs.replace(/\+/gi, "\\+");
		strQs = strQs.replace(/\^/gi, "\\^");
		strQs = strQs.replace(/\$/gi, "\\$");
		
		for(i=0; i<arrRemoves.length; i++) {
			eval('rExp = /[\?\&]{0,1}' + arrRemoves[i] + '\=[^\&]*/gi;');
			strQs = strQs.replace(rExp, "");
		}
		if (strQs != "") {
			strSep = "&";
			strQs = "?" + strQs;
		}
	} else {
		strQs = "";
	}
	
	strFinal = strFile + strQs + strSep + add;
	strFinal = strFinal.replace(/\\\./gi, ".");
	strFinal = strFinal.replace(/\\\*/gi, "*");
	strFinal = strFinal.replace(/\\\?/gi, "?");
	strFinal = strFinal.replace(/\\\+/gi, "+");
	strFinal = strFinal.replace(/\\\^/gi, "^");
	strFinal = strFinal.replace(/\\\$/gi, "$");
	return strFinal;
}

function downloadImages(productId) {
    download = window.open('download_images.aspx?ProductID='+productId,'downloadWin','width=350,height=500,statusbar=no,status=no,resizable=yes,scrollbars=yes');
    setTimeout('download.focus();',100);
}

var timClose = null;
var timClose2 = null;
function openDiv(divName) {
	resetCloseTimer('timClose')
	objDiv = document.getElementById(divName);
	objDiv.style.display = 'block';
	objDiv.style.visibility='visible';
}
function closeDiv(divName) {
	objDiv = document.getElementById(divName);
	objDiv.style.visibility='hidden';
	objDiv.style.display = 'none';
}
function closeDelayedDiv(divName) {
	resetCloseTimer('timClose');
	timClose = setTimeout("closeDiv('"+divName+"');",2000)
}
function resetCloseTimer(timer) {
	eval("objTimer = " + timer + ";")
	if (objTimer) clearTimeout(objTimer);
		objTimer = null;
}

function QuickLogin() {
	document.forms[0].action = "default.aspx?page=login";
	document.forms[0].method = "post";
	document.forms[0].__VIEWSTATE.value = '';
	document.forms[0].__VIEWSTATE.name = 'HACKHACK';
	document.forms[0].submit();
}
function viewObj(objName) {
	objElement = document.getElementById(objName);
	objElement.style.visibility='visible';
}
function viewDelayedObj(objName) {
	resetCloseTimer('timClose2');
	timClose2 = setTimeout("viewObj('"+objName+"');",2000)
}
function hideObj(objName) {
	resetCloseTimer('timClose2');
	objElement = document.getElementById(objName);
	objElement.style.visibility='hidden';
}

function openDiv1(divName) {
	objDiv = document.getElementById(divName);
	objDiv.style.display = 'block';
	objDiv.style.visibility='visible';
}
function closeDiv1(divName) {
	objDiv = document.getElementById(divName);
	objDiv.style.visibility='hidden';
	objDiv.style.display = 'none';
}

function Preload(arr_Image) {	
	if(!arr_Image.length) return
	for(i=0; i< arr_Image.length; i++) {
		var obj_Image = new Image();
		obj_Image.src = arr_Image[i];
		arr_Image[i] = obj_Image;
	}
}

function BrowserCheck() {
	var browser = navigator.appName
	// er browser netscape?
	if (browser == "Netscape") this.browser = "ns"
	// er browser ie?
	else if (browser == "Microsoft Internet Explorer") this.browser = "ie"
	else this.browser = browser
	this.ver = parseInt(navigator.appVersion)
	// tjek version
	this.ns = (this.browser == "ns" && this.ver >= 4)
	this.ns4 = (this.browser == "ns" && this.ver == 4)
	this.ns5 = (this.browser == "ns" && this.ver == 5)
	this.ns6 = (this.browser == "ns" && this.ver == 6)
	this.ie = (this.browser == "ie" && this.ver >= 4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4') > 0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5') > 0)
	this.ie6 = (navigator.userAgent.indexOf('MSIE 6') > 0)
	if (this.ie5) this.ver = 5
	if (this.ie6) this.ver = 6
	this.min = (this.ns || this.ie)
}

// automatically create the "is" object
var is = new BrowserCheck()
var isLoaded = false

function Defuscate(strMailStart, strClass) {
	document.write('<a class="' + strClass + '" href="mailto:' + strMailStart + '@hesehus.dk">' + strMailStart + '@hesehus.dk</a>');
}

function ChangeImage(intIndex) {
	if(!arr_Images.length) return
	var int_Index;
	if (intIndex == -1) {
		intCurrent++;
		int_Index = intCurrent;
		if (int_Index >= arr_Images.length) {
			int_Index = 0;
			intCurrent = 0;
		}
	} else {
		int_Index = intIndex;
	}
	if (is.ie) {
		document.getElementById(strIDName).filters[0].apply();
	}
	document.images[strIDName].src = arr_Images[int_Index].src;
	if (is.ie) {
		document.getElementById(strIDName).filters[0].play();
	}
}
function ViewSpecific(intIndex) {
	clearInterval(itvChange);
	setTimeout('ChangeImage(' + intIndex + ');', 50);
	intCurrent = intIndex;
}
function StartStandardInterval() {
	itvChange = setInterval('ChangeImage(-1)', 5000);
}
