function selectDays(val) {
	$('#ANTALDAGE').val(val);
	$('#selectedDays').html(val);
	$('#daysSelect').hide();
}
function selectParticipants(val, name) {
	$('#DELTAGERE').val(val);
	$('#selectedParticipants').html(name);
	$('#participantsSelect').hide();
}
function showPage(page) {
	document.location.href="indkvartering-"+page+".html";
}
function doSearch() {

			var fradato = $('#FRADATO').val();
			var antaldage = $('#ANTALDAGE').val();
			var deltagere = parseInt($('#DELTAGERE').val());
			
			$.get("php_noloads/prepareSearch.php", {"phpFRADATO": fradato, "phpANTALDAGE": antaldage, "phpDELTAGERE": deltagere}, function(data) {
				if(data!='') {
					document.location.href="indkvartering.html";
				}
			});
}

function doKeyEvent(e) {
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if(code == 13) {
		doSearch();
	}
}

function hentPladsBilleder(pladsnr) {
	$.get("php_noloads/hentPladsBilleder.php", {"phpPLADSNR": pladsnr},  function(data) {
		var arrData = data.split("|"); 
		$('#billeder-'+pladsnr).html(arrData[1]);
		$("a[rel=image_"+pladsnr+"]").colorbox({photo: true});
		$.colorbox({href: arrData[0], rel:'image_'+pladsnr, photo: true});
	});
}
function openColorBox(id) {
	$("a[rel="+id+"]").colorbox({photo: true});
}

var hotelinfo = '';
var hotelnr = '';
var show = '';
var showContent = '';
function getHotelInformation(info, hotel) {
	//$('#test').html("H: " + hotel + " = " +hotelnr+" & I: " +info+ " = "+hotelinfo);
	var hID = '#hotelinfo-'+hotel;
	var hIDOpen = '#hotelinfo-'+hotelnr;
	if(show!='' && showContent!='') {
		$(show).html(showContent);
	}
		if(info=='vaerelser') {
			$.get("php_noloads/hentVaerelse.php", {"phpPLADSNR": hotel}, function(data) {
				show = '';
				showContent = '';
				$(hID).html(data);
			});
		} else if(info=='billeder') {
			$.get("php_noloads/hentPladsBilleder.php", {"phpPLADSNR": hotel},  function(data) {
				show = '';
				showContent = '';
				$(hID).html(data);
			});
		} else if(info=='tilkoeb') {
			var fradato = $('#FRADATO-'+hotel).val();
			var dag = $('#ANTALDAGE-'+hotel).val();
			var udbyder = $('#UDBYDER-'+hotel).val();
			$.get("php_noloads/hentTilkoeb.php", {"phpPLADSNR": hotel, "phpUDBYDER": udbyder, "phpFRADATO": fradato, "phpDAG": dag},  function(data) {
				show = '';
				showContent = '';
				$(hID).html(data);
			});
		} else {
			show = '#'+info+'-'+hotel;
			showContent = $(show).html();
			$(hID).html($(show).html());
			$(show).html('');
		}
	
if(hotelnr!='') {
	if(hotel==hotelnr) {
		if(info==hotelinfo) {
			$(hID).hide();
			hotelinfo = '';
		} else {
			$(hID).show();
			hotelinfo = info;
		}
	} else {
		$(hIDOpen).hide();
		$(hID).show();
		hotelnr = hotel;
	}
} else {
	$(hID).show();
	hotelnr = hotel;
	hotelinfo = info;
}
}
function closeHotelInfo(hotel) {
	var hID = '#hotelinfo-'+hotel;
	$(hID).toggle();
	hotelinfo='';
}

function chooseHotelRoomPopup(plads, roomid, dato, dage) {
	//var dato = $.trim($('#FRADATO-'+plads).val());
	//var dage = $.trim($('#ANTALDAGE-'+plads).val());
	$('#room-container').fadeIn('fast');
	$.get("php_noloads/chooseRoom.php", {"phpPLADSNR": plads, "phpFRADATO": dato, "phpDAGE": dage, "phpSELECTED": roomid}, function(data) {
		$('#room-inner-content').html(data);
	});
}

function closeRoomContainer() {
	$('#room-container').fadeOut('fast');
	$('#room-inner-content').html('');
}
function showRabatInfo(id, show) {
	if(show==1) {
		$('#rabat-'+id).show();
	} else {
		$('#rabat-'+id).hide();
	}
}

