function sidlo( pref ) 
{
	window.open(pref + '_img/images/sidlo.jpg', '_blank', 'toolbar=0, menubar=0, location=0, directories=0, scrollbars=no, resizable=0, status=0, width=520, height=405,top=40, left=155');
}
function prepazka( pref ) 
{
	window.open(pref + '_img/images/prepazka.jpg', '_blank', 'toolbar=0, menubar=0, location=0, directories=0, scrollbars=no, resizable=0, status=0, width=520, height=405,top=40, left=155');
}
function indexOnLoad()
{
	changePrice();//'sheet');
	regishowexte('regiexte','regishowexte',false);
//	selectOneWay(false)
	oneWayDisable();
	otherReturnDisable();
	arrivalTimeDisable();
	departureTimeDisable();
//	regishowexte('otherReturnIndicator','otherReturnBox',false);
	regishowexte('regiext4','ext4',false);

}

//regishowexte('otherReturnIndicator','otherReturnBox')
function otherReturnChange()
{
	oldValue = document.getElementById('otherReturnIndicator').value;
	if ( oldValue == 'N' && document.getElementById('oneWayIndicator').value == "N" )
	{
		otherReturnEnable();
	}
	else
	{
		otherReturnDisable();
	}
}
function otherReturnEnable()
{
	document.getElementById('otherReturnSwitcher').checked = "checked";
	document.getElementById('otherReturnIndicator').value = "Y";
	document.getElementById('otherReturnBox').style.display='';
	document.getElementById('JOURNEY_TYPE').value = 'OJ';
}
function otherReturnDisable()
{
	document.getElementById('otherReturnSwitcher').checked = "";
	document.getElementById('otherReturnIndicator').value = "N";
	document.getElementById('otherReturnBox').style.display='none';
	if ( document.getElementById('oneWayIndicator').value == "Y" )
	{
		document.getElementById('JOURNEY_TYPE').value = 'OW';
	}
	else
	{
		document.getElementById('JOURNEY_TYPE').value = 'RT';
	}
}
function otherReturnHide()
{
	otherReturnDisable();
	document.getElementById("otherReturnLabel").style.color="#DDDDDD";
	document.getElementById("otherReturnSwitcher").disabled=true;
}
function otherReturnUnhide()
{
	otherReturnDisable();
	document.getElementById("otherReturnLabel").style.color='';
	document.getElementById("otherReturnSwitcher").disabled=false;
}
function arrivalTimeDisable()
{
	document.getElementById("arrivalTimeLabel").style.color='#DDDDDD';
	document.getElementById("arrivalTimeSwitcher").disabled=true;
	document.getElementById("arrivalTimeSwitcher").checked=false;
	document.getElementById("arrivalTimeIndicator").value='N';
	document.getElementById("arrivalTimeBox").style.display="none";
}
function arrivalTimeEnable()
{
	document.getElementById("arrivalTimeLabel").style.color='';
	document.getElementById("arrivalTimeSwitcher").disabled=false;
}
function departureTimeDisable()
{
	document.getElementById("departureTimeLabel").style.color='#DDDDDD';
	document.getElementById("departureTimeSwitcher").disabled=true;
	document.getElementById("departureTimeSwitcher").checked=false;
	document.getElementById("departureTimeIndicator").value='N';
	document.getElementById("departureTimeBox").style.display="none";
}
function departureTimeEnable()
{
	document.getElementById("departureTimeLabel").style.color='';
	document.getElementById("departureTimeSwitcher").disabled=false;
}

function oneWayChange()
{
	oldValue = document.getElementById('oneWayIndicator').value;
	if ( oldValue == 'N' )
	{
		oneWayEnable();
	}
	else
	{
		oneWayDisable();
	}
}

function oneWayEnable()
{
	otherReturnHide();
	arrivalTimeDisable();
		
		document.getElementById('regiextZ').value="N";
		document.getElementById('return').style.display='none';
	
	document.getElementById('oneWaySwitcher').checked = "checked";
	document.getElementById('oneWayIndicator').value = "Y";
	document.getElementById('JOURNEY_TYPE').value = 'OW';
	
}
function oneWayDisable()
{
	document.getElementById('oneWaySwitcher').checked = "";
	document.getElementById('oneWayIndicator').value = "N";
	document.getElementById('JOURNEY_TYPE').value = 'RT';
	otherReturnUnhide();
	arrivalTimeEnable();
		document.getElementById('regiextZ').value="Y";
		document.getElementById('return').style.display='inline';
}

function changePrice()
{
	var type = document.getElementById( 'PRICER_PREF' ).value;
//	document.getElementById( type ).checked = "checked";
	if ( type == 'AVB' )
	{
		arrivalTimeEnable();
		departureTimeEnable();
	}
	else
	{
		arrivalTimeDisable();
		departureTimeDisable();
	}
}

