function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}


var NoXMLHTTP = 'Din browser understøtter ikke XMLHTTP og det er ikke muligt for dig at benytte denne funktion';


function getXMLHTTP() {
    var http_request = false;

    if  (window.XMLHttpRequest) { // Mozilla, Safari, IE7.0+  ...
        //alert("XMLHttpRequest")
        http_request = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)  { // IE 6.0-
        //alert("ActiveX")
        try {
        //alert("Msxml2.XMLHTTP")
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            //alert("Kunne ikke Msxml2.XMLHTTP")
            try {
                alert("Microsoft.XMLHTTP")
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                //alert("Kunne ikke Microsoft.XMLHTTP")
            }
        }
    }
    return http_request;
}

var currentShowCaseId;

function getLocation() {
	return currentShowCaseId;	
}


function initShowcase(showcase_id,showcase_name,category_id) {
	var currentHash = window.location.hash;
	if(currentHash.indexOf("showCase=")>0) {
		var newShowcase_id = currentHash.substring(10,currentHash.length);
		currentShowCaseId = newShowcase_id;
		getShowcase(newShowcase_id,category_id);
	}	else {
		currentShowCaseId = showcase_id;
		getShowcase(showcase_id,category_id);
	}
}


function getShowcase(showcase_id,category_id) {
	window.location.hash = "showCase=" + showcase_id
	http_request = getXMLHTTP();
	
	// Kontrollerer XML paa klienten
	if (!http_request){
	alert(NoXMLHTTP);
	return false;
	}

	var strURL = "/ajax_getShowcase.asp?id=" + showcase_id + "&cat=" + category_id + "&noCache=" + Math.random(); + "";
	
	http_request.onreadystatechange = function() 
	{
		if (http_request.readyState == 4) 
		{
			if (http_request.status == 200) 
			{
				document.getElementById("content").innerHTML = http_request.responseText;
			}
			else
			{
				alert(http_request.responseText);
			}
		}
	}

	http_request.open("GET", strURL, true);
	http_request.send(null);
	
}

function tipEnVen(theUrl) {
	var theHash = window.location.hash;
	theHash = theHash.replace("#","__HL__");
	window.open(theUrl+theHash, "mywindow", "width=560, height=300, directories=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no, location=no, channelmode=no, fullscreen=no");
	
}


function initShops(region_id,region_name) {
	var currentHash = window.location.hash;
	if(currentHash.indexOf("region=")>0 && currentHash.indexOf("-")>0) {
		var newRegion_id = currentHash.substring(currentHash.indexOf("=")+1,currentHash.indexOf("-"));
		var newRegion_name = currentHash.substring(currentHash.indexOf("-")+1,currentHash.length);
		getShops(newRegion_id,newRegion_name,0);
	}	else {
		getShops(region_id,region_name,0);
	}
}

function getShops(region_id,region_name,shop_id) {
	window.location.hash = "region=" + region_id + "-" + region_name;
	if(!shop_id) {
		shop_id = 0;
	}
	http_request = getXMLHTTP();
	
	// Kontrollerer XML paa klienten
	if (!http_request){
	alert(NoXMLHTTP);
	return false;
	}

	var strURL = "/ajax_getShops.asp?id=" + region_id + "&shopid=" + shop_id + "&noCache=" + Math.random(); + "";
	
	http_request.onreadystatechange = function() 
	{
		if (http_request.readyState == 4) 
		{
			if (http_request.status == 200) 
			{
				document.getElementById("shopsContent").innerHTML = http_request.responseText;
			}
			else
			{
				alert(http_request.responseText);
			}
		}
	}

	http_request.open("GET", strURL, true);
	http_request.send(null);
	
}

function jobToggle(theId) {

	var d1 = document.getElementById("jobDescExpand_"+theId);
	var d2 = document.getElementById("jobDesc_"+theId);
	var d3 = document.getElementById("jobPlace_"+theId);
	
	if(d1.style.display=="block") {
	 	d1.style.display="none";
	} else {
		d1.style.display="block";
	}

	if(d2.style.display=="block") {
	 	d2.style.display="none";
	 	document.getElementById("jobTitle_"+theId).style.backgroundColor = "";
	} else {
		d2.style.display="block";
		document.getElementById("jobTitle_"+theId).style.backgroundColor = "#c6d47f";
		document.location.href = "#" + theId;
	}	

	if(d3.style.display=="block") {
	 	d3.style.display="none";
	} else {
		d3.style.display="block";
	}
	
}

function encEmail(name,domain1){
   var prefix ='mai'+'lto:';
   var at='@';
   var url= prefix+name+at+domain1;
   document.location.href=eval('"'+url+'"');
   window.status=url;
}
