(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);;video={clientID:0,videoID:0,listingID:0,init:function(){if(null!=jQuery('#hidClientID'))
this.setClientID(jQuery('#hidClientID').attr('value'));if(null!=jQuery('#hidVideoID'))
this.setVideoID(jQuery('#hidVideoID').attr('value'));if(undefined!=jQuery('#hidListingID').val())
this.setListingID(jQuery('#hidListingID').attr('value'));else
this.setListingID(0);},setClientID:function(clientID){this.clientID=clientID;},setListingID:function(listingID){this.listingID=listingID;},setVideoID:function(videoID){this.videoID=videoID;},setHasLinks:function(hasLinks){this.hasLinks=hasLinks;},getClientID:function(){return this.clientID;},getListingID:function(){return this.listingID;},getVideoID:function(){return this.videoID;},getHasLinks:function(){return this.hasLinks;},loadCollection:function(param){jQuery('#loadingCollection').show();jQuery('#videos_content').hide();jQuery.ajax({type:'GET',dataType:'text/html',url:'/video/ajaxViewCollection?ID='+this.clientID+'&listingID='+this.listingID+'&vID='+this.videoID+'&'+param,success:function(html){jQuery('#loadingCollection').hide();jQuery('#videos_content').html(html);jQuery('#videos_content').show();}});},refresh:function(videoID){jQuery('#loadingVideo').show();jQuery('#videoPlayer').hide();this.setVideoID(videoID);this.modifyClassNameOfElements();jQuery.ajax({type:'GET',dataType:'text/html',url:'/video/ajaxViewVideo?vID='+this.videoID+'&flag='+jQuery('#hidFlagForListingUrl').attr('value'),success:function(html){jQuery('#loadingVideo').hide();jQuery('#videoPlayer').html(html);jQuery('#videoPlayer').show();}});},modifyClassNameOfElements:function(){var oldSelectedObjects=jQuery('.media.fontReset.selected');if(0<oldSelectedObjects.length){for(var i=0;i<oldSelectedObjects.length;i++){if(i==0){var oldSelectedObject=oldSelectedObjects[i];jQuery('#'+oldSelectedObject.id).removeClass().addClass('media fontReset');}}}
this.setSelectedVideo();},setSelectedVideo:function(){jQuery('#'+this.videoID).removeClass().addClass('media fontReset selected');}};
