/*!
 * Copyright 2011 Pebble Design Pty Ltd. All Rights Reserved.
 * Custom JavaScript ///////////////////////////////////////
 * ////////////////// Author: Reiss Watts, Gary Swanepoel
 */

$.noConflict();
jQuery(document).ready(function($) {

/* -- START ----------------------------------*/

    /* Homepage Hover */
    $('#main .beachbreaks').hover(
        function(){$('#main .beachbreaks').stop().animate({opacity:'1', top:'0'}, 150);},
        function(){$('#main .beachbreaks').stop().animate({opacity:'0.75', top:'-21'}, 300);}
    );

    $('#main .citybreaks').hover(
        function(){$('#main .citybreaks').stop().animate({opacity:'1', top:'0'}, 150);},
        function(){$('#main .citybreaks').stop().animate({opacity:'0.75', top:'-21'}, 300);}
    );

    $('#main .budgetbreaks').hover(
        function(){$('#main .budgetbreaks').stop().animate({opacity:'1', top:'0'}, 150);},
        function(){$('#main .budgetbreaks').stop().animate({opacity:'0.75', top:'-21'}, 300);}
    );

    /* Image Hover */
    $('a.hover').hover(function(){
	$('img',$(this)).stop().animate({opacity:'0.75'}, 150) 
	},function(){
		{ $('img',$(this)).stop().animate({opacity:'1'}, 150) }
	});

    /* 257 Product Hover */
    $('div.catProdAttributeItem').hover(
		function(){$('img',$(this)).stop().animate({opacity:'1'}, 150) },
		function(){$('img',$(this)).stop().animate({opacity:'0.25'}, 300) }
    );

    /* Info Pop-Up */
	$('a.poplight[href^=#]').click(function() {
		var poplightID = $(this).attr('rel');
		var poplightURL = $(this).attr('href');
		var poplightquery = poplightURL.split('?');
		var poplightdim = poplightquery[1].split('&');
		var poplightWidth = poplightdim[0].split('=')[1];
	
		$('#' + poplightID).fadeIn().css({ 'width': Number( poplightWidth ) }).prepend('<a href="#" class="close"><img src="/images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');
	
		var poplightMargTop = ($('#' + poplightID).height() + 80) / 2;
		var poplightMargLeft = ($('#' + poplightID).width() + 80) / 2;
	
		$('#' + poplightID).css({
			'margin-top' : -poplightMargTop,
			'margin-left' : -poplightMargLeft
		});
	
		$('body').append('<div id="fade"></div>');
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
	
		return false;
	});

	$('a.close, #fade').live('click', function() {
		$('#fade , .popup_block').fadeOut(function() {
			$('#fade, a.close').remove();
		});
		return false;
	});

	/* Replace BC Images */
	function replaceStrings() {
		var facilities = document.getElementById('testimonial');
		facilities.innerHTML = facilities.innerHTML.replace(/CatalystImages/g, 'images');
		facilities.innerHTML = facilities.innerHTML.replace(/"12"/g, '"14"');
		facilities.innerHTML = facilities.innerHTML.replace(/"61"/g, '"75"');
	}
	
	/* Property Bullet Points */
	$(".column ul").each(function () {
		var htmlStr = $(this).text();
		htmlStr = htmlStr.replace(/\*/gi,"</li><li>");
		$(this).html(htmlStr);
		//return htmlStr;
	});

/*-- END -------------------------------------*/
	
});