function regishowexte(xhc,xhd,change)
{
	if ( change == null )
	{
		change = true;
	}
	if ( document.getElementById('JOURNEY_TYPE').value == 'OW' && xhd=='otherReturnBox' )
	{
		return;
	}
	
	if (document.getElementById(xhc).value==(change?"N":"Y"))
	{
		if ( xhd=='otherReturnBox' )
		{
			document.getElementById('JOURNEY_TYPE').value == 'OJ';
		}
		document.getElementById(xhc).value="Y";
	}
	else
	{
		if ( xhd=='otherReturnBox' )
		{
			document.getElementById('JOURNEY_TYPE').value == 'OW';
		}
		document.getElementById(xhc).value="N";
	}
//document.getElementById('journey').checked=false;document.getElementById('extZ').style.display='inline';document.getElementById('extZZ').style.display='inline';document.getElementById('regiextZ').value='Y';	
	if (document.getElementById(xhc).value=="Y")
	{
		if ( xhd=='otherReturnBox' )
		{
//			document.getElementById('extZ').style.display='none';
//			document.getElementById('extZZ').style.display='none';
//			document.getElementById('regiextZ').value='N';	
		}
		else
		{
			
			//document.getElementById('JOURNEY_TYPE').value == ( document.getElementById('journey').checked ?=false;document.getElementById('extZ').style.display='inline';document.getElementById('extZZ').style.display='inline';document.getElementById('regiextZ').value='Y';	
//			'OJ';
		}

		document.getElementById(xhd).style.display='block';
	}
	else
	{
		if ( xhd=='otherReturnBox' )
		{
//			document.getElementById('extZ').style.display='inline';
//			document.getElementById('extZZ').style.display='inline';
			document.getElementById('regiextZ').value='Y';	
		}
		document.getElementById(xhd).style.display='none';
	}
}
function regishowexte2(xhc,xhd,jxhd)
{
	if (document.getElementById(xhc).value=="N")
	{
		document.getElementById(xhd).style.display='inline';
		document.getElementById(jxhd).style.display='inline';
		document.getElementById(xhc).value="Y";
	}
	else
	{
		document.getElementById(xhd).style.display='none';
		document.getElementById(jxhd).style.display='none';
		document.getElementById(xhc).value="N";
	}
}

function checkIndexForm()
{
	var vypis="";
  var kdyTam = document.getElementById('amkdytam').value;
  var kdySem = document.getElementById('amkdysem').value;
	
	if ( /^[0-3][0-9][./-][0-1][0-9][./-]20[0-1][0-9]$/.test( kdyTam ) )
	{
		var a = document.getElementById('amkdytam').value.split('.');
		document.getElementById('DAY_0').value       = Number( a[0] );
		document.getElementById('MONTH_0').value     = Number( a[1] );
		document.getElementById('YEAR_0').value      = Number( a[2] );
		document.getElementById('MONTH_SEL_0').value = a[1] + "/" + a[2];
	}
	else 
	{
		vypis += "Prosím vyplňte den odletu ve správném formátu.\n";
//		document.getElementById('amkdytam').focus(); 
	}
	if ( document.getElementById('JOURNEY_TYPE').value != 'OW' )
	{
		if ( /^[0-3][0-9][./-][0-1][0-9][./-]20[0-1][0-9]$/.test( kdySem ) )
		{
			var a2 = document.getElementById('amkdysem').value.split('.');
			document.getElementById('DAY_1').value       = Number( a2[0] );
			document.getElementById('MONTH_1').value     = Number( a2[1] );
			document.getElementById('YEAR_1').value      = Number( a2[2] );
			document.getElementById('MONTH_SEL_1').value = a2[1] + "/" + a2[2];
		}
		else 
		{
		  vypis += "Prosím vyplňte den příletu ve správném formátu.\n";
		}
	}
	if (vypis!="") 
	{
		alert( vypis );
		return false; 
	}
/*	document.getElementById('ARR_1').value = document.getElementById('DEP_0').value;

	document.getElementById('AIRLINES').value = '';
	if ( document.getElementById('sairlines').value != '' )
	{
		document.getElementById('AIRLINES').value += document.getElementById('sairlines').value;
	}
	if ( document.getElementById('oairlines').value != '' )
	{
		document.getElementById('AIRLINES').value += "," + document.getElementById('oairlines').value;
	}
	document.getElementById('next').value = 1;*/
	return true;
}

function checkFormLetenky(){
	// ekonomicka/obchodni trida
	if ($('#CABIN_PREF_CY').is(':checked')){
		$('#CABIN_PREF').val('CY');
	} else {
		$('#CABIN_PREF').val('Y');
	}

	// datum odletu
	var odlet = $('input[name="amkdytam"]').val().toString().split('.');
	$('input[name="DAY_0"]').val(odlet[0]);
	$('input[name="MONTH_SEL_0"]').val(odlet[1]+'/'+odlet[2]);

	// datum priletu
	var prilet = $('input[name="navrat"]').val().toString().split('.');
	$('input[name="DAY_1"]').val(prilet[0]);
	$('input[name="MONTH_SEL_1"]').val(prilet[1]+'/'+prilet[2]);

	return true;
}




