function displayBookAndPayNow(val) {

            if(val.value>0) {
                jQuery("#button_pay_online_extranet_1").hide();
            }else{
                jQuery("#button_pay_online_extranet_1").show();
            }
}


function button_over(idc) {
   if(selected!=idc) {
     list_el=document.getElementById("list"+idc);
     var clas="list"+idc+"_sel list_all";
     list_el.className=clas;
   } 
}
function button_out(idc) {
   
   if(selected!=idc) {
     list_el=document.getElementById("list"+idc);
     var clas="list"+idc+" list_all";
     list_el.className=clas; 
   }
}

selected=1;

function show_part(div_id,id){

  parts_id=new Array(); 
  parts_id[0]="div_description";
  parts_id[1]="div_price";
  parts_id[2]="div_photogallery";
  parts_id[3]="div_rating";
    parts_id[4]="div_conferences";
    parts_id[5]="div_restaurants";
    parts_id[6]="div_services";

  
  parts_id_len=parts_id.length;
  
  for(i=0 ; i< parts_id_len ; i++) {
     el=document.getElementById(parts_id[i]);
     el.style.display="none";  
  }  

     //el=document.getElementById("div_price");
 
     el=document.getElementById(div_id);
     el.style.display="block";
 
    
  
  for(i=1 ; i<= parts_id_len ; i++) {
    var name="list"+i;
    list_el=document.getElementById(name);
    
    var clas="list"+i+" list_all";
    if(list_el) {
      list_el.className=clas;
    }

  }

  name="list"+id;
  selected=id;

  list_el=document.getElementById(name);
  var clas="list"+id+"_sel list_all";
  list_el.className=clas;

    
}

function useMenu(div_id, menu_id)
{
    parts_id=new Array(); 
    parts_id[0]="div_description";
    parts_id[1]="div_price";
    parts_id[2]="div_photogallery";
    parts_id[3]="div_rating";
    parts_id[4]="div_conferences";
    parts_id[5]="div_restaurants";
    parts_id[6]="div_services";
    
    
    
    
    parts_id_len=parts_id.length;
    
    for(i=0 ; i< parts_id_len ; i++)
    {
        el=document.getElementById(parts_id[i]);
        if (el)
            el.style.display="none";  
    }  
    
    el=document.getElementById(div_id);
    el.style.display="block";
    jQ(".active").removeClass("active");
    jQ("#"+menu_id).addClass("active");
    
    return false;
}

function setPricelistDate(day_id, month_id, year_id,acm_id,currency)
{
    day = document.getElementById(day_id);
    month = document.getElementById(month_id);
    year = document.getElementById(year_id);
    day = day.value;
    month = month.value;
    year = year.value;
    date = year+"-"+month+"-"+day;
    SmartyAjax.update('pricelist', '/inc_show_page.php', 'get', 'page=inc_prices_extra_table_detail&id='+acm_id+'&currency='+currency+'&currencies=show&start_date='+date+'&from=detail');
}

function setPricelistDatePopup(day_id, month_id, year_id,acm_id,currency)
{
    day = document.getElementById(day_id);
    month = document.getElementById(month_id);
    year = document.getElementById(year_id);
    day = day.value;
    month = month.value;
    year = year.value;
    date = year+"-"+month+"-"+day;
    jQ("#loading").css("display","inline");
    SmartyAjax.update('pricelist', '/inc_show_page.php', 'get', 'page=inc_prices_extra_table_popup&id='+acm_id+'&currency='+currency+'&currencies=show&start_date='+date+'&from=detail');
}


function calculatorChangeDate(acm_id)
{
    in_day = document.getElementById("in_list_day");
    in_month = document.getElementById("in_list_month");
    in_year = document.getElementById("in_list_year");
    in_day = in_day.value;
    in_month = in_month.value;
    in_year = in_year.value;
    in_date = in_year+"-"+in_month+"-"+in_day;

    out_day = document.getElementById("out_list_day");
    out_month = document.getElementById("out_list_month");
    out_year = document.getElementById("out_list_year");
    out_day = out_day.value;
    out_month = out_month.value;
    out_year = out_year.value;
    out_date = out_year+"-"+out_month+"-"+out_day;
    
    product_id = document.getElementById("product_calculate");
    product_id = product_id.value;
    //alert(product_id);
    
    cur = document.getElementById("price_calculator_currency");
    cur = cur.value;
    var nights=Math.round((new Date(out_year, out_month-1 , out_day, 0, 0, 0) - new Date(in_year, in_month-1 , in_day, 0, 0, 0))/86400000);
    //alert(nights);
    if(nights<1) {
      nights_el = document.getElementById("calulate_price_nights");
      nights_el.innerHTML="1";
    }else {
      nights_el = document.getElementById("calulate_price_nights");
      nights_el.innerHTML=nights;
    }
    SmartyAjax.update('extra_price_calculator', '/inc_show_page.php', 'get', 'page=inc_extra_price_calculator&id='+acm_id+'&start_date='+in_date+'&end_date='+out_date+'&currency='+cur+'&product_id='+product_id);
}

