﻿//PrettyPhoto - Initial Google Map - NJ
function initializeNJ() {
    var latlng = new google.maps.LatLng(40.0723227, -74.0445108);  //40.0723227, -74.0445108
    var latlng2 = new google.maps.LatLng(40.0729491, -74.044354);  //40.0729491, -74.044354
    var latlngCenter = new google.maps.LatLng(40.0729491, -74.044354);  //(40.0725052534807, -74.04913902282715)
    var myOptions = {
        zoom: 16,
        center: latlngCenter,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var marker2 = new google.maps.Marker({ position: latlng, map: map, title: "416 Lake Ave, Bay Head NJ 08742" });
    var marker3 = new google.maps.Marker({ position: latlng2, map: map, title: "412 Lake Ave, Bay Head NJ 08742" });
}
//PrettyPhoto - Initial Google Map - NC
function initializeNC() {
    var latlng = new google.maps.LatLng(35.1378251, -80.9317919);  //35.1378251, -80.9317919
    var myOptions = {
        zoom: 12,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var marker = new google.maps.Marker({ position: latlng, map: map, title: "2015 Ayrsley Town Blvd Suite 202 Charlotte, NC 28273" });
}

//Hide Message Box
function msg_Hide() {
    elem = $("#msg p");
    if (elem.hasClass("hidefast")) {
        $('#msg').hide();  //hide instantly
    } else {
        $('#msg').slideUp();  //slide pane up
    }
    $('#msg p').html("");
}
//Show Success Message     
function msg_Success(strResult) {
    //$('html, body').animate({ scrollTop: 0 }, '100');
    $('#msg').removeClass().addClass('msg-ok');
    $('#msg p').html(strResult);
    $('#msg').delay(400).slideDown();
    endAJAX();
}
//Show Error Message     
function msg_Error(strResult) {
    //$('html, body').animate({ scrollTop: 0 }, '100');
    $('#msg').removeClass().addClass('msg-error');
    $('#msg p').html(strResult);
    $('#msg').delay(400).slideDown();
    endAJAX();
}
//Show Warn Message     
function msg_Warn(strResult) {
    //$('html, body').animate({ scrollTop: 0 }, '100');
    $('#msg').removeClass().addClass('msg-warn');
    $('#msg p').html(strResult);
    $('#msg').delay(400).slideDown();
    endAJAX();
}
//Show Info Message     
function msg_Info(strResult) {
    //$('html, body').animate({ scrollTop: 0 }, '100');
    $('#msg').removeClass().addClass('msg-info');
    $('#msg p').html(strResult);
    $('#msg').delay(400).slideDown();
    endAJAX();
}
//AJAX Start
function startAJAX() {
    msg_Hide();
    document.body.style.cursor = 'wait';
    //$('.loading').fadeIn('fast');
    $('.loading').show();
    //alert("start AJAX");
}
//AJAX End
function endAJAX() {
    document.body.style.cursor = 'default';
    $('.loading').fadeOut('slow');
    //alert("end AJAX");
}



//jQuery - After Page Load Ready
$(function () {


    //-----------------------------------------Header-----------------------------------------//
    //Main Nav
    $("ul.sf-menu").superfish({
        delay: 400,
        //animation: { height: 'show' },
        animation: { opacity: "show" },
        easing: 'linear',
        speed: 0,
        autoArrows: false,
        dropShadows: false
    });
    //Tool Nav
    $(".toolslink").click(function (e) {
        e.preventDefault();
        $("div#toolsmenu").toggle();
        $(".toolslink").toggleClass("toolslink-open");
    });
    $("div#toolsmenu").mouseup(function () {
        return false
    });
    $(document).mouseup(function (e) {
        if ($(e.target).parent("a.toolslink").length == 0) {
            $(".toolslink").removeClass("toolslink-open");
            $("div#toolsmenu").hide();
        }
    });

    //ipad and iphone fix
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/Android/i))) {
        $("a.sf-with-ul").each(function () { // have to use an `each` here - either a jQuery `each` or a `for(...)` loop
            if (!$(this).hasClass("non-link")) {

                var onClick; // this will be a function
                var firstClick = function () {
                    onClick = secondClick;
                    return false;
                };
                var secondClick = function () {
                    onClick = firstClick;
                    return true;
                };
                onClick = firstClick;
                $(this).click(function () {
                    return onClick();
                });
            }; //end if
        });
    }

    function InitjScrollPane() {
        //console.log('Re-Init jScrollPane');
        var jScrollPaneSettings = {
            showArrows: true,
            maintainPosition: true
        };

        //Social Pane
        if ($(".tab_container_white").length > 0) {

            var paneS = $('.tab_container_white .scroll-pane');
            paneS.jScrollPane(jScrollPaneSettings);
            var apiS = paneS.data('jsp');
            var r = 1;

            var refreshIdS = setInterval(function () {
                //console.log('r: ' + r);
                apiS.reinitialise();
                //check for 'jspScrollable' class
                if ($(".tab_container_white .jspScrollable").length > 0) {
                    clearInterval(refreshIdS);
                }
                r = r + 1;
            }, 2000);
        }

        //Footer Pane
        var pane = $('.tab_container .scroll-pane');
        pane.jScrollPane(jScrollPaneSettings);
        var api = pane.data('jsp');
        var i = 1;

        var refreshId = setInterval(function () {
            //console.log('i: ' + i);
            api.reinitialise();
            //check for 'jspScrollable' class
            if ($(".tab_container .jspScrollable").length > 0) {
                clearInterval(refreshId);
            }
            i = i + 1;
        }, 2000);


    }

    //-----------------------------------------Job Form-----------------------------------------//
    $("input[id$='btnApply']").click(function () {
        //hide
        $(".jobdetails").hide(); //Job Details
        $(".lnk-apply").hide(); //Apply Link
        //show Form
        $(".jobform").fadeIn(800, "linear");
        $(".lnk-return").fadeIn(800, "linear");
    });

    $(".jobreturn").click(function (e) {
        //hide
        $(".jobform").hide(); //Job Form
        $(".lnk-return").hide(); // Return Link
        //show Details
        $(".lnk-apply").fadeIn(800, "linear");
        $(".jobdetails").fadeIn(800, "linear");
    });

    //-----------------------------------------Mailing List Form-----------------------------------------//
    $(".FormDefault").focus(function (srcc) {
        if ($(this).val() == $(this)[0].title) {
            //$(this).removeClass("defaultTextActive");
            $(this).val("");
        }
    });

    $(".FormDefault").blur(function () {
        if ($(this).val() == "") {
            //$(this).addClass("defaultTextActive");
            $(this).val($(this)[0].title);
        }
    });

    $(".FormDefault").blur();

    //-----------------------------------------Services Blocks-----------------------------------------//
    $(".sub-iconservices .block").click(function (event) {
        event.preventDefault();
        window.location = $(this).find('.col-iconhead a').attr("href");
    });


    //-----------------------------------------PrettyPhoto-----------------------------------------//
    //Standard Lightbox
    $("a[rel^='modal']").prettyPhoto({ social_tools: false, overlay_gallery: false, show_title: false });

    //Google Map NJ Locations
    $("a[rel^='modalmapNJ']").prettyPhoto({
        custom_markup: '<div id="map_canvas" style="width:720px; height:360px"></div>',
        changepicturecallback: function () { initializeNJ(); }
    });

    //Google Map North Carolina Locations
    $("a[rel^='modalmapNC']").prettyPhoto({
        custom_markup: '<div id="map_canvas" style="width:720px; height:360px"></div>',
        changepicturecallback: function () { initializeNC(); }
    });


    //-----------------------------------------Mini Gallery Slider-----------------------------------------//


    $('.slider_holder .slider').each(function (i) {  // i will increment from 0 to number of elements -1
        // within an each  "this" refers to the element the each is attached to, so when run on multiple ".slideshow" it will refer to the one that is currently being processed

        $(this).after().cycle({
            fx: 'scrollHorz',
            easing: 'easeOutSine',
            speed: 300,
            timeout: 10000 + (i * 1000),
            prev: $('.slideprev').eq(i),
            next: $('.slidenext').eq(i),
            before: function (curr, next, opts) { // use args to access internals of cycle
                $('.counter').eq(i).html(this.title)
                //$('.counter').eq(i).html(this.alt);  //  eq(i)  -  will match the proper index of $('caption) to the correct slideshow
                //var msg = (opts.currSlide + 1) + ' of ' + opts.slideCount;
                //$('.msg').eq(i).html(msg);
            }
        });
    });



    //-----------------------------------------Scrollable Items-----------------------------------------//
    //Scrollables
    $("#chained").scrollable({ easing: 'easeInOutExpo', speed: 800, circular: true, mousewheel: false }).navigator(".navi");
    $("#chained-rotator").scrollable({ easing: 'easeInOutExpo', speed: 800, circular: true, next: ".nextRotate", prev: ".prevRotate", mousewheel: false }).navigator(".navRotate").autoscroll({ autoplay: true, interval: 10000, autopause: true });
    $("#chained-portfolio").scrollable({ easing: 'easeInOutExpo', speed: 800, circular: true, next: ".next2", prev: ".prev2", mousewheel: false }).navigator(".navi2");
    $("#chained-casestudies").scrollable({ easing: 'easeInOutExpo', speed: 800, circular: false, next: ".next4", prev: ".prev4", mousewheel: false }).navigator(".navi4");
    $("#chained").stop().animate();

    //Fix HomeRotator
    if ($(".banner-container").length > 0) {
        var curLeft = $("#chained-rotator div.items").css('left');
        //console.log('left: ' + curLeft);
        if (curLeft == '0px') {
            $("#chained-rotator div.items").css('left', '-940px');
            //console.log('added left fix');
        }
    }
    //End HomeSlider Fix

    //Fix HomeSlider
    if ($(".homeslider").length > 0) {
        var curLeft = $("#chained div.items").css('left');
        //console.log('left: ' + curLeft);
        if (curLeft == '0px') {
            $("#chained div.items").css('left', '-871px');
            //console.log('added left fix');
        }
    }
    //End HomeSlider Fix

    //Fix Community Slider
    if ($(".communityslider").length > 0) {
        var curLeft = $("#chained div.items").css('left');
        //console.log('left: ' + curLeft);
        if (curLeft == '0px') {
            $("#chained div.items").css('left', '-600px');
            //console.log('added left fix');
        }
    }
    //End Community Fix

    //Fix Project Slider
    //    if ($("#work").length > 0) {
    //        var curLeft = $("#chained-portfolio div.items").css('left');
    //        //console.log('left: ' + curLeft);
    //        if (curLeft == '0px') {
    //            $("#chained-portfolio div.items").css('left', '-600px');
    //            //console.log('added left fix');
    //        }
    //    }
    //End Community Fix

    //HomeSlider Logo Hover
    //    $(".homeslider div.scrollable div.item").hover(function () {
    //        $(this).stop().animate({ opacity: 1 }, 300, 'easeOutSine');
    //    }, function () {
    //        $(this).stop().animate({ opacity: 0.6 }, 700, 'easeInSine');
    //    });

    //HomeSlider Logo Hover
    $(".homeslider div.scrollable div.item").hover(function () {
        //$(this).find("img").stop().animate({ marginLeft: 0, marginTop: -7 }, 200);
        var imgWidth = $(this).find("img").width();
        //console.log('imgWidth: ' + imgWidth);
        $(this).find("img").css("z-index", "100");
        $(this).find(".large_thumb_shine").css("z-index", "500");
        $(this).find(".large_thumb_shine").stop();
        $(this).find(".large_thumb_shine").css("background-position", "-99px 0px");
        //$(this).find(".large_thumb_shine").animate({ backgroundPosition: '99px 0px' }, 1000);
        $(this).find(".large_thumb_shine").animate({ 'backgroundPosition': +imgWidth + 'px 0px' }, (600 + (300 - imgWidth) * 1.2));
    }, function () {
        //$(this).find("img").stop().animate({ marginLeft: 0, marginTop: 0 }, 200);
    });

    //Community Logo Hover
    $(".community-slider div.scrollable div.item").hover(function () {
        //$(this).find("img").stop().animate({ marginLeft: 0, marginTop: -7 }, 200);
        var imgWidth = $(this).find("img").width();
        //console.log('imgWidth: ' + imgWidth);
        $(this).find("img").css("z-index", "100");
        $(this).find(".large_thumb_shine").css("z-index", "500");
        $(this).find(".large_thumb_shine").stop();
        $(this).find(".large_thumb_shine").css("background-position", "-99px 0px");
        //$(this).find(".large_thumb_shine").animate({ backgroundPosition: '99px 0px' }, 1000);
        $(this).find(".large_thumb_shine").animate({ 'backgroundPosition': +imgWidth + 'px 0px' }, (600 + (300 - imgWidth) * 1.2));
    }, function () {
        //$(this).find("img").stop().animate({ marginLeft: 0, marginTop: 0 }, 200);
    });

    //-----------------------------------------Glossary-----------------------------------------//
    //Glossary Mosaic
    $('.bar').mosaic({ animation: 'slide', speed: 300 });

    //-----------------------------------------Team Toggle-----------------------------------------//
    //Toggler to Team
    $("#Ateam").click(function (e) {
        e.preventDefault();
        if (!$(this).is('.active')) {
            //Initial Load Fix
            var curLeft = $("#chained div.items").css('left');
            //console.log('left: ' + curLeft);
            if (curLeft == '0px') {
                $("#chained div.items").css('left', '-620px');
                //console.log('added left fix');
            }
            //End Fix
            $(this).toggleClass("active");
            $("#Aexec").toggleClass("active");
            $("div.exec").hide();
            $("div.team").fadeIn(800, "linear");
        }
    });
    //Toggler Exec
    $("#Aexec").click(function (e) {
        e.preventDefault();
        if (!$(this).is('.active')) {
            $(this).toggleClass("active");
            $("#Ateam").toggleClass("active");
            $("div.team").hide();
            $("div.exec").fadeIn(800, "linear");
        }
    });

    //-----------------------------------------Project Toggle-----------------------------------------//

    //    $(window).hashchange(function () { //Requires hashchange plugin
    //        $('#worknav a').removeClass('active'); //Make all tabs inactive
    //        $(location.hash).addClass('active'); //Activate the tab that has the same ID as the hash
    //    });

    //Work - URL Hash - OnChange
    if ($(".work-container").length > 0) {

        $(window).hashchange(function () {
            var hash = location.hash;
            var hashname = hash.replace(/^#/, '')
            // Set the page title based on the hash.
            //document.title = 'The hash is ' + (hash.replace(/^#/, '') || 'blank') + '.';

            // Iterate over all toggler links, setting the "active" class as-appropriate.
            if (hashname == "") {
                //NO HASH - Load casestudies
                //console.log('No Hash - Load 1st Tab');
                hashname = "casestudies";
                $("#tab_casestudies").addClass('active');
            }
            else {
                //HAS HASH - load tab where hash = href
                $('#worknav a').each(function () {
                    var that = $(this);
                    that[that.attr('href') === hash ? 'addClass' : 'removeClass']('active');
                });
            }

            //console.log('load: ' + hashname);  //debug

            //Load Container
            switch (hashname) {
                case 'casestudies':
                    //e.preventDefault();
                    //End Fix
                    $(".casestudies").fadeIn(800, "linear"); //show case studies
                    $(".work").hide();
                    $(".rankings").hide();
                    break;
                case 'work':
                    //e.preventDefault();
                    //Initial Slider Load Fix
                    var curLeft = $(".work div.items").css('left');
                    if (curLeft == '0px') { $(".work div.items").css('left', '-871px'); }
                    //End Fix
                    $(".casestudies").hide();
                    $(".work").fadeIn(800, "linear"); //show work
                    $(".rankings").hide();
                    break;
                case 'rankings':
                    //e.preventDefault();
                    $(".casestudies").hide();
                    $(".work").hide();
                    $(".rankings").fadeIn(800, "linear"); //show rankings
                    break;
                default:
                    $(".casestudies").fadeIn(800, "linear"); //show case studies
                    $(".work").hide();
                    $(".rankings").hide();
            }
        });

        //Work - URL Hash - OnLoad
        $(window).hashchange();
    }


    //    //Toggle Work
    //    $("#tab_work-INACTIVE").click(function (e) {
    //        e.preventDefault();
    //        if (!$(this).is('.active')) {
    //            //Initial Load Fix
    //            var curLeft = $("#work div.items").css('left');
    //            //console.log('left: ' + curLeft);
    //            if (curLeft == '0px') {
    //                $("#work div.items").css('left', '-871px');
    //                //console.log('added left fix');
    //            }
    //            //End Fix
    //            $(this).toggleClass("active");
    //            $("#tab_casestudies").removeClass('active');
    //            $("#tab_linkbuilding").removeClass('active');
    //            $("#casestudies").hide();
    //            $("#linkbuilding").hide();
    //            $("#work").fadeIn(800, "linear");
    //        }
    //    });

    //    //Toggle Case Studies
    //    $("#tab_casestudies-INACTIVE").click(function (e) {
    //        e.preventDefault();
    //        if (!$(this).is('.active')) {
    //            //Initial Load Fix
    //            var curLeft = $("#casestudies div.items").css('left');
    //            //console.log('left: ' + curLeft);
    //            if (curLeft == '0px') {
    //                $("#casestudies div.items").css('left', '-871px');
    //                //console.log('added left fix');
    //            }
    //            //End Fix
    //            $(this).toggleClass("active");
    //            $("#tab_work").removeClass('active');
    //            $("#tab_linkbuilding").removeClass('active');
    //            $("#work").hide();
    //            $("#linkbuilding").hide();
    //            $("#casestudies").fadeIn(800, "linear");
    //        }
    //    });

    //    //Toggle Link Building
    //    $("#tab_linkbuilding-INACTIVE").click(function (e) {
    //        e.preventDefault();
    //        if (!$(this).is('.active')) {
    //            //fixSlider("#linkbuilding");
    //            $(this).toggleClass("active");
    //            $("#tab_work").removeClass('active');
    //            $("#tab_casestudies").removeClass('active');
    //            $("#work").hide();
    //            $("#casestudies").hide();
    //            $("#linkbuilding").fadeIn(800, "linear");
    //        }
    //    });

    //-----------------------------------------Project Grids-----------------------------------------//
    // Fade animation
    $(".team .grid-item img, .exec .grid-item img").hover(function () {
        $(".team .grid-item img, .exec .grid-item img").stop().animate({ opacity: "0.3" });
        $(this).stop().animate({ opacity: "1" });
    }, function () {
        $(".team .grid-item img, .exec .grid-item img").stop().animate({ opacity: "1" });
    });
    //SEO Site-Side
    $(".grid a.cat1").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#138e30", borderColor: '#0e7d28' }, 200);
        //$(this).find(".right-icon img").stop().animate({ opacity: "1" });
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
        //$(this).find(".right-icon img").stop().animate({ opacity: "0.5" });
    });
    //Web
    $(".grid a.cat2").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#138e30", borderColor: '#0e7d28' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
    });
    //PPC
    $(".grid a.cat3").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#f97808", borderColor: '#e26b04' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
    });
    //Social
    $(".grid a.cat4").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#545454", borderColor: '#404040' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
    });
    //Mobile
    $(".grid a.cat5").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#138e30", borderColor: '#0e7d28' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
    });
    //Email
    $(".grid a.cat6").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#f30b0b", borderColor: '#df0606' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
    });
    //Brand
    $(".grid a.cat7").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#ebbc01", borderColor: '#d5aa00' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
    });
    //Analytics
    $(".grid a.cat8").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#138e30", borderColor: '#0e7d28' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 400);
    });
    //Page Flip - Whole Block
    $(".grid a.catflip").hover(function () {
        $(this).find(".pageflip img, .msg_block").stop().animate({ width: '144px', height: '144px' }, 'normal', 'easeOutQuart');
        $(this).stop().animate({ backgroundColor: "#138e30", borderColor: '#0e7d28' }, 200);
    }, function () {
        $(this).find(".pageflip img").stop().animate({ width: '50px', height: '50px' }, 220);
        $(this).find(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
        $(this).stop().animate({ backgroundColor: "#cfcfcf", borderColor: '#bbb' }, 600);
    });

    //Social Icons (header & footer)
    $(".social a").mouseover(function () {
        $(this).children("img").stop().animate({ opacity: 1 }, 100, "easeOutSine");
    });
    $(".social a").mouseout(function () {
        $(this).children("img").stop().animate({ opacity: 0.6 }, 500, 'easeInSine');
    });

    //-----------------------------------------Footer-----------------------------------------//
    //Load Tabs
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content
    //Toggle Tabs
    $("ul.tabs li").click(function () {
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).show(); //Fade in the active content
        InitjScrollPane(); //Re-Initialize jScrollPane
        return false;
    });

    //Twitter
    $('#tweets ul').twitterfeed('Teknicks', { type: "user", timer: 5000, autoplay: 0, count: 10 })

    //Facebook
    $('#fbwall').fbWall({ id: 'teknicks', accessToken: 'AAAC7gAoWDQ0BABoYKGuKEZCit4pWfQc1m5iJDDChXceKO9VLCtygjUtRjdoKQixim6Gs3kW8yABJYTY2FEmBJOfM5ZAL8ZD', max: 6, timeConversion: 12 });

    //-----------------------------------------Socialize-----------------------------------------//
    //Galleriffic Gallery
    var onMouseOutOpacity = 0.5;
    $('#thumbs ul.thumbs li').opacityrollover({
        mouseOutOpacity: onMouseOutOpacity,
        mouseOverOpacity: 1.0,
        fadeSpeed: 'fast',
        exemptionSelector: '.selected'
    });
    // Initialize Advanced Galleriffic Gallery
    if ($("#mini-gallery #thumbs").length > 0) {

        var gallery = $('#mini-gallery #thumbs').galleriffic({
            delay: 8000,
            numThumbs: 5,
            preloadAhead: 30,
            enableTopPager: false,
            enableBottomPager: false,
            maxPagesToShow: 7,
            imageContainerSel: '#slideshow',
            controlsContainerSel: '#controls',
            captionContainerSel: '#caption',
            loadingContainerSel: '#loading',
            renderSSControls: false,
            renderNavControls: true,
            playLinkText: 'Play',
            pauseLinkText: 'Pause',
            prevLinkText: '',
            nextLinkText: '',
            nextPageLinkText: '',
            prevPageLinkText: '',
            enableHistory: false,
            autoStart: false,
            syncTransitions: true,
            defaultTransitionDuration: 900,
            onSlideChangeOut: function (prevIndex) {
                // 'this' refers to the gallery, which is an extension of $('#thumbs')
                this.find('ul.thumbs').children().eq(prevIndex).fadeTo('fast', onMouseOutOpacity);
            },
            onSlideChangeIn: function (nextIndex) {
                this.find('ul.thumbs').children().eq(nextIndex).fadeTo('fast', 1.0);
            },
            onPageTransitionOut: function (callback) {
                //$('#slideshow, #caption').fadeOut('fast', callback);
                this.fadeTo('fast', 0.0, callback);
            },
            onPageTransitionIn: function () {
                //$('#slideshow, #caption').fadeIn('fast');

                var prevPageLink = this.find('a.prev')
                var nextPageLink = this.find('a.next')

                // Show appropriate next / prev page links
                if (this.displayedPage > 0) {
                    prevPageLink.css('visibility', 'visible');
                    prevPageLink.fadeTo('fast', 1.0);
                } else { prevPageLink.fadeTo('fast', 0.3); }

                var lastPage = this.getNumPages() - 1;
                if (this.displayedPage < lastPage) {
                    nextPageLink.css('visibility', 'visible');
                    nextPageLink.fadeTo('fast', 1.0);
                } else { nextPageLink.fadeTo('fast', 0.3); }
                this.fadeTo('fast', 1.0);
            }
        });

        gallery.find('a.prev').click(function (e) {
            gallery.previousPage();
            e.preventDefault();
        });

        gallery.find('a.next').click(function (e) {
            gallery.nextPage();
            e.preventDefault();
        });

    } //End Galleriffic


    //Load Tabs
    $(".tab_content_white").hide(); //Hide all content
    $("ul.tabs_white li:first").addClass("active").show(); //Activate first tab
    $(".tab_content_white:first").show(); //Show first tab content
    //Toggle Tabs
    $("ul.tabs_white li").click(function () {
        $("ul.tabs_white li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content_white").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        InitjScrollPane(); //Re-Initialize jScrollPane
        return false;
    });

    //Twitter    
    $('#tweets-social ul').twitterfeed('Teknicks', { type: "user", timer: 5000, autoplay: 0, count: 10 });

    //Facebook
    $('#fbwall-social').fbWall({ id: 'teknicks', accessToken: 'AAAC7gAoWDQ0BABoYKGuKEZCit4pWfQc1m5iJDDChXceKO9VLCtygjUtRjdoKQixim6Gs3kW8yABJYTY2FEmBJOfM5ZAL8ZD', max: 8, timeConversion: 12 });

    //-----------------------------------------jScrollPane-----------------------------------------//
    //InitjScrollPane();  //Re-Initialize
    //    $('.scroll-pane').jScrollPane({
    //        showArrows: true,
    //        reinitialiseOnImageLoad: true
    //    });
    //-----------------------------------------Next-----------------------------------------//

    InitjScrollPane(); //Re-Initialize jScrollPane


});                           //END:jQuery - After Page Load Ready 
