checkPWUID = function () {
	var uid	= $("#username").val();
	var pw 	= $("#password").val();
	
	$.getJSON("https://" + document.domain + "/common/validatie/pwuidcombination.php?callback=?", 	
		{
			username: uid, 
			password: pw
		}, 
		function(data) {
			if (data.msg === "true")
			{
				$('#loginform').submit();
			}
			else
				$("#uidpwerror").html(data.msg);
		});
}

slideOut = function(elmname) {
		setTimeout(function(){
			$(elmname).slideUp("slow", function () {
			 });

	}, 2000);
}


function typeAlert(type)
{
	if (type == 1){	
		document.getElementById("huurder").style.visibility = 'hidden';
		document.getElementById("kamer").style.visibility = 'visible';
		$('#kamer').slideDown('fast');
		$('#huurder').slideUp('fast');		
	}
	else{
		document.getElementById("kamer").style.visibility = 'hidden';
		document.getElementById("huurder").style.visibility = 'visible';
		$('#huurder').slideDown('fast');
		$('#kamer').slideUp('fast');		
	}
}


function CheckForRemoval(rid)
{
	var doRemoval = confirm(advertentieverwijderen);

	if (doRemoval)
	{
		window.location = '/verhuren/reactie/?removal=1&rid=' + rid;
	}
}

function CheckForDenied(urid)
{
	var doDenied = confirm(huurderafwijzen);

	if (doDenied)
	{
		window.location = '/verhuren/reactie/?deny=1&urid=' + urid;
	}
}

function switchLang(langcode, uri) {
	$.get("/common/ajax/languageswitch.php",{lang:langcode, requri:uri}, function(data){
		window.location=data;
	});
}

function da(e) {
  return $("#" + e);
}

function showNode(e) {
  $("#" + e).show();
}

function hideNode(e) {
	$("#" + e).hide();
}

function showHideNode(e) {
	if($('#' + e).is(':hidden') == true) {
		showNode(e);
	} else {
		hideNode(e);
	}
}

function searchFromHomepage(){
	var f = document.getElementById('searchFormDashBoard2');
	if(document.getElementById('searchGoal1').checked){
		f.action = "/huurders";
	} else {
		f.action = "/kamers";
	}
	f.submit();
}

locationBoxSlide = function(direction) {
	if(direction == 'open') {
		$('#LocationBoxReadMore').slideDown('fast');
		$('#btnLocationBoxMore').hide();
	}
	if (direction == 'close') {
		$('#LocationBoxReadMore').slideUp('fast');
		$('#btnLocationBoxMore').show();
	}
}

dashboardSlide = function(areaname) {
	
	if ($('#btn'+areaname+'less').css("display") == "none")
	{
		direction = "open";
	}
	else
	{
		direction = "close";
	}
	
	if(direction == 'open') {
		$('#'+areaname+'readmore').slideDown('fast');
		$('#btn'+areaname+'more').hide();
		$('#btn'+areaname+'less').show();
	}
	if (direction == 'close') {
		$('#'+areaname+'readmore').slideUp('fast');
		$('#btn'+areaname+'more').show();
		$('#btn'+areaname+'less').hide();
	}
}

searchExtendedSlide = function() {
	if($('#extendedSearch').css('display') == 'none')
	{
		$('#extendedSearch').slideDown('fast');
		$('#searchType').val('3');
		$('#zoekresbalk').val('0');
		$('#btn_search').css('display','none');
		$('#SpanAsAlert').css('display','none');
		$('#smsAlert').css('display','none');
		$('input[name=asAlert]').attr('checked', false);
		$('#btn_search_extended').css('display','block');
	}
	else
	{
		$('#extendedSearch').slideUp('fast');
		$('#searchType').val('2');
		$('#zoekresbalk').val('1');
		$('#multiple').html("");
		$('#btn_search').css('display','block');
		$('#SpanAsAlert').css('display','inline');
		$('#btn_search_extended').css('display','none');
	}
}

searchExtendedSlideVerhuren = function() {
	if($('#extendedSearchVerhuren').css('display') == 'none')
	{
		$('#extendedSearchVerhuren').slideDown('fast');
		$('#zoekextendedverhuren').val('1');
		$('#btn_search_verhuren').css('display','none');
		$('#btn_search_extended_verhuren').css('display','block');
	}
	else
	{
		$('#extendedSearchVerhuren').slideUp('fast');
		$('#zoekextendedverhuren').val('0');
		$('#btn_search_verhuren').css('display','block');
		$('#btn_search_extended_verhuren').css('display','none');
	}
}

