function updateTPInfoCallback(data) {
    try {tpBoxRefreshMe(); }  catch(e) {}
    try { travelPlannerRefreshMe()}  catch(e) {}
    try { addToCalendarRefreshMe()} catch(e) {}
    try { activePortletRefreshMe()}  catch(e) {}

}
function updateCalendarCallback(data) {
}
function updateTpPage(data) {
    try {
    addToCalendarRefreshMe();
 }
 catch(e) {

 }
    tpBoxRefreshMe();
}

function objectEval(text)
{
    // eval() breaks when we use it to get an object using the { a:42, b:'x' }
    // syntax because it thinks that { and } surround a block and not an object
    // So we wrap it in an array and extract the first element to get around
    // this.
    // This code is only needed for interpreting the parameter input fields,
    // so you can ignore this for normal use.
    // The regex = [start of line][whitespace]{[stuff]}[whitespace][end of line]
    text = text.replace(/\n/g, ' ');
    text = text.replace(/\r/g, ' ');
    (text.match(/^\s*\{.*\}\s*$/))
    {
        text = '[' + text + '][0]';
    }
    return eval(text);
}

var mapRegionViewPopup = null;
function openMapRegionViewPopup(capt, showSearchInfo, referer)
{
  var refCat = "MapRegionOverview";
  if (referer != null)
	refCat = "MapRegionDestination";

	_gaq.push(['_trackEvent', refCat, 'open', document.location.href]);

  if(capt==null)
        capt='';
  var params = "";
  if (showSearchInfo == null)
	  showSearchInfo = false;

  if (showSearchInfo == true)
	  params = "&_MapPortlet_WAR_MapPortlet_displaySearchInfo=true";
  
  var d = new Date(); 
  params = params + "&v="+d.getTime();

    var mapRegionViewPopupCloseCallback = function()
    {
        try {
//            refreshRecommender();
        }
        catch(e) {}
    }
    mapRegionViewPopup = showModalWindow(new ModalWindowContext({
        url : "/c/portal/render_portlet?p_p_id=MapPortlet_WAR_MapPortlet&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&_MapPortlet_WAR_MapPortlet_action=chooseRegionView" + params,
        caption : capt,
        width: 780,
        onCloseFunction : null
    }));
}
function openchooseRec(capt)
{
    var caption=TravelPlannerGetLabel('whichRecommendations');

    var openchooseRecCallback = function()
    {
    }
    openchooseRecCallback = showModalWindow(new ModalWindowContext({
        url : "/web/guest/my-travel-plans/-/travel_plan/action/chooseRecFunction.htm?p_p_id=travel_plan_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view",
        caption : caption,
        width: 400,
        onCloseFunction : null
    }));
}
function openTravelPreference(capt)
{

      var openPrefReadyCallback = function(fn2,popup2)
    {
        	fn2.call(this,popup2);
         expandHearts();

    }
    var caption=TravelPlannerGetLabel('travelPlan.editTravelProfile');
    opentpRefCallback = showModalWindow(new ModalWindowContext({
        url : "/web/guest/my-travel-plans/preferences?p_p_id=travel_context_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_travel_context_WAR_travelplanner_action=travelContextShow.htm&_travel_context_WAR_travelplanner_FROM_URL=popup",
        caption : caption,
        width: 700,
         onReadyFunction : openPrefReadyCallback,
        onCloseFunction : null
    }));
}

function openTravelPlanHelpPopup(portletid, caption)
{
     jQuery("#tp_help").remove();
      var openHelpReadyCallback = function(fn2,popup2)
    {
    	  jQuery(".copofi-tabs").tabs({'show' : function(){jQuery(popup2).find('#tp_help:eq(0)').show();fn2.call(this,popup2);}});
    }
      var url="/web/guest/travel-planner/home?p_p_id="+portletid+"&p_p_lifecycle=1&p_p_state=exclusive&p_p_col_id=tpl_2_left&p_p_col_count=1";

    //var caption=TravelPlannerGetLabel('travelPlanHome.travelPlanHelp')
    opentpHelpCallback = showModalWindow(new ModalWindowContext({
        url : url,
        caption : caption,
        width: 400,
         onReadyFunction :  openHelpReadyCallback,
        onCloseFunction : null
    }));
}



