/*
//only override IE since they dont neccessary
// give you the element with the sought id, but
// might give something with that name instead.
if (/msie/i.test (navigator.userAgent))
{   
    if( !(/MSIE 8.0/i.test (navigator.userAgent)) ) {
        document.nativeGetElementById = document.getElementById;    
    }

	document.getElementById = function(id)
	{
         if( !(/MSIE 8.0/i.test (navigator.userAgent)) ) {
            var elem = document.nativeGetElementById(id);
         }else{
            var elem = document.getElementById(id);    
         }

		if(elem)
		{
			//make sure that it is a valid match on id
			if(elem.id == id)
			{
				return elem;
			}
			else
			{
				//otherwise find the correct element
				for(var i=1;i<document.all[id].length;i++)
				{
					if(document.all[id][i].id == id)
					{
						return document.all[id][i];
					}
				}
			}
		}
		return null;
	};
}
*/

var idCounter = 0;

function putDistance() {
    var distObj = nullIfEmpty(document.getElementById('distance_object').value);
    var distName = nullIfEmpty(document.getElementById('distance_name').value);
    var distDist = nullIfEmpty(document.getElementById('distance_distance').value);
    var distDim = nullIfEmpty(document.getElementById('distance_dimension').value);
    var distTime = nullIfEmpty(document.getElementById('distance_timedistance').value);

    var distWalking = document.getElementById('distance_walkingdistance').checked;

    var distId = distName;

    //alert("distObj: "+distObj+" distName: "+distName+" distDist: "+distDist+ " distDim: "+distDim);
    if((distObj == null || distObj.toLowerCase() == 'choose type')) {
        alert('You must choose a type');
        return true;
    }
    if(distName == null) {
//        alert('You must give a name to the '+distObj);
//        alert(idCounter);
        idCounter = idCounter + 1;
        distId = "newDistance" + idCounter;
//        return true;
    }
/*
    if(distDist == null) {
        alert('You must fill in a distance to the '+distObj);
        return true;
    }
    if(!isNumeric(distDist.replace(/\s/g,'').replace(/\.|\,/g,''))) {
        alert('Distance must be a number');
        return true;
    }
    //TODO: here i replace , with . since that will work better for calculations etc, decide how to display it later
    // Note that if one decides to write 1350m as 1.350m it will be saved as just that 1,350 m, not as 1,35km
    distDist = distDist.replace(/\s/g,'').replace(/\,/g,'\.');
*/
    var parentId = getIdForDistance(distObj);
    // get the ul-elements for this kind of distances
    var parentElement = document.getElementById(parentId);
    var newDistanceElem = document.createElement('li');
//    newDistanceElem.id = distObj.replace(/\s/g,'')+'_'+distName.replace(/\s/g,'')+'_'+distDist.replace(/\s/g,'')+'_'+distDim;
    newDistanceElem.id = distObj.replace(/\s/g,'')+'_'+distId.replace(/\s/g,'');
    //TODO: Should we do this a little prettier with createElement etc?
    // Or perhaps just add the hidden here as well? Dunno...
    var newHtml = '<span class="remove" onclick=\"removeElement(\''+newDistanceElem.id+'\',\''+parentId+'\')\">x</span>';
    newHtml = newHtml + '<span class="destination">'+emptyIfNull(distName)+'</span>';
    if (distWalking) {
        newHtml = newHtml + '<span class="distance">'+ 'Walking Distance' +'</span>';
    } else {
        newHtml = newHtml + '<span class="distance">' + emptyIfNull(distTime) + ' minutes' + '</span>';
    }
    newDistanceElem.innerHTML = newHtml;
    parentElement.insertBefore(newDistanceElem, parentElement.firstChild);

    // we have to add a hidden field with this info to the form as well
    var newHiddenDistance = document.createElement('input');
    newHiddenDistance.type = 'hidden';
    newHiddenDistance.name = 'distance_'+distObj;
    newHiddenDistance.id = 'hidden_'+newDistanceElem.id;
    newHiddenDistance.value = emptyIfNull(distName)+';'+emptyIfNull(distDist)+';'+emptyIfNull(distDim)+';'+emptyIfNull(distTime)+';'+distWalking;
    newDistanceElem.insertBefore(newHiddenDistance, newDistanceElem.firstChild);

    // there we are ready to clear the inputfields to be ready for a new distance
    clearDistanceFields();
    return true;
}