DisableDialogButton = function(dialogId, buttonName) {
    var dialog_selector = "#" + dialogId;

    $(dialog_selector).parent().find("button").each(function() {
        if( $(this).text() == buttonName ) {
            $(this).attr('disabled', true);
        }
    });	
	
}

EnableDialogButton = function(dialogId, buttonName) {
    var dialog_selector = "#" + dialogId;

    $(dialog_selector).parent().find("button").each(function() {
        if( $(this).text() == buttonName ) {
            $(this).attr('disabled', false);
        }
    });
}

sendReaction = function() {
	
	$.ajax({ url: "/common/ajax/getUserProfile.php", 
		type: "POST",
		data: $("#mailUser").serialize(),
		dataType: 'json',
        success: function (data, status)
        {
			$("#statusreaction").html(data.msg);
			$("#statusreaction").show();
			
			DisableDialogButton('getprofile', sendreactiontekst);
        },
        error: function (data, status, e)
        {
			$("#statusreaction").html('test');
			$("#statusreaction").show();
        }
	});
}

sendReactionLandLord = function() {
	
	$.ajax({ url: "/common/ajax/getUserProfileLandlord.php", 
		type: "POST",
		data: $("#mailUser").serialize(),
		dataType: 'json',
        success: function (data, status)
        {
			$("#statusreaction").html(data.msg);
			$("#statusreaction").show();
			
			DisableDialogButton('getprofilelandlord', sendreactiontekst);
        },
        error: function (data, status, e)
        {
			$("#statusreaction").html('test');
			$("#statusreaction").show();
        }
	});
}

setTranslateThis = function(langused) {
	var url  = "https://ajax.googleapis.com/ajax/services/language/translate?callback=?";
	var url2  = "https://ajax.googleapis.com/ajax/services/language/translate?callback=?";
	if (langused == "fr")
		{
		var langpair1 = "fr|nl";
		var langpair2 = "fr|en";
		}
	else if (langused == "en")
		{
		var langpair1 = "en|nl";
		var langpair2 = "en|fr";
		}
	else if (langused == "nl")
		{
		var langpair1 = "nl|en";
		var langpair2 = "nl|fr";
		}
	
	$.getJSON(url,
		  {
			q:	$("#room_Omschrijving_" + langused).val(),
			v:	"1.0",
			langpair:	langpair1
		  },
		  function(data) {
			  if (langpair1 === "fr|nl")
			  	{
			  	var newText = data.responseData["translatedText"];			  	
			  	var newText2 = newText.replace("&#39;", "'");		  	
			  	var newText3 = newText2.replace("&quot;", "\"");
				$("#descr_nl").val(newText3);
				}
			  else if (langpair1 === "en|nl")
			  	{
			  	var newText = data.responseData["translatedText"];			  	
			  	var newText2 = newText.replace("&#39;", "'");		  	
			  	var newText3 = newText2.replace("&quot;", "\"");
			  	$("#descr_nl").val(newText3);
			  	}
			  else if (langpair1 === "nl|en")
			  	{
			  	var newText = data.responseData["translatedText"];			  	
			  	var newText2 = newText.replace("&#39;", "'");		  	
			  	var newText3 = newText2.replace("&quot;", "\"");
			  	$("#descr_en").val(newText3);
			  	}
		  });	
	$.getJSON(url2,
		  {
			q:	$("#room_Omschrijving_" + langused).val(),
			v:	"1.0",
			langpair:	langpair2
		  },
		  function(data) {
			  if (langpair2 === "fr|en")
			  	{
			  	var newText = data.responseData["translatedText"];			  	
			  	var newText2 = newText.replace("&#39;", "'");		  	
			  	var newText3 = newText2.replace("&quot;", "\"");
				$("#descr_en").val(newText3);
				}
			  else if (langpair2 === "en|fr")
			  	{
			  	var newText = data.responseData["translatedText"];			  	
			  	var newText2 = newText.replace("&#39;", "'");		  	
			  	var newText3 = newText2.replace("&quot;", "\"");
			  	$("#descr_fr").val(newText3);
			  	}
			  else if (langpair2 === "nl|fr")
			  	{
			  	var newText = data.responseData["translatedText"];			  	
			  	var newText2 = newText.replace("&#39;", "'");		  	
			  	var newText3 = newText2.replace("&quot;", "\"");
			  	$("#descr_fr").val(newText3);
			  	}
		  });
};

