function menu_item_color(item_chosen) {
if(document.getElementById(item_chosen)) document.getElementById(item_chosen).style.backgroundColor = "#DB3924";
}

function bottom_sizer(minusHeight) {
var windowHeight = document.body.clientHeight;
var bottomHeight = windowHeight-minusHeight;

if(windowHeight>400)
{
	if(document.getElementById('main')) document.getElementById('main').style.height = bottomHeight+"px";
	if(document.getElementById('spacer')) document.getElementById('spacer').style.height = bottomHeight+"px";
	if(document.getElementById('right')) document.getElementById('right').style.height = bottomHeight+"px";
}
}

function set_over_color(nr) {
document.getElementById('row_'+nr).style.backgroundColor = "#C2BDC4";
}

function set_out_color(nr) {
document.getElementById('row_'+nr).style.backgroundColor = "transparent";
}

function pic_chosen_color(id) {
if(document.getElementById(id)) document.getElementById(id).style.color = "#DB3924";
if(document.getElementById(id)) document.getElementById(id).style.fontWeight = "bold";
}

function case_chosen_color(case_id) {
if(document.getElementById('case_id_'+case_id)) document.getElementById('case_id_'+case_id).style.color = "#DB3924";
//if(document.getElementById('case_id_'+case_id)) document.getElementById('case_id_'+case_id).style.fontWeight = "bold";
}

function popup(url)
{
	window.open(url,"window", "toolbar=no,width=810,height=610, left=5, top=5, directories=no,status=no,scrollbars=no,resizable=yes,menubar=no");
}

function termsPopup(url)
{
	window.open(url,"window", "toolbar=no,width=520,height=600, left=5, top=5, directories=no,status=no,scrollbars=yes,resizable=no,menubar=no");
}

function contactSelection(lang)
{
	var contactType=document.getElementById("contactType");
	
	var phoneDiv=document.getElementById("phoneDiv");
	var freeTextResidenceWhereDiv=document.getElementById("freeTextResidenceWhereDiv");
	var freeTextHelpDiv=document.getElementById("freeTextHelpDiv");
	var freeTextDemoDiv=document.getElementById("freeTextDemoDiv");	
	var newsLetterDiv=document.getElementById("newsLetterDiv");
	var buttonDiv=document.getElementById("buttonDiv");
	var theButton=document.getElementById("theButton");
	var newsLetterCheckBox=document.getElementById("newsLetterCheckBox");
		
	phoneDiv.style.display="none";
	freeTextResidenceWhereDiv.style.display="none";
	freeTextHelpDiv.style.display="none";
	freeTextDemoDiv.style.display="none";
	newsLetterDiv.style.display="none";
	buttonDiv.style.display="none";
	theButton.value="";
	newsLetterCheckBox.checked=false;
	
	if(contactType.value=="callMe")
	{		
		phoneDiv.style.display="block";
		freeTextResidenceWhereDiv.style.display="block";
		newsLetterDiv.style.display="block";
		buttonDiv.style.display="block";
		if(lang=="da") theButton.value="Ring mig op";
		else theButton.value="Please call me";
	}
	if(contactType.value=="question")
	{
		freeTextHelpDiv.style.display="block";
		newsLetterDiv.style.display="block";
		buttonDiv.style.display="block";
		if(lang=="da") theButton.value="Send spørgsmål";
		else theButton.value="Send question";
	}
	if(contactType.value=="residenceDemo")
	{
		phoneDiv.style.display="block";
		freeTextDemoDiv.style.display="block";
		newsLetterDiv.style.display="block";
		buttonDiv.style.display="block";
		if(lang=="da") theButton.value="Bestil fremvisning";
		else theButton.value="Send presentation request";
	}
	if(contactType.value=="newsLetter")
	{
		newsLetterDiv.style.display="block";
		buttonDiv.style.display="block";
		if(lang=="da") theButton.value="Tilmeld nyhedsbrev";
		else theButton.value="Sign me up";
		newsLetterCheckBox.checked=true;
	}	
}

function preventUncheck()
{
	var contactType=document.getElementById("contactType");
	var newsLetterCheckBox=document.getElementById("newsLetterCheckBox");
	
	if(contactType.value=="newsLetter")
	{
		newsLetterCheckBox.checked=true;
	}
}

