function sopen(id) {
	if(id=="simple") {
		document.getElementById("advanced1").style.display="block";
		document.getElementById("simple").style.display="none";
		document.getElementById("advanced2").style.display="none";
		document.getElementById("searchForm").advanced.value = 0;
		return 1;
	}
	if(id=="advanced") {
		document.getElementById("advanced1").style.display="none";
		document.getElementById("simple").style.display="block";
		document.getElementById("advanced2").style.display="block";
		document.getElementById("searchForm").advanced.value = 1;
		return 1;
	}
}

function calcLength(inputObject)
{
	var startDate	= document.getElementById('start_date').value;
	var endDate		= document.getElementById('end_date').value;

	if (startDate && endDate)
	{
		var start_day	= 0;
		var start_month	= 0;
		var start_year	= 0;

		var end_day		= 0;
		var end_month	= 0;
		var end_year	= 0;
				
		poz = startDate.indexOf('/');
		if (poz >= 0)
		{
			start_day = startDate.substr(0, poz);
			startDate = startDate.substr(poz+1);
		}
		poz = startDate.indexOf('/');
		if (poz >= 0)
		{
			start_month = startDate.substr(0, poz);
			startDate = startDate.substr(poz+1);
			start_year = startDate; 
		}
		
		poz = endDate.indexOf('/');
		if (poz >= 0)
		{
			end_day = endDate.substr(0, poz);
			endDate = endDate.substr(poz+1);
		}
		poz = endDate.indexOf('/');
		if (poz >= 0)
		{
			end_month = endDate.substr(0, poz);
			endDate = endDate.substr(poz+1);
			end_year = endDate; 
		}
		if (start_day > 0 && start_day < 32 && end_day > 0 && end_day < 32)
		{
			startDate = new Date(Date.UTC(start_year,start_month-1,start_day,0,0,0,0));
			endDate = new Date(Date.UTC(end_year,end_month-1,end_day,0,0,0,0));
			var diff = Math.round((endDate.getTime() - startDate.getTime()) / (1000*60*60*24));
			if (diff<=0) {       
				if  (inputObject.id=='start_date') {
					document.getElementById('end_date').value='';
				} else {
					document.getElementById('start_date').value='';
				}
				document.getElementById('count_nights').innerHTML = '';
			} else {
				document.getElementById('count_nights').innerHTML = diff;
			}
		}
	}
}

function getPeriodLength(startDate,endDate)
{
	if (startDate && endDate)
	{
		var start_day	= 0;
		var start_month	= 0;
		var start_year	= 0;

		var end_day		= 0;
		var end_month	= 0;
		var end_year	= 0;
				
		poz = startDate.indexOf('/');
		if (poz >= 0)
		{
			start_day = startDate.substr(0, poz);
			startDate = startDate.substr(poz+1);
		}
		poz = startDate.indexOf('/');
		if (poz >= 0)
		{
			start_month = startDate.substr(0, poz);
			startDate = startDate.substr(poz+1);
			start_year = startDate; 
		}
		
		poz = endDate.indexOf('/');
		if (poz >= 0)
		{
			end_day = endDate.substr(0, poz);
			endDate = endDate.substr(poz+1);
		}
		poz = endDate.indexOf('/');
		if (poz >= 0)
		{
			end_month = endDate.substr(0, poz);
			endDate = endDate.substr(poz+1);
			end_year = endDate; 
		}
		if (start_day > 0 && start_day < 32 && end_day > 0 && end_day < 32)
		{
			startDate = new Date(Date.UTC(start_year,start_month-1,start_day,0,0,0,0));
			endDate = new Date(Date.UTC(end_year,end_month-1,end_day,0,0,0,0));
			var diff = Math.round((endDate.getTime() - startDate.getTime()) / (1000*60*60*24));
			return diff;
		}
	}
	if ((startDate=='' || startDate=='ГГ' ||startDate=='YY') && (endDate=='' || endDate=='ГГ' || endDate=='YY')) {
		return 'e';
	}
	return 'f';
}

function arrSet(param) {
	selectBox('__'+param);
}

function arrUnset(param) {
	selectBox('__'+param);
}
function arrSetAll(param) {
	selectAll();	
}

function arrUnsetAll(param) {
	unSelectAll();	
}

