(function($){$.extend({progressBar:new function(){this.defaults={steps:20,stepDuration:20,max:100,showText:true,textFormat:'percentage',width:120,height:12,callback:null,boxImage:'images/progressbar.gif',barImage:{0:'images/progressbg_red.gif',30:'images/progressbg_orange.gif',70:'images/progressbg_green.gif'},running_value:0,value:0,image:null};this.construct=function(arg1,arg2){var argvalue=null;var argconfig=null;if(arg1!=null){if(!isNaN(arg1)){argvalue=arg1;if(arg2!=null){argconfig=arg2;}}else{argconfig=arg1;}}
return this.each(function(child){var pb=this;var config=this.config;if(argvalue!=null&&this.bar!=null&&this.config!=null){this.config.value=parseInt(argvalue)
if(argconfig!=null)
pb.config=$.extend(this.config,argconfig);config=pb.config;}else{var $this=$(this);var config=$.extend({},$.progressBar.defaults,argconfig);config.id=$this.attr('id')?$this.attr('id'):Math.ceil(Math.random()*100000);if(argvalue==null)
argvalue=$this.html().replace("%","")
config.value=parseInt(argvalue);config.running_value=0;config.image=getBarImage(config);var numeric=['steps','stepDuration','max','width','height','running_value','value'];for(var i=0;i<numeric.length;i++)
config[numeric[i]]=parseInt(config[numeric[i]]);$this.html("");var bar=document.createElement('img');var text=document.createElement('span');var $bar=$(bar);var $text=$(text);pb.bar=$bar;$bar.attr('id',config.id+"_pbImage");$text.attr('id',config.id+"_pbText");$text.html(getText(config));$bar.attr('title',getText(config));$bar.attr('alt',getText(config));$bar.attr('src',config.boxImage);$bar.attr('width',config.width);$bar.css("width",config.width+"px");$bar.css("height",config.height+"px");$bar.css("background-image","url("+config.image+")");$bar.css("background-position",((config.width*-1))+'px 50%');$bar.css("padding","0");$bar.css("margin","0");$this.append($bar);$this.append($text);}
function getPercentage(config){return config.running_value*100/config.max;}
function getBarImage(config){var image=config.barImage;if(typeof(config.barImage)=='object'){for(var i in config.barImage){if(config.running_value>=parseInt(i)){image=config.barImage[i];}else{break;}}}
return image;}
function getText(config){if(config.showText){if(config.textFormat=='percentage'){return" "+Math.round(config.running_value)+"%";}else if(config.textFormat=='fraction'){return" "+config.running_value+'/'+config.max;}}}
config.increment=Math.round((config.value-config.running_value)/config.steps);if(config.increment<0)
config.increment*=-1;if(config.increment<1)
config.increment=1;var t=setInterval(function(){var pixels=config.width/100;if(config.running_value>config.value){if(config.running_value-config.increment<config.value){config.running_value=config.value;}else{config.running_value-=config.increment;}}
else if(config.running_value<config.value){if(config.running_value+config.increment>config.value){config.running_value=config.value;}else{config.running_value+=config.increment;}}
if(config.running_value==config.value)
clearInterval(t);var $bar=$("#"+config.id+"_pbImage");var $text=$("#"+config.id+"_pbText");var image=getBarImage(config);if(image!=config.image){$bar.css("background-image","url("+image+")");config.image=image;}
$bar.css("background-position",(((config.width*-1))+(getPercentage(config)*pixels))+'px 50%');$bar.attr('title',getText(config));$text.html(getText(config));if(config.callback!=null&&typeof(config.callback)=='function')
config.callback(config);pb.config=config;},config.stepDuration);});};}});$.fn.extend({progressBar:$.progressBar.construct});})(jQuery);