function openTravelPreferenceFromTPEdit(capt)
{

      var openPrefReadyCallback = function(fn2,popup2)
    {
        	fn2.call(this,popup2);
         expandHearts();

    }
    var caption=TravelPlannerGetLabel('travelPlan.editTravelProfile');
    opentpRefCallback = showModalWindow(new ModalWindowContext({
        url : "/web/guest/my-travel-plans/preferences?p_p_id=travel_context_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_travel_context_WAR_travelplanner_action=travelContextShow.htm&_travel_context_WAR_travelplanner_FROM_URL=tpedit",
        caption : caption,
        width: 700,
         onReadyFunction : openPrefReadyCallback,
        onCloseFunction : null
    }));
}


function clearRegionIfEmpty() {
    if(jQuery('#suggestRegions').val()=='')
        jQuery('#suggestRegionVal').val('');

}
function travelPlannerUtilShowModalWindow (urlvar, caption,formid,width) {


    var travelPlannerUtilCallback = function(fn2,popup2)
    {
        	fn2.call(this,popup2);
            setDatePickers();
            if(formid!=null)
            jQuery('#'+formid).submit();


    }
    if(width==null)
        width=380;
    showModalWindow(new ModalWindowContext({
        url : urlvar,
        caption : caption,
        width: width,
        onReadyFunction : travelPlannerUtilCallback,
        onCloseFunction : null
    }));



}


function travelPlannerUtilShowModalWindowWidth (urlvar, caption,formid,width) {


    var travelPlannerUtilCallback = function(fn2,popup2)
    {
        	fn2.call(this,popup2);
            setDatePickers();
            if(formid!=null)
            jQuery('#'+formid).submit();


    }
    showModalWindow(new ModalWindowContext({
        url : urlvar,
        caption : caption,
        width: width,
        onReadyFunction : travelPlannerUtilCallback,
        onCloseFunction : null
    }));



}
function  addItemToCartFormCallback(data) {
    jQuery('#titleAdd').text(data);
    tpBoxRefreshMe();
    return true;


}

function travelPlannerAddItemShowModalWindow (pid,itemType,rank,caseid,refcaseid,refitemid,position,rid,onCloseFunction) {

    var addItemOnReadyCloseCallback = function(fn2,popup2)
    {
        	fn2.call(this,popup2);
        addItemToTravelPlan(pid,itemType,rank,caseid,refcaseid,refitemid,position,rid, addItemToCartFormCallback);

    }
    showModalWindow(new ModalWindowContext({
        url : "/web/guest/my-travel-plans?p_p_id=travel_plan_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&_travel_plan_WAR_travelplanner_action=addingItemController.htm",
        caption : '',
        width: 300,
        onReadyFunction : addItemOnReadyCloseCallback,
        onCloseFunction : onCloseFunction
    }));
}

function travelPlannerAddTransportShowModalWindow (transportItem,onCloseFunction) {

    var addItemOnReadyCloseCallback = function(fn2,popup2)
    {
        	fn2.call(this,popup2);
        TravelPlanTransportService.addTransportItem(transportItem, addItemToCartFormCallback);
    }
    showModalWindow(new ModalWindowContext({
        url : "/web/guest/my-travel-plans?p_p_id=travel_plan_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&_travel_plan_WAR_travelplanner_action=addingItemController.htm",
        caption : '',
        width: 300,
        onReadyFunction : addItemOnReadyCloseCallback,
        onCloseFunction : onCloseFunction
    }));
}

function popUpPrint(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=700,left = 10,top = 10');");
}

function travelPlannerSearchAccommodationShowModalWindow (caption,type) {
    var setJs = function(fn2,popup2)
    {
        fn2.call(this,popup2);
        setForm();
    }
    var szurl="/web/guest/travel-planner/accommodation/suggestions?p_p_id=acco_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&_acco_search_WAR_travelplanner_action=searchAccommodationShow.htm";
    if(type!=null && type!="")
        szurl="/web/guest/travel-planner/accommodation/suggestions?p_p_id=acco_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&_acco_search_WAR_travelplanner_action=searchAccommodationShow.htm&_acco_search_WAR_travelplanner_accoType="+type;
    showModalWindow(new ModalWindowContext({
        url : szurl,
        caption : caption,
         onReadyFunction : setJs,
        width: 300
    }));
}

