$(document).ready(function() {

	$('#block-tvmenu-0 .content > ul').prepend('<li class="added_by_funcs"><a href="/option/alumni">Alumni</a></li>');

	$('#block-tvmenu-0 .content > ul').prepend('<li class="added_by_funcs"><a target="_blank" href="http://forms.iupstore.com/textres.htm" class="confirm">Textbook Reservations</a></li>');


	$('a#dhtml_menu-t1944').parent().addClass('hide hidden_by_funcs');



	// --- Changes title of this fieldset on the checkout page

	$('#extra_information-pane legend a').html('Student Information');


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


	$('.form-submit').each(function() {
		var valcheck = $(this).attr('value');
		if(valcheck == 'Out of stock') {
			$(this).addClass('out-of-stock');
		}
	});


	//---Sample if statement
	if ($('.view-projects-menu').length>0) {
	$('.view-projects-menu .proj-menu-container.last').html($('.view-projects-menu .proj-menu-container.last').html().replace('military-aerospace','<a href="/portfolio/military-aerospace">military-aerospace</a>'));
				};


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


//--- Primary menu interactivity

	$('#block-tvmenu-0 .expanded>a, #block-tvmenu-0 .collapsed>a').each(function() {
		$(this).after('<a class="direct" title="Show All" href="'+$(this).attr('href')+'">&nbsp;</a>');
	});


//--- Remove Delete Button from Taxonomy Term Edit Screen
	
//	$('#taxonomy-form-term #edit-delete').css('display','none');
//	$('.user-admin #taxonomy-form-term #edit-delete').css('display','inline-block');

//---search
		$('#solr-search-text').val('Use a keyword, title, author or ISBN');
	$('#solr-search-text').focus(function () {
		if($(this).val() == 'Use a keyword, title, author or ISBN') {
			$(this).val('').addClass('filled');
		}
	});
	$('#solr-search-text').blur(function () {
		if($(this).val() == '') {
			$(this).val('Use a keyword, title, author or ISBN').removeClass('filled');
		}
	});




	$('a#dhtml_menu-1107').addClass('confirm');
	$('a#dhtml_menu-1108').addClass('confirm');
	$('a#dhtml_menu-1109').addClass('confirm');



//---java-confirm
	$('a.confirm').click(function() {
		return confirm("WEBSITE DISCLAIMER\n\nTextbook information is as up-to-date as possible based on information provided to The Co-op Store by the IUP faculty and the publishers. The book list is subject to change at any time and at the discretion of the faculty.\n\n We strive to provide the most accurate pricing information available; however, all prices are subject to change by the publishers at any time. The Co-op Store's prices are based on the publishers' prices and are updated as stock arrives.\n\nTextbook orders to be shipped will be filled and shipped within 2 business days of all books on the order being in stock. This applies to all Ground, 2nd Day and Next Day shipments. Returns by mail are only accepted with prior approval. Call 724-357-3067 to request return approval.\n\nThe Co-op Store reserves the right to substitute new books for used, or used books for new, depending on availability; the price will be adjusted accordingly. We cannot guarantee that every book is in stock, or that new and used copies are available for each title listed.\n\nPlease note that, because textbook information can change at any time (due to faculty changes, publisher substitutions, cancelled classes, etc.), we are not responsible for information used from this site, or information obtained from any Co-op Store employee, for purchase of textbooks from other sources. Students purchasing materials from The Co-op Store are protected under our returns policies.")});



//---Add a print button to the Orders Page

	$('tr.ucOrderClick-processed').each(function() {
		var oid= $(this).attr('id');
		var oidsubstr = oid.split('-')		
		$(this).children(":first").append('<a href="/admin/store/orders/' + oidsubstr[1] + '/invoice/print">Print</a>');
	});
	






});