saveRoomDesc = function(lang, translate) {
	$("#descr_" + lang).val($("#room_Omschrijving_" + lang).val());
	if (translate)
	{
		if (lang === "nl")
			$("#descr_en").val("translating...");
		else
			$("#descr_nl").val("aan het vertalen...");
	
		setTranslateThis(lang);
	}
}

loadRoomDesc = function(elm) {	
	var $loading = $('<img src="/common/images/load.gif" alt="loading">');
	var $dialog = $("<div id='roomdesc_" + lang + "'></div>").append($loading.clone());
	var $link = $(elm);
	
	    var ep = "save";
	    if (savetekst != null) {
	    	ep = savetekst;
	    }
	
	    var up = "saveandtranslate";
	    if (saveandtranslatetekst != null) {
	    	up = saveandtranslatetekst;
	    }
	    
	    var buttonOpts = {};
		buttonOpts[up] = function () {
			saveRoomDesc($link.attr('usedlang'), true);
			$dialog.remove();
		};
		
		buttonOpts[ep] = function () {
			saveRoomDesc($link.attr('usedlang'), false);
			$dialog.remove();
		};
		
		$dialog
			.load( $link.attr('href') + '?lang=' + $link.attr('usedlang'))
			.dialog({
				title: $link.attr('title'),
				width: 500,
				height: 350,
				modal: true,
				resizable: false,
				autoOpen: true,
			    buttons: buttonOpts,
			    close: function(ev, ui) { $(this).remove(); }
			});
		
		return false;
	}

loadGetProfileReactionDialog = function(urid, userid) {

	   var ep = "sendreaction";
	    if (viewprofile != null) {
	    	ep = viewprofile;
	    }
	    
		

		var $loading = $('<img src="/common/images/load.gif" alt="loading">');
		var $dialog = $("<div id='getprofilelandlord'></div>")
		.append($loading.clone());

		$dialog
			.load('/common/ajax/getUserProfileLandlord.php?u=' + userid + '&urid=' + urid)
			.dialog({
				title: viewprofile,
				width: 550,
				height: 570,
				modal: true,
				resizable: false,
				autoOpen: true,
			    buttons: {
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				}
			});
		
		return false;
	}

loadTestimonial = function(testid) {

		var $loading = $('<img src="/common/images/load.gif" alt="loading">');
		var $dialog = $("<div id='testimonialdialog'></div>")
		.append($loading.clone());

		$dialog
			.load('/common/ajax/getTestimonial.php?tid=' + testid)
			.dialog({
				title: 'Testimonial',
				width: 550,
				height: 450,
				modal: true,
				resizable: false,
				autoOpen: true
			
			});
		
		return false;
	}

loadGetProfileDialogEmail = function(userid, elm) {
		var $loading = $('<img src="/common/images/load.gif" alt="loading">');
		var $dialog = $("<div id='getprofile'></div>")
		.append($loading.clone());
		
		var $link = $(elm);
		$dialog
			.load('/common/ajax/getUserProfile.php?u=' + userid)
			.dialog({
				title: $link.attr('title'),
				width: 500,
				height: 350,
				modal: true,
				resizable: false,
				autoOpen: true
			});
		
		return false;
	}

loadGetProfileDialog = function(rwid, userid) {

   var ep = "sendreaction";
    if (sendreactiontekst != null) {
    	ep = sendreactiontekst;
    }
    
	var buttonOpts = {};
	buttonOpts[ep] = function () {
		sendReaction();
	};

	var $loading = $('<img src="/common/images/load.gif" alt="loading">');
	var $dialog = $("<div id='getprofile'></div>")
	.append($loading.clone());

	$dialog
		.load('/common/ajax/getUserProfile.php?u=' + userid + '&rwid=' + rwid)
		.dialog({
			title: sendreactiontekst,
			width: 550,
			height: 570,
			modal: true,
			resizable: false,
			autoOpen: true,
		    buttons: buttonOpts,
			close: function(ev, ui) { $(this).remove(); }
		});
	
	return false;
}