function calculatorChangeDateApartment(acm_id)
{
    in_day = document.getElementById("in_list_day");
    in_month = document.getElementById("in_list_month");
    in_year = document.getElementById("in_list_year");
    in_day = in_day.value;
    in_month = in_month.value;
    in_year = in_year.value;
    in_date = in_year+"-"+in_month+"-"+in_day;

    out_day = document.getElementById("out_list_day");
    out_month = document.getElementById("out_list_month");
    out_year = document.getElementById("out_list_year");
    out_day = out_day.value;
    out_month = out_month.value;
    out_year = out_year.value;
    out_date = out_year+"-"+out_month+"-"+out_day;
    
    number_people = document.getElementById("number_people");
    number_people = number_people.value;
    //alert(product_id);
    
    cur = document.getElementById("price_calculator_cur");
    cur = cur.value;
    var nights=Math.round((new Date(out_year, out_month-1 , out_day, 0, 0, 0) - new Date(in_year, in_month-1 , in_day, 0, 0, 0))/86400000);
    //alert(nights);
    if(nights<1) {
      nights_el = document.getElementById("calulate_price_nights");
      nights_el.innerHTML="1";
    }else {
      nights_el = document.getElementById("calulate_price_nights");
      nights_el.innerHTML=nights;
    }
    SmartyAjax.update('extra_price_calculator', '/inc_show_page.php', 'get', 'page=inc_apartment_price_calculator&id='+acm_id+'&start_date='+in_date+'&end_date='+out_date+'&currency='+cur+'&people='+number_people);

    
   
}

function bookingChangeDate(acm_id)
{
    in_day = document.getElementById("in_list_day");
    in_month = document.getElementById("in_list_month");
    in_year = document.getElementById("in_list_year");
    in_day = in_day.value;
    in_month = in_month.value;
    in_year = in_year.value;
    in_date = in_year+"-"+in_month+"-"+in_day;

    out_day = document.getElementById("out_list_day");
    out_month = document.getElementById("out_list_month");
    out_year = document.getElementById("out_list_year");
    out_day = out_day.value;
    out_month = out_month.value;
    out_year = out_year.value;
    out_date = out_year+"-"+out_month+"-"+out_day;
    
    product_id = document.getElementById("product_calculate");
    product_id = product_id.value;
    //alert(product_id);
    
    cur = document.getElementById("price_calculator_currency");
    cur = cur.value;

    SmartyAjax.update('extra_price_calculator', '/inc_show_page.php', 'get', 'page=inc_change_term&id='+acm_id+'&start_date='+in_date+'&end_date='+out_date+'&currency='+cur+'&product_id='+product_id);
}


function calcExtranetPrice(product_id)
{
    in_day = document.getElementById("in_list_day");
    in_month = document.getElementById("in_list_month");
    in_year = document.getElementById("in_list_year");
    in_day = in_day.value;
    in_month = in_month.value;
    in_year = in_year.value;
    in_date = in_year+"-"+in_month+"-"+in_day;

    out_day = document.getElementById("out_list_day");
    out_month = document.getElementById("out_list_month");
    out_year = document.getElementById("out_list_year");
    out_day = out_day.value;
    out_month = out_month.value;
    out_year = out_year.value;
    out_date = out_year+"-"+out_month+"-"+out_day;
    

    product_id = document.getElementById("product_calculate");
    product_id = product_id.value;

    calc_acm_id = document.getElementById("calc_acm_id");
    calc_acm_id = calc_acm_id.value;

    

    cur = document.getElementById("price_calculator_currency");
    cur = cur.value;
    
    //SmartyAjax.update('extra_price_calculator_result', '/inc_show_page.php', 'get', 'page=calculate_extranet_price&check_in='+in_date+'&check_out='+out_date+'&product_id='+product_id+'&currency='+cur+'&calc_acm_id='+calc_acm_id);
    makeRequestCalculator('extra_price_calculator_result','check_in='+in_date+'&check_out='+out_date+'&product_id='+product_id+'&currency='+cur+'&calc_acm_id='+calc_acm_id);
}

