$(document).ready(function() {

	// ---  Start Input Box Interactivity   [not used]

	// ---  Start Input Box Interactivity   

	$('#edit-submitted-name').val('Name');
	$('#edit-submitted-name').focus(function () {
		if($(this).val() == 'Name') {
			$(this).val('').addClass('filled');
		}
	});
	$('#edit-submitted-name').blur(function () {
		if($(this).val() == '') {
			$(this).val('Name').removeClass('filled');
		}
	});
	

	$('#edit-submitted-e-mail-address').val('you@youremailaddress.com');	
	$('#edit-submitted-e-mail-address').focus(function () {
		if($(this).val() == 'you@youremailaddress.com') {
			$(this).val('').addClass('filled');
		}
	});
	$('#edit-submitted-e-mail-address').blur(function () {
		if($(this).val() == '') {
			$(this).val('you@youremailaddress.com').removeClass('filled');
		}
	});
	
	$('#edit-submitted-phone-1').val('Phone');	
		$('#edit-submitted-phone-1').focus(function () {
			if($(this).val() == 'Phone') {
				$(this).val('').addClass('filled');
			}
		});
		$('#edit-submitted-phone-1').blur(function () {
			if($(this).val() == '') {
				$(this).val('Phone').removeClass('filled');
			}
		});
	$('#edit-submitted-phone').val('Phone');	
		$('#edit-submitted-phone').focus(function () {
			if($(this).val() == 'Phone') {
				$(this).val('').addClass('filled');
			}
		});
		$('#edit-submitted-phone').blur(function () {
			if($(this).val() == '') {
				$(this).val('Phone').removeClass('filled');
			}
		});		
		
		
	$('#edit-submitted-questions-requests').val('Please enter your questions or request here');	
		$('#edit-submitted-questions-requests').focus(function () {
			if($(this).val() == 'Please enter your questions or request here') {
				$(this).val('').addClass('filled');
			}
		});
		$('#edit-submitted-questions-requests').blur(function () {
			if($(this).val() == '') {
				$(this).val('Please enter your questions or request here').removeClass('filled');
			}
		});

	//---Sample if statement
	if ($('#overweight-alert').length>0) {
		$('#checkout-form-bottom').addClass('hide');
	};


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

	$('.views-row').bind('mouseenter', function() {
		$(this).addClass('hover');
	}).bind('mouseleave', function() {
		$(this).removeClass('hover');
	});

	$('.block').bind('mouseenter', function() {
		$(this).addClass('hover');
	}).bind('mouseleave', function() {
		$(this).removeClass('hover');
	});


// --- Make links open in new window

	$("#jdock #block-menu-primary-links").each(function() {
		$("a[href^='http']").attr('target','_blank');
	});

//---- 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'));
		});
	});



//--- Cleanup admin UI

	//--- Lightbox Set, Testimonial, Rotated Image

		var hidden_sections=new Array();
		var i;
	
		hidden_sections[0] = ".page-node-add-lightbox-set";
		hidden_sections[1] = ".node-type-lightbox-set.section-node-edit";
		hidden_sections[2] = ".page-node-add-rotated-image";
		hidden_sections[3] = ".node-type-rotated-image.section-node-edit";				
	
		for (i = 0; i < hidden_sections.length; ++i) {
			$(hidden_sections[i]+" #edit-format-2-wrapper").parent().parent().addClass('hide');			
			$(hidden_sections[i]+" #edit-node-weight-wrapper").parent().parent().addClass('hide');						
			$(hidden_sections[i]+" fieldset").addClass('hide');									
			$(hidden_sections[i]+" .body-field-wrapper").addClass('hide');												
		}	





	//--- Testimonial

		var hidden_sections=new Array();
		var i;
	
		hidden_sections[0] = ".page-node-add-testimonial";
		hidden_sections[1] = ".node-type-testimonial.section-node-edit";		
	
		for (i = 0; i < hidden_sections.length; ++i) {
			$(hidden_sections[i]+" #edit-format-2-wrapper").parent().parent().addClass('hide');			
			$(hidden_sections[i]+" #edit-node-weight-wrapper").parent().parent().addClass('hide');						
			$(hidden_sections[i]+" fieldset").addClass('hide');									
		}	

});
