﻿/// <reference path="jquery-1.4.1.js" />
/// <reference path="jquery.validate-vsdoc.js" />
$(function () {

    //set up cufon (if the page has it)
    if (typeof (Cufon) != 'undefined') {
        Cufon.replace('div#section-content h1');
        Cufon.replace('div.home-half h1 a', { hover: true });
        Cufon.replace('div.sub-section h2');
        Cufon.replace('div.home-content h2');
        Cufon.replace('li.sidenav-section a');
        Cufon.replace('p.names');
        Cufon.replace('div#header-container', { hover: true });
        Cufon.replace('#content-static h1');
        //Cufon.replace('p.names'); //if you use this, you need to compensate for poor line-height support by using padding or something
    }

    //on homepage, toggle color of all links on each half when any other link on that half is hovered-over
    //    $('div.salon a').mouseover(function () {
    //        $('a#topnav-salon').css("color", "red");
    //    });

    //open/close side nav, second level, on click
    var categories = $('li.sidenav-category>a');
    categories.next('ul').hide(); //hide first
    categories.click(function () {
        $(this).next('ul').toggle('fast');
        return false;
    });

    //on product page, open selected category in sidenav
    $('ul.selected').show();

    //slideshow (on section and 2nd tier home pages)
    if ($('.slideshow').length) {
        $('.slideshow').cycle({
            slideExpr: 'img',
            timeout: 5000,
            speed: 1000
        });
    }

    //set up product page clickable-gallery
    $('.item').hide();
    $('.item').first().show();
    $('#items-thumb a').first().addClass('borderize');
    $('#items-thumb a').click(function () {
        var id = $(this).attr('parent').toString();
        $('.item').hide(); //clean house
        $('#' + id).fadeIn('fast');

        $('#items-thumb a').removeClass('borderize');
        $(this).addClass('borderize');
        return false;
    });

    //set up materials / specifications + link to toggle info on product pages
    $('.materials').hide();
    $('.materials-title').click(function () {
        //$(this).parent().siblings('.materials').slideToggle('fast');
        $(this).parent().siblings('.materials').toggleFade({ speedIn: 100 });
        return false;
    });
});


/*tools*/
(function ($) {
    $.fn.toggleFade = function (settings) {
        settings = jQuery.extend(
  		{
  		    speedIn: "fast",
  		    speedOut: settings.speedIn
  		}, settings
  	);
        return this.each(function () {
            var isHidden = jQuery(this).is(":hidden");
            jQuery(this)[isHidden ? "fadeIn" : "fadeOut"](isHidden ? settings.speedIn : settings.speedOut);
        });
    };
})(jQuery);