PreviewImage = function(uri) {

	  //Get the HTML Elements
	  imageDialog = $("#imagedialog");
	  imageTag = $('#image');
	 
	  //Split the URI so we can get the file name
	  uriParts = uri.split("/");

	  //Set the image src
	  imageTag.attr('src', uri);
	 
	  //When the image has loaded, display the dialog
	  imageTag.load(function(){

	    $('#imagedialog').dialog({
	      modal: true,
	      resizable: false,
	      draggable: false,
	      width: '850',
	      height: '700',
	      title: uriParts[uriParts.length - 1]
	    });
	  });  
	}

loadfaq = function(elm) {
	var $loading = $('<img src="/common/images/load.gif" alt="loading">');
	var $link = $(elm);
	
	var $dialog = $("<div></div>").append($loading.clone());
	$dialog
		.load($link.attr('href'))
		.dialog({
			title: $link.attr('title'),
			width: 700,
			height: 350,
			modal: true,
			resizable: false
		});	
	
	$dialog.dialog('open');
}


$(document).ready(function() {
	$('input[name=searchtypeRoom]').click(function(){
		if($('input[name=searchtypeRoom]:checked').val() == 'huurder')
		{
			$('#searchFormRoom').hide();
			$('#searchFormTenant').show();
			$('input[name=searchtypeTenant]').filter("[value=huurder]").attr("checked","checked");
			$('input[name=searchtypeRoom]').filter("[value=huurder]").attr("checked","checked");
		}
		else
		{		
			$('#searchFormRoom').show();
			$('#searchFormTenant').hide();
			$('input[name=searchtypeTenant]').filter("[value=kamer]").attr("checked","checked");
			$('input[name=searchtypeRoom]').filter("[value=kamer]").attr("checked","checked");	
		}	
	});
	$('input[name=searchtypeTenant]').click(function(){
		if($('input[name=searchtypeTenant]:checked').val() == 'huurder')
		{
			$('#searchFormRoom').hide();
			$('#searchFormTenant').show();	
			$('input[name=searchtypeTenant]').filter("[value=huurder]").attr("checked","checked");
			$('input[name=searchtypeRoom]').filter("[value=huurder]").attr("checked","checked");
		}
		else
		{		
			$('#searchFormRoom').show();
			$('#searchFormTenant').hide();	
			$('input[name=searchtypeTenant]').filter("[value=akmer]").attr("checked","checked");
			$('input[name=searchtypeRoom]').filter("[value=kamer]").attr("checked","checked");
		}	
	});
	
	$('a[name="showimage"]').click(function(event){
	       
		    event.preventDefault();
		    PreviewImage($(this).attr('href'));
		                                       
		  }); 

	var $loading = $('<img src="/common/images/load.gif" alt="loading">');

	$('a[name="contentlinksmall"]').each(function() {

		var $dialog = $("<div></div>")
			.append($loading.clone());

		var $link = $(this).one('click', function() {		
			$dialog
				.load($link.attr('href'))
				.dialog({
					title: $link.attr('title'),
					width: 600,
					height: 450,
					modal: true,
					resizable: false
				});					
			$link.click(function() {
				
				$dialog.dialog('open');
				

				return false;
			});

			return false;
		});
	});

	$('a[name="contentlink"]').each(function() {
		var $dialog = $('<div></div>')
			.append($loading.clone());
		var $link = $(this).one('click', function() {
			$dialog
				.load($link.attr('href'))
				.dialog({
					title: $link.attr('title'),
					width: 600,
					height: 600,
					modal: true
				});

			$link.click(function() {
				$dialog.dialog('open');

				return false;
			});

			return false;
		});
	});
	
	// Even wat extra rules toevoegen om te kunnen gebruiken
	jQuery.validator.addMethod("greaterThanZero", function(value, element) {
	    return this.optional(element) || (parseFloat(value) > 0);
	}, greaterThanZero);

	var illegal=/ttp|@|www|hyve|hotmail|heetmail|punt nl|</;
	jQuery.validator.addMethod("NoHTML", function(value, element) {
		return !illegal.test(value); }, 
		NoHTML);

	var illegal2=/\d{5}/;
	jQuery.validator.addMethod("NoPhone", function(value, element) {
		return !illegal2.test(value); }, 
		NoPhone);

	var illegal3=/sex|geil|seks/;
	jQuery.validator.addMethod("NoDirtyWords", function(value, element) {
			return !illegal3.test(value);}, 
			NoDirtyWords);
		
	//get the current year for the datepicker
	var d = new Date();
	var curr_year = d.getFullYear();

	if ($("#geboortedatum, #oproep_UserGeboortedatum").length > 0) //check of #geboortedatum bestaat
	{	
		$("#geboortedatum, #oproep_UserGeboortedatum").datepicker({
			onSelect: function() { $("#geslacht0").focus();},
			dateFormat: 'dd-mm-yy',
			monthNames: [month1, month2, month3, month4, month5, month6, month7, month8, month9, month10, month11, month12],
			monthNamesShort: [month1, month2, month3, month4, month5, month6, month7, month8, month9, month10, month11, month12],
			dayNamesMin: [Day7Min, Day1Min, Day2Min, Day3Min, Day4Min, Day5Min, Day6Min],
			dayNamesShort: [Day7Short, Day1Short, Day2Short, Day3Short, Day4Short, Day5Short, Day6Short],
			changeYear: true,
			changeMonth: true,
			yearRange: "1900:" + (curr_year - 15),
			maxDate: "-15y",
			defaultDate: "-15y"
		});
	}
	$('#registeralert0').click(function() {
		if($('#registeralert0:checked').length > 0) {
			$("#divregistermobile").show();
			$("#divsms_maxperday").show();
		} else {
			$("#divregistermobile").hide();
			$("#divsms_maxperday").hide();
		}
	});

	if ($("#logindialog").length > 0) //check of #geboortedatum bestaat
	{
		$('#logindialog').dialog({
			height: 200,
			modal: true,
			autoOpen: false,
			title: logindialog
		});
	}
	$('.logindialoglink').click(function() {
		$('#logindialog').dialog('open');
	});
	
	if ($("#imagepopup").length > 0) //check of #geboortedatum bestaat
	{
		$('#imagepopup').dialog({
			title: imagepopup,
			autoOpen: false,
			modal: true,
			height: 500,
			width: 700
		});
	}
	$('.detailimage').click(function() {
		imagesrc = $(this).attr('src');
		imagetitle = $(this).attr('alt');
		$('#imagepopup img').attr('src', imagesrc);
		$('#imagepopup').dialog('open');
		$('#imagepopup').dialog('option', 'title', imagetitle);
	});

	if ($("#tabs").length > 0) //check of #geboortedatum bestaat
	{
		$("#tabs").tabs();
	}

	$("#ookpersms0").click(function() {
		if($('#ookpersms0:checked').length > 0) {
			$("#divalleen_email").hide();
			$("#divmobiel").show();
			$("#divmaxperdag").show();
		} else {
			$("#divalleen_email").show();
			$("#divmobiel").hide();
			$("#divmaxperdag").hide();
		}	
	});

	$("#kaart_500_575_link").click(function() {
		var mapinhoud = document.getElementById('gmKaart_500_575').innerHTML;
		
		if (mapinhoud=='') {
			GMapsInitialize_500_575();
			}
	});

	$("#kaart_600_400_link").click(function() {
		var mapinhoud = document.getElementById('gmKaart_600_400').innerHTML;
		if (mapinhoud=='') {
			GMapsInitialize_600_400();
		}
	});
		    
	if (document.forms["alertform"] != undefined) {
	/*	
		$("#alertform").validate({
		rules: {
			mobiel: { required: function() {
						return $('#ookpersms0').is(':checked'); 
						} 
					}
		}});
	*/	
	}

	if (document.forms["editPassword"] != undefined) {
	$("#editPassword").validate({
		rules: {
	 		user_Password: {remote: '/common/validatie/getpassword.php'},
	 		user_NewPassword: {remote: '/common/validatie/password.php'},
	 		user_ReNewPassword: {remote: '/common/validatie/password.php'},
	 		user_ReNewPassword: {equalTo: '#user_NewPassword'}
		},
		messages: {
		 	user_Password: CurrentPassword,
		 	user_NewPassword: PasswordLength,
			user_ReNewPassword: PasswordsEqual
		}
		});
	}
	
	if (document.forms["nsubscribeProfile"] != undefined) {
		$("#unsubscribeProfile").validate({
			rules: {
				Unsubscribe_Akkoord: { equalTo: "#Unsubscribe_AkkoordVal" }
			},
				messages: {Unsubscribe_Akkoord: unsubscribeProfile}
			});
	}
		
	if($(".hasDatepicker").val() == "") 
	{
		$(".hasDatepicker").val(defaultTextDate); 
		$(".hasDatepicker").css({color:'gray'});	
		if ($("#geboortedatum").val() == defaultTextDate)
			$("#geboortedatum").val("");
	}
	$(".hasDatepicker").blur(function()
	{
		if($(this).val().length == 0) { 
			$(this).val(defaultTextDate); 
			$(this).css({color:'gray'});
		}});
		
	$(".hasDatepicker").focus(function()
	{
		$(this).css({color:'black'});
		if($(this).val() == defaultTextDate) {
			$(this).val(""); 
	}});	
});