function visKortImage(pladsnr, nr) {
	$('#hotellegend-wrap-'+pladsnr).children().hide();
	$('#kort-'+nr+'-'+pladsnr).show();
}

function visPaaKort(pladsnr, zoom, show_hide, ff) {
var hotel = pladsnr;
var info = 'viskort';

var hID = '#hotelinfo-'+hotel;
var hIDOpen = '#hotelinfo-'+hotelnr;
	
    var hotel_zoom_1 = 12;
    var hotel_zoom_2 = 14;
    var show_zoom = 9;

    var hotel_lon = '';
    var hotel_lat = '';

    var fly_lon = '';
    var fly_lat = '';

    var center_lon = '';
    var center_lat = '';

    var coords = new Array();

    $.get("php_noloads/vis_paa_kort_make_div.php", { "phpPLADSNR": pladsnr, "phpFF": ff}, function(data) {

        $('#hotelinfo-'+pladsnr).html(data);
    
        $.get("php_noloads/vis_paa_kort.php", { "phpPLADSNR": pladsnr, "phpFF": ff}, function(data) {
            coords = data.split("|");
            
            hotel_lon = coords[0];
            hotel_lat =  coords[1];
        
            fly_lon =  coords[2];
            fly_lat =  coords[3];
        
            center_lon =  coords[4];
            center_lat =  coords[6];

            hotel_zoom_1 =  coords[5];
            hotel_zoom_2 =  coords[7];
			
            kort_zoom =  coords[8];

            if (zoom == 'hotel') {
                //show_zoom = parseInt(hotel_zoom_2);
                show_zoom = parseInt(kort_zoom);
                center_lon =  hotel_lon;
                center_lat =  hotel_lat;
            } else if (zoom == 'airport') {
                show_zoom = parseInt(hotel_zoom_2);
                center_lon =  fly_lon;
                center_lat =  fly_lat;
            } else {
                //show_zoom = parseInt(hotel_zoom_1);
                show_zoom = parseInt(kort_zoom);
            }

			//alert(show_zoom);
            $('#hotelmap-'+pladsnr).html(function() {
    //, "GOverviewMapControl"
                $('#hotelmap-'+pladsnr).gMap({
                                                controls: ["GSmallZoomControl3D"],
                                                scrollwheel: false,
                                                markers: [{
                                                        latitude: hotel_lat,
                                                        longitude: hotel_lon,
                                                        icon: {image: "../images/map_pins/hotel_kort_naal.png",
                                                                  iconsize: [16, 20],
                                                                  iconanchor: [16,20],
                                                                  infowindowanchor: [16, 0] } 
                                                        }
                                                        ,
                                                        {
                                                        latitude: fly_lat,
                                                        longitude: fly_lon,
                                                        icon: {image: "../images/map_pins/lufthavn_kort_naal.png",
                                                                  iconsize: [16, 20],
                                                                  iconanchor: [16,20],
                                                                  infowindowanchor: [16, 0] } 
                                                        }],
    
                                                latitude: center_lat,
                                                longitude: center_lon,
                                                zoom: show_zoom,
												maptype: G_HYBRID_MAP
                });
            });
        });
    
    });
 
if(hotelnr!='') {
	if(hotel==hotelnr) {
		if(info==hotelinfo && show_hide == 'toggle') {
			$(hID).hide();
			hotelinfo = '';
		} else {
			$(hID).show();
			hotelinfo = info;
		}
	} else {
		$(hIDOpen).hide();
		$(hID).show();
		hotelnr = hotel;
		hotelinfo = info;
	}
} else {
	$(hID).show();
	hotelnr = hotel;
	hotelinfo = info;
}
 
    //if (show_hide == 'toggle') {
       // $('#hotelinfo-'+pladsnr).toggle();
    //}
}

function seoShow(elm) {
	var value = $(elm).html();
	value = (value=='Lęs mere') ? 'Skjul tekst' : 'Lęs mere';
	$(elm).html(value);
	$('.hidden').fadeToggle();
}

function goToPayment() {
	$('input[name=Ekstra]').val(0);
	$('form[name=payment]').submit();
}
function payExtra() {
	$('input[name=Ekstra]').val(1);
	$('form[name=payment]').submit();
}