function validateContact(lang)
{
	var space = /\s/g;
	var contactType=document.getElementById("contactType");
	
	var fullName=document.getElementById("fullName");
	var email=document.getElementById("email");
	var phone=document.getElementById("phone");
	var freeTextCallMe=document.getElementById("freeTextCallMe");
	var freeTextQuestion=document.getElementById("freeTextQuestion");
	var freeTextResidenceDemo=document.getElementById("freeTextResidenceDemo");
	
	if(contactType.value=="callMe")
	{		
		if(fullName.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet dit fulde navn.");
			else alert("Please fill out your full name.");
			return false;
		}
		if(fullName.value.length<5)
		{
			if(lang=="da") alert("Dit fulde navn bør være længere end 4 tegn.");
			else alert("Your full name must be at least 4 chars.");
			return false;
		}
		if(email.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet din e-mail adresse.");
			else alert("Please fill out your e-mail address.");
			return false;
		} else
		{
			if(validateAddress(email.value)==false)
			{
				if(lang=="da") alert("E-mail adressen er ikke indtastet korrekt.");
				else alert("Your e-mail address is not correct.");
				return false;
			}
		}
		if(phone.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet dit kontakt telefonnummer.");
			else alert("Please fill out your contact phonenumber.");
			return false;
		}
		if(phone.value.length<8)
		{
			if(lang=="da") alert("Dit kontakt telefonnummer er ikke indtastet korrekt.");
			else alert("Your contact phonenumber is not correct.");
			return false;
		}
		if(freeTextCallMe.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet hvor du søger bolig.");
			else alert("Please fill out where you are looking for a dwelling.");
			return false;
		}
		if(freeTextCallMe.value.length<10)
		{
			if(lang=="da") alert("For at vi kan hjælpe dig bedst muligt, bør du skrive en længere tekst, om hvor du søger bolig.");
			else alert("For us to be able to help you, please fill out more information, about where you are looking for a dwelling.");
			return false;
		}
	}
	if(contactType.value=="question")
	{
		if(fullName.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet dit fulde navn.");
			else alert("Please fill out you full name.");
			return false;
		}
		if(fullName.value.length<5)
		{
			if(lang=="da") alert("Dit fulde navn bør være længere end 4 tegn.");
			else alert("Your full name must be at least 4 chars.");
			return false;
		}
		if(email.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet din e-mail adresse.");
			else alert("Please fill out your e-mail address.");
			return false;
		} else
		{
			if(validateAddress(email.value)==false)
			{
				if(lang=="da") alert("E-mail adressen er ikke indtastet korrekt.");
				else alert("Your e-mail address is not correct.");
				return false;
			}
		}
		if(freeTextQuestion.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke skrevet et spørgsmål.");
			else alert("Please fill out your question.");
			return false;
		}
		if(freeTextQuestion.value.length<10)
		{
			if(lang=="da") alert("For at vi kan hjælpe dig bedst muligt, bør dit spørgsmål være længere.");
			else alert("For us to be able to help you, please fill out a longer question.");
			return false;
		}
	}
	if(contactType.value=="residenceDemo")
	{
		if(fullName.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet dit fulde navn.");
			else alert("Please fill out your full name.");
			return false;
		}
		if(fullName.value.length<5)
		{
			if(lang=="da") alert("Dit fulde navn bør være længere end 4 tegn.");
			else alert("Your full name must be at least 4 chars.");
			return false;
		}
		if(email.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet din e-mail adresse.");
			else alert("Please fill out your e-mail address.");
			return false;
		} else
		{
			if(validateAddress(email.value)==false)
			{
				if(lang=="da") alert("E-mail adressen er ikke indtastet korrekt.");
				else alert("Your e-mail address is not correct.");
				return false;
			}
		}
		if(phone.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet dit kontakt telefonnummer.");
			else alert("Please fill out your contact phonenumber.");
			return false;
		}
		if(phone.value.length<8)
		{
			if(lang=="da") alert("Dit kontakt telefonnummer er ikke indtastet korrekt.");
			else alert("Your contact phonenumber is not correct.");
			return false;
		}
		if(freeTextResidenceDemo.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet hvilken bolig du ønsker fremvist.");
			else alert("Please fill out wich dwelling, you want a presentation of.");
			return false;
		}
		if(freeTextResidenceDemo.value.length<10)
		{
			if(lang=="da") alert("For at vi kan hjælpe dig bedst muligt, bør du specificere nærmere hvilken bolig du ønsker fremvist.");
			else alert("For us to be able to help you, please fill out more information, about wich dwelling you want a presentation of.");
			return false;
		}
	}
	if(contactType.value=="newsLetter")
	{
		if(fullName.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet dit fulde navn.");
			else alert("Please fill out your full name.");
			return false;
		}
		if(fullName.value.length<5)
		{
			if(lang=="da") alert("Dit fulde navn bør være længere end 4 tegn.");
			else alert("Your full name must be at least 4 chars.");
			return false;
		}
		if(email.value.replace(space, "")=="")
		{
			if(lang=="da") alert("Du har ikke indtastet din e-mail adresse.");
			else alert("Please fill out your e-mail address.");
			return false;
		} else
		{
			if(validateAddress(email.value)==false)
			{
				if(lang=="da") alert("E-mail adressen er ikke indtastet korrekt.");
				else alert("Your e-mail address is not correct.");
				return false;
			}
		}
	}
    
    var space = /\s/g;
    
    var verify_key=document.getElementById("verify_key");
    
    if(verify_key.value.replace(space, "")=="")
    {
        alert("Du har ikke indtastet koden fra det blåskraverede felt");
        return false;
    }
}