var $j = jQuery.noConflict();
$j(document).ready(function() {
var ratingbookpercent = $j('#pbbook').html();
var rating1percent = $j('#rating1').html();
var rating2percent = $j('#rating2').html();
var rating3percent = $j('#rating3').html();
var rating4percent = $j('#rating4').html();
var rating5percent = $j('#rating5').html();
var ratingavgpercent = $j('#ratingavg').html();
$j("#pb0").progressBar(ratingbookpercent,{barImage: 'images/progressbg_purple.png'});
$j("#pb1").progressBar(rating1percent,{barImage: 'images/progressbg_purple.png'});
$j("#pb2").progressBar(rating2percent,{barImage: 'images/progressbg_purple.png'});
$j("#pb3").progressBar(rating3percent,{barImage: 'images/progressbg_purple.png'});
$j("#pb4").progressBar(rating4percent,{barImage: 'images/progressbg_purple.png'});
$j("#pb5").progressBar(rating5percent,{barImage: 'images/progressbg_purple.png'});
$j("#pbavg").progressBar(ratingavgpercent,{barImage: 'images/progressbg_purple.png'});

$j('.fullreview').hide();
$j('#discounts').hide();
$j(".introreview").hover(function() {
$j('.introreview').css({'background-color' : '#ffffff', 'opacity' : '0.7'});
$j(this).css({'background-color' : '#f4f5c0', 'opacity' : '1.0'});
return false;
});
$j(".introreview").click(function() {
$j('.fullreview').hide();
$j(".introreview").css({'opacity' : '0.7'});
$j(this).css({'background-color' : '#ffffff', 'opacity' : '0.9'});
var review = $j(this).attr("id").replace('intro','');
$j("#fulltext" + review).fadeIn();
return false;
});
$j('#fulltext1').show();
$j("a#property_back[title]").tooltip({tip: '#tooltiptwo', effect: 'slide', direction: 'left', bounce: 'true'});
$j("#ratingsheading[title]").tooltip({tip: '#tooltiptwo', effect: 'slide', direction: 'left', bounce: 'true'});
$j("#print_info_sheeta3[title]").tooltip({tip: '#tooltiptwo', effect: 'slide', direction: 'left', bounce: 'true'});
$j("#print_info_sheeta4[title]").tooltip({tip: '#tooltiptwo', effect: 'slide', direction: 'left', bounce: 'true'});
$j("#askowner[title]").tooltip({tip: '#tooltip', effect: 'bouncy', position: 'center left'});
$j("#property_main").tabs();
$j("ul#property_menu li#menu_overview a").addClass("active");
$j("ul#property_menu li a").click(function() {
$j("ul#property_menu li a").removeClass("active");
$j("a#property_availability").removeClass("active");
$j(this).addClass("active");

$j($j(this).find("a").attr("href")).fadeIn();

return false;
});
Shadowbox.init({
overlayOpacity: 0
});

var $tabs = $j('#property_main').tabs(); // first tab selected
//var selected = $tabs.tabs('option', 'selected');
$j('#property_availability, li#menu_prices a, a#property_booknow, a#property_enquire, a#enquirenow, #property_availability_base, a#quick_availability, #prices_reservations, a#reservebox, #priceboxheading').click(function() { // bind click event to link
    $tabs.tabs('select', 5); // switch to availability / booking tab
    //alert(selected);
    $j("#features").hide();
    $j('#discounts').show();
    $j("ul#property_menu li a").removeClass("active");
    $j("a#property_availability").addClass("active");
    return false;
});
$j('#ratingsheading').click(function() { // bind click event to link
    $tabs.tabs('select', 4); // switch to availability / booking tab
    //alert(selected);
    $j('#discounts').hide();
    $j("#features").hide();
    $j("ul#property_menu li a").removeClass("active");
    $j("#menu_reviews li a").addClass("active");
    return false;
});
$j('a#askowner, a#askowner_profile, #menu_enquiry a').click(function() { // bind click event to link
    $tabs.tabs('select', 6); // switch to enquiry form
    //alert(selected);
    $j("#features").hide();
    $j('#discounts').show();
    //$j("ul#property_menu li a").removeClass("active");
    //$j("a#property_availability").addClass("active");
    return false;
});
$j('li#menu_overview a, li#menu_local a, #menu_awards a, #menu_reviews a, #menu_owner a').click(function() {
    $j('#discounts').hide();
    $j("#features").show();
    return false;
});
$j('#menu_reviews a').click(function() {
    $j('#discounts').hide();
    $j("#features").hide();
    return false;
});
if(document.location.hash!='') {
var indexToLoad = (document.location.hash).replace("#","");
if(indexToLoad=="availability") {
$tabs.tabs('select',5);
location.href="#property_main";
$j("#features").hide();
$j('#discounts').show();
} else if(indexToLoad=="offers") {
$tabs.tabs('select',3);
location.href="#property_main";
} else {
$j('#discounts').hide();
$j("#features").show();
}
}
$j('a#property_availability, #property_availability_base, a#property_booknow, a#property_enquire, a#enquirenow, ul#property_menu li a, a#quick_availability, #prices_reservations, a#reservebox, #priceboxheading, a#askowner, a#askowner_profile').click(function() {
   location.href="#property_main";
});
$j('#print_page').click(function () {
//window.print();
});
});