(function($){$(function(){var loaderImage=new Image();loaderImage.src='/images/loading_small.gif';});$(function(){$('#programs_other_country').click(function(){var clientID=otherListingOptions.clientID;var countryID=otherListingOptions.countryID;var programID=otherListingOptions.programID;var listingID=otherListingOptions.listingID;var country=otherListingOptions.countryName;var programName=otherListingOptions.programName;$('#programs_other_country').hide();$('#programs_other').hide();$('#program_other_block').hide();if($.trim($('#programs').html())===""){$(this).showLoader('loader');$('#programs_other_country').managePrograms(clientID,countryID,programID,listingID,'program',country,programName);}else{$('#programs').slideToggle('slow');}
return false;});});$(function(){var clientID=$('#hidClientID').attr('value');$('.flagLinks').find('a').each(function(){var countryID=$(this).attr('id').slice(7);$(this).click(function(){if($(this).text().length>0){var country=$(this).text();}else{var country=$(this).next().find('a').text();}
$('#countryProgramsDiv').empty();$(this).showLoader('loader');$(this).managePrograms(clientID,countryID,10,0,'all',country,'All');return false;});});});$(function(){$(this).showOtherCity();});$.fn.managePrograms=function(clientID,countryID,programID,listingID,view,country,program){var label=(isAA<=0)?'programs':'accommodations';$.ajax({type:'POST',data:{id:clientID,countryID:countryID,programID:programID,listingID:listingID,view:view},url:'/listing/ajaxClientListings',success:function(html){$(this).hideLoader('loader');$('#countryProgramsDiv').empty();if('all'==view){if('- Multi-Country'==country){country='Multiple Countries';}
$('#countryProgramsDiv').append($('<h5></h5>').addClass("sectionHeader").append('All '+label+' for '+country)).append(html);}
if('program'==view){$('#programs').empty().append($('<h5></h5>').addClass("sectionHeader toLeft").appendHeader(country,program)).append(html).slideToggle('slow');$('#programs_close').click(function(){$('#programs').slideToggle('slow',function(){if($(this).is(':hidden')){$('#programs_other_country').show();$('#programs_other').show();$('#program_other_block').show();}});});}
$(this).showOtherCity();}});return $(this);}
$.fn.appendHeader=function(country,program){$(this).append(program+' Programs');if(country.length>0)
$(this).append(' for '+country);return $(this);}
$.fn.showLoader=function(divID){var label=(isAA<=0)?'Programs':'Accommodations';var $loader=$('#'+divID);var img=new Image();if($loader.is(':empty')){$loader.append($(img).addClass('setBlock toCenter').attr('src','/images/loading_small.gif').attr('width','20').attr('height','20')).append($('<p></p>').addClass('alignCenter').text('Loading '+label+' ...'));}
$loader.show();}
$.fn.hideLoader=function(divID){$('#'+divID).empty().hide();}
$.fn.showOtherCity=function(){$('.oListingCity').click(function(){var id=$(this).attr('id').split('_');if($('#oHiddenListingCity_'+id[1]).length){$(this).empty().text($('#oHiddenListingCity_'+id[1]).text()).css('cursor','');$('#oHiddenListingCity_'+id[1]).remove();}});$('.oListingCity').hover(function(){var id=$(this).attr('id').split('_');if($('#oHiddenListingCity_'+id[1]).length){$(this).css('cursor','pointer');}},function(){var id=$(this).attr('id').split('_');if($('#oHiddenListingCity_'+id[1]).length){$(this).css('cursor','');}});}})(jQuery);