function travelPlannerSearchDestinationShowModalWindow (caption,type) {
    var szurl="/web/guest/travel-planner/destinations/suggestions?p_p_id=dest_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_dest_search_WAR_travelplanner_action=searchDestinationShow.htm";
    if(type!=null && type!="")
        szurl="/web/guest/travel-planner/destinations/suggestions?p_p_id=dest_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_dest_search_WAR_travelplanner_action=searchDestinationShow.htm&_dest_search_WAR_travelplanner_interests="+type;
   var setJs = function(fn2,popup2)
    {
        fn2.call(this,popup2);
//       setForm();
    }
    showModalWindow(new ModalWindowContext({
        url :szurl,
        caption : caption,
        onReadyFunction : setJs,
        width: 300
    }));
}

function travelPlannerSearchEventShowModalWindow (caption,type) {
    var szurl="/web/guest/travel-planner/events/suggestions?p_p_id=event_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_event_search_WAR_travelplanner_action=searchEventShow.htm";
    if(type!=null && type!="")
        szurl="/web/guest/travel-planner/events/suggestions?p_p_id=event_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_event_search_WAR_travelplanner_action=searchEventShow.htm&_event_search_WAR_travelplanner_interests="+type;
    showModalWindow(new ModalWindowContext({
        url : szurl,
        caption : caption,
        width: 300
    }));
}
// ActivityTypes.Hunting
function travelPlannerSearchActivitesShowModalWindow (caption,type) {
    var szurl="/web/guest/travel-planner/travel-offers/suggestions?p_p_id=to_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_to_search_WAR_travelplanner_action=searchTOShow.htm";
    if(type!=null && type!="")
        szurl="/web/guest/travel-planner/travel-offers/suggestions?p_p_id=to_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_to_search_WAR_travelplanner_action=searchTOShow.htm&_to_search_WAR_travelplanner_interests="+type;
    showModalWindow(new ModalWindowContext({
        url : szurl,
        caption : caption,
        width: 300
    }));
}

function travelPlannerSearchAttractionsShowModalWindow (caption,type) {
    var szurl="/web/guest/travel-planner/interests/suggestions?p_p_id=attr_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_att_search_WAR_travelplanner_action=searchAttractionShow.htm";
    if(type!=null && type!="")
        szurl="/web/guest/travel-planner/interests/suggestions?p_p_id=attr_search_WAR_travelplanner&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&p_p_col_id=tpl_4_left&p_p_col_count=1&_att_search_WAR_travelplanner_action=searchAttractionShow.htm&_attr_search_WAR_travelplanner_interests="+type;
    showModalWindow(new ModalWindowContext({
        url : szurl,
        caption : caption,
        width: 300
    }));
}

