/* -------------------------------------------------- *
 * ToggleVal Plugin for jQuery                        *
 * Version 1.0                                        *
 * -------------------------------------------------- *
 * Author:   Aaron Kuzemchak                          *
 * URL:      http://kuzemchak.net/                    *
 * E-mail:   afkuzemchak@gmail.com                    *
 * Date:     8/18/2007                                *
 * -------------------------------------------------- */
jQuery.fn.toggleVal = function(focusClass) {
	this.each(function() {
		$(this).focus(function() {
			// clear value if current value is the default
			if($(this).val() == this.defaultValue) { $(this).val(""); }
			// if focusClass is set, add the class
			if(focusClass) { $(this).addClass(focusClass); }
		}).blur(function() {
			// restore to the default value if current value is empty
			if($(this).val() == "") { $(this).val(this.defaultValue); }
			// if focusClass is set, remove class
			if(focusClass) { $(this).removeClass(focusClass); }
		});
	});
}
/*
==============================================================
jQuery Perciformes (Sons of Suckerfish)
http://www.matthewjrichards.co.uk/files/jquery-perciformes-demo.html
==============================================================
*/
jQuery.fn.sfHover = function() {
  jQuery(this).hover(
    function() { jQuery(this).addClass("sfHover"); },
    function() { jQuery(this).removeClass("sfHover"); }
  )
  return this
}
/*
==============================================================
File: jquery.mf.js
Created by: Osman Gormus <osman@project6.com>
Created: 1/10/2008 5:28:34 PM
==============================================================
*/
$(document).ready(function() {
    // Append a new class when search box gets focus
    $(".searchTxt").toggleVal("active");

    // Homepage heros
    $('.hero-home ol').css({overflow: 'hidden', height: '266px'}).innerfade({ animationtype: 'fade',speed: 'slow',timeout: 4000,type: 'random_start',containerheight: '266px' });

    //Navigation menu state selection
    var path = location.pathname.substring(1);

    // Use parent path for all 4th tier pages
    var pathparts = new Array();
        pathparts = path.split('/');

    if (path) {
      $('#topNav a[@href$="' + path + '"]').parents('li').addClass('at');

      $('#mainNav a[@href$="' + path + '"] img').addClass('at');
      // Add class="at" to main nav image when you are at one of the sub pages
      $('#mainNav a[@href$="' + pathparts[0] + '.aspx"] img').addClass('at');

      // Left navigation class overrides
      $('#leftNav a[@href$="' + path + '"]').parents('li').addClass('at');
      // Fix top border when it's at "at" state
      $('#leftNav li:first a[@href$="' + path + '"]').parent('li').css({borderTop:0,paddingTop:'1px'});

      //$("body").addClass(path);
    }



    // Rollover effect for mainNav and topNav
    //$('#mainNav img.at, #topNav img.at')
    $('#topNav img.at').each(function(){
    		if($(this).attr("src").indexOf("_down") == -1) {
    			var newAtSrc = $(this).attr("src").replace("_regular.ashx","_down.ashx#hover");
    			$(this).attr("src",newAtSrc);
    		}
    });
    //$('#mainNav img, #topNav img')
    $('#topNav img').not('.at').hover(function(){
    		if($(this).attr("src").indexOf("_over") == -1) {
    			var newSrc = $(this).attr("src").replace("_regular.ashx","_over.ashx#hover");
    			$(this).attr("src",newSrc);
    		}
      },function(){
    		if($(this).attr("src").indexOf("_over.ashx#hover") != -1) {
    			var oldSrc = $(this).attr("src").replace("_over.ashx#hover","_regular.ashx");
    			$(this).attr("src",oldSrc);
    		}
    });


    // Rollover effect for mainNav and topNav
    //$('#mainNav img.at, #topNav img.at')
    $('#mainNav img.at').each(function(){
    		if($(this).attr("src").indexOf("_down") == -1) {
    			var newAtSrc = $(this).attr("src").replace(".ashx","_down.ashx#hover");
    			$(this).attr("src",newAtSrc);
    		}
    });
    //$('#mainNav img, #topNav img')
//     $('#mainNav img').not('.at').hover(function(){
//     		if($(this).attr("src").indexOf("_over") == -1) {
//     			var newSrc = $(this).attr("src").replace(".ashx","_over.ashx#hover");
//     			$(this).attr("src",newSrc);
//     		}
//       },function(){
//     		if($(this).attr("src").indexOf("_over.ashx#hover") != -1) {
//     			var oldSrc = $(this).attr("src").replace("_over.ashx#hover",".ashx");
//     			$(this).attr("src",oldSrc);
//     		}
//     });







    // Custom list bullets
    //$("ul").addClass("custom");
    $("ul.custom > li").prepend("&raquo; ");

    $(".recommended-products ol li").hover(function(){
      $(this).siblings().find("img").addClass("opaqueImage");
    },function(){
      $(this).siblings().find("img").removeClass("opaqueImage");
    });
        //{filter: "alpha(opacity=75)", moz-opacity: "0.75", opacity: "0.75"}


    // Collapsable Events & Testimonials at Community page
    $('.collapsable-list li p').hide();
    $('.collapsable-list li a').click(function(){
			$(this).next().slideToggle('fast');
		});

    // Collapsable Product Specifications page
    $('#ProductSpecifications .product-specification').hide();
    //$('#ProductSpecifications #specifications').hide();
    $('#ProductSpecifications a.a').click(function(){
      //alert( $(this).parent().next('.product-specification').html() );
      //$('#specifications').empty().prepend( $(this).parent().next('.product-specification').html() ).slideDown('slow');
			$(this).parent().next('.product-specification').slideToggle('fast');
		});

    // Collapsable FAQs
    $('.faqAnswer').hide();
    $('.faqQuestion').click(function(){
			$(this).next().slideToggle('fast');
		});

		// Product Details > Tabs
		$('.ProductTabs ul').idTabs();
		//$('.ProductTabs table th:last, .ProductTabs table td:last').css("borderBottom", 0);


		// Products page tooltips
		$('a.tooltip').cluetip({
  		local:true,
  		cursor: 'pointer',
  		positionBy: 'auto',
  		tracking: true,
  		activation: 'hover',
  		attribute: 'rel',
  		width: 120,
  		cluetipClass: 'mf',
  		dropShadow: false
  		});


    // Print Product Specifications
//     $("#expandAll").click(function(){
//         $("#ProductSpecifications .product-specification").slideDown("fast");
//       });
      
    $("#expandAll").toggle(function(){
        $("#ProductSpecifications .product-specification").slideDown("fast");
    },function(){
        $("#ProductSpecifications .product-specification").slideUp("fast");
    });      

    $("#printAll").click(function(){
        $("#ProductSpecifications .product-specification").slideDown("fast");
        fnPrint();
      });

    $("#printSelected").click(function(){
        fnPrint()
      });


});

function fnPrint(){
  window.print();
}
