$(document).ready(function() {


//--validation-salesforce

 $("#devere-quote-request").validate();

	$("#content-inner a").each(function() {
		$("a[href$='pdf']").attr('target','_blank');
	});
	$("#content-inner a").each(function() {
		$("a[href$='mp3']").attr('target','_blank');
	});


	//--- Audio Player
	if($('a.audio').length>0) {
		//---- One Pixel Out Audio Player
		AudioPlayer.setup("/sites/all/libraries/player/audio-player/player.swf", {
			width: 290,
			initialvolume: 100,
			transparentpagebg: "yes",
			left: "000000",
			lefticon: "FFFFFF"
		});
		$('a.audio').each( function() {
			AudioPlayer.embed($(this).attr('id'), {
				soundFile: $(this).attr('href'),
				titles: $(this).attr('title'),
				//artists: "Artist name",
				autostart: "no"
			});
		});
	}

													 
	// ---  Energy House Interactivity

	$('.eh-link').bind('mouseenter', function() {
    $(this).children().removeClass("hide");
    $('#eh-mask').fadeIn(400);		
  });
	
  $('.eh-link').bind('mouseleave', function() {
    $(this).children().addClass("hide");
    $('#eh-mask').css("display","none");				
	});


	// ---  Locations Page Interactivity

	$('.location-pin').bind('mouseenter', function() {
    $(this).children().removeClass("hide");
  });
	
  $('.location-pin').bind('mouseleave', function() {
    $(this).children().addClass("hide");
	});

// ---  DeVere Contact Form - Conditional Functions


    $('#node-150 form').addClass("hide");
    $('.page-devere-contact #content-mid').addClass("hide");
	
	$('#general-requests').bind('click', function() {
		$('#node-150 form').removeClass("hide");
		$('.page-devere-contact #content-mid').addClass("hide");			
	});	

	$('#quote-requests').bind('click', function() {
		$('#node-150 form').addClass("hide");
		$('.page-devere-contact #content-mid').removeClass("hide");			
	});		


	// ---  Start Input Box Interactivity 
	
	$('#edit-search-block-form-1').val('SEARCH THIS SITE');

	$('#edit-search-block-form-1').each(function() {
			var default_value = this.value;
			$(this).focus(function() {
					if(this.value == default_value) {
							this.value = '';
					}
			});
			$(this).blur(function() {
					if(this.value == '') {
							this.value = default_value;
					}
			});
	});
	
	// ---  End Input Box Interactivity 



	// --- Lightbox Interactivity 
	//Detail image block
	//$('#block-views-property_images-block_1');
	//Thumbs block
	$('#block-views-property_images-block_2 img').each(function (i) {
		$(this).bind('mouseenter',function(e){
			detailimg = $(this).parent().parent().parent().parent().find('.views-field-field-images-fid-1 img').attr('src');
			$('#block-views-property_images-block_1 img').attr('src',detailimg);
		});
	});
	
	// --- Homepage Stars 	
	$('.map-button').each(
        function () {
            $(this).bind('mouseenter', function (e) {
                $('.amenity-lf').removeClass('amenity-lf');
                var idEl = this.id.split("-");
                $('.amenity-on').fadeOut("fast").removeClass('amenity-on');
                $('#amenities-'+idEl[1]).fadeIn("fast");
                $('#amenities-'+idEl[1]).addClass('amenity-on').addClass('amenity-hover');
            });
            $(this).bind('mouseleave', function () {
                $(this).addClass('amenity-lf');
                setTimeout(function () {
                    if ($('.amenity-lf').length == 1) {
                        $('.amenity-on').fadeOut("fast").removeClass('amenity-on');
                    }
                }, 1000);
            });
        }
    );


//--- Makes seperate lines of links function as one

	$('.view-id-video .views-row').bind('mouseenter mouseleave', function() {
		$(this).toggleClass('hover');
	});

// --- Gives class to video nav links via a rewrite

	$('.view-id-video.view-display-id-block_1 .view-content ul').addClass('menu');

});