function validateAddress(incoming) {
    var emailstring = incoming;
    var ampIndex = emailstring.indexOf("@");
    var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
    var dotIndex = afterAmp.indexOf(".");
    dotIndex = dotIndex + ampIndex + 1;
    afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
    var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
    var beforeAmp = emailstring.substring(0,(ampIndex));
    var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/ 
    if ((emailstring.indexOf("@") != "-1") &&
        (emailstring.length > 5) &&
        (afterAmp.length > 0) &&
        (beforeAmp.length > 1) &&
        (afterDot.length > 1) &&
        (email_regex.test(emailstring)) ) {
          return true;
    } else {
          return false;
    }
}

function IsNumeric(checkStr) {
   var ValidChars = "0123456789+";
   var IsNumber=true;
   var Char;

   for (i = 0; i < checkStr.length && IsNumber == true; i++) 
      { 
      Char = checkStr.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         return false;
         }
      }
      return IsNumber;
}

function confirm_and_location(confirm_text, url) 
{
	if(!confirm(confirm_text)) 
	{
		return false;
	} else {
		location.href=url;	
	}
}

function validate_contact_data(type) {
if(type == "contact") {
document.getElementById('empty_contact_name').style.visibility = "hidden";
document.getElementById('empty_contact_name').style.position = "absolute";
/*document.getElementById('empty_contact_adress').style.visibility = "hidden";
document.getElementById('empty_contact_adress').style.position = "absolute";
document.getElementById('empty_contact_zipcode').style.visibility = "hidden";
document.getElementById('empty_contact_zipcode').style.position = "absolute";
document.getElementById('error_contact_zipcode').style.visibility = "hidden";
document.getElementById('error_contact_zipcode').style.position = "absolute";
document.getElementById('empty_contact_town').style.visibility = "hidden";
document.getElementById('empty_contact_town').style.position = "absolute";*/
document.getElementById('empty_contact_phone').style.visibility = "hidden";
document.getElementById('empty_contact_phone').style.position = "absolute";
document.getElementById('error_contact_phone').style.visibility = "hidden";
document.getElementById('error_contact_phone').style.position = "absolute";
document.getElementById('empty_contact_email').style.visibility = "hidden";
document.getElementById('empty_contact_email').style.position = "absolute";
document.getElementById('error_contact_email').style.visibility = "hidden";
document.getElementById('error_contact_email').style.position = "absolute";
/*document.getElementById('empty_contact_text').style.visibility = "hidden";
document.getElementById('empty_contact_text').style.position = "absolute";*/
        
    if(document.getElementById('contact_name').value == "") {
        document.getElementById('empty_contact_name').style.visibility = "visible";
        document.getElementById('empty_contact_name').style.position = "static";
        return false;
    }
    /*if(document.getElementById('contact_adress').value == "") {
        document.getElementById('empty_contact_adress').style.visibility = "visible";
        document.getElementById('empty_contact_adress').style.position = "static";
        return false;
    }
    if(document.getElementById('contact_zipcode').value == "") {
        document.getElementById('empty_contact_zipcode').style.visibility = "visible";
        document.getElementById('empty_contact_zipcode').style.position = "static";
        return false;
    }
    if(IsNumeric(document.getElementById('contact_zipcode').value) == false || document.getElementById('contact_zipcode').value.length < 4) {
        document.getElementById('error_contact_zipcode').style.visibility = "visible";
        document.getElementById('error_contact_zipcode').style.position = "static";
        return false;
    }
    if(document.getElementById('contact_town').value == "") {
        document.getElementById('empty_contact_town').style.visibility = "visible";
        document.getElementById('empty_contact_town').style.position = "static";
        return false;
    } */
    if(document.getElementById('contact_phone').value == "") {
        document.getElementById('empty_contact_phone').style.visibility = "visible";
        document.getElementById('empty_contact_phone').style.position = "static";
        return false;
    }
    if(IsNumeric(document.getElementById('contact_phone').value) == false || document.getElementById('contact_phone').value.length < 8) {
        document.getElementById('error_contact_phone').style.visibility = "visible";
        document.getElementById('error_contact_phone').style.position = "static";
        return false;
    }
    if(document.getElementById('contact_email').value == "") {
        document.getElementById('empty_contact_email').style.visibility = "visible";
        document.getElementById('empty_contact_email').style.position = "static";
        return false;
    }                                                                                       
    if(validateAddress(document.getElementById('contact_email').value) == false) {
        document.getElementById('error_contact_email').style.visibility = "visible";
        document.getElementById('error_contact_email').style.position = "static";
        return false;
    }
    /*if(document.getElementById('contact_text').value == "") {
        document.getElementById('empty_contact_text').style.visibility = "visible";
        document.getElementById('empty_contact_text').style.position = "static";
        return false;
    }*/
}

if(type == "sign") {
document.getElementById('empty_sign_name').style.visibility = "hidden";
document.getElementById('empty_sign_name').style.position = "absolute";
/*document.getElementById('empty_sign_adress').style.visibility = "hidden";
document.getElementById('empty_sign_adress').style.position = "absolute";
document.getElementById('empty_sign_zipcode').style.visibility = "hidden";
document.getElementById('empty_sign_zipcode').style.position = "absolute";
document.getElementById('error_sign_zipcode').style.visibility = "hidden";
document.getElementById('error_sign_zipcode').style.position = "absolute";
document.getElementById('empty_sign_town').style.visibility = "hidden";
document.getElementById('empty_sign_town').style.position = "absolute";
document.getElementById('empty_sign_phone').style.visibility = "hidden";
document.getElementById('empty_sign_phone').style.position = "absolute";
document.getElementById('error_sign_phone').style.visibility = "hidden";
document.getElementById('error_sign_phone').style.position = "absolute";*/
document.getElementById('empty_sign_email').style.visibility = "hidden";
document.getElementById('empty_sign_email').style.position = "absolute";
document.getElementById('error_sign_email').style.visibility = "hidden";
document.getElementById('error_sign_email').style.position = "absolute";
/*document.getElementById('empty_sign_text').style.visibility = "hidden";
document.getElementById('empty_sign_text').style.position = "absolute";*/
        
    if(document.getElementById('sign_name').value == "") {
        document.getElementById('empty_sign_name').style.visibility = "visible";
        document.getElementById('empty_sign_name').style.position = "static";
        return false;
    }
    /*if(document.getElementById('sign_adress').value == "") {
        document.getElementById('empty_sign_adress').style.visibility = "visible";
        document.getElementById('empty_sign_adress').style.position = "static";
        return false;
    }
    if(document.getElementById('sign_zipcode').value == "") {
        document.getElementById('empty_sign_zipcode').style.visibility = "visible";
        document.getElementById('empty_sign_zipcode').style.position = "static";
        return false;
    }
    if(IsNumeric(document.getElementById('sign_zipcode').value) == false || document.getElementById('sign_zipcode').value.length < 4) {
        document.getElementById('error_sign_zipcode').style.visibility = "visible";
        document.getElementById('error_sign_zipcode').style.position = "static";
        return false;
    }
    if(document.getElementById('sign_town').value == "") {
        document.getElementById('empty_sign_town').style.visibility = "visible";
        document.getElementById('empty_sign_town').style.position = "static";
        return false;
    }*/
    /*if(document.getElementById('sign_phone').value == "") {
        document.getElementById('empty_sign_phone').style.visibility = "visible";
        document.getElementById('empty_sign_phone').style.position = "static";
        return false;
    }
    if(IsNumeric(document.getElementById('sign_phone').value) == false || document.getElementById('sign_phone').value.length < 8) {
        document.getElementById('error_sign_phone').style.visibility = "visible";
        document.getElementById('error_sign_phone').style.position = "static";
        return false;
    }*/
    if(document.getElementById('sign_email').value == "") {
        document.getElementById('empty_sign_email').style.visibility = "visible";
        document.getElementById('empty_sign_email').style.position = "static";
        return false;
    }                                                                                       
    if(validateAddress(document.getElementById('sign_email').value) == false) {
        document.getElementById('error_sign_email').style.visibility = "visible";
        document.getElementById('error_sign_email').style.position = "static";
        return false;
    }
    /*if(document.getElementById('sign_text').value == "") {
        document.getElementById('empty_sign_text').style.visibility = "visible";
        document.getElementById('empty_sign_text').style.position = "static";
        return false;
    }*/
} 
}