function putSeason() {
    var seasonName = "Mid";
    if (document.getElementById('season_select')) {
        seasonName = nullIfEmpty(document.getElementById('season_select').value);
    }
    var seasonCurrency = nullIfEmpty(document.getElementById('season_currency_select').value);
    var seasonPrice = nullIfEmpty(document.getElementById('season_price').value);
    var seasonPriceOptional = nullIfEmpty(document.getElementById('season_price_optional').value);
    var seasonStartMonth = nullIfEmpty(document.getElementById('season_start_month').value);
    var seasonStartDay = nullIfEmpty(document.getElementById('season_start_day').value);
    var seasonEndMonth = nullIfEmpty(document.getElementById('season_end_month').value);
    var seasonEndDay = nullIfEmpty(document.getElementById('season_end_day').value);

    //alert("name: "+seasonName+", currency: "+seasonCurrency+", price: "+seasonPrice+", priceOpt: "+seasonPriceOptional+", startM: "+seasonStartMonth+", startD: "+seasonStartDay+", endM: "+seasonEndMonth+", endD: "+seasonEndDay);
    if(seasonName == null || seasonName.toLowerCase() == '-') {
        alert('You must choose a season');
        return true;
    }
    if(seasonCurrency == null || seasonCurrency.toLowerCase() == '-') {
        alert('You must choose a currency');
        return true;
    }
    if(seasonPrice == null || !isNumeric(seasonPrice.replace(/\s/g,'').replace(/\.|\,/g,''))) {
        alert('Price must be a number');
        return true;
    }
    if(seasonStartMonth == null || seasonStartMonth.toLowerCase() == '-') {
        alert('You must pick a start month for the '+seasonName+' season');
        return true;
    }
    if(seasonStartDay == null || seasonStartDay.toLowerCase() == '-') {
        alert('You must pick a start day in '+seasonStartMonth);
        return true;
    }
    if(seasonEndMonth == null || seasonEndMonth.toLowerCase() == '-') {
        alert('You must pick an end month for the '+seasonName+' season');
        return true;
    }
    if(seasonEndDay == null || seasonEndDay.toLowerCase() == '-') {
        alert('You must pick an end day in '+seasonEndMonth);
        return true;
    }
    if(seasonPriceOptional == null) {
        seasonPriceOptional = -1;
    } else if(!isNumeric(seasonPriceOptional.replace(/\s/g,'').replace(/\.|\,/g,''))) {
        alert('Second price must be a number');
        return true;
    }

    //TODO: here i replace , with . since that will work better for calculations etc, decide how to display it later
    seasonPrice = seasonPrice.replace(/\s/g,'').replace(/\,/g,'\.');
    if(seasonPriceOptional > 0) {
        seasonPriceOptional = seasonPriceOptional.replace(/\s/g,'').replace(/\,/g,'\.');        
    }
    var parentId = getIdForSeason(seasonName);
    // get the ul-elements for this season
    var parentElement = document.getElementById(parentId);
    var newSeasonElem = document.createElement('li');
    newSeasonElem.id = seasonName+'_'+seasonPrice.replace(/\./g,'')+'_'+seasonCurrency+'_'+seasonStartMonth+'_'+seasonStartDay+'_'+seasonEndMonth+'_'+seasonEndDay;
    //TODO: Should we do this a little prettier with createElement etc?
    // Or perhaps just add the hidden here as well? Dunno...
    var newHtml = '<span class=\"remove\" onclick=\"removeElement(\''+newSeasonElem.id+'\',\''+parentId+'\')\">x</span>';
    newHtml = newHtml + '<span class=\"period\">'+seasonPrice+' '+(seasonPriceOptional > 0 ? ' / '+seasonPriceOptional : '')+' '+seasonCurrency+'</span>';
    newHtml = newHtml + '<span class=\"distance\">'+seasonStartMonth+' '+seasonStartDay+' - '+seasonEndMonth+' '+seasonEndDay+'</span>';
    newSeasonElem.innerHTML = newHtml;
    parentElement.insertBefore(newSeasonElem, parentElement.firstChild);
    // we have to add a hidden field with this info to the form as well
    //var formElement = document.getElementById('addaccommodationform');
    var newHiddenSeason = document.createElement('input');
    newHiddenSeason.type = 'hidden';
    newHiddenSeason.name = 'season_price_info_'+seasonName;
    newHiddenSeason.id = 'hidden_'+newSeasonElem.id;
    newHiddenSeason.value = seasonName+';'+seasonStartMonth+';'+seasonStartDay+';'+seasonEndMonth+';'+seasonEndDay+';'+seasonCurrency+';'+seasonPrice+';'+seasonPriceOptional;
    newSeasonElem.insertBefore(newHiddenSeason, newSeasonElem.firstChild);
    // there we are ready to clear the inputfields to be ready for a new season
    clearSeasonFields();
    return true;
}


