/*
window.alert = function(msg){
	 $.modal(msg,{
	 	containerCss:{},
		opacity:60,
		overlayCss: {backgroundColor:"#222222"},
		onOpen: function (dialog) {
			dialog.overlay.slideDown('fast', function () {
				dialog.data.hide();
				dialog.container.fadeIn('fast', function () {
					dialog.data.fadeIn('fast');
				});
			});
		},
		onClose: function (dialog) {
			dialog.data.fadeOut('fast', function () {
				dialog.container.hide('fast', function () {
					dialog.overlay.slideUp('fast', function () {
						$.modal.close();
					});
				});
			});
		}


		});
	 }
	*/
	
$(document).ready (function () {

var montharr = Array();
montharr['jan'] = "January";
montharr['feb'] = "February";
montharr['mar'] = "March";
montharr['apr'] = "April";
montharr['jun'] = "June";
montharr['jul'] = "July";
montharr['aug'] = "August ";
montharr['sep'] = "September";
montharr['oct'] = "October";
montharr['nov'] = "November";
montharr['dec'] = "December";


if($("#website_url a").length){
	$("#website_url").hide();
}
if($(".commentauthor")){
	// rearrange date string
	$(".commentauthor").each(function(){
		// split date by hyphen
		var sectarr = $(".date",this).html().split("-");
		var yeararr = sectarr[2].split(" "); 
		if(sectarr.length > 0){
			$(".date",this).html("&mdash; "+montharr[sectarr[1].toLowerCase()] +" "+ yeararr[0]);
		}
	});
}
if($(".product-small").length != 0){
	$(".product-small").each(function(){
		$("a.modal",this).attr("href",$("div.detailsdata .largeimage img",this).attr("src"));
		$("a.modal",this).fancybox();
	});
}
function fancyRestore(){$("#booking-enquiry").append( fancyBackupData ) ;	}
function fancyDestroy(){ $("#booking-enquiry").empty() }	
function fancyBackup(){fancyBackupData = $("#booking-enquiry").html()}

	$("a.propthumb").each( function() { 
	   $(this).attr('href', $("#nav"+$(this).attr('id') +" a").attr("href"));
	});

	$(".smallimages a").each( function() { 
		if($(this).attr('href') == "" || $(this).attr('href').indexOf("{") > -1 ){
                     $("#"+$(this).attr("id")+" img").attr("src","/images/noimage-small.jpg");
                     $(this).removeAttr("href");
                     $(this).removeAttr("rel");
                     $(this).removeClass("imagezoom");
                     $(this).addClass("noimage");
                     $(this).onclick = function(){return false;}
                }
	});

	$(".price:contains('Enquire')").each( function() { $(this).html("<em>Enquire for pricing</em>");});
	$(".nightly:contains('Enquire')").each( function() { $(this).html("<em>Enquire for nightly</em>");});
	$(".weekly:contains('Enquire')").each( function() { $(this).html("<em>Enquire for weekly</em>");});
	//if( $(this).html().toLowerCase.indexOf("enquire") > -1){}
if($('.property-testimonial blockquote').html() == "&ldquo;&rdquo;" ){
    $('.property-testimonial').addClass('hide');
}
$("a.imagezoom").fancybox({'hideOnContentClick':true,'overlayOpacity':.2,'centerOnScroll':false,'padding':0});
	// Setup selected catalogue
	$(".property-nav a").each( function() { 
		if($(this).html() == act_cat || $(this).html() == $(".breadcrumbs a:last").html() ){
			 $(this).parent().addClass("active");  $(this).prepend("&laquo; ");}
	});
// comment modal
$("a.comment-form-btn").fancybox({'hideOnContentClick':false,'overlayOpacity':.2,'centerOnScroll':false,'padding':0,'imageScale':true,'frameHeight':600,'frameWidth':413,'callbackOnStart':fancyBackup, 'callbackOnShow':fancyDestroy,'callbackOnClose':fancyRestore });

// booking modal
$("a.booking-form").fancybox({'hideOnContentClick':false,'overlayOpacity':.2,'centerOnScroll':false,'padding':0,'imageScale':true,'frameHeight':840,'frameWidth':400,'callbackOnStart':fancyBackup, 'callbackOnShow':fancyDestroy,'callbackOnClose':fancyRestore });
// $(".breadcrumbs a:first").addClass("basecat");
// replace input text values
var default_values = {};
  $('#specials-subscribe input, #specials-subscribe textarea').each(function(i) {
    var index = jQuery(this).attr('name');
    var value = jQuery(this).val();
    default_values[index] = value;
  });

  $('input, textarea').focus(function() {
    if($(this).val() === default_values[$(this).attr('name')]) {
      $(this).val('');
    };
  });

  $('input, textarea').blur(function() {
    if($(this).val() === '') {
      $(this).val(default_values[$(this).attr('name')]);
	  
    };
	
  });

});

 Cufon.replace(['#primary-nav li a','.intro-text'], {textShadow: '1px 1px black',hover: true});  
Cufon.replace(['#home-primary-cell h2','.view-properties a'], {textShadow: '1px 1px #305971',fontFamily: 'achrbld',hover: true});  
Cufon.replace(['.backnav'], {textShadow: '1px 1px #000',fontFamily: 'achrbld',hover: true});  
Cufon.replace(['#specials-subscribe h3','#follow-us h3','#content-cell h2', '#content-cell h3', '.nav-column h3','.property-testimonial'], {textShadow: '1px 1px #000',fontFamily: 'archmed',hover: true});  
Cufon.replace(['.cover-testimonial','#featured-items-cell h3'], {hover: true,fontFamily: 'achrbld',textShadow:'#010101 0.15px 0px 0px' });
Cufon.replace(['.box h2','.system-message h1','.system-error-message h1'], {fontFamily: 'archmed',hover: true,textShadow: '1px 1px #201e1e'	});  	
			
