$(document).ready(function() {

	// ---  Start Input Box Interactivity   [ NOT USED IN WOODMAN ]

/* Hides the ubercart redundant profile tab from the user edit page (IE6/7/8 VERSION) */
$('.section-user.arg2-edit .tabs.secondary li:last-child').hide();

	$('#edit-submitted-name').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;
					}
			});
	});
	$('#edit-submitted-e-mail-address').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;
					}
			});
	});
	$('#edit-submitted-phone').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);
		});
	});



	//--- Fixes display issue with IE

	$.fn.delay = function(time, callback){
			// Empty function:
			jQuery.fx.step.delay = function(){};
			// Return meaningless animation, (will be added to queue)
			return this.animate({delay:1}, time, callback);
	}

	$('a').delay(100, function(){
		$("#l-content-border").height("100%");
		$("#r-content-border").height("100%");
	});


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

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


//---- This block makes the tabs behave properly
	
	$("#nice-menu-1 li a.active").parent().css('background-position', "right -28px");   // -- Sets the top-level LI back to where it should be
	$("#nice-menu-1 li a.active").css('background-position', "left -28px");  // -- Sets the top-level A back to where it should be	

	$('#block-nice_menus-1 .nice-menu li a').bind('mouseenter', function () {
        $(this).css('background-position', "left -28px").parent().css('background-position', "right -28px");
    }).bind('mouseleave', function () {
        $(this).css('background-position', "left 1px").parent().css('background-position', "right 1px");
				$("li a.active").parent().css('background-position', "right -28px");  // -- Sets the top-level LI back to where it should be
				$("li a.active").css('background-position', "left -28px");  // -- Sets the top-level A back to where it should be
	});
	







//---- Lightbox Multi-View   [ -- Dont' forget the CSS and to enable the Lightbox 2 Module!!! -- ]
	// These blocks set up a mouseenter event system that replaces the visible detail image with a detail image matching the moused-over thumbnail
	// Visible Thumbnails are in  .views-field-field-images-fid-1
	// Hidden Details are in      .views-field-field-images-fid
	// Visible Detail image is    .views-field-field-images-fid-2

	var view_class = '.view-id-lightbox_multi_view';
	var visible_thumbs = '.views-field-field-images-fid-1';
	var hidden_details = '.views-field-field-images-fid';
	var visible_detail = '.views-field-field-images-fid-2';

	//Give field-images matching item numbers
	$(view_class+' .views-row').each(function() {
		var itemid = 0;
		var sibling = $(this).find(hidden_details+' .field-item:first-child');
		$(this).find(visible_thumbs+' .field-item').each(function() {
			$(this).attr('itemid',itemid);
			sibling.attr('itemid',itemid).addClass('item-'+itemid);
			sibling = sibling.next();
			itemid++;
		});
	});
	//Add mouseenter events to each of the thumbnail images
	$(view_class+' '+visible_thumbs+' img').each(function (i) {
		$(this).bind('mouseenter',function(e){
			viewsrow = $(this).parent().parent().parent().parent().parent();
			var itemid = $(this).parent().parent().attr('itemid');
			var linkobj = $(this).parent();

			previewimg = viewsrow.find(hidden_details+' .item-'+itemid+' img').attr('src');
			viewsrow.find(visible_detail+' img').attr('src',previewimg);
			viewsrow.find(visible_detail+' a').attr('href',linkobj.attr('href'));
		});
	});




});
