$(document).ready(function() { // @ zobrazovanie ajax loaderu $("#loading").bind("ajaxSend", function(){ $(this).show(); }).bind("ajaxComplete", function(){ $(this).hide(); }); // @ ajax call pri zmene hlavneho regionu $('#region_select').change(function() { var val = $(this).val(); var type = $("input[@name='typ']:checked").val(); loadSubregionsCombo(val,type); }); // @ zmena form action pri zmene searchtype // @ taktiez skrytie formularovych poli $('.search_type').change(function() { loadSubregionsCombo($('#region_select').val(),$(this).val()) hideFields($(this).val()); }); $('.changetoc').live('click',function() { xhr = $.ajax({ url: "http://www.nawar.sk/ajax/hotelinfo/", cache: false, type: "GET", data: ({ toc : $(this).data('toc'), gid : $(this).data('gid') }), success: function(html){ $('#altaBox').html(html).hide().fadeIn(); $('.hotel_info_wrapper').html(html); init_cycle('cycle2','nav2'); $(' ').appendTo('#altaBox'); } }); }); $('#frmlocalities-oid').change(function() { var oid = $(this).val(); insertParam('oid',oid); }); }); // @ zavola ajaxom controller, ktory natiahne podregiony function loadSubregionsCombo(val,type) { if(val=='') return false; xhr = $.ajax({ url: "http://www.nawar.sk/ajax/loadsubregions/", cache: false, type: "GET", global: false, data: ({ relation_id : val, typ : type }), dataType : 'script' }); } // @ lubovolny element zameni za loading obrazok function switchForLoading(ele) { $(ele+' a').replaceWith(' Prosím čakajte...'); } // @ skryva a odkryva polia pre jednotlive typy vyhladavania vo vyhladavaci function hideFields(type,speed) { switch(type) { case 'f': $('#frm-searchform').attr('action','http://www.nawar.sk/termin/'); $('#frmsearchform-out').val('detail'); $('.nohotelonly').fadeIn(); $('.nopauschal').fadeIn(); $('.noflight').fadeOut(); $('.noflight select').val(''); $('.noflight input').val(''); break; case 'p': $('#frm-searchform').attr('action','http://www.nawar.sk/destinacia/'); $('#frmsearchform-out').val('commonobject'); $('.nohotelonly').fadeIn(); $('.nopauschal').fadeOut(); $('.nopauschal select').val(''); $('.nopauschal input').val(''); $('.noflight').fadeIn(); break; case 'h': $('#frm-searchform').attr('action','http://www.nawar.sk/destinacia/'); $('#frmsearchform-out').val('commonobject'); $('.nohotelonly').fadeOut(); $('.nohotelonly select').val(''); $('.nohotelonly input').val(''); $('.nopauschal').fadeIn(); $('.noflight').fadeIn(); break; } } function insertParam(key, value) { key = escape(key); value = escape(value); var kvp = document.location.search.substr(1).split('&'); var i=kvp.length; var x; while(i--) { x = kvp[i].split('='); if (x[0]==key) { x[1] = value; kvp[i] = x.join('='); break; } } if(i<0) {kvp[kvp.length] = [key,value].join('=');} document.location.search = kvp.join('&'); }