function set_sort_head_color(sort_table, sort_way) {
if(document.getElementById('row_'+sort_table)) document.getElementById('row_'+sort_table).style.backgroundColor = "#8A868D";

if(sort_way == "ASC") {
if(document.getElementById('pic_'+sort_table)) document.getElementById('pic_'+sort_table).src = "../main_img/red_arrow_down.gif";
if(document.getElementById('print_pic_'+sort_table)) document.getElementById('print_pic_'+sort_table).src = "../main_img/red_arrow_down.gif";
}
if(sort_way == "DESC") {
if(document.getElementById('pic_'+sort_table)) document.getElementById('pic_'+sort_table).src = "../main_img/red_arrow_up.gif";
if(document.getElementById('print_pic_'+sort_table)) document.getElementById('print_pic_'+sort_table).src = "../main_img/red_arrow_up.gif";
}

}


function place_quick_search(minus_height) {
var windowHeight = document.body.clientHeight;
var fra_top = windowHeight-minus_height;
if(document.getElementById('quick_search')) document.getElementById('quick_search').style.top = (fra_top-40)+"px";
}

function valRadioButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return true;
    else return false;
}

function validate_quick_search_and_submit(lang) {
if(document.getElementById('quick_search_gruppe_id').value == "" && document.getElementById('quick_search_leje_pr_md').value == "" && valRadioButton(document.getElementById('quick_search_form').antal_vearelser) == false) {
	if(lang=="da") alert("Du har ikke valgt hvad du vil søge efter\nMinimum ét af felterne skal udfyldes");
    if(lang=="en") alert("Chose what you are searching for\nAt least one of the fields has to be chosen");
    return false;
} else { 
document.getElementById('quick_search_form').submit();
}
}

