$(document).ready(function() {

	sll_height = sl_height = 0;
	sll_height = ($('.not-front #sidebar-left #block-menu_block-1 .content').height()*1.22);
	sl_height = ($('.not-front #main').height() - 10);
	
	if (sll_height > sl_height) {
		sl_height = (sll_height*1.22);
		$('.not-front #main').css('height', sl_height);
	}	


	$('.not-front #sidebar-left').css('height',sl_height);
	$('.not-front #sidebar-left-inner').css('height',sl_height);



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

	$('#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;
					}
			});
	});

	//---Sets active class on top level of Nice menu

	if ($('#nice-menu-1 ul li a.active').length>0) {
		$('#nice-menu-1 ul li a.active').parent().parent().parent().addClass('active-trail');
	};
	if ($('#nice-menu-1 ul ul li a.active').length>0) {
		$('#nice-menu-1 ul ul li a.active').parent().parent().parent().parent().parent().addClass('active-trail');
	};


	//--Cleans up unwanted options on menu

	$('#nice-menu-1 li a:contains("Mobile Calendar")').parent().addClass('hide hidden-by-funcs');
	$('#block-menu_block-1 li a:contains("Mobile Calendar")').parent().addClass('hide hidden-by-funcs');


//--- Add some classes

	$('.view-video-type-year .views-row a, #block-views-home_recent-block_2 .left a').append('<div class="video-play">');


	$(".nice-menu li:last-child").each(function() {
		$(this).addClass('last');
	});


//--- Correct the display of the supporting, sidebar-left H2s

	slh2_height = ($('.not-front #sidebar-left h2').height());
	if(slh2_height > 29) {
	$('.not-front #sidebar-left h2').css('letter-spacing',0);
	}


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


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





//--- Cleanup admin UI

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

		var hidden_sections=new Array();
		var i;
	
		hidden_sections[0] = ".page-node-add-photo-set";
		hidden_sections[1] = ".node-type-photo-set.section-node-edit";
		hidden_sections[2] = ".page-node-add-testimonial";
		hidden_sections[3] = ".node-type-testimonial.section-node-edit";		
		hidden_sections[4] = ".page-node-add-rotated-image";
		hidden_sections[5] = ".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');												
		}	
		
	//--- Video Clip

		var hidden_sections=new Array();
		var i;
	
		hidden_sections[0] = ".page-node-add-video-clip";
		hidden_sections[1] = ".node-type-video-clip.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');												
		}			
		
		
		
		

	//--- Show some things in the Admin UI
	
	$('.section-node-edit #edit-taxonomy-1-wrapper').parent().parent().removeClass('hide');
	$('.section-node-add #edit-taxonomy-1-wrapper').parent().parent().removeClass('hide');	


	//--- Make CIVI Registration Pages a little more presentable

	$('.page-civicrm-event-register .description:contains("First and last name will be shared with other visitors to the site.")')
		.html($('.page-civicrm-event-register .description:contains("First and last name will be shared with other visitors to the site.")')
	  .html().replace("First and last name will be shared with other visitors to the site.", "");





	$('.page-civicrm-event-register .description:contains("Your state/province and country of residence will be shared with others so folks can find others in their community.")').html($('.page-civicrm-event-register .description:contains("Your state/province and country of residence will be shared with others so folks can find others in their community.")')
	    .html().replace("Your state/province and country of residence will be shared with others so folks can find others in their community.", "");
	
	$('.page-civicrm-event-register input#CIVICRM_QFID_3_6').remove();
	$('.page-civicrm-event-register label:contains("Transgender")').remove();


});
