// JavaScript Document

$(function () {

    //$('#coda-slider-1').codaSlider();
    //Screenwidth adjust for Scrolling divs

    var screenwidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0;
    $('.coda-slider, .coda-slider .panel, .boardroom-background').css('width', screenwidth);

    $(window).resize(function () {
        $('.coda-slider, .coda-slider .panel, .boardroom-background, .coda-nav').css('width', window.innerWidth);
        $('.panel-container').css('width', window.innerWidth * 3);
        $('.panel-container').css('margin-left', window.innerWidth * -1);
    });

    $('.coda-slider .panel').css('visibility', 'visible');
	

    //Floating link hover effects

    /*	$(".floating-link").hover(function () {
    $(this).children('.floating-link-icon').css('opacity', '1');
    }, function () {
    $(this).children('.floating-link-icon').css('opacity', '0.75');
    });
    */
    //Main Tab styling

    var rootURL = "http://" + location.hostname + (location.hostname == 'rkdweb1' ? '/Client%20Web/Strive/Website%202011/Web/' : '/');
    if ($('li.home-link a').hasClass('active')) {
        $('li.home-link').append('<img class="active-tab png" src="' + rootURL + 'images/home-active.png" alt="Home" />');
    }
    if ($('li.why-link a').hasClass('active')) {
        $('li.why-link').append('<img class="active-tab png" src="' + rootURL + 'images/why-strive-active.png" alt="Why Strive" />');
    }
    if ($('li.models-link a').hasClass('active')) {
        $('li.models-link').append('<img class="active-tab png" src="' + rootURL + '/images/models-active.png" alt="Our Models" />');
    }
    if ($('li.services-link a').hasClass('active')) {
        $('li.services-link').append('<img class="active-tab png" src="' + rootURL + '/images/services-active.png" alt="Services" />');
    }
    if ($('li.resources-link a').hasClass('active')) {
        $('li.resources-link').append('<img class="active-tab png" src="' + rootURL + '/images/resources-active.png" alt="Resources" />');
    }
    if ($('li.events-link2 a').hasClass('active')) {
        /*$('li.events-link').append('<img class="active-tab png" src="' + rootURL + '/images/events-active.png" alt="events" />');*/
		$('img.events-active-tab').css('display', 'block');
    }

    //Popup windows for Contact page

    $(".canada-popup-link").click(function () {
        $(".canada-popup").css('display', 'block');
    });
    $(".usa-popup-link").click(function () {
        $(".usa-popup").css('display', 'block');
    });

    $(".close").click(function () {
        $(this).parents('.popup').css('display', 'none');
    });

    $(".close").click(function () {
        $(this).parents('.popup').css('display', 'none');
    });

    //BEGIN MOVIE FADE IN

    $('.dim-switch').toggle(function () {
        $('.dim-bg').fadeIn('slow');
        return false;
    },
		function () {
		    $('.dim-bg').fadeOut('slow');
		    return false;
		});

    $('.floating-link').click(function () {
        $('.dim-bg').css('display', 'none');
    });

    //RESOURCES ZOOM PRODUCT LAYOUT


    $('.product-section').each(function () {
        var cellCount = $(this).children('.pro-row').size();
        if (cellCount == 1) {
            $(this).children('.pro-row').addClass('last-row');
        } else {
            $('.pro-row:last').addClass('last-row');
        }
    });
	
	//GENERAL TEAM MEMBER 
	

	if ($('.bio-column-left h2').is(":contains('Friendly Faces')")) {
		$('.bio-column-left').css('width', '100%');
		$('.bio-column-right').css('display', 'none');
		}


    /*$('div.pro-row > div:nth-child(4n)').addClass("last-cell");*/

    //ZOOM SUBNAV HOVER EFFECTS

    $('#zoom-sidebar li a.active').parent().css('background', '#f1eee4 url(../images/sidebar-bg.png) repeat-x');

    $('.gem-intro').css('display', 'block');

    $('.respect-link').hover(function () {
        $('.top-left').css('display', 'block');
    }, function () {
        $('.top-left').css('display', 'none');
    });
    $('.reflect-link').hover(function () {
        $('.top-middle').css('display', 'block');
    }, function () {
        $('.top-middle').css('display', 'none');
    });
    $('.select-link').hover(function () {
        $('.top-right').css('display', 'block');
    }, function () {
        $('.top-right').css('display', 'none');
    });
    $('.connect-link').hover(function () {
        $('.bottom-left').css('display', 'block');
    }, function () {
        $('.bottom-left').css('display', 'none');
    });
    $('.direct-link').hover(function () {
        $('.bottom-middle').css('display', 'block');
    }, function () {
        $('.bottom-middle').css('display', 'none');
    });
    $('.expect-link').hover(function () {
        $('.bottom-right').css('display', 'block');
    }, function () {
        $('.bottom-right').css('display', 'none');
    });


    $(".direct-link").click(function () {
		$('.gem-holder').css('background-position', '0 -1435px');
        
        $('.module').hide();
        $('.direct').show();
    });

    $(".reflect-link").click(function () {
        $('.gem-holder').css('background-position', '0 -574px');
        $('.module').hide();
        $('.reflect').show();
        return false;
    });
    $(".expect-link").click(function () {
		$('.gem-holder').css('background-position', '0 -1722px');
        
        $('.module').hide();
        $('.expect').show();
    });
    $(".select-link").click(function () {
		$('.gem-holder').css('background-position', '0 -861px');
        
        $('.module').hide();
        $('.gem-select').show();
    });
    $(".connect-link").click(function () {
		$('.gem-holder').css('background-position', '0 -1148px');
        
        $('.module').hide();
        $('.connect').show();
    });
    $(".respect-link").click(function () {
        $('.gem-holder').css('background-position', '0 -287px');
        $('.module').hide();
        $('.respect').show();
    });

    //Team Resizing

    var PortraitNumber = $('#portrait-container > div.portrait').size();

    if (PortraitNumber > 5) {
        $('.portrait').css('margin-right', '15px');
        $('.last-portrait').css('margin-right', '0');
    }

    if (PortraitNumber > 6) {
        $('.portrait').css({ height: '150px', width: '110px', marginRight: '30px' });
        $('.portrait-frame').attr('src', '../images/boardroom/portrait-frame-small.png');
        $('.portrait img.member').css({ height: '75px', width: '60px', marginTop: '20px' });
        $('a.info-card').css({ height: '25px', width: '45px', top: '120px', left: '31px' });
        $('.last-portrait').css('margin-right', '0');
    }
    if (PortraitNumber > 7) {
        $('.portrait').css({ height: '150px', width: '110px', marginRight: '0' });
        $('.portrait-frame').attr('src', '../images/boardroom/portrait-frame-small.png');
        $('.portrait img.member').css({ height: '75px', width: '60px', marginTop: '20px' });
        $('a.info-card').css({ height: '25px', width: '45px', top: '120px', left: '31px' });
        $('.last-portrait').css('margin-right', '0');
    }
	
	
	//HINT styling 

	$('a.hint').click(function() {
		$('div.hint').fadeIn('fast');
	});
	$('a.hint-close').click(function() {
		$('div.hint').css('display', 'none');						 
	});

});