function nullIfEmpty(val) {
    if(val != null) {
        if(val.length > 0) {
            return val;
        }
        else {
            return null;
        }
    }
    else {
        return null;
    }
}

function emptyIfNull(val) {
    if(val == null) {
        return "";
    }
    return val;
}

function isNumeric(val) {
    return ((val - 0) == val && val.length > 0 && !isNaN(val));
}

function getIdForDistance(type) {
    if(type.toLowerCase() == 'golfcourse') {
        return 'distance_golfcourse_id';
    }
    else if(type.toLowerCase() == 'airport') {
        return 'distance_airport_id';
    }
    else if(type.toLowerCase() == 'trainstation') {
        return 'distance_trainstation_id';
    }
    else if(type.toLowerCase() == 'citycenter') {
        return 'distance_citycenter_id';
    }
    else if(type.toLowerCase() == 'beach') {
        return 'distance_beach_id';
    }
}

function getIdForSeason(season) {
    if(season.toLowerCase() == 'low') {
        return 'season_low';
    }
    else if(season.toLowerCase() == 'mid') {
        return 'season_mid';
    }
    else if(season.toLowerCase() == 'high') {
        return 'season_high';
    }
}

function removeElement(elementId, parentId) {
    //alert("we are beeing called with elemid: "+elementId+ " parentId: "+parentId);
    var parent = document.getElementById(parentId);
    parent.removeChild(document.getElementById(elementId));
    //alert('1');
    //now also remove the hidden-field representing this visible element
//    var form = document.getElementById('addaccommodationform');
//    form.removeChild(document.getElementById('hidden_'+elementId));
    return true;
}


function clearDistanceFields() {
    document.getElementById('distance_object').selectedIndex = 0;
    document.getElementById('distance_name').value = "";
    document.getElementById('distance_distance').value = "";
    document.getElementById('distance_dimension').selectedIndex = 0;
    document.getElementById('distance_timedistance').value = "";
    document.getElementById('distance_walkingdistance').checked = false;
}

function clearSeasonFields() {
    if (document.getElementById('season_select')) {
        document.getElementById('season_select').selectedIndex = 0;
    }
    document.getElementById('season_currency_select').selectedIndex = 0;
    document.getElementById('season_price').value = "";
    document.getElementById('season_price_optional').value = "";
    document.getElementById('season_start_month').selectedIndex = 0;
    document.getElementById('season_start_day').selectedIndex = 0;
    document.getElementById('season_end_month').selectedIndex = 0;
    document.getElementById('season_end_day').selectedIndex = 0;
}

