function povratni(){document.getElementById("multidestination").style.display='none';document.getElementById("round").style.display='block';document.getElementById("oneway").style.display='block';}
function jedansmijer(){document.getElementById("multidestination").style.display='none';document.getElementById("oneway").style.display='none';document.getElementById("round").style.display='block';}
function multidestination(){document.getElementById("round").style.display='none';document.getElementById("oneway").style.display='none';document.getElementById("multidestination").style.display='block';}
function GetSelectedItem(){chosen="";len=document.aviokarte.TRIP_TYPE.length;for(i=0;i<len;i++){if(document.aviokarte.TRIP_TYPE[i].checked){chosen=document.aviokarte.TRIP_TYPE[i].value;if(chosen=="R"){povratni();}
if(chosen=="O"){jedansmijer();}
if(chosen=="M"){multidestination();}}}}
$(document).ready(function(){var dateforsearch=new Date();var departure_date=new Date(dateforsearch.getFullYear(),dateforsearch.getMonth(),dateforsearch.getDate()+1,00,01,00);var return_date=new Date(dateforsearch.getFullYear(),dateforsearch.getMonth(),dateforsearch.getDate()+8,00,01,00);$('input[name^="B_DATE_"]').val((departure_date.getDate()<10?'0':'')+departure_date.getDate()+"-"+(departure_date.getMonth()<9?'0':'')+(departure_date.getMonth()+1)+"-"+departure_date.getFullYear());$('input[name^="E_DATE_"]').val((return_date.getDate()<10?'0':'')+return_date.getDate()+"-"+(return_date.getMonth()<9?'0':'')+(return_date.getMonth()+1)+"-"+return_date.getFullYear());$('input[name="E_DATE_1"], #tcalico_1').live('mouseover',function(){var thisname=$('input[name^="B_DATE_1"]').val();A_TCALS[1].a_cfg.allowedate=thisname;});$('input[id^="pol"], input[id^="odr"]').blur(function(){if(window.spaceforme==undefined){var current_id=$(this).attr("id");var send_value=this.value;var send_leng=send_value.length;if(send_leng==3){var search_type="code";}else{var search_type="full_code";}
$.get("http://"+window.location.hostname+"/wp-content/themes/aviokarte/getcity.php",{data:send_value,sertype:search_type},function(data,suc){var city_obj=jQuery.parseJSON(data);if(city_obj[0]!==undefined){$("#"+current_id+"").val(city_obj[0].value);$("#"+current_id+"").next("input").val(city_obj[0].value2);}else{$("#"+current_id+"").next("input").val(send_value);}});}});$('input[id^="pol"], input[id^="odr"]').autocomplete({source:function(request,response){$.get("http://"+window.location.hostname+"/wp-content/themes/aviokarte/getcity.php",{data:request.term,sertype:"full_code"},function(data){response($.map(data,function(item){return{value:item.value,value2:item.value2}}))},"json");},minLength:3,dataType:"json",cache:false,focus:function(event,ui){return false;},open:function(event,ui){if(typeof(x)!="undefined"){delete spaceforme;}
return false},select:function(event,ui){this.value=ui.item.value;$(this).next("input").val(ui.item.value2)
window.spaceforme=ui.item.value2;return false;}});$('#rezervacijska-forma').submit(function(){if(document.aviokarte.TRIP_TYPE[0].checked||document.aviokarte.TRIP_TYPE[1].checked){pol_len=$("#pol").val();odr_len=$("#odr").val();if(pol_len.length<2){alert("Popunite polazište");return false;}
if(odr_len.length<2){alert("Popunite odredište");return false;}}});});