function travelContextSubmit(fromurl) {

    var tc={
        szTravelParty:jQuery("#id_szTravelParty").val(),
       szTransportMean:jQuery("#id_szTransportMean").val(),
     szAccoInPlace:jQuery("#id_szAccoInPlace").val(),
        szBudget:jQuery("#id_szBudget").val(),
        depContinent:jQuery("#id_depContinent").val(),
        szSeason:jQuery("#id_szSeason").val(),
        szDuration:jQuery("#id_szDuration").val(),
        szKnowledgeOfPlace:jQuery("#id_szKnowledgeOfPlace").val(),
        b_mainTG_adventure: (jQuery('#cb_fg_slider_0:checked').val()!=null) ,
        i_mainTG_adventure:  jQuery('#fg_slider_0').val(),
         b_mainTG_art_design: (jQuery('#cb_fg_slider_1:checked').val()!=null),
        i_mainTG_art_design:  jQuery('#fg_slider_1').val(),
        b_mainTG_cuisine: (jQuery('#cb_fg_slider_2:checked').val()!=null),
        i_mainTG_cuisine:  jQuery('#fg_slider_2').val(),
        b_mainTG_culture_sightseeing: (jQuery('#cb_fg_slider_3:checked').val()!=null),
        i_mainTG_culture_sightseeing:  jQuery('#fg_slider_3').val(),
        b_mainTG_fun_nightlife: (jQuery('#cb_fg_slider_4:checked').val()!=null),
        i_mainTG_fun_nightlife:  jQuery('#fg_slider_4').val(),
        b_mainTG_health_wellbeing: (jQuery('#cb_fg_slider_5:checked').val()!=null),
        i_mainTG_health_wellbeing:  jQuery('#fg_slider_5').val(),
        b_mainTG_learning: (jQuery('#cb_fg_slider_6:checked').val()!=null),
        i_mainTG_learning:  jQuery('#fg_slider_6').val(),
        b_mainTG_traditions: (jQuery('#cb_fg_slider_7:checked').val()!=null),
        i_mainTG_traditions:  jQuery('#fg_slider_7').val(),
        b_mainTG_nature: (jQuery('#cb_fg_slider_8:checked').val()!=null),
        i_mainTG_nature:  jQuery('#fg_slider_8').val(),
        b_mainTG_shopping: (jQuery('#cb_fg_slider_9:checked').val()!=null),
        i_mainTG_shopping:  jQuery('#fg_slider_9').val(),
        b_mainTG_sports: (jQuery('#cb_fg_slider_10:checked').val()!=null),
        i_mainTG_sports:  jQuery('#fg_slider_10').val(),
        b_activitiesTG_boating: (jQuery('#cb_fs_slider_11:checked').val()!=null),
        i_activitiesTG_boating:  jQuery('#fs_slider_11').val(),
        b_activitiesTG_canoeing: (jQuery('#cb_fs_slider_12:checked').val()!=null),
        i_activitiesTG_canoeing:  jQuery('#fs_slider_12').val(),
        b_activitiesTG_car_touring: (jQuery('#cb_fs_slider_13:checked').val()!=null),
        i_activitiesTG_car_touring:  jQuery('#fs_slider_13').val(),
        b_activitiesTG_cruises: (jQuery('#cb_fs_slider_14:checked').val()!=null),
        i_activitiesTG_cruises:  jQuery('#fs_slider_14').val(),
        b_activitiesTG_country_holidays: (jQuery('#cb_fs_slider_15:checked').val()!=null),
        i_activitiesTG_country_holidays:  jQuery('#fs_slider_15').val(),
        b_activitiesTG_cycling: (jQuery('#cb_fs_slider_16:checked').val()!=null),
        i_activitiesTG_cycling:  jQuery('#fs_slider_16').val(),
        b_activitiesTG_fishing: (jQuery('#cb_fs_slider_17:checked').val()!=null),
        i_activitiesTG_fishing:  jQuery('#fs_slider_17').val(),
        b_activitiesTG_golf: (jQuery('#cb_fs_slider_18:checked').val()!=null),
        i_activitiesTG_golf:  jQuery('#fs_slider_18').val(),
        b_activitiesTG_hiking: (jQuery('#cb_fs_slider_19:checked').val()!=null),
        i_activitiesTG_hiking:  jQuery('#fs_slider_19').val(),
        b_activitiesTG_horse_riding: (jQuery('#cb_fs_slider_20:checked').val()!=null),
        i_activitiesTG_horse_riding:  jQuery('#fs_slider_20').val(),
        b_activitiesTG_hunting: (jQuery('#cb_fs_slider_21:checked').val()!=null),
        i_activitiesTG_hunting:  jQuery('#fs_slider_21').val(),
        b_activitiesTG_bird_watching: (jQuery('#cb_fs_slider_22:checked').val()!=null),
        i_activitiesTG_bird_watching:  jQuery('#fs_slider_22').val(),
        b_activitiesTG_crosscountry_ski: (jQuery('#cb_fw_slider_23:checked').val()!=null),
        i_activitiesTG_crosscountry_ski:  jQuery('#fw_slider_23').val(),
        b_activitiesTG_safaris: (jQuery('#cb_fw_slider_24:checked').val()!=null),
        i_activitiesTG_safaris:  jQuery('#fw_slider_24').val(),
        b_activitiesTG_downhill_ski: (jQuery('#cb_fw_slider_25:checked').val()!=null),
        i_activitiesTG_downhill_ski:  jQuery('#fw_slider_25').val(),
        b_activitiesTG_driving_ice: (jQuery('#cb_fw_slider_26:checked').val()!=null),
        i_activitiesTG_driving_ice:  jQuery('#fw_slider_26').val(),
        b_activitiesTG_ice_cruises: (jQuery('#cb_fw_slider_27:checked').val()!=null),
        i_activitiesTG_ice_cruises:  jQuery('#fw_slider_27').val(),
        b_activitiesTG_ice_skating:  (jQuery('#cb_fw_slider_28:checked').val()!=null),
        i_activitiesTG_ice_skating:  jQuery('#fw_slider_28').val(),
        b_activitiesTG_new_year: (jQuery('#cb_fw_slider_29:checked').val()!=null),
        i_activitiesTG_new_year:  jQuery('#fw_slider_29').val(),
        b_activitiesTG_northern_lights:( jQuery('#cb_fw_slider_30:checked').val()!=null),
        i_activitiesTG_northern_lights:  jQuery('#fw_slider_30').val(),
        b_activitiesTG_christmas: (jQuery('#cb_fw_slider_31:checked').val()!=null),
        i_activitiesTG_christmas:  jQuery('#fw_slider_31').val(),
        b_activitiesTG_snow_accomm: (jQuery('#cb_fw_slider_32:checked').val()!=null),
        i_activitiesTG_snow_accomm:  jQuery('#fw_slider_32').val(),
        b_activitiesTG_snowmobile_riding: (jQuery('#cb_fw_slider_33:checked').val()!=null),
        i_activitiesTG_snowmobile_riding:  jQuery('#fw_slider_33').val(),
        b_activitiesTG_snowboarding:( jQuery('#cb_fw_slider_34:checked').val()!=null),
        i_activitiesTG_snowboarding:  jQuery('#fw_slider_34').val(),
        b_activitiesTG_snowshoe_walking: (jQuery('#cb_fw_slider_35:checked').val()!=null),
        i_activitiesTG_snowshoe_walking:  jQuery('#fw_slider_35').val(),
        b_activitiesTG_winter_fishing: (jQuery('#cb_fw_slider_36:checked').val()!=null),
        i_activitiesTG_winter_fishing:  jQuery('#fw_slider_36').val(),
        b_activitiesTG_winter_swimming: (jQuery('#cb_fw_slider_37:checked').val()!=null),
        i_activitiesTG_winter_swimming:  jQuery('#fw_slider_37').val()
    };

    var closeAndRefreshCallback = function () {
            Liferay.Popup.close(jQuery('#id_travelcontext'));
            if(fromurl=='popup') {
            try {
                refreshRecommender();
            }
            catch (e){
                try{
                updateTravelPlan();
                    openchooseRec();
                }
                catch(e2) {
                    openchooseRec();

                }
            }
            }
            else {
                try { updateTravelPlan();} catch(e) {}
            }

    }
         _gaq.push(['_trackEvent', 'Travel Planner - FormProfiler', 'options', 'showRecommendation']);
         TravelContextExtService.submitTravelContext(tc,closeAndRefreshCallback);
            return false;
  }

  function  travelContextReset(fromurl) {

    var resetCallback = function () {
            if(fromurl=='popup') {
                try{    updateTravelPlan();} catch(e2) {}
                Liferay.Popup.close(jQuery('#id_travelcontext'));
                openTravelPreference();
            }
            else {
                try{    updateTravelPlan();} catch(e2) {}
                Liferay.Popup.close(jQuery('#id_travelcontext'));
                openTravelPreferenceFromTPEdit();
            }
    }

          _gaq.push(['_trackEvent', 'Travel Planner - FormProfiler', 'options', 'reset']);

         TravelContextExtService.resetTravelContext(resetCallback);
       return false;
  }