function addFreetextCourseToSelection() {
/*
    var id = 'hidden_included_course_' + document.getElementById('freetext_golfcourse').value.replace(/\s/g,'_');
    var hiddenSpanElem = document.getElementById('hidden_included_courses');

    var newHtml = '<span class="remove" onclick=\"removeElement(\'' + id + '\', \'missing_golfcourses_list\')\">x</span>';
    newHtml = newHtml + '<span>' + document.getElementById('freetext_golfcourse').value + '</span>';

    var newMissingElem = document.createElement('li');
    newMissingElem.innerHTML = newHtml;

    var parentElement = document.getElementById('missing_golfcourses_list');
    parentElement.insertBefore(newMissingElem, parentElement.firstChild);

    var hiddenSpanElem = document.getElementById('hidden_included_courses');
    var newHidden = document.createElement('input');
    newHidden.type = 'hidden';
    newHidden.name = 'package_included_courses';
    newHidden.id = id;
    newHidden.value = document.getElementById('freetext_golfcourse').value;
    hiddenSpanElem.insertBefore(newHidden, hiddenSpanElem.firstChild);
    // clear the textfield
    document.getElementById('freetext_golfcourse').value = "";
*/    
}

function selectCourse() {
    var availableSelectElem = document.getElementById('available_courses');
    // add it to the selected courses-box
    addCourseToSelection(availableSelectElem.value, availableSelectElem.options[availableSelectElem.selectedIndex].text, document.getElementById('included_courses'));
    //add it to the hidden fields
    var hiddenSpanElem = document.getElementById('hidden_included_courses');
    var newHidden = document.createElement('input');
    newHidden.type = 'hidden';
    newHidden.name = 'package_included_courses';
    newHidden.id = 'hidden_included_course_'+availableSelectElem.value.replace(/\s/g,'_');
    newHidden.value = availableSelectElem.value;
    hiddenSpanElem.insertBefore(newHidden, hiddenSpanElem.firstChild);
    // remove it from the list
    removeCourseFromSelection(availableSelectElem.selectedIndex, availableSelectElem);
}

function unselectCourse() {
    var selectedSelectElem = document.getElementById('included_courses');
    // add it to the selectable courses
    addCourseToSelection(selectedSelectElem.value, selectedSelectElem.options[selectedSelectElem.selectedIndex].text, document.getElementById('available_courses'));
    //remove the hidden-field
    var hiddenSpanElem = document.getElementById('hidden_included_courses');
    hiddenSpanElem.removeChild(document.getElementById('hidden_included_course_'+selectedSelectElem.value.replace(/\s/g,'_')));

    // remove it from the list
    removeCourseFromSelection(selectedSelectElem.selectedIndex, selectedSelectElem);
}

function addCourseToSelection(coursePath, courseName, selectElement) {
    var newOption = document.createElement('option');
    newOption.value = coursePath;
    newOption.innerHTML = courseName;
    selectElement.insertBefore(newOption, selectElement.firstChild);
}

function removeCourseFromSelection(index, selectElement) {
    var options = selectElement.options;
    selectElement.removeChild(options[index]);
}