function calcAptPrice(product_id)
{
    in_day = document.getElementById("in_list_day");
    in_month = document.getElementById("in_list_month");
    in_year = document.getElementById("in_list_year");
    in_day = in_day.value;
    in_month = in_month.value;
    in_year = in_year.value;
    in_date = in_year+"-"+in_month+"-"+in_day;

    out_day = document.getElementById("out_list_day");
    out_month = document.getElementById("out_list_month");
    out_year = document.getElementById("out_list_year");
    out_day = out_day.value;
    out_month = out_month.value;
    out_year = out_year.value;
    out_date = out_year+"-"+out_month+"-"+out_day;
    
    people = document.getElementById("number_people");
    people = people.value;

    calc_acm_id = document.getElementById("calc_acm_id");
    calc_acm_id = calc_acm_id.value;

    cur = document.getElementById("price_calculator_cur");
    cur = cur.value;
 
    var params='check_in='+in_date+'&check_out='+out_date+'&people='+people+'&currency='+cur+'&id='+calc_acm_id;
    jQuery("#apt_price_calculator_result").html("Calculating...");
    jQuery.ajax({
        type: "POST",
        url: "/inc_show_page.php?page=inc_apt_price_calculator_result",
        data: params,
        success: function(html)
        {
            jQuery("#apt_price_calculator_result").html("");
            jQuery("#apt_price_calculator_result").append(html);
        }
    });
    
    //makeRequestCalculator('apt_price_calculator_result','check_in='+in_date+'&check_out='+out_date+'&people='+people+'&currency='+cur+'&calc_acm_id='+calc_acm_id);
}

function changeTerm(product_id)
{
    in_day = document.getElementById("in_list_day");
    in_month = document.getElementById("in_list_month");
    in_year = document.getElementById("in_list_year");
    in_day = in_day.value;
    in_month = in_month.value;
    in_year = in_year.value;
    in_date = in_year+"-"+in_month+"-"+in_day;

    out_day = document.getElementById("out_list_day");
    out_month = document.getElementById("out_list_month");
    out_year = document.getElementById("out_list_year");
    out_day = out_day.value;
    out_month = out_month.value;
    out_year = out_year.value;
    out_date = out_year+"-"+out_month+"-"+out_day;
    

    product_id = document.getElementById("product_calculate");
    product_id = product_id.value;

    calc_acm_id = document.getElementById("calc_acm_id");
    calc_acm_id = calc_acm_id.value;

    

    cur = document.getElementById("price_calculator_currency");
    cur = cur.value;
    
    //SmartyAjax.update('extra_price_calculator_result', '/inc_show_page.php', 'get', 'page=calculate_extranet_price&check_in='+in_date+'&check_out='+out_date+'&product_id='+product_id+'&currency='+cur+'&calc_acm_id='+calc_acm_id);
    makeRequestCalculator('extra_price_calculator_result','check_in='+in_date+'&check_out='+out_date+'&product_id='+product_id+'&currency='+cur+'&calc_acm_id='+calc_acm_id+'&booking_style=1');
}

function onDataReceivedCalculator(req, destination) {
  var div = document.getElementById(destination);
  
  if (req.readyState == 4) {
            
			if (req.status == 200) {
			          
                div.innerHTML=req.responseText;
            } else {
                
               	var s=" CHYBA ..." + req.responseText;
 				       div.innerHTML = s;
            }
			
        } else {
               
			}
 
}

function makeRequestCalculator(destination,data_input){
    
	  
			if (window.XMLHttpRequest) { // Mozilla, Safari, ...
				req = new XMLHttpRequest();
				
				if (req.overrideMimeType) {
					req.overrideMimeType('text/xml');
					// See note below about this line
				}
			} else if (window.ActiveXObject) { // IE
				try {
					req = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try {
						req = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {}
				}
			}
	  
	  var data = '';
	  data += data_input;
	  
	  req.onreadystatechange =  function() { onDataReceivedBookingVip(req,'extra_price_calculator_result'); };
	  req.open("POST", "/inc_show_page.php?page=calculate_extranet_price", true);
	  req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	  req.send(data);  
	 
}



