﻿// File JScript

function HideTable(tableName)
{
    var tabella = document.getElementById(tableName);

    if (tabella.style.display == 'block' || tabella.style.display == '')
    {
        tabella.style.display = 'none';
    }
    else
    {
	    tabella.style.display = '';
    }
}

function ShowProgress()
{
    setTimeout('document.images["imgwait"].src = "http://www.booking.hellobologna.it/blqfiera/images/waiting.gif"', 200); 

    var progress = document.getElementById("progress");
    progress.style.display = "";

    return true;
}
        
function openPopUp(url,w,h)
{
    var lt = (screen.width - w) / 2;
	var tp = (screen.height - h) / 2;
	window.open(url,'','width='+w+',height='+h+',left='+lt+',top='+tp+',scrollbars=yes,resize=no');
}

function sommaData(start_day, number_nights)
{	  
    var days = start_day;

    var exp = days.split("-");
    var giorno = exp[0];
    var mese = exp[1];
    var anno = exp[2];

    var diff = parseInt(number_nights, 10);
    var part = new Date(anno, parseInt(mese,10)-1, giorno);  

    var currentDate = new Date();
    var currYear = currentDate.getFullYear() + 1;
    var currMonth = currentDate.getMonth();

    var sumDayToCheck = parseInt(giorno,10) + diff;
    
    if(mese == 12 && sumDayToCheck > 31) anno = currYear;

    var fine = part;
    fine.setDate(fine.getDate() + diff);   

    //var prova = fine.toLocaleDateString();  alert(fine.getDate());
    var meseToDisplay = part.getMonth() + 1;
    
    if((meseToDisplay/10) < 1) meseToDisplay = '0' + meseToDisplay;

	var giornoToDisplay = fine.getDate();

	if((giornoToDisplay/10) < 1) giornoToDisplay = '0' + giornoToDisplay;
	
	var annoToDisplay = fine.getFullYear();
    
	var str = annoToDisplay + '-' + meseToDisplay + '-' + giornoToDisplay;

    return str;
}

function fillcombo(thecombo, value)
{
	var dest = document.getElementById(thecombo);

	for (var i=dest.options.length-1; i>=1; i--)
	{
		dest.options[i] = null;
	}

	dest.selectedIndex = -1;

	if (eval("typeof("+value+")!='undefined'"))
	{
		var arrDest = eval(value);

		for (var i = 0; i < arrDest.length; i++)
		{
			dest.options[dest.options.length] = new Option(arrDest[i].value, arrDest[i].text);
		}
	}
	else
	{
	    dest.options[0] = new Option("", "");
	}	
}