﻿$(document).ready(function () {
    var path = window.location.pathname;
    prod = path.substring(0, 15);
    storySec = path.substring(0, 11);
    article = path.substring(0, 26);
    sup = path.substring(0, 22);


    
    Cufon.replace('.nav-search ul li a', {
        hover: { color: '#9fb2a0' }
    });
    Cufon.replace('.navBar ul.subnav li a', {
        hover: { color: '#B2D234' }
    });

    Cufon.replace('h1,h2,h3,h4, .cufon'); // Works without a selector engine
    Cufon.replace('h1:not(.clean)');

    //fancybox call for specific videos
    $('a.video').fancybox({
        type: 'iframe'
    });

    //fancybox call for manually built videos
    $('a.manual').click(function () {
        $.fancybox([
		    'http://www.youtube.com/embed/JS4RCjqHDVM',
			'http://www.youtube.com/embed/93uRvAP20qo',
			'http://www.youtube.com/embed/skuv2jxdOHU',
			'http://www.youtube.com/embed/nfqA-T3ao_c'
			], {
				'padding': 7,
				'transitionIn': 'none',
				'transitionOut': 'none',
				'type': 'iframe',
				'changeFade': 0
		});
    });

    $('#search').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
    });

    $('#search').blur(function () {
        if (!this.value.length) {
            this.value = this.defaultValue;
        }
    });


    $('#mainContent_ContentPageContent_ButtonSubmit').click(function () {
        pageTracker._trackPageview('/joinus/submit');
    });

    $('#mainContent_ContentPageContent_ButtonFeedback').click(function () {
        pageTracker._trackPageview('/feedback/submit');
    });

    $('#subnav-story,#subnav-products').hide();

    if (storySec == '/our-story/') {
        $('#subnav-story').show();
        $('.nav-search ul li').find('a[href="' + storySec + '"]').addClass('on');

        var nav = $('#subnav-story li');
        nav.find('a[href="' + path + '"]').addClass('on');
    }

    if (prod == '/soft-carriers/') {
        $('#subnav-products').show();
        $('.nav-search ul li').find('a[href="' + prod + '"]').addClass('on');

        var nav = $('#subnav-products li');
        nav.find('a[href="' + path + '"]').addClass('on');
    }

    if (article == '/snugli-baby-carrier-news/') {
        $('a#news').addClass('on');
    }

    if (sup == '/soft-carrier-support/') {
        $('.nav-search ul li').find('a[href="' + sup + '"]').addClass('on');
    }

    $('#navBar ul li').mouseover(function () {
        var cur = $(this).children('a').attr('id');

        if (cur == 'products') {
            $('#subnav-story').hide();
            $('#subnav-products').show();
        }

        if (cur == 'story') {
            $('#subnav-products').hide();
            $('#subnav-story').show();
        }

        if (cur == 'support' || cur == 'news') {
            $('#subnav-story,#subnav-products').hide();
        }
    });
   
});
