/*
$(document).ready(function()
{
	var t = setTimeout("setHeight()", 500);
})
*/

function setHeight()
{
	/*****************************************************************************************
	*	Variabili che prendono l'UserAgent, il nome originale del Browser e la versione
	*	in seguito le stringhe vengono ripulite del non necessario.
	*/
	var nAgt = navigator.userAgent;
	var browserName  = navigator.appName;
	var nameOffset, verOffset;

	// Internet Explorer
	if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
		browserName = "MSIE";
	}
	// Opera
	else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
		browserName = "Opera";
	}
	// Chrome
	else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
		browserName = "Chrome";
	}
	// Safari
	else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
		browserName = "Safari";
	}
	// Firefox
	else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
		browserName = "Firefox";
	}
	// Altri browser
	else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) )
	{
		browserName = nAgt.substring(nameOffset,verOffset);
		if (browserName.toLowerCase()==browserName.toUpperCase()) {
			browserName = navigator.appName;
		}
	}

	/***********************************************************************************************
	* heights regulations
	*/
	var h_box_column = 0, h_box_column_bot = 0, h_content = 0, tmp = 0, final_height = 0, col_offset = 0, wrapper_offset = 0;

	if((browserName == 'Chrome') || (browserName == 'Safari'))
	{
		// col_offset = 10;
		wrapper_offset = 10;
	}
	
	h_box_column = $('#box_column').outerHeight({margin: true});
	h_box_column_bot = $('#column_bottom').outerHeight({margin: true});
	h_content = $('#header').outerHeight({margin: true}) + $('#wrapper_box').outerHeight({margin: true});

	/******************************************************************************
	* $('#div_id').get(0) == $('#div_id')[0] == document.getElementById('div_id');
	*/
	if(h_content > h_box_column)
	{
		tmp = h_content - h_box_column;
		if($('#switch_structure_box').get(0))
		{
			final_height = $('#switch_structure_box').outerHeight({margin: true}) + tmp - (3*h_box_column_bot) - col_offset;
			$('#switch_structure_box').height(final_height);
		}
		if($('#info_prenotazione_box').get(0))
		{
			final_height = $('#info_prenotazione_box').outerHeight({margin: true}) + tmp - (3*h_box_column_bot) - col_offset;
			$('#info_prenotazione_box').height(final_height);
		}
	}
	else if(h_content < h_box_column)
	{
		tmp = h_box_column - h_content;
		final_height = $('#container').outerHeight({margin: true}) + tmp + (2*h_box_column_bot) + wrapper_offset;
		$('#container').height(final_height);
	}
}
	