function GMapsInitialize_500_575() {
	var title = $('#kaart_title').val();
	var price = $('#kaart_price').val();
	var availability = $('#kaart_availability').val();

	var map = new google.maps.Map2(document.getElementById("gmKaart_500_575"));
	var RoomLatlng = new google.maps.LatLng($("#lat").val(), $("#lon").val());
	map.setCenter(RoomLatlng, 16);
	map.addControl(new GLargeMapControl());

	function createMarker(point) {  
		var marker = new GMarker(point);  
		GEvent.addListener(marker, "click", function() { 
			marker.openInfoWindowHtml('<strong>' + title + '</strong><br />&euro; ' + price + createMarkerTekst + availability);  
		});
		return marker;
	}

	map.addOverlay(createMarker(RoomLatlng));
	map.openInfoWindowHtml(RoomLatlng,'<strong>' + title + '</strong><br />&euro; ' + price + createMarkerTekst + availability);
}

function GMapsInitialize_230_230() {
	 var map2 = new google.maps.Map2(document.getElementById("gmKaart_230_230"));
	 var RoomLatlng = new google.maps.LatLng($("#lat").val(), $("#lon").val());
	 map2.setCenter(RoomLatlng, 15);
		
	 marker2 = new GMarker(RoomLatlng);
	 map2.addOverlay(marker2);
	 
	//add the 'loaded' listener
	GEvent.addListener(map2, 'tilesloaded', function() {
		setTimeout("fixGMap_230_230()", 200);
	});
 }