function  travelContextCleanAndColse() {

        var closeCallback = function () {
            Liferay.Popup.close( jQuery('#id_travelcontext'));
            try {
                refreshRecommender();
            }
            catch (e){
                try {updateTravelPlan(); } catch(e1){};}
            }
          _gaq.push(['_trackEvent', 'Travel Planner - FormProfiler', 'options', 'close']);

         TravelContextExtService.resetTravelContext(closeCallback);

       return false;
  }

  function travelContextClose() {
            Liferay.Popup.close( jQuery('#id_travelcontext'));
            _gaq.push(['_trackEvent', 'Travel Planner - FormProfiler', 'options', 'close']);
            return false;

  }

function addToCalendarRefresh() {
        jQuery('.tabs').tabs('select','calendar_view');
        travelPlannerRefreshMe();
        addToCalendarRefreshMe();
        tpBoxRefreshMe();

}
function travelPlanAddtoCalendar(url) {

    var caption=TravelPlannerGetLabel('Add-item-to-calendar');

  var travelPlannerUtilCallback = function(fn2,popup2)
    {
        	fn2.call(this,popup2);
            setDatePickers();
    }
    showModalWindow(new ModalWindowContext({
        url : url,
        caption : caption,
        width: 600,
        onReadyFunction : travelPlannerUtilCallback,
        onCloseFunction : null
    }));

}

