jQuery.noConflict();


////////////////////////////////////////////////////////////////////////////////
//All document on ready functionality should be placed here
jQuery(document).ready(function(){
   //IE6 hover bug fix
   //allow function to only add mouse events if browser is IE
   if (document.all&&document.getElementById) {
	   //get navigation menu parent
	   navRoot = document.getElementById("sub_nav");
	   //get all list items
	   if (navRoot != null) {
		   liList = navRoot.getElementsByTagName("li");
		   //add onmounseover and onmouseout events to each <li>
		   //that change the class of the element top .over
		   for (i = 0; i < liList.length; i++) {
			   node = liList[i];
			   if (node.nodeName == "LI") {
				   node.onmouseover = function(){
					   this.className += " over";
				   }
				   node.onmouseout = function(){
					   this.className = this.className.replace(" over", "");
				   }
			   }
		   }
	   }

	   navRoot = document.getElementById("navigation");
	   if (navRoot != null) {
		   liList = navRoot.getElementsByTagName("li");
		   for (i = 0; i < liList.length; i++) {
			   node = liList[i];
			   if (node.nodeName == "LI") {
				   node.onmouseover = function(){
					   this.className += " over";
				   }
				   node.onmouseout = function(){
					   this.className = this.className.replace(" over", "");
	   }}}}
   }

   //Set up product tabs
   jQuery('#product_info_headings tr td').click(changeTab);

   jQuery('a#write-review-link').click(changeTab);
   jQuery('a#reviews-link-closed').click(changeTab);

});  //End of jQuery(document).ready

/////////////////////////////////////////////////////////////////////////////////////////////
//collapse all expandable areas in secondary nav
jQuery('div#sub_nav ul ul').hide();

//add img link and image for expanding
jQuery('div#sub_nav ul li.has_children > a').after("<img src='/images/plus.gif' alt='plus.gif' />");

//add functionality to expand and collapse hidden sub nav ul
jQuery('div#sub_nav ul li.has_children img').toggle(function(){
	 jQuery(this).parent().children( 'ul' ).show('slow');
	 jQuery(this).attr({
	   src: "/images/minus.gif",
	   alt: "minus.gif"
	 });

},function(){
	 jQuery(this).parent().children( 'ul' ).hide('slow');
	 jQuery(this).attr({
	   src: "/images/plus.gif",
	   alt: "plus.gif"
	 });
});

//show current subnav ul
jQuery('div#sub_nav ul li.current img').click();

function changeTab(){
   var content_id;
   var tab_id = jQuery(this).attr('id');
   if(tab_id == 'write-review-link' || tab_id == 'reviews-link-closed'){
	  content_id = '#product_review_content';
   } else {
	  content_id = '#'+tab_id.substring(0, tab_id.length - 4) + '_content';
   }

   jQuery('table#product_info_headings td').removeClass('active_tab');
   jQuery('table#product_info_headings td').addClass('inactive_tab');
   jQuery(this).removeClass('inactive_tab');
   jQuery(this).addClass('active_tab');

   jQuery('#product_info_box div').removeClass('active_tab');
   jQuery('#product_info_box div').addClass('inactive_tab');
   jQuery('#product_info_box '+content_id).removeClass('inactive_tab');
   jQuery('#product_info_box '+content_id+' div').removeClass('inactive_tab');
   jQuery('#product_info_box '+content_id).addClass('active_tab');

   if(tab_id == 'write-review-link' || tab_id == 'reviews-link-closed'){
	  if(tab_id == 'reviews-link-closed'){
		 jQuery('#write-review-container').hide();
	  }
	  jQuery('#product_info_box').focus();
   }
}