function fixGMap_230_230() {
	$('#gmAttr').html($('#gmKaart_230_230 #logocontrol').next('div').html());
	$('#gmKaart_230_230 #logocontrol').next('div').hide();
}

function GMapsInitialize_600_400() {
	var title = $('#kaart_title').val();
	var price = $('#kaart_price').val();
	var availability = $('#kaart_availability').val();

	var map3 = new google.maps.Map2(document.getElementById("gmKaart_600_400"));
	var RoomLatlng = new google.maps.LatLng($("#lat").val(), $("#lon").val());
	map3.setCenter(RoomLatlng, 16);
	map3.addControl(new GLargeMapControl());
	map3.addControl(new GOverviewMapControl());

	function createMarker(point) {  
	var marker = new GMarker(point);  
	GEvent.addListener(marker, "click", function() { 
		marker.openInfoWindowHtml('<strong>' + title + '</strong><br />&euro; ' + price + createMarkerTekst + availability);  
	});
	return marker;
	}

	map3.addOverlay(createMarker(RoomLatlng));
	map3.openInfoWindowHtml(RoomLatlng,'<strong>' + title + '</strong><br />&euro; ' + price + createMarkerTekst + availability);
  }



function textCounter(fieldName,cntfieldName,maxlimit)
{
	field = $('#'+fieldName);
	cntfield = $('#'+cntfieldName);
	
	if (field.val().length > maxlimit)
	{
		field.val(field.val().substring(0, maxlimit));
	}
	cntfield.text(maxlimit - field.val().length);
}