function homepageChangeTabRefresh() {
        jQuery('.tabs').tabs('select','book-and-personalise');
}

function homepageChangeThirdTabRefresh() {
        jQuery('.tabs').tabs('select','how-to-manage');
}

function homepageChangeNewTabRefresh(tabname) {
        jQuery('.tabs').tabs('select',tabname);
}

function askProfileMatchOnSort() {
    var sortBy=jQuery("#idSort_by").val();
    if(sortBy=="pm") {
    openPicProPopup(true);
    return false;
    }
    return true;
}

function popupOpen() {
    vfPopup = Liferay.Popup({
        autoResize: true,
        //dialogClass: 'one',
        handles : '',
        resizable: false,
        draggable: false,
        dragHelper : null,
        modal: true,
        title: '',
        //position: position,
        // resizeHelper: resizeHelper,
        //stack: stack,
        //zIndex: Liferay.zIndex.ALERT,
        zIndex: 13000,
        width:50,
        height:50,
        message: '<div align="center"><img style="margin-top: 9px" src="/copofi-theme/images/progress_bar/loading_animation.gif"/></div>'
    });
//
    jQuery(vfPopup).parents('.ui-dialog:eq(0)').find('.ui-dialog-titlebar').css('display','none');

    // Toglie la X per chiudere
    jQuery(vfPopup).parents('.ui-dialog-container:eq(0)').find('.ui-dialog-titlebar-close').css('display','none');
    return vfPopup;
}
function popupClose(vfPopup) {
    Liferay.Popup.close(vfPopup);
}
function hideShowCapacity(accoType) {
    var at="";
    if(accoType==null)
       at=jQuery("#idAccoType").val();
   else
       at=accoType;

       var date1=jQuery("#datepicker1").val();
       var date2=jQuery("#datepicker2").val();
       var noCapacity=false;
       if(at!=null &&
               (at=="AccommodationTypes.Apartment" ||
               at=="AccommodationTypes.CottageAndChalet" ||
               at=="AccommodationTypes.CampingAndCaravaning" ||
                at==""
                )
         )
               noCapacity=true;
        if(date1!=null && date1!='' && date2!=null && date2!='') {
            jQuery("#id_persons").show();
	    if(noCapacity==true)
            	jQuery("#id_room_type").hide();
	    else
            	jQuery("#id_room_type").show();
	    
	    }
        else {
            jQuery("#id_persons").hide();
            jQuery("#id_room_type").hide();
            try {
            jQuery("#idRoomType").val("");
            } catch(e) {};
            jQuery("#idNumPersons").val("1");
            jQuery("#idNumRooms").val("1");

        }

    };

