/* MAIN NAVIGATION */

$(document).ready(function(){
	
		// remove link background images since we're re-doing the hover interaction below 
		// (doing it this way retains the CSS default hover states for non-javascript-enabled browsers)
		// we also want to only remove the image on non-selected nav items, so this is a bit more complicated
		$(".nav").children("li").each(function() {
			var current = "nav current-" + ($(this).attr("class"));
			var parentClass = $(".nav").attr("class");
			if (parentClass != current) {
				$(this).children("a").css({backgroundImage:"none"});
			}
		});	


		// create events for each nav item
		attachNavEvents(".nav", "nav1");
		attachNavEvents(".nav", "nav2");
		attachNavEvents(".nav", "nav3");
		attachNavEvents(".nav", "nav4");
		attachNavEvents(".nav", "nav5");
		attachNavEvents(".nav", "nav6");
	

		function attachNavEvents(parent, myClass) {
			$(parent + " ." + myClass).mouseover(function() {
				$(this).append('<div class="nav-' + myClass + '"></div>');
				$("div.nav-" + myClass).css({display:"none"}).fadeIn(200);
			}).mouseout(function() {
				$("div.nav-" + myClass).fadeOut(200, function() {
					$(this).remove();
				});
			}).mousedown(function() {
				$("div.nav-" + myClass).attr("class", "nav-" + myClass + "-click");
			}).mouseup(function() {
				$("div.nav-" + myClass + "-click").attr("class", "nav-" + myClass);
			});
		}



	});

/* END MAIN NAVIGATION */

/* BANNER REPLACEMENT */

$(document).ready(function() {
	$('#banner img').addClass('hidden1');
	$('#banner').append(' <a href="/index.html"><img src="/system/galleries/webresources/hospital/images/logo_contrast.gif" alt="Home" id="homebutton" class="hidden2" /></a>');
	});
	
	
/*$(document).ready(function() {
$('.button').each(function() {
     $(this).attr('src', 'img_contrast_' + $(this).attr('src'));
});
});*/
	
/*$(document).ready(function() {
	$('.buttoncontrast').attr('src', 'contrast_');
	});*/
	
/*$(document).ready(function() {
	$('.button').remove('input[type="image"]');
	$('.button').append('input[type="submit"]');
	});*/
	
	
/*$("input[type='image']").each(function(){
  var name = $(this).attr('search_text'); // grab name of original
  var value = $(this).attr(''); // grab value of original
  // create new visible input
var html = '<input type="text" name="'search_text'" value="'+value+'" />';
  $(this).after(html).remove(); // add new, then remove original input
});*/
	



  
  	
  	
  	
 

/* START HIGH CONTRAST */


/* END HIGH CONTRAST */

/* START ICONS */

  
 $(document).ready(function() {
  	$('<span class="doc">(Word)</span>').insertAfter("a[href$='.doc']");
  	$('<span class="doc">(Word)</span>').insertAfter("a[href$='.dot']");
  	$('<span class="doc">(Word)</span>').insertAfter("a[href$='.dotx']");
  	$('<span class="doc">(Word)</span>').insertAfter("a[href$='.docx']");
  	$('<span class="pdf">(PDF)</span>').insertAfter("a[href$='.pdf']");
  	$('<span class="zip">(Zip)</span>').insertAfter("a[href$='.zip']");
  	$('<span class="xls">(XLS)</span>').insertAfter("a[href$='.xls']");
  	$('<span class="ppt">(PPT)</span>').insertAfter("a[href$='.ppt']");
  	});
  	
 //	$('(zip)').not('.nodoctype').insertAfter("a[href$='.zip']");

 
 // NEED TO FIGURE OUT HOW TO REMOVE THE FILETYPE

  /* POP UP STYLES */
  
  $(function() {
			$('a.pdf1').click(function() {
			var href = $(this).attr('href');
			ko = new Date();
			ji = ko.getTime();
			var winName = ji;
			window.open(href, ji, 'height=550,width=612,toolbar=yes,resizable=yes,scrollbars=yes,menubar=yes, statusbar=yes,location=yes');
			return false;
			});
		});
		
  $(function() {
			$('a.pop1').click(function() {
			var href = $(this).attr('href');
			ko = new Date();
			ji = ko.getTime();
			var winName = ji;
			window.open(href, ji, 'height=550,width=760,toolbar=yes,resizable=yes,scrollbars=yes,menubar=yes, statusbar=yes,location=yes');
			return false;
			});
		});
		
  $(function() {
			$('a.transcript').click(function() {
			var href = $(this).attr('href');
			ko = new Date();
			ji = ko.getTime();
			var winName = ji;
			window.open(href, ji, 'height=550,width=612,toolbar=yes,resizable=yes,scrollbars=yes,menubar=yes, statusbar=yes,location=yes');
			return false;
			});
		});
		
		
//ko = new Date();
//ji = ko.getTime();
//var winName = ji;

/* HIDE AND SHOW ON FOCUS ACCESSIBILITY NAV */

$(document).ready(function() {
			$('#navaccess a').addClass("idlenav");
       		$('#navaccess a').focus(function() {
       			$(this).removeClass("idlenav").addClass("focusnav");
    		    if (this.value == this.defaultValue){ 
    		    	this.value = '';
				}
				if(this.value != this.defaultValue){
	    			this.select();
	    		}
    		});
    		$('#navaccess a').blur(function() {
    			$(this).removeClass("focusnav").addClass("idlenav");
    		    if ($.trim(this.value) == ''){
			    	this.value = (this.defaultValue ? this.defaultValue : '');
				}
    		});
		});		
		
/* END HIDE AND SHOW ON FOCUS ACCESSIBILITY NAV */
		

/* START STRIPED TABLES - keep at end for now, or icons stop working, don't know why */
	
$(document).ready(function() {
	var rowClass = 'even';
	var rowIndex = 0;
	$('table.table2 tbody tr').each(function(index) {
		if ($('th', this).length) {
			rowClass = 'subhead';
			rowIndex = -1;
			} else if (rowIndex % 1 == 0) {
				rowClass = (rowClass == 'even' ? 'odd' : 'even');
			};
			$(this).addClass(rowClass);
			rowIndex++;
		});
	});

/* END STRIPY TABLES */

/* REMOVE THE P TAGS */


/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/


/*$('.button').each(function() {
     $(this).attr('src', 'img_contrast_' + $(this).attr('src'));
});*/





$(document).ready(function() {
	$('#tools ul li.icn_print a').click(function() {
		window.print();
		return false;
	});
});
