function soegKortLand(pagetype) {
	var land = $j('#KORTLAND').val();
	if(land.length>0) {
		if(pagetype=='portal' || pagetype=='ekstern_domaene') {
			document.location.href="soegpaakort-alle-"+land+".html";
		} else {
		document.location.href="soegpaakort-"+land+"-"+pagetype+".html";
		}
	}
}
function convertToUrl(string) {

	string = string.replace("ä", "ae");
	string = string.replace("Ä", "AE");

	string = string.replace("ö", "oe");
	string = string.replace("Ö", "OE");
	
	string = string.replace("ü", "u");
	string = string.replace("Ü", "U");

	string = string.replace("æ", "ae");
	string = string.replace("Æ", "AE");

	string = string.replace("ø", "oe");
	string = string.replace("Ø", "OE");

	string = string.replace("å", "aa");
	string = string.replace("Å", "AA");
	
	string = string.replace(/ /g, "+");
	string = string.toLowerCase(string);

	return string;
}

function doSubmit(form)
{
  document.forms[form].submit();
}
function unfoldMenu(sub) {
	var menu;
	menu = document.getElementById("panel-sub-menu-"+sub);
	if(menu.style.display == "none") {
	menu.style.display="block";
	} else {
	menu.style.display="none";
	}
}

function showBeskrivelse(val, antal) {

	var main_info, main_info_space, showhide;
	showhide = 0;

	if (document.getElementById) {
		main_info_space = document.getElementById("INDEX_MAIN_INFO_SPACE");
	} else if (document.all) {
		main_info_space = document.all["INDEX_MAIN_INFO_SPACE"];
	} else if (document.layers) {
		main_info_space = document["INDEX_MAIN_INFO_SPACE"];
	}


	for (i=1; i<=antal; i++) {
		if (document.getElementById) {
			main_info = document.getElementById("INDEX_MAIN_INFO_" + i);
		} else if (document.all) {
			main_info = document.all["INDEX_MAIN_INFO_" + i];
		} else if (document.layers) {
			main_info = document["INDEX_MAIN_INFO_" + i];
		}

		if (main_info.style.display == 'block' && i == val) {
			showhide = i;
		}

		main_info.style.display = 'none';
		main_info_space.style.display = 'none';

	}

	if (document.getElementById) {
		main_info = document.getElementById("INDEX_MAIN_INFO_" + val);
	} else if (document.all) {
		main_info = document.all["INDEX_MAIN_INFO_" + val];
	} else if (document.layers) {
		main_info = document["INDEX_MAIN_INFO_" + val];
	}

	if (showhide == val) {
		main_info.style.display = 'none';
		main_info_space.style.display = 'none';
	} else {
		main_info.style.display = 'block';
		main_info_space.style.display = 'block';
	}

}

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();

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

        $j('#hotelinfo-'+pladsnr).html(data);
    
        $j.get("googlemap_php/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);
            $j('#hotelmap-'+pladsnr).html(function() {
    //, "GOverviewMapControl"
                $j('#hotelmap-'+pladsnr).gMap({
                                                controls: ["GSmallZoomControl3D"],
                                                scrollwheel: false,
                                                markers: [{
                                                        latitude: hotel_lat,
                                                        longitude: hotel_lon,
                                                        icon: {image: "/googlemap_php/map_pins/hotel_kort_naal.png",
                                                                  iconsize: [16, 20],
                                                                  iconanchor: [16,20],
                                                                  infowindowanchor: [16, 0] } 
                                                        }
                                                        ,
                                                        {
                                                        latitude: fly_lat,
                                                        longitude: fly_lon,
                                                        icon: {image: "googlemap_php/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') {
			$j(hID).hide();
			hotelinfo = '';
		} else {
			$j(hID).show();
			hotelinfo = info;
		}
	} else {
		$j(hIDOpen).hide();
		$j(hID).show();
		hotelnr = hotel;
		hotelinfo = info;
	}
} else {
	$j(hID).show();
	hotelnr = hotel;
	hotelinfo = info;
}
 
    //if (show_hide == 'toggle') {
       // $j('#hotelinfo-'+pladsnr).toggle();
    //}
}

function number_format(a, b, c, d) {
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}


function beregnPris(e, udbyderid, pladsnr, pladstypeid) {

	var valgte_antal_person = $j('#valgteantalpersoner-'+pladsnr).html();
	var antal_person = $j('#antalpersoner-'+pladstypeid).html();
	var antal_rum = $j('#antalrum-'+pladstypeid).html();
	
	var org_total_pris = $j('#total-pris-'+pladstypeid).html();
   	var aPris = $j('#apris-'+pladstypeid).html();
    var newPris = e.value * aPris;
    var sumPris = (e.value == 0) ? 1 * aPris : e.value * aPris;
   	var pakke_pris = $j('#valgtepakkepris-'+pladsnr).html();

    var src = (e.value == 0) ? 'design_images/skiferie/skjul.png' : 'design_images/skiferie/skjul_flueben.png' ;
	$j('#image-'+pladstypeid).attr('src', src);

	$j('#sum-pris-'+pladstypeid).html(number_format(sumPris, 0, ',', '.'));
	$j('#total-pris-'+pladstypeid).html(newPris);

    pakke_pris = parseInt(pakke_pris.replace(".",""));
    pakke_pris = pakke_pris - org_total_pris;
    pakke_pris = pakke_pris + newPris;
   	$j('#valgtepakkepris-'+pladsnr).html(number_format(pakke_pris, 0, ',', '.'));

    valgte_antal_person = valgte_antal_person - (antal_person * antal_rum);
    valgte_antal_person = valgte_antal_person + (antal_person * e.value);
    $j('#antalrum-'+pladstypeid).html(e.value);
   	$j('#valgteantalpersoner-'+pladsnr).html(valgte_antal_person);
}

/*
function chooseHotelRoom(plads) {
	if(navigator.appName == "Microsoft Internet Explorer")
	{
	window.document.execCommand('Stop');
	}
	else
	{
	window.stop();
	}
	var select = plads.split("|");
	$j('#highlightMessage').show();
	var room = $j('#valgte-'+select[0]).html();
	var count = $j('#valgteantal-'+select[0]).html();
	var price = $j('#valgtepris-'+select[0]).html();
	var num = $j('#valgtenum-'+select[0]).html();
	var dato = $j('#valgtedato-'+select[0]).html();
	$j.get("php_noloads/skiferie/vaelgHotelSki.php", {"phpPLADS": plads, "phpPLADSTYPE": room, "phpPRICE": price, "phpNUMBER": num, "phpDATE": dato}, function(data) {
		document.location.href="skiferie-<?=$LAND;?>-<?=$DESTINATION;?>-ankomst.html";
	});
}
*/

function chooseHotelRoom(udbyderid, pladsnr) {

    var aktiveboliger = '';
    var bolig_liste = '';
    var split = '';
    var antal = 0;

    //if (udbyderid == 'EUR') {

        chooseHotelRoomPopup(pladsnr);
	/*
    } else {

        aktiveboliger = $j('#aktiveboliger-'+pladsnr).html();
        arr_boliger = aktiveboliger.split("|");
        for (b=0; b<arr_boliger.length; b++) {

            antal = $j('#antal-'+arr_boliger[b]).val();

            bolig_liste += split + arr_boliger[b] + "=" + antal;
            split = '|';
        }
        
        $j.get("php_noloads/makeXML.php", {"phpPLADSNR": pladsnr, "phpPLADSTYPER": bolig_liste, "phpUDBYDERID": udbyderid}, function(data) {
            var answer = data.replace("\n", "");

            if (answer == 'OK') {
                //document.location.href="vac_booking.php";
				chooseHotelRoomPopup(pladsnr);
            } else {
                alert("Der opstod en fejl, prøv igen !");
            }
        });        
    }
	*/
}


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

function closeRoomContainer() {
	$j('#room-container').fadeOut('fast');
	$j('#room-inner-content').html('');
}
function showRabatInfo(id, show) {
	if(show==1) {
		$j('#rabat-'+id).show();
	} else {
		$j('#rabat-'+id).hide();
	}
}
var beskrivelse = 0;
function visBeskrivelse(id) {
	if(beskrivelse>0) {
		$j('#LINKINFO'+beskrivelse).hide();
	}
	if(beskrivelse==id) {
		$j('#LINKINFO'+id).hide();
		beskrivelse=0;
	} else {
		beskrivelse = id;
		$j('#LINKINFO'+id).show();
	}
	
}
function proceedOrder() {
	document.location.href="vac_booking.php";
}

$j(".input_firstname").focus(function () {
	alert('test');
	var value = $j(this).val();
	if(value="Fornavn") {
		$j(this).val('');
	}
});

$j(function() {
	$j('.center-hotel-centrum-ski-info').mouseenter(function() {
		$j(this).children('.box').show();
	});
	$j('.center-hotel-centrum-ski-info').mouseleave(function() {
		$j(this).children('.box').hide();
	});
});