function toggleInvoiceAddressInput() {
    var sameAsVisitingisChecked = document.getElementById('accommodation_invoiceaddress_same').checked;
    if(sameAsVisitingisChecked) {
        document.getElementById('accommodation_invoicename').value = document.getElementById('accommodation_name').value;
        document.getElementById('accommodation_invoicestreet').value = document.getElementById('accommodation_address_street').value;
        document.getElementById('accommodation_invoicezip').value = document.getElementById('accommodation_address_zip').value;
        document.getElementById('accommodation_invoicecity').value = document.getElementById('accommodation_address_city').value;
        document.getElementById('accommodation_invoicepobox').value = document.getElementById('accommodation_address_pobox').value;
        document.getElementById('accommodation_invoiceregion').value = document.getElementById('accommodation_address_region').value;
        document.getElementById('accommodation_invoicecountry').value = document.getElementById('accommodation_address_country').value;
        document.getElementById('accommodation_invoicename').disabled = true;
        document.getElementById('accommodation_invoicestreet').disabled = true;
        document.getElementById('accommodation_invoicezip').disabled = true;
        document.getElementById('accommodation_invoicecity').disabled = true;
        document.getElementById('accommodation_invoicepobox').disabled = true;
        document.getElementById('accommodation_invoiceregion').disabled = true;
        document.getElementById('accommodation_invoicecountry').disabled = true;
    }
    else {
        document.getElementById('accommodation_invoicename').disabled = false;
        document.getElementById('accommodation_invoicestreet').disabled = false;
        document.getElementById('accommodation_invoicezip').disabled = false;
        document.getElementById('accommodation_invoicecity').disabled = false;
        document.getElementById('accommodation_invoicepobox').disabled = false;
        document.getElementById('accommodation_invoiceregion').disabled = false;
        document.getElementById('accommodation_invoicecountry').disabled = false;
    }
}


jQuery(document).ready(function(){
  jQuery('#hidden_forms_expanded').click(function(){
    jQuery("#optionalFields").hide()
    jQuery(".hidden_forms_collapsed").show()
    jQuery(".hidden_forms_expanded").hide()
  })
  jQuery("#hidden_forms_collapsed").click(function(){
    jQuery("#optionalFields").show()
    jQuery(".hidden_forms_collapsed").hide()
    jQuery(".hidden_forms_expanded").show()
  })
  jQuery("#resettipfriend").click(function(){
    jQuery("#reciever").show()
    jQuery("#sender").hide()
    jQuery("#sent").hide()
    document.getElementById("recieveremail").value = '';              
  })

   jQuery("#showBookingRequest").click(function(){
    jQuery("#wishlisttop").hide();
    jQuery("#wishlist").hide();
    jQuery("#wishlistbottom").hide();
    jQuery("#bookingrequesttop").show();
    jQuery("#bookingrequest").show();
    jQuery("#bookingrequestbottom").show();
  });

    jQuery(document).click(function(event){
      var elemId = event.target;
      var tipsVisibility = document.getElementById("tips").style.display;
      var aboutVisibility = document.getElementById("about").style.display;
      var searchVisibility = document.getElementById("search").style.display;

      if(elemId.id!='about' && elemId.id!='tips' && elemId.id!='search'){
         jQuery('#search').hide();
         jQuery('#tips').hide();
         jQuery('#about').hide();
      }else{
          if(searchVisibility==false && elemId.id!='search'){
            jQuery('#search').hide();
          }
          if(tipsVisibility == false && elemId.id!='tips'){
            jQuery('#tips').hide();
          }
          if(aboutVisibility == false && elemId.id!='about'){
            jQuery('#about').hide();
          }
    }

      //  alert(e.id);
       // alert(elem);

  });

})

function showRoadMapFrom() {
    jQuery("#roadMapFrom").show();
    jQuery("#route").show();
    jQuery("#showMapFromInput").hide();
}

function hideRoadMap(){
    jQuery("#route").empty();
    jQuery("#hideRoadMap").hide();
    jQuery("#printRoadMap").hide();
    jQuery("#showMapFromInput").show();

}


function loadGolfCourse(inparam, id, language){
    if(inparam == 'accommodation'){
        jQuery("#showContent1").show();
        jQuery("#showContent2").hide();
        jQuery("#accommodation").addClass("active");
    }else{
        jQuery("#showContent1").hide();
        jQuery("#showContent2").show();

        jQuery(".first").removeClass("active");
        var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/includes/golfcoursetab.jsp?golfCoursePath='+inparam+'&language='+language;
        jQuery("#showContent2").load(url, function() {

        });    
    }
    if(id!=null && id !=''){
        var tabs = document.getElementsByName("golfcourse");
        for(i=0; i<tabs.length; i++ ){

           // var tab = document.getElementById();
            jQuery(tabs[i]).removeClass("active");
        }
        var elem = document.getElementById(id);
        jQuery(elem).addClass("active");
    }

}