/* huren.favorites.php/ huren.zoek.php  */
function addUserFavorite(user, type, id)
{

	if(type == 'kamer'){

		$.get("/common/ajax/editUserFavorite.php", {f_userID: user, ID: id, action: "add" } ,
			function(data) {
			  if(data != false) {
				$('#divRoomMid'+id).removeClass("bgGray");
				$('#divRoomMid'+id).addClass("bgYellow");
				$('#aAddRoom'+id).hide();
				$('#aDelRoom'+id).show();
			  }
		});
	} else if(type == 'oproep') {
		$.get("/common/ajax/editUserFavorite.php", {f_userID: user, ID: id, action: "add_oproep" } ,
			function(data) {
			  if(data != false) {
				$('#divOproepMid'+id).removeClass("bgGray");
				$('#divOproepMid'+id).addClass("bgYellow");
				$('#aAddOproep'+id).hide();
				$('#aDelOproep'+id).show();
			  }
		});
	}
}

function delUserFavorite(user, type, id) {

	if(type == 'kamer'){

		$.get("/common/ajax/editUserFavorite.php", {f_userID: user, ID: id, action: "del" } ,
			function(data) {
			  if(data != false) {
				$('#divRoomMid'+id).removeClass("bgYellow");
				$('#divRoomMid'+id).addClass("bgGray");
				$('#aAddRoom'+id).show();
				$('#aDelRoom'+id).hide();
			  }
		});
		
	} else if(type == 'oproep'){

		$.get("/common/ajax/editUserFavorite.php", {f_userID: user, ID: id, action: "del_oproep" } ,
			function(data) {
			  if(data != false) {
				$('#divOproepMid'+id).removeClass("bgYellow");
				$('#divOproepMid'+id).addClass("bgGray");
				$('#aAddOproep'+id).show();
				$('#aDelOproep'+id).hide();
			  }
		});
	}
}




function delUserOproep(RWID)
{
	if ( confirm(confirmdeloproep) )
	{
		$.get("/common/ajax/editOproep.php", {RWID: RWID, action: "del" } ,
			function(data){
			
			  if(data == true)
			  {
				$('#OproepBox'+RWID).hide();
			  }
			  else
			  {
				  alert (data);
			  }
			});
	}
}

var activeMainMenuItem = 1;

function switchMainMenu(id) {
	var items = new Array();
	items[1] = 'itemHuren';
	items[2] = 'itemVerhuren';

	for(i = 1; i <= 2; i++) {
		if(i == id) {
			da('mainmenuItem' + i).className = 'item ' + items[i] + 'Active';
		}
		else {
			da('mainmenuItem' + i).className = 'item ' + items[i];
		}		
	}
	switchSubMenu(id, 2);
}

function switchSubMenu(id, n) {
	for(i = 1; i <= n; i++) {
		if(i == id) {
			da('subMenu' + i).className = 'db';
		}
		else {
			da('subMenu' + i).className = 'dn';		
		}
	}
}

var activeSubMenuItem = 11;

function switchSubMenuItem(menuId, id, n) {
	for(i = 1; i <= n; i++) {
		if(i == id) {
			da('subMenu' + menuId + i).className = 'itemActive';
		}
		else {
			da('subMenu' + menuId + i).className = 'item';
		}
	}
}

function goto_URL(object) {
    window.location.href = object.options[object.selectedIndex].value;
}

/*==============================================================================

Routines written by John Gardner - 2003 - 2005

See www.braemoor.co.uk/software for information about more freeware
available.

================================================================================

Routine to write a session cookie

Parameters:
    cookieName        Cookie name
    cookieValue       Cookie Value

Return value:
    true              Session cookie written successfullly
    false             Failed - persistent cookies are not enabled

e.g. if (writeSessionCookie("pans","drizzle") then
       alert ("Session cookie written");
    else
       alert ("Sorry - Session cookies not enabled");
*/

function writeSessionCookie(cookieName, cookieValue) {
	document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
}

/*==============================================================================

Routine to get the current value of a cookie

Parameters:
    cookieName        Cookie name

Return value:
    false             Failed - no such cookie
    value             Value of the retrieved cookie

e.g. if (!getCookieValue("pans") then  {
       cookieValue = getCoookieValue ("pans2);
    }
*/

function getCookieValue(cookieName) {
	var exp = new RegExp(escape(cookieName) + "=([^;]+)");
	if (exp.test (document.cookie + ";")) {
		exp.exec (document.cookie + ";");
		return unescape(RegExp.$1);
	}
	else return false;
}
