$(document).ready(function() {
	
    $('div#advancedFilters div.advChecks').hide();

	
    //check for valuable info content
    checkValuablePost();
	
    $('#sponsors-inner').cycle();
	
    $('div#advancedFilters a').click(function(e) {
	$('div#advancedFilters div.advChecks').slideToggle('slow');
	e.preventDefault();
    });
	

    $("a.colorbox").colorbox({
	transition : 'elastic'
    });

    $(".property-details-right a").colorbox({
        
	slideshow:true,
	slideshowStart:"start",
	slideshowStop:"stop",
	current:"{current} of {total}",
	slideshowAuto:true,
	slideshowSpeed:5000
    });

    $('#enquiry-form form').live('submit', function(ev){            
	// ev.preventDefault();
	$(this).ajaxSubmit({
	    target: '#colorBoxContainer',
	    beforeSubmit: function(){
	    },
	    success: function(response){
		$.colorbox.resize();
		$('#enquiry-form form').show();
	    }
	});
	return false;
    });

    $('#colorbox a').live('click', function(ev){
	ev.preventDefault();
	$.ajax({
	    url: '/enquiries/forget',
	    success: function(data) {
		$('#colorBoxContainer').html(data);
		$.colorbox.close();
	    }
	});

    });
	
    $('.enqAlert').live('click', function(e) {
	if(!confirm('Are you sure you want to enquire about this property?')){
	    e.preventDefault();
	    $.colorbox.close();
	}
    });
    
    
    // Privacy Policy link interception
    
    $('.policyPopup').live('click',function(){
	
	newwindow=window.open('http://'+window.location.hostname+'/privacy','name');
	if (window.focus) {
	    newwindow.focus()
	    }
	return false;
	
    });
    
    
    

});


function checkValuablePost(){
    //get the url
    var path = $(location).attr('href');
    //if were on the valuable information page and have submitted the form - hide the text
    if(path.indexOf('valuable-information') >= 0 && path.indexOf('#') >= 0){
	$('.contentText').hide();
    }
}

