$(function() {
	//For this form: /ri-real-estate-information.php
	$('.other-entry').hide();
	$('ul#how-heard-list li').each(function() { 
		 var x =$(this);
		 $('.radio', x).click( function(){
			$('.other-entry').hide().removeClass('required');
			$('.other-entry',x).show().addClass('required');
		});

	});
	//Sifr
	$('div#content h1').sifr({ strSWF: '/flash/warnock-pro.swf', strColor: '#20407a', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div.push-item h3').sifr({ strSWF: '/flash/warnock-pro-italic.swf', strColor: '#54430f', strWmode: 'transparent' },{ expressInstall: true });
	$('div.home-push-offer h3').sifr({ strSWF: '/flash/warnock-pro-italic.swf', strColor: '#54430f', strWmode: 'transparent' },{ expressInstall: true });
	$('body.home h3#header-request-info').sifr({ strSWF: '/flash/warnock-pro-italic.swf', strColor: '#fefefe', strWmode: 'transparent' },{ expressInstall: true });
	$('h3#header-request-info').sifr({ strSWF: '/flash/warnock-pro-italic.swf', strColor: '#294a86', strWmode: 'transparent' },{ expressInstall: true });
	
	$('body.home h3#header-booking').sifr({ strSWF: '/flash/warnock-pro-italic.swf', strColor: '#fefefe', strWmode: 'transparent' },{ expressInstall: true });
	$('div#sidebar h3#header-booking').sifr({ strSWF: '/flash/warnock-pro-italic.swf', strColor: '#294a86', strWmode: 'transparent' },{ expressInstall: true });
	
	//Homepage push marketing rotation with jcycle
	
	var randomPush = Math.floor(Math.random()*10);
	$('div#right-push div.home-push-offers').cycle({ 
		fx:     'scrollHorz', 
		speed: 1500,
		timeout: 7500,
		startingSlide: 0,
		cleartypeNoBg: true,
		next:   '.home-push-next2'
		//prev:   '#prev-push' 
	});

	$("body.home div#masthead-wrapper").flash(
		{src:"flash/home-masthead.swf",
		 width:918,
		 height:419,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlPath = "/flash/xml/home-masthead.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});

	$("div#photo-gallery").flash(
		{src:"/flash/gallery.swf",
		 width:600,
		 height:420,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlPath = "/flash/xml/images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	
	$(".post").each(function() {
		var father = $(this);
		$("a.post-icon-more-btn", father).click(function() {
			$(".post-details a",father).click();     								  
			return false;
		});
	});
	$('#current_owner_y').click(function(){if(!$(this).is(':selected')){$('#current-owner').show().children().addClass('required');}});
	$('#current_owner_n').click(function(){$('#current-owner').hide().children().removeClass('required');});


	var openFnMap=function(hash){
		hash.w.show();
		$('#map-modal').css({left:($(window).width()-$('#map-modal').width())/2,top:$(window).scrollTop()+10});
	};
	var openFnRes=function(hash){
		hash.w.show();
		$('#res-modal').css({left:($(window).width()-$('#res-modal').width())/2,top:$(window).scrollTop()+10});
	};
	var openFnChart=function(hash){
		hash.w.show();
		var chartimg =  hash.t;
		var chartimghtml = $(chartimg).attr('href');
		$('div#chart-content').html( '<img src="'+chartimghtml+'" alt="" />');
		$('#chart-modal').css({left:($(window).width()-$('#chart-modal').width())/2,top:$(window).scrollTop()+10});
	};
	var hideFn=function(hash){
		hash.w.hide()
		hash.o.remove();
	};

	$('#map-modal').jqm({ajax:'../includes/map.php', trigger: 'a#map-link', onShow: openFnMap, onHide: hideFn, target:'div#map-content'});
	$('#res-modal').jqm({ajax:'../includes/interactive-map.php', trigger: 'li#secondary-residences-interactive-floorplans a', onShow: openFnRes, onHide: hideFn, target:'div#res-content' });

	$('#chart-modal').jqm({trigger: 'table.capacity-chart a', onShow: openFnChart, onHide: hideFn, target:'div#chart-content'});
	

	/* $('body.home div.push-item').click(function() { 		
		var pushLink = $(this).find('a').attr('href');
		window.location=pushLink;
	}); */

});