function addBookingRequest(lang){
    var packageId = document.getElementById("packageId").value;
    var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/storechosengolfpackage.jsp?packageId=' + packageId + '&lang=' + lang;
    jQuery('#wishlist').load(url, function() {
        jQuery(".bigArrow").addClass('noArrow');
        jQuery("#addToBookingRequest").hide();
    });
    var url2 = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/getchosenobjects.jsp?lang=' + lang;
    jQuery('#chosenobjects').load(url2, function() {
        jQuery("#explanation").show();
        jQuery("#explanation").animate({opacity: 1.0}, 3000).fadeOut();
    });

}

function remove(id, lang) {
    var packageId = id;
    var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/removegolfpackage.jsp?packageId=' + packageId + "&lang=" + lang;
    jQuery('#wishlist').load(url, function() {
       showHideArrow();
   });
}

function removeCompare0bject(id, lang){
    var objectId = id;
    jQuery('#cb_' + id).attr('checked', false);
    var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/removecompareobject.jsp?objectId=' + objectId + "&lang=" + lang;
    jQuery('#chosenobjects').load(url, function() {
        if (checkNbOfferings() > 0) {
            jQuery("#chosenObjectsWrapper").show();
        } else {
            jQuery("#chosenObjectsWrapper").hide();    
        }
    });

}

function checkNbOfferings() {
    var elems = document.forms['compareOfferings'].getElementsByTagName("input");
    var checkboxes = 0;
    for (var i=0;i<elems.length;i++) {
        if (elems[i].type == 'checkbox') {checkboxes++}
    }
    return checkboxes;
}

function showHideArrow(){
    var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/showHideArrow.jsp';
   jQuery.get(url, function(data) {
       data = jQuery.trim(data);       
       if(data=="noArrow"){
            jQuery(".bigArrow").addClass("noArrow");
       } else {
            jQuery(".bigArrow").removeClass("noArrow");
            jQuery("#addToBookingRequest").show();
       }
});
}

function showhide(divid, show) {
        jQuery("#" + divid).toggle();
}

function sendTip(step) {
    sendTip(step, 'se');
}

function sendTip(step, lang){
    var url="/opencms/opencms/system/modules/se.golfresan.opencms.module/web/email/sendTip.jsp";
    var reciever = document.getElementById("recieveremail").value;
    var sender = document.getElementById("senderemail").value;
    //var forwardPath =window.location.href + window.location.search;
    var forwardPath =window.location.href;
        url=url+"?reciever=" + reciever;
        url=url+"&sender=" + sender;
        url = url+"&path=[" + forwardPath + "]";
        url = url +"&step=" + step + "&lang=" + lang;
      jQuery('#tipyourfriend').load(url, function() {
               
      });
}


/*function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}  */

//var xmlhttp
//function sendTip()
//{
//    var reciever = document.getElementById("recieveremail").value;
//    var sender = document.getElementById("senderemail").value;
//    var forwardPath = document.URL;
//if (reciever.length==0)
//  {
//  document.getElementById("result").innerHTML="";
//  return;
//  }
//xmlhttp=GetXmlHttpObject();
//if (xmlhttp==null)
//  {
//  alert ("Your browser does not support XMLHTTP!");
//  return;
//  }
//var url="../email/sendTip.jsp";
//url=url+"?reciever=" + reciever;
//url=url+"&sender=" + sender;
//url = url+"&path=" + forwardPath;
//
//xmlhttp.open("GET",url,true);
//xmlhttp.send(null);
//document.getElementById("result").innerHTML=xmlhttp.responseText;
//}
//