function validate_form(lang) {
if(document.getElementById('quick_search_gruppe_id').value == "" && document.getElementById('quick_search_leje_pr_md').value == "" && valRadioButton(document.getElementById('quick_search_form').antal_vearelser) == false) {
	alert(lang);
    if(lang=="da") alert("Du har ikke valgt hvad du vil søge efter\nMinimum ét af felterne skal udfyldes");
    if(lang=="en") alert("Chose what you are searching for\nAt least one of the fields has to be chosen");
    return false;
} else {
return true;
}
}


function write_select(this_sag_id_array, this_sag_kaldenavn_array) {
for(i=0; i<this_sag_id_array.length; i++) {
document.write("<option value='"+this_sag_id_array[i]+"'>"+this_sag_kaldenavn_array[i]+"</option>");
}
//document.getElementById{'search_sag_id').options[1] = null;
}

function set_num_residence_shown(field, value) {
if(document.getElementById(field)) document.getElementById(field).value = value;
}

function remove_show_txt_unsubscribe(func, lang)
{
    var UnsubInput = document.getElementById('UnsubInput');
    
    if(func=="rem")
    {
        if(lang=="da")
        {
        	if(UnsubInput.value=="din@email.dk") UnsubInput.value="";
        } else
        {
        	if(UnsubInput.value=="your@email.com") UnsubInput.value="";
        }
    }
    if(func=="show")
    {
    	if(lang=="da")
        {
        	if(UnsubInput.value=="") UnsubInput.value="din@email.dk";
        } else
        {
        	if(UnsubInput.value=="") UnsubInput.value="your@email.com";
        }
    }
}


