(function($){ 
	$(function(){
		// Advanced CSS
		if ($('p:has(cite)').length > 0){
			$('p:has(cite)').addClass('citation');	
		}
		$('#navigation li:first').addClass('first');
		$('#navigation li:last').addClass('last');
		$('input:radio').addClass('radio-button');
		$('input:checkbox').addClass('radio-button');
		$('input:radio').addClass('radio-button');
		var theurl = $('#referring_url').val();
		$('#referrring').val(theurl);
		// Cufon
		Cufon.replace('#navigation a');
		Cufon.replace('#home-news h3');
		Cufon.replace('#content h2');
		Cufon.replace('#content h3');
		Cufon.replace('#content-wide h2');
		Cufon.replace('#our-homes h3');
		Cufon.replace('#sidebar h4');
		// Slider
		if ($('h5.slide').length > 0){
			// hide those divs
			$('div.slide-sample').hide();//
			// slide effect
			$('h5.slide').click(function(){
				$(this).next().slideToggle('fast');
				if($(this).hasClass('hide')){
					$(this).removeClass('hide');
				} else {
					$(this).addClass('hide');
				}
				return false;
			});
		}
		
		// Hide empty PDF links
		if ($('.pdf').length > 0){
			$('.pdf:empty').remove();
		}
		
		$('.email').mailto();

		$('input:checkbox').addClass('checkbox');
	
		$('div.home-news-2').each(function(){
			$(this)
				.find('p:last')
				.addClass('last');
		});
		$('div.home-news-3').each(function(){
			$(this)
				.find('p:last')
				.addClass('last');
		});
		
		/* Add Anchors to Image Captions
		$('div.wp-caption').each(function(){
			var $href = $(this).find('a').attr('href');
			var $captionText = $(this).find('p.wp-caption-text').text();
			$captionHtml = '<a href="'+$href+'">'+$captionText+'</a>';
			$(this).find('p.wp-caption-text').html($captionHtml);
		});
		*/
			
		// Focus & Blur
		if ($('input.valueFx').length > 0) {
			$.getScript('/wp-content/themes/bluhomes/js/jquery.valueFx.js',function(){
				$('input.valueFx').valueFx();
			});
		}
		
		if ($('#video').length > 0) {
			$video = $('#video').attr('href');
			$($video).hide();
			$('#video').click(function(){
				$($video).show();
				$videoPlay = $(this);
				$($videoPlay).hide();
				$videoTitle = $(this).attr('title');
				if(window.console&&window.console.log) { 
					console.log($videoTitle);
				}
				$('p')
				return false;
			});
		}
		
		// Cycle Plugin for Image Rotation
		if ($('ul.gallery').length > 0){
			$('ul.gallery').cycle({ 
				fx:		'fade', 
				speed:	1000,
				random:	1,
				timeout:	5000
			});
		}
	});
})(jQuery);