﻿// Functions specific to a site.
Cufon.replace('h1, .achilles-moreinfo-tab, .manufacturers-img');
Cufon.replace('.generic', {
			  color: '-linear-gradient(0.2=#666666, 0.8=#1a1a1a)'
});
Cufon.replace('.generic .overview', {
			  color: '-linear-gradient(0.2=#88b7e5, 0.8=#426cba)'
});

(function ($) {
    $(document).ready(function () {
        // Place document manipulation code here
        var bgImageSource, bgImageFinal;
        $('#subnav li').each(function () {
            bgImageSource = $(this).css('background-image');
            if (bgImageSource != 'none')
                bgImageFinal = bgImageSource.replace(/"/g, "").replace(/url\(|\)$/ig, "");
            else
                bgImageFinal = '/images/sub-nav_hover.png';
            // $(this).css({ 'background-image': 'none' });
            // $(this).prepend('<img class="bg-stretch" src="' + bgImageFinal + '" style="height: ' + $(this).height() + 'px; width: 150px; position: absolute; z-index: 1;" />');

            if (!$(this).hasClass('active'))
                $(this).find('img').hide();

            $(this).find('a').each(function () {
                $(this).css({ 'z-index': '5', 'position': 'relative' });
            });
        });

        $('#subnav li:not([class~=active])').hover(function () {
            $(this).find('img').show();
        },
		function () {
		    $(this).find('img').hide();
		});

            /*$('.main-nav ul.L1').superfish({
                delay: 500,                            // one second delay on mouseout 
                animation: { opacity: 'show' },  // fade-in and slide-down animation 
                speed: 'fast',                          // faster animation speed 
                autoArrows: false,
                dropShadows: false
            });*/
            // Alternate font replacement
            Cufon.replace("h1, .manufacturers-img");
            Cufon.replace(".subnav-title", { color: '-linear-gradient(#f26611, #b34b0d)' });
            Cufon.replace("h2");
            //Cufon.replace(".blog-btn-nav");
    });
    $(document).ready(function () {

        var showText = 'Show';
        var hideText = 'Hide';

        var is_visible = false;

        $('.toggle').hide();
        $('a.toggleLink').click(function () {

            is_visible = !is_visible;

            $(this).parent().next('.toggle').toggle('slow');
            return false;
        });
    });
    /*************** overview **********************/
    $(document).ready(function () {
        time = 200;

        $(".products").hover(function () {
            $(this).animate({ height: '89px' }, time, 'swing');
        }, function () {
            $(this).animate({ height: '48px' }, time, 'swing');
        });

        $(".practice").hover(function () {
            $(this).animate({ height: '89px' }, time, 'swing');
        }, function () {
            $(this).animate({ height: '48px' }, time, 'swing');
        });
    });
    /*************** scrollable **********************/
    $(document).ready(function () {
        if ($('#main').length != 0) {
            $("#main").scrollable({
                vertical: true,
                keyboard: 'static',
                onSeek: function (event, i) {
                    horizontal.eq(i).data("scrollable").focus();
                }
            }).navigator("#main_navi");
            var horizontal = $(".scrollable").scrollable({ circular: false }).navigator(".navi");
            horizontal.eq(0).data("scrollable").focus();
        }
    });
    $(document).ready(function () {
        if ($('.scrollable-numbers').length != 0) {

            $('.scrollable-numbers').scrollable();
            var links = $('.numbers a');
            var slideWidth = 0;
            var currentPosition = 0;
            var positionsDiv = [];
            positionsDiv['one'] = 0;
            positionsDiv['two'] = 1;
            positionsDiv['three'] = 2;
            positionsDiv['four'] = 3;
            positionsDiv['five'] = 4;
            positionsDiv['six'] = 5;
            positionsDiv['seven'] = 6;
            positionsDiv['eight'] = 7;
            positionsDiv['nine'] = 8;
            positionsDiv['ten'] = 9;
            links.click(function (e) {
                var link = $(this);
                var linkAttr = link.attr('rel');
                var featureDivId = linkAttr.substr(1, linkAttr.length);
                var featureDiv = $('#' + featureDivId);
                slideWidth = featureDiv.outerWidth();
                $('.features').animate({
                    'left': -(slideWidth * positionsDiv[featureDivId])
                });
                return false;
            });
        }
        if ($('.scrolling-banner').length != 0) {
            $('.scrolling-banner').scrollable({
                next: '#next-button',
                prev: '#previous-button'
            });
        }
		$('.first a.one').attr('id','selected');
		$('a.one').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.two').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.three').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.four').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.five').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.six').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.seven').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.eight').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.nine').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		$('a.ten').bind('click',
    		function(){
				$('#selected').attr('id','');
				$(this).attr('id','selected');
		});
		
    });
	
	$(document).ready(function () {
			$('#logo-slideshow').cycle({
				fx: 'fade'
			});
		});	
	$(document).ready( function(){
		
		$('.certification-table tr:first-child').addClass('first-child');
	});

})(jQuery);