function createCookie(name,value,secs) {
	if (secs) {
		var date = new Date();
		date.setTime(date.getTime()+(secs*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function show_hide_Menu(id, menu, func)
{
    var tDiv=document.getElementById(id+"Div");
    var tFoldBtn=document.getElementById(id+"FoldBtn");
    
    if(tDiv.style.visibility=="hidden"||func=="show")
    {
    	tFoldBtn.src="../main_img/menu_minus.gif";
    	tDiv.style.position = "relative";
    	tDiv.style.visibility = "visible";
    	tDiv.style.left = "0px";
    	tDiv.style.top = "0px";
    	createCookie(menu, '1','86400');	
    } else
    {
    	tFoldBtn.src="../main_img/menu_plus.gif";
    	tDiv.style.position = "absolute";
    	tDiv.style.visibility = "hidden";
    	tDiv.style.left = "-1000px";
    	tDiv.style.top = "-1000px";
    	eraseCookie(menu);
    }
}

function show_hide_quickContact(func, fromWhere)
{
    var DivID=document.getElementById("quickContactLayer");
    var behind_screenDiv=document.getElementById("behindScreenQuicContact");

    if(func=="show")
    {
    	behind_screenDiv.style.visibility = "visible";
    	DivID.style.visibility = "visible";
    	DivID.style.left = "330px";
    	DivID.style.top = "40px";
    }
    if(func=="hide")
    {
    	behind_screenDiv.style.visibility = "hidden";
    	DivID.style.visibility = "hidden";
    	DivID.style.left = "-1000px";
    	DivID.style.top = "-1000px";
    }
    
    if(fromWhere=="residence_details")
    {
    	if(document.getElementById("boligDataContainer")&&document.getElementById("freeTextResidenceDemo"))
    	{
    		var boligDataContainer=document.getElementById("boligDataContainer");

    		document.getElementById("freeTextResidenceDemo").value=boligDataContainer.value;
    	}
    }
}

function show_hide_unsubscribe(func)
{
    var LayerWidth=200;
    var LayerHeight=70;
    var PageWidth=987;
    var winW = document.documentElement.clientWidth; 
    var winH = document.documentElement.clientHeight; 
    var DivID=document.getElementById("unsubscribe_newsletter");
    var behind_screenDiv=document.getElementById("behind_screen_nyhedsbrev");

    if(func=="show")
    {
    	behind_screenDiv.style.visibility = "visible";
    	DivID.style.visibility = "visible";
    	var left = ((PageWidth/2)-(LayerWidth/2))+"px";
    	var top = ((winH/2)-(LayerHeight/2))+"px";
    	DivID.style.left = left;
    	DivID.style.top = top;
    	DivID.style.filter='progid:DXImageTransform.Microsoft.Shadow(color=black, direction=135, strength=10)';
    }
    if(func=="hide")
    {
    	behind_screenDiv.style.visibility = "hidden";
    	DivID.style.visibility = "hidden";
    	var left = "-1000px";
    	var top = "-1000px";
    	DivID.style.left = left;
    	DivID.style.top = top;
    }
}


function show_hide_tip(func, url)
{
	var LayerWidth=400;
    //var LayerHeight=330;
    var PageWidth=987;
    var winW = document.documentElement.clientWidth; 
    //var winH = document.documentElement.clientHeight;
    var DivID=document.getElementById("tipDiv");
    var TipUrl=document.getElementById("tip_url");
    var FromName=document.getElementById("from_name");
    var behind_screenDiv=document.getElementById("behind_screen_tip");
    
    if(func=="show")
    {
    	TipUrl.value = url;
    	behind_screenDiv.style.visibility = "visible";
    	DivID.style.visibility = "visible";
    	var left = ((PageWidth/2)-(LayerWidth/2))+"px";
    	//var top = ((winH/2)-(LayerWidth/2))+"px";
        var top = 100+"px";
    	DivID.style.left = left;
    	DivID.style.top = top;
    	FromName.focus();
    }
    if(func=="hide")
    {
    	behind_screenDiv.style.visibility = "hidden";
    	DivID.style.visibility = "hidden";
    	var left = "-1000px";
    	var top = "-1000px";
    	DivID.style.left = left;
    	DivID.style.top = top;
    }
}

function show_hide_analysis(func, LayerWidth, LayerHeight, cookie_runout_time, notParticipating)
{
	//eraseCookie('lejdinboligAnalysis')
	if(!readCookie('lejdinboligAnalysis'))
	{
    	var PageWidth=987;
    	var behind_screenDiv=parent.document.getElementById("behind_screen_analysis");
    	var analysisDiv=parent.document.getElementById("analysisDiv");
    
    	if(func=="show")
    	{
    		behind_screenDiv.style.visibility = "visible";
    		analysisDiv.style.visibility = "visible";
    		analysisDiv.style.left = "110px";
    		analysisDiv.style.top = "20px";
    		
    		analysisDiv.style.filter='progid:DXImageTransform.Microsoft.Shadow(color=black, direction=135, strength=10)';
    	}
    	if(func=="hide")
    	{
    		behind_screenDiv.style.visibility = "hidden";
    		analysisDiv.style.visibility = "hidden";
    		analysisDiv.style.left = "-1000px";
    		analysisDiv.style.top = "-1000px";
    		
    		createCookie('lejdinboligAnalysis', '1',cookie_runout_time);
    		if(parent.document.getElementById("CompetitionImg")) parent.document.getElementById("CompetitionImg").style.visibility="hidden";
    		
    		if(notParticipating) createCookie('notParticipating', '1',cookie_runout_time);
    	}
	}
}

function show_hide_datapolicy(func)
{
    var datapolicyDiv=document.getElementById("datapolicyDiv");
    
    if(func=="show")
    {
    	datapolicyDiv.style.visibility = "visible";
    	datapolicyDiv.style.left = "195px";
    	datapolicyDiv.style.top = "110px";
    }
    if(func=="hide")
    {
    	datapolicyDiv.style.visibility = "hidden";
    	datapolicyDiv.style.left = "-1000px";
    	datapolicyDiv.style.top = "-1000px";
    }
}

function show_hide_decline(id, func)
{
    var declineDiv=document.getElementById("declineDiv"+id);
    var behind_screenDiv=parent.document.getElementById("behind_screen_decline");
    
    if(func=="show")
    {
    	behind_screenDiv.style.visibility = "visible";
    	declineDiv.style.visibility = "visible";
    	declineDiv.style.position = "fixed";
    	declineDiv.style.left = "310px";
    	declineDiv.style.top = "110px";
    	declineDiv.style.filter='progid:DXImageTransform.Microsoft.Shadow(color=black, direction=135, strength=10)';
    }
    if(func=="hide")
    {
    	behind_screenDiv.style.visibility = "hidden";
    	declineDiv.style.visibility = "hidden";
    	declineDiv.style.position = "absolute";
    	declineDiv.style.left = "-1000px";
    	declineDiv.style.top = "-1000px";
    }
}

function validateDeclineCarUser(id)
{
	var space = /\s/g;
	var afvis_beskrivelseInput = document.getElementById('afvis_beskrivelse'+id);
	
	if(afvis_beskrivelseInput.value.replace(space, "")=="")
	{
		alert('Du har ikke indtastet en grund til afvisningen.');
		return false;
	}
}

function show_hide_login(func)
{
    var loginDiv=document.getElementById("loginDiv");
    var behind_screenDiv=document.getElementById("behind_screen_login");
    
    	if(func=="show")
    	{
    		behind_screenDiv.style.visibility = "visible";
    		loginDiv.style.visibility = "visible";
    		loginDiv.style.left = "680px";
    		loginDiv.style.top = "58px";
    		//window.frames['auth_login'].document.forms[0].userN.focus();
    		
    		createCookie('lejdinboligLoginBox', '1','86400');
    	}
    	if(func=="hide")
    	{
    		behind_screenDiv.style.visibility = "hidden";
    		loginDiv.style.visibility = "hidden";
    		loginDiv.style.left = "-1000px";
    		loginDiv.style.top = "-1000px";
    		eraseCookie('lejdinboligLoginBox');
    	}
}

function show_hide_send_corrections(func, type)
{
    var sendCorrectionsDiv=document.getElementById("sendCorrectionsDiv");
    var behind_screenDiv=document.getElementById("behind_screen_sendCorrections");

    	if(func=="show")
    	{
    		behind_screenDiv.style.visibility = "visible";
    		sendCorrectionsDiv.style.visibility = "visible";
    		sendCorrectionsDiv.style.left = "290px";
    		sendCorrectionsDiv.style.top = "50px";
    		sendCorrectionsDiv.style.filter='progid:DXImageTransform.Microsoft.Shadow(color=black, direction=135, strength=10)';
    		
    		createCookie('sendCorrectionsBox', '1','86400');
    	}
    	if(func=="hide")
    	{
    		behind_screenDiv.style.visibility = "hidden";
    		sendCorrectionsDiv.style.visibility = "hidden";
    		sendCorrectionsDiv.style.left = "-1000px";
    		sendCorrectionsDiv.style.top = "-1000px";
    		eraseCookie('sendCorrectionsBox');
    	}
    	
		insertDataBeboer(type);
}

	function changeBG(id, color)
	{
		document.getElementById(id).style.backgroundColor=color;
	}
	
	function textareaFill(id, state, text)
	{
		var tField=document.getElementById(id);
		
		if(state=="focus")
		{
			if(tField.value==text) tField.value="";
		} else if(state=="blur") 
		{
			if(tField.value=="") tField.value=text;
		}
	}

function show_hide_campaign(func, LayerWidth, LayerHeight, cookie_runout_time)
{
	//eraseCookie('lejdinboligCampaign')
	if(!readCookie('lejdinboligCampaign'))
	{
    	var PageWidth=987;
    	var winW = document.documentElement.clientWidth; 
    	var winH = document.documentElement.clientHeight;
    	var behind_screenDiv=document.getElementById("behind_screen_campaign");
    	var campaignDiv=document.getElementById("campaignDiv");
    	var closeDiv=document.getElementById("close");
    
    	if(func=="show")
    	{
    		behind_screenDiv.style.visibility = "visible";
    		campaignDiv.style.visibility = "visible";
    		var left = ((PageWidth/2)-(LayerWidth/2))+"px";
    		var top = ((winH/2)-(LayerWidth/2))+"px";
    		campaignDiv.style.left = left;
    		campaignDiv.style.top = top;
    		
    		closeDiv.style.visibility = "visible";
    		var leftClose = ((PageWidth/2)-(LayerWidth/2))+"px";
    		var topClose = ((winH/2)-(LayerWidth/2))+"px";
    		closeDiv.style.left = leftClose;
    		closeDiv.style.top = topClose;
    		
    		campaignDiv.style.filter='progid:DXImageTransform.Microsoft.Shadow(color=black, direction=135, strength=10)';
    	}
    	if(func=="hide")
    	{
    		behind_screenDiv.style.visibility = "hidden";
    		campaignDiv.style.visibility = "hidden";
    		var left = "-1000px";
    		var top = "-1000px";
    		campaignDiv.style.left = left;
    		campaignDiv.style.top = top;
    		
    		closeDiv.style.visibility = "visible";
    		var leftClose = "-1000px";
    		var topClose = "-1000px";
    		closeDiv.style.left = leftClose;
    		closeDiv.style.top = topClose;
    		
    		createCookie('lejdinboligCampaign', '1',cookie_runout_time);
    	}
	}
}

function change_close_img(state)
{
	var closeBTN=document.getElementById("close_btn");
	
	if(state=="over")
	{
		closeBTN.src="../main_img/close_campaign_over.jpg";
	}
	if(state=="out")
	{
		closeBTN.src="../main_img/close_campaign.jpg";
	}
}

function change_img(state, id, normal_img, over_img)
{
	var BTN=document.getElementById(id);
	
	if(state=="over")
	{
		BTN.src=over_img;	
	}
	if(state=="out")
	{
		BTN.src=normal_img;	
	}
}

function validateCarUserData()
{
	var space = /\s/g;
	
	var fornavnInput=document.getElementById("fornavn");
	var efternavnInput=document.getElementById("efternavn");
	/*var adresseInput=document.getElementById("adresse");
	var postnrInput=document.getElementById("postnr");
	var postnrInput=document.getElementById("by");*/
	var cprInput=document.getElementById("cpr");
	var mobilInput=document.getElementById("mobil");
	var emailInput=document.getElementById("email");
	var koerekortnrInput=document.getElementById("koerekortnr");
	var koerekortPicInput=document.getElementById("koerekortPic");
	
	if(fornavnInput.value.replace(space, "")=="")
	{
		alert("Du har ikke indtastet dit fornavn");
		return false;
	}
	if(efternavnInput.value.replace(space, "")=="")
	{
		alert("Du har ikke indtastet dit efternavn");
		return false;
	}
	if(cprInput.value.replace(space, "")=="")
	{
		alert("Du har ikke indtastet dit CPR nr.");
		return false;
	}
	
	var cpr=cprInput.value;
	var cpr1=cpr.substring(0,6);
	var cpr2=cpr.substring(7,11);
	var bindestreg=cpr.substring(6,7);
	
	if(IsNumeric(cpr1)==false || IsNumeric(cpr2)==false || cpr1.length<6 || cpr2.length<4 || bindestreg!="-")
	{
		alert("CPR nr. er ikke indtastet korrekt. Indtastes XXXXXX-XXXX.");
		return false;
	}
	
	
	if(mobilInput.value.replace(space, "")=="")
	{
		alert("Du har ikke indtastet dit mobil nr.");
		return false;
	}
	if(IsNumeric(mobilInput.value)==false || mobilInput.value.length<8)
	{
		alert("Mobilnr. er ikke indtastet korrekt. Mobilnr. må kun indeholde tal og skal være på min. 8 tal.");
		return false;
	}
	if(emailInput.value.replace(space, "")=="")
	{
		alert("Du har ikke indtastet din e-mail adresse");
		return false;
	}
	if(validateAddress(emailInput.value)==false)
	{
		alert("E-mail adressen er ikke indtastet korrekt.");
		return false;
	}
	if(koerekortnrInput.value.replace(space, "")=="")
	{
		alert("Du har ikke indtastet dit kørekort nr.");
		return false;
	}
	if(koerekortPicInput.value.replace(space, "")=="")
	{
		alert("Du har ikke valgt noget kørekort billede");
		return false;
	}
	
	var imgpath = koerekortPicInput.value;
	var arr1 = new Array;
	arr1 = imgpath.split("\\");
	var len = arr1.length;
	var img1 = arr1[len-1];
	var filext = img1.substring(img1.lastIndexOf(".")+1);
	
	if(filext.toLowerCase() != "jpg" && filext.toLowerCase() != "jpeg")
	{
		alert("Kørekortbilledet skal være af typen jpg/jpeg.");
		return false;
	}
}

function validateJPG()
{
	var space = /\s/g;
	var koerekortPicInput=document.getElementById("koerekortPic");
	if(koerekortPicInput.value.replace(space, "")!="")
	{
		var imgpath = koerekortPicInput.value;
		var arr1 = new Array;
		arr1 = imgpath.split("\\");
		var len = arr1.length;
		var img1 = arr1[len-1];
		var filext = img1.substring(img1.lastIndexOf(".")+1);
		
		if(filext.toLowerCase() != "jpg" && filext.toLowerCase() != "jpeg")
		{
			alert("Kørekortbilledet skal være af typen jpg/jpeg.");
			return false;
		}
	}
}

function validateFGPW_Email(email)
{
	var space = /\s/g;
	
	if(email.replace(space, "")=="")
	{
		alert("Du har ikke indtastet din e-mail adresse.");
		return false;
	}
	if(validateAddress(email)==false)
	{
		alert("E-mail adressen er ikke indtastet korrekt.");
		return false;
	}
}

function validateCPR()
{
	var cprInput=document.getElementById('cprInput');
	var cpr=cprInput.value;
	var cpr1=cpr.substring(0,6);
	var cpr2=cpr.substring(7,11);
	var bindestreg=cpr.substring(6,7);
	
	if(IsNumeric(cpr1)==false || IsNumeric(cpr2)==false || cpr1.length<6 || cpr2.length<4 || bindestreg!="-")
	{
		alert("CPR nr. er ikke indtastet korrekt. Indtastes XXXXXX-XXXX.");
		return false;
	}
}

function validateNewPW()
{
	var space = /\s/g;
	
	var newPWInput=document.getElementById("newPWInput");
	var confirmPWInput=document.getElementById("confirmPWInput");
	
	if(newPWInput.value.replace(space, "")=="")
	{
		alert("Den nye adgangskode er ikke indtastet.");
		return false;
	}
	
	if(newPWInput.value.length < 8) 
	{
		alert('Adgangskoden skal være på min. 8 tegn');
		return false;
	}

	if(checkPW(newPWInput, "Adgangskoden") == false)
	{
		return false;
	}
	
	if(confirmPWInput.value.replace(space, "")=="")
	{
		alert("Bekræftelsen af den nye adgangskode er ikke indtastet.");
		return false;
	}
	if(newPWInput.value!=confirmPWInput.value)
	{
		alert("Adgangskoden stemmer ikke overens med den bekræftede adgangskode.");
		return false;
	}
}

function checkPW(thisField, Text) {
	
    re = /^\w+$/;
    if(!re.test(thisField.value)) {
      alert(Text +" må kun indeholde bogstaver og tal dog ikke æ, ø, å");
      thisField.focus();
      return false;
    }
    re = /[0-9]/;
    if(!re.test(thisField.value)) {
      alert(Text +" skal indeholde min. ét tal");
      thisField.focus();
      return false;
    }
    re = /[a-z]/;
    if(!re.test(thisField.value)) {
      alert(Text +" skal indeholde min. ét lille bogstav");
      thisField.focus();
      return false;
    }
    re = /[A-Z]/;
    if(!re.test(thisField.value)) {
      alert(Text +" skal indeholde min. ét stort bogstav");
      thisField.focus();
      return false;
    }
}

function constructEmail(field, front, domain)
{
	var email="mailto: "+front+"@"+domain;
	field.href = email;
}