function removeGolfPackage(){
var packageId = document.getElementById("packageId").value;

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/removegolfpackage.jsp";
url=url+"?packageId=" + packageId;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function loadBookingRequestForm(lang, type){

    //var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/booking/bookingrequestform.jsp?objects=' + param + "&lang=" + lang;
    var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/booking/bookingrequestform.jsp?lang=' + lang + "&typeOfRequest=" + type;
    jQuery('#gavidare').load(url, function() {
      jQuery.getScript("/opencms/opencms/system/modules/se.golfresan.opencms.module/web/scripts/bookingForm.js");
        pageTracker._trackPageview('/bookning/requestform');
    });
    
    
}

function go(){
    location = document.getElementById("golfpackages").value;
    
}

function backToBookingForm(lang, type) {
    var str = $("#addhotel").serialize();
    //alert(str);
    var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/booking/bookingrequestform.jsp?lang=' + lang + "&typeOfRequest=" + type + "&" + str;
    $('#gavidare').load(url, function() {
        $.getScript("/opencms/opencms/system/modules/se.golfresan.opencms.module/web/scripts/bookingForm.js");
    });
}

function leaveBookingForm() {
        var str = jQuery("#addhotel").serialize();
        var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/removegolfpackage.jsp?' + str;
        $('#wishlist').load(url, function() {
            showHideArrow();
        });
}

function showAboutLinks() {
    jQuery('#search').hide();
    jQuery('#tips').hide();
    var isVisible = document.getElementById("about").style.display;
    if(isVisible == 'none'){
         jQuery('#about').show();
    }else{
         jQuery('#about').hide();
    }
}

function showTipsLinks() {
    jQuery('#search').hide();
    jQuery('#about').hide();
    var isVisible = document.getElementById("tips").style.display;
    if(isVisible == 'none'){
         jQuery('#tips').show();
    }else{
         jQuery('#tips').hide();
    }
}


function showDestinationsLinks() {
    jQuery('#tips').hide();
    jQuery('#about').hide();
    var isVisible = document.getElementById("search").style.display;
    if(isVisible == 'none'){
         jQuery('#search').show();
    }else{
         jQuery('#search').hide();
    }
}

function showTab(id, tabid){
    jQuery('#showContent1').hide();
    jQuery('#showContent2').hide();
    jQuery('#showContent3').hide();
    jQuery('#showContent4').hide();
    jQuery("#destination").removeClass("active");
    jQuery("#accommodation").removeClass("active");
    jQuery("#golf").removeClass("active");
    jQuery("#operator").removeClass("active");

    jQuery(id).show();
    jQuery(tabid).addClass("active");
}

function showreportages(id){
    jQuery(".reportageList").hide();
    jQuery(id).show();
}

function signUpForNewsLetter(){
    signUpForNewsLetter("sv");    
}


function signUpForNewsLetter(lang){
    var url="/opencms/opencms/system/modules/se.golfresan.opencms.module/web/includes/newsletter/signupfornewslettercontent.jsp";
    var email = document.getElementById("idEmail").value;
    url = url + "?email=" + email + "&lang=" + lang;
      jQuery('#signupfornewsletter').load(url, function() {

      });
}

function deleteNewsletterSubscriber(lang){
    var url="/opencms/opencms/system/modules/se.golfresan.opencms.module/web/includes/newsletter/cancelnewslettersubscriptioncontent.jsp";
    var email = document.getElementById("cancelsubemail").value;
    url = url + "?email=" + email;
    url = url + "&lang=" + lang;
      jQuery('#cancelnewsletter').load(url, function() {
      
      });
}


function storeChosenObject(id, lang){
    var url = '/opencms/opencms/system/modules/se.golfresan.opencms.module/web/user/storechosenobjects.jsp?id=' + id + '&lang=' + lang;
    jQuery('#chosenobjects').load(url, function() {
        jQuery("#chosenObjectsWrapper").show();
    });
}




