/* - - - - - - - - - - - - - - - - - - - - -

Title : Colliers Residential (Australia)
URL : http://www.colliersresidential.com

Author : SiteSuite Australasia
Author URL : http://www.sitesuite.com.au

Description : Custom Javascript Includes

- - - - - - - - - - - - - - - - - - - - - */

/* On Document Ready */
$(function() {
	
	// Load My Shortlist
	$.ajax({
				 cache: false,
				 url: '/bookmarks.cgi',
				 success: function(html){
					 $('#left #shortlistTarget').empty().append(html);
				 		}
	});
	
	// Add to My Favourites
	$(".updateMe").click(function(){
	var url = $(this).attr('href');
	$.blockUI('<h1 style="background:none;"><img src="/persistent/imgs/loader.gif" align="absmiddle" /> &nbsp;<strong>Updating My Favourites...</strong></h1>'); 
	$.ajax({
				 cache:false,
				 url:url,
				 success: function(html){
						$('#left #shortlistTarget').empty().append(html);
						$().ajaxStop($.unblockUI); 
						}
				});
	return false; 
	});
		
	// Delete My Favourites
	$.listen('click','.removeMe',function(){
	if (!confirm('Are you sure you want to delete this saved listing?')) return false;
	var url = $(this).attr('href');
	$.blockUI('<h1 style="background:none;"><img src="/persistent/imgs/loader.gif" align="absmiddle" /> &nbsp;<strong>Updating My Favourites...</strong></h1>'); 
	$.ajax({
				 cache:false,
				 url:url,
				 success: function(html){
						$('#left #shortlistTarget').empty().append(html);
						$().ajaxStop($.unblockUI); 
						}
				});
	return false; 
	});
	
	// Buttons Hovers
	$(".rollover").hover(
		function(){
			if($(this).attr("src").indexOf("-on") == -1) {
				var newSrc = $(this).attr("src").replace(".gif","-on.gif#hover");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("-on.gif#hover") != -1) {
				var oldSrc = $(this).attr("src").replace("-on.gif#hover",".gif");
				$(this).attr("src",oldSrc);
			}
		});

	/* Disabled Buttons Links */
	$("input.disabled").fadeTo('show',0.5).css('cursor','default');

	/* Semantic External Links */
	$("a[@rel$='external']").click(function(){
	 this.target = "_blank"});

	/* Print this Page */
	$("a[@rel$='print']").click(function(){
		window.print();
		return false; 
		});
	
	/* Change Country by Select Box */
	$("select#countrySelect").change(function(){
		var selectCountry = $("select#countrySelect").val();
		self.location.href = selectCountry;
		});
	
	/* Fix PNG images in IE6 */
	$("#logo img,#btnForSale,#btnForLease").pngfix();

});


/* Other Javascript */

function chgChoices(selTwo,choices){
	var looper;
	
	for (looper = selTwo.options.length; looper > 0; looper--){
		selTwo.options[1] = null;
		}
	
	for (looper = 0; looper < choices.length; looper++){
		selTwo.options[looper+1] = new Option(choices[looper],choices[looper]);
		}
}




