function resizer(template) {

    elem_resizer($('#rest-of-it').width(), '#logo', 'margin-left', 1920, 991, 45, 20, parseInt(45 - ((1920 - $('#rest-of-it').width()) / 37.2)));
    
    if (template == 'Home Page') {
        var font_size = parseInt($('#incred-def-wrapper').css('font-size'));

        while (($('#incred-def').width() + 15) < $('#incred-def-wrapper').width()) {
            if (font_size >= 83) {
                $('#incred-def').css({ 'font-size': '83px' });
                font_size = 83;
                break;
            }
            $('#incred-def').css({ 'font-size': (font_size + 1) + 'px' });
            font_size = parseInt($('#incred-def').css('font-size')) + 1;
        }
        while (($('#incred-def').width() + 15) > $('#incred-def-wrapper').width()) {
            if (font_size <= 60) {
                $('#incred-def').css({ 'font-size': '60px' });
                font_size = 60;
                break;
            }
            $('#incred-def').css({ 'font-size': (font_size - 1) + 'px' });
            font_size = parseInt($('#incred-def').css('font-size')) - 1;
        }

        var slider_width = parseInt($('#slider-wrapper').width());

        elem_resizer(slider_width, '#slider img', 'width', 1920, 991, 600, 288, parseInt((slider_width - 70) / 3 - 18));
        elem_resizer(slider_width, '#slider-wrapper', 'height', 1920, 991, 363, 197, (Math.round($('#slider img').width() / 1.875) + 43));
        elem_resizer(slider_width, '#slider', 'width', 1920, 991, 1850, 918, parseInt(($('#slider img').width() * 3) + 54));
        elem_resizer(slider_width, '#previous, #next', 'top', 1920, 991, 170, 89, parseInt(($('#slider-wrapper').height() - 20) / 2));
        //elem_resizer(slider_width, '#social-wrapper .facebook-icon, #social-wrapper .twitter-icon, #social-wrapper .youtube-icon', 'width', 1920, 991, 516, 206, parseInt((slider_width - 252) / 3 - 40));
        elem_resizer(slider_width, '#social-wrapper .facebook-icon, #social-wrapper .twitter-icon, #social-wrapper .youtube-icon, #social-wrapper .ivc-icon', 'width', 1920, 991, 377, 144, parseInt((slider_width - 252) / 4 - 40));

        var resizable = parseInt($('#resizable-content-block').width());

        elem_resizer(resizable, '#headline-wrapper', 'width', 1246, 1145, 346, 246, parseInt(346 - (1245 - resizable)));
        elem_resizer(resizable, '#content-swap', 'margin-left', 1145, 1085, 60, 0, (60 - (1145 - resizable)));
        elem_resizer(resizable, '#content-swap', 'width', 1085, 991, 422, 327, (422 - (1085 - resizable)));
        elem_resizer(resizable, '#content-swap ul li, #content-swap ul li img', 'width', 1085, 991, 132, 101, (132 - parseInt((1085 - resizable) / 3)));
        elem_resizer(resizable, '#content-swap ul li a', 'line-height', 1085, 991, 30, 22, parseInt((($('#content-swap ul li img').width() * .3409)) * .666));
        elem_resizer(resizable, '#content-swap ul li a', 'font-size', 1085, 991, 11, 9, parseInt(11 - ((1085 - resizable) / 47)));
        elem_resizer(resizable, '#content-swap p', 'top', 1085, 991, 30, 0, parseInt(30 - ((1085 - resizable) / 3.1)));
        elem_resizer(resizable, '#content-swap p', 'font-size', 1085, 991, 13, 11, parseInt(13 - ((1085 - resizable) / 47)));
        elem_resizer(resizable, '#ul-rollover a', 'font-size', 1085, 991, 13, 11, parseInt(13 - ((1085 - resizable) / 47)));

        if ((slider_width <= 1920) && (slider_width >= 990)) {
            $('#previous, #next').css({ 'top': parseInt(($('#slider-wrapper').height() - 20) / 2) + 'px' });
        }
    }
    else if (template == 'Skills Page') {
        var wwd_center = parseInt($('#wwd-center').width());

        elem_resizer(wwd_center, '#wwd-box1,#wwd-box2,#wwd-box3,#wwd-box4,#wwd-box6,#wwd-box7,#wwd-box8,#wwd-box9', 'margin-right', 1920, 1825, 44, 20, (44 - ((1920 - wwd_center) / 4)));
        elem_resizer(wwd_center, '.wwd-box,.white-box', 'width', 1824, 991, 329, 162, parseInt((wwd_center - 179) / 5));
        elem_resizer(wwd_center, '.black-box', 'width', 1824, 991, 307, 140, (parseInt((wwd_center - 179) / 5) - 22));
        elem_resizer(wwd_center, '.black-box', 'font-size', 1824, 991, 14, 12, (14 - parseInt((1824 - wwd_center) / 375)));
        elem_resizer(wwd_center, '.white-box-title', 'font-size', 1824, 991, 36, 20, (36 - parseInt((1824 - wwd_center) / 52)));
        elem_resizer(wwd_center, '.white-box-caption', 'font-size', 1824, 991, 32, 25, (32 - parseInt((1824 - wwd_center) / 119)));
    }
    else if (template == 'Who We Are') {
                
    }
    else if (template == 'Portfolio Landing') {

        var portfolio_wrapper = parseInt($('#portfolio-wrapper').width());

        elem_resizer(portfolio_wrapper, '#portfolio-thumbs', 'width', 1425, 991, 1146, 751, (portfolio_wrapper - $('#portfolio-ul').width() - 35));
        elem_resizer(portfolio_wrapper, '#portfolio-thumbs', 'margin-right', 1425, 991, 0, 0, 10);
        elem_resizer(portfolio_wrapper, '#portfolio-thumbs img, #portfolio-thumbs li', 'width', 1425, 991, 374, 242, parseInt(($('#portfolio-thumbs').width() - 24) / 3));
        elem_resizer(portfolio_wrapper, '#portfolio-ul a', 'font-size', 1425, 991, 18, 12, parseInt(portfolio_wrapper / 79));
        elem_resizer(portfolio_wrapper, '#view-by-service', 'font-size', 1425, 991, 24, 16, parseInt(portfolio_wrapper / 59));

        if (($('#rest-of-it').width() < 1435) && ($('#portfolio-wrapper').width() >= 1425)) {
            $('#portfolio-ul').css('width', (254 - (1435 - $('#rest-of-it').width())) + 'px');
        }

        if ((portfolio_wrapper < 1425) && (portfolio_wrapper >= 991)) {
            $('#portfolio-ul').css('width', parseInt(244 - (1425 - parseInt($('#portfolio-wrapper').width()) / 434 * 40)) + 'px');
        }
        else if (portfolio_wrapper >= 1435) {
            $('#portfolio-ul').css('width', '254px');
        }
        else if (portfolio_wrapper == 990) {
            $('#portfolio-ul').css('width', '204px');
        }
    }
    else if (template == 'Case Study') {

        var casestudy_wrapper = parseInt($('#casestudy-wrapper').width());
        elem_resizer(casestudy_wrapper, '#portfolio-thumbs', 'width', 1186, 991, 1146, 950, (1146 - (1186 - casestudy_wrapper)));
        elem_resizer(casestudy_wrapper, '#portfolio-thumbs img, #portfolio-thumbs li', 'width', 1186, 991, 374, 308, parseInt((($('#portfolio-thumbs').width() - 24) / 3)));
    }
    else if (template == 'Portfolio Detail') {
        var portfolio_wrapper = parseInt($('#portfolio-detail-wrapper').width());

        var font_size = parseInt($('#portfolio-right-header').css('font-size'));

        while ($('#portfolio-right-header').width() < $('#portfolio-highlights').width()) {
            if (font_size >= 30) {
                $('#portfolio-right-header').css({ 'font-size': '30px' });
                font_size = 30;
                break;
            }
            $('#portfolio-right-header').css({ 'font-size': (font_size + 1) + 'px' });
            font_size = parseInt($('#portfolio-right-header').css('font-size')) + 1;
        }
        while ($('#portfolio-right-header').width() > $('#portfolio-highlights').width()) {
            $('#portfolio-right-header').css({ 'font-size': (font_size - 1) + 'px' });
            font_size = parseInt($('#portfolio-right-header').css('font-size')) - 1;
        }
        elem_resizer(portfolio_wrapper, '#slideshow-wrapper', 'margin-left', 1625, 1595, 45, 15, (45 - (1625 - portfolio_wrapper)));
        elem_resizer(portfolio_wrapper, '#portfolio-content', 'margin-left', 1595, 1554, 56, 15, (56 - (1595 - portfolio_wrapper)));
        elem_resizer(portfolio_wrapper, '#portfolio-content', 'margin-right', 1554, 1504, 65, 15, (65 - (1554 - portfolio_wrapper)));
        elem_resizer(portfolio_wrapper, '#portfolio-content', 'width', 1504, 1201, 703, 400, (703 - (1504 - portfolio_wrapper)));
        elem_resizer(portfolio_wrapper, '.portfolio-header', 'font-size', 1504, 1201, 30, 21, (30 - parseInt((1504 - portfolio_wrapper) / 30)));
        elem_resizer(portfolio_wrapper, '.portfolio-url', 'font-size', 1504, 1201, 14, 13, (14 - parseInt((1504 - portfolio_wrapper) / 150)));
        elem_resizer(portfolio_wrapper, '#portfolio-content', 'font-size', 1504, 1201, 13, 11, (13 - parseInt((1504 - portfolio_wrapper) / 140)));
        elem_resizer(portfolio_wrapper, '#portfolio-content ul li, #portfolio-content ul li img', 'width', 1404, 1311, 132, 101, (132 - parseInt((1404 - portfolio_wrapper) / 3)));
        elem_resizer(portfolio_wrapper, '#portfolio-content ul li a', 'top', 1404, 1311, 1, -2, (1 - parseInt((1404 - portfolio_wrapper) / 31)));
        elem_resizer(portfolio_wrapper, '#portfolio-content ul li a', 'font-size', 1404, 1311, 11, 10, (11 - parseInt((1404 - portfolio_wrapper) / 60)));
        elem_resizer(portfolio_wrapper, '#slideshow-wrapper', 'width', 1201, 991, 515, 304, (515 - (1201 - portfolio_wrapper)));
        elem_resizer(portfolio_wrapper, '#slideshow-large img', 'width', 1201, 991, 513, 302, (513 - (1201 - portfolio_wrapper)));
        elem_resizer(portfolio_wrapper, '#slideshow-filmstrip img', 'width', 1201, 991, 119, 66, (119 - Math.round((1201 - portfolio_wrapper) / 4)));
        elem_resizer(portfolio_wrapper, '#slideshow-wrapper', 'top', 1201, 991, 0, 40, parseInt((1201 - portfolio_wrapper) / 5.2));
        elem_resizer(portfolio_wrapper, '#left-arrow, #right-arrow', 'bottom', 1201, 991, 46, 25, Math.round((parseInt($('#slideshow-filmstrip img').width()) / 1.1782 + 6) / 2 - 7));
    }
    else if (template == 'Contact Us') {

        var center_width = parseInt($('#contact-wrapper').width());

        elem_resizer(center_width, '.contact-center', 'width', 1835, 1635, 542, 342, (542 - (1834 - center_width)));
        elem_resizer(center_width, '.contact-center', 'margin-right', 1635, 1559, 58, 20, (58 - parseInt((1634 - center_width) / 2)));
        elem_resizer(center_width, '.contact-center', 'margin-left', 1635, 1559, 58, 20, (58 - parseInt((1634 - center_width) / 2)));
        elem_resizer(center_width, '#contact_name, #contact_email, #contact_phone', 'width', 1559, 1459, 250, 150, (250 - (1558 - center_width)));
        elem_resizer(center_width, '#contact_captcha', 'width', 1559, 1459, 148, 48, ((148 - (1558 - center_width))));
        elem_resizer(center_width, '#contact_message2', 'width', 1459, 1340, 269, 150, (269 - (1458 - center_width)));
        elem_resizer(center_width, '#contact-left-form', 'width', 1559, 1340, 569, 350, (569 - (1558 - center_width)));
        elem_resizer(center_width, '#contact-right-img', 'width', 1340, 951, 596, 209, (596 - (1339 - center_width)));
    }
    else if (template == 'Skills Detail') {
        var seo_center = parseInt($('#seo-center').width());

        var slider_width = parseInt($('#skill-slider-wrapper').width());
        var slider_diff = parseInt(1161 - slider_width);

        $('#seo-center').css('min-height', (parseInt($('#right-resources').height()) + 20));

        elem_resizer(slider_width, '#skill-slider, #skill-slider li', 'width', 1161, 626, 1161, 626, slider_width);
        elem_resizer(slider_width, '.seo_slider img', 'width', 1161, 626, 543, 275, (543 - Math.round(slider_diff / 2)));
        elem_resizer(slider_width, '.seo_slider_content > p', 'font-size', 1161, 626, 30, 20, (30 - parseInt(slider_diff / 50)));
        elem_resizer(slider_width, '.seo_slider_content > p + p', 'font-size', 1161, 626, 16, 14, (16 - parseInt(slider_diff / 266)));
        elem_resizer(slider_width, '#skill-slider-title a', 'font-size', 1161, 626, 12, 11, (12 - parseInt(slider_diff / 500)));
        elem_resizer(slider_width, '.seo_slider_content', 'padding-right', 1161, 626, 40, 15, (40 - parseInt(slider_diff / 21)));
        elem_resizer(slider_width, '.seo_slider_content', 'width', 1161, 626, 578, 336, (parseInt($('.seo_slider').width())) - (parseInt($('.seo_slider img').width())) - (40 - parseInt(slider_diff / 21)));
        elem_resizer(slider_width, '.seo_slider img', 'top', 1161, 626, 0, 31, (parseInt(($('#skill-slider').height() - $('.seo_slider img').width() / 1.3052884615384615384615384615385) / 2)));

        if ((slider_width <= 1161) && (slider_width >= 626)) {
            $('#skill-slider').scrollTo('#seo_slider' + current, 0);
        }
    }

    if ((template != 'Portfolio Detail') && (template != 'Home Page')) {

        var header_width = $('#sub-header-wrapper').width();

        var font_size = parseInt($('#sub-header').css('font-size'));

        $('#sub-header').css({ 'left': parseInt(($('#sub-header-wrapper').width() - $('#sub-header').width()) / 2) + 'px' });

        header_third_function();

        while ($('#sub-header').width() < header_third) {
            if (font_size >= 75) {
                $('#sub-header').css({ 'font-size': '75px' });
                font_size = 75;
                break;
            }
            $('#sub-header').css({ 'font-size': (font_size + 1) + 'px' });
            font_size = parseInt($('#sub-header').css('font-size')) + 1;
            $('#sub-header').css({ 'left': parseInt(($('#sub-header-wrapper').width() - $('#sub-header').width()) / 2) + 'px' });
        }

        font_size = parseInt($('#title').css('font-size'));
        while (($('#title').width() + 45) < parseInt($('#sub-header-wrapper').width() / 3)) {
            if (font_size >= 30) {
                $('#title').css({ 'font-size': '30px' });
                font_size = 30;
                break;
            }
            $('#title').css({ 'font-size': (font_size + 1) + 'px' });
            font_size = parseInt($('#title').css('font-size')) + 1;
        }

        while ($('#sub-header').width() > header_third) {
            if (parseInt($('#title').css('font-size')) >= 18) {
                font_size = parseInt($('#title').css('font-size'));
                $('#title').css({ 'font-size': (font_size - 1) + 'px' });
                font_size = parseInt($('#title').css('font-size')) - 1;

                header_third_function();
            }
            else {
                font_size = parseInt($('#sub-header').css('font-size'))
                $('#sub-header').css({ 'font-size': (font_size - 1) + 'px' });
                font_size = parseInt($('#sub-header').css('font-size')) - 1;
                $('#sub-header').css({ 'left': parseInt(($('#sub-header-wrapper').width() - $('#sub-header').width()) / 2) + 'px' });

                header_third_function();
            }
        }

        header_third_function();

        if ((parseInt($('#sub-header').width() + ($('#title').width() + 65))) > parseInt(header_third + parseInt($('#title').width() + 65))) {
            resizer(template);
        }
    }
}

var header_third = '';

function header_third_function() {
    if (($('#title').width() + 45) < parseInt($('#sub-header-wrapper').width() / 3)) {
        header_third = parseInt($('#sub-header-wrapper').width()) - (($('#title').width() + 65) * 2);
    }
    else {
        header_third = parseInt($('#sub-header-wrapper').width() / 3);
    }
}

function elem_resizer(wrapper, selector, attrib, upper, lower, upper_val, lower_val, formula) {
    if (wrapper >= upper) {
        eval('$("' + selector + '").css({ "' + attrib + '" : "' + upper_val + 'px" });');
    }
    else if ((wrapper < upper) && (wrapper >= lower)) {
        eval('$("' + selector + '").css({ "' + attrib + '" : "' + formula + 'px" });');
    }
    else if (wrapper < lower) {
        eval('$("' + selector + '").css({ "' + attrib + '" : "' + lower_val + 'px" });');
    }
}

var current_portfolio = 0;

var current_large = 0;

function next_portfolio() {
    var li_width = parseInt($('#slideshow-filmstrip ul li').width()) + 18;
    var child_li = ($('#slideshow-filmstrip ul > li').size());
    var total_width = li_width * child_li;
    if (current_portfolio < (child_li - 4)) {
        $('#slideshow-filmstrip').scrollTo('.film-thumb:eq(' + (current_portfolio + 1) + ')', 800);
        current_portfolio += 1;
    }
    else
    {
        $('#slideshow-filmstrip').scrollTo('.film-thumb:eq(0)', 800);
        current_portfolio = 0;
    }
}
function previous_portfolio() {
    var child_li = ($('#slideshow-filmstrip ul > li').size());
    if (current_portfolio > 0) {
        $('#slideshow-filmstrip').scrollTo('.film-thumb:eq(' + (current_portfolio - 1) + ')', 800);
        current_portfolio -= 1;
    }
    else if (child_li > 4) {
        $('#slideshow-filmstrip').scrollTo('.film-thumb:eq(' + (child_li - 4) + ')', 800);
        current_portfolio = child_li - 4;
    }
}

var social_link = "";

function social_show(social) {
    if ($('#facebook-content').html() == "") {
        if (social == 'facebook') {
            $('#facebook-content').html('<iframe src="http://www.facebook.com/plugins/likebox.php?id=117797648968&amp;width=990&amp;colorscheme=light&amp;show_faces=yes&amp;connections=5&amp;stream=yes&amp;header=yes&amp;height=582" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:990px; height:582px;" allowTransparency="true"></iframe>');
        }
        else if (social == 'twitter') {
            $('#facebook-content').html('<iframe src="http://www.incrediblemarketing.com/wp-content/themes/whiteboard/twitter.php" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:990px; height:582px;" allowTransparency="true"></iframe>');
        }
        else if (social == 'youtube') {
            $('#facebook-content').html('<iframe src="http://www.incrediblemarketing.com/wp-content/themes/whiteboard/youtube.php" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:990px; height:582px;" allowTransparency="true"></iframe>');
        }
        $('#facebook-wrapper').slideDown();
    }
    else {
        $('#facebook-content').html('');
        $('#facebook-wrapper').slideUp();
        if (social_link != social) {
            social_show(social);
        }
    }
    social_link = social;
}

function portfolio_retrieve(active, cat, template_dir) {
    $.getJSON(template_dir + '/portfolio-json.php', { active_page: active, category: cat },
        function (data) {
            $('#portfolio-thumbs ul').html('');
            $('.pager').html('');

            var page_count = 1;
            var page_links = '';

            if (data.rcount > 9) {
                page_count = parseInt(data.rcount / 9);
                if ((data.rcount % 9) > 0) {
                    page_count += 1;
                }
                page_links = '<a href="javascript: portfolio_retrieve(1, ' + data.category + ', \'' + template_dir + '\'); void(0);">&lt;&lt; First</a>';

                var active_class = '';

                for (i = 1; i <= page_count; i++) {
                    if (i == data.active_page) {
                        active_class = 'class="active"';
                    }
                    else {
                        active_class = '';
                    }
                    page_links = page_links + '<a href="javascript: portfolio_retrieve(' + i + ', ' + data.category + ', \'' + template_dir + '\'); void(0);" ' + active_class + '>' + i + '</a>';
                }

                page_links = page_links + '<a href="javascript: portfolio_retrieve(' + page_count + ', ' + data.category + ', \'' + template_dir + '\'); void(0);">Last &gt;&gt;</a>';

                $('.pager').html(page_links);
            }

            $.each(data.portfolio, function (i, portfol) {

                $('<li><a href="' + portfol.url + '">' + portfol.bottom_img + '</a><div>' + portfol.top_img + '</div></li>').appendTo('#portfolio-thumbs ul');

            });
            resizer('Portfolio Landing');
            $('#portfolio-thumbs li').hover(function () {
                $(this).find('div').stop().animate({ top: '260px' }, { queue: false, duration: 300 });
            }, function () {
                $(this).find('div').stop().animate({ top: '0px' }, { queue: false, duration: 300 });
            });
            $('#portfolio-ul ul li a, #view-by-service').removeClass('active-portfolio').addClass('port-list');
            if (cat >= 0) {
                $('#portfolio-ul ul li a:eq(' + cat + ')').removeClass('port-list').addClass('active-portfolio');
            }
            else {
                $('#view-by-service').removeClass('port-list').addClass('active-portfolio');
            }
        }, 'json');
}

function casestudy_retrieve(active, template_dir) {
    $.getJSON(template_dir + '/casestudy-json.php', { active_page: active },
        function (data) {
            $('#portfolio-thumbs ul').html('');
            $('.pager').html('');

            var page_count = 1;
            var page_links = '';

            if (data.rcount > 9) {
                page_count = parseInt(data.rcount / 9);
                if ((data.rcount % 9) > 0) {
                    page_count += 1;
                }
                page_links = '<a href="javascript: casestudy_retrieve(1, \'' + template_dir + '\'); void(0);">&lt;&lt; First</a>';

                var active_class = '';

                for (i = 1; i <= page_count; i++) {
                    if (i == data.active_page) {
                        active_class = 'class="active"';
                    }
                    else {
                        active_class = '';
                    }
                    page_links = page_links + '<a href="javascript: casestudy_retrieve(' + i + ', \'' + template_dir + '\'); void(0);" ' + active_class + '>' + i + '</a>';
                }

                page_links = page_links + '<a href="javascript: casestudy_retrieve(' + page_count + ', \'' + template_dir + '\'); void(0);">Last &gt;&gt;</a>';

                $('.pager').html(page_links);
            }

            $.each(data.portfolio, function (i, portfol) {
                $('<li><a href="' + portfol.case_study + '" onclick="window.open(this.href); return false;">' + portfol.bottom_img + '</a><div>' + portfol.top_img + '</div></li>').appendTo('#portfolio-thumbs ul');
            });
            resizer('Case Study');
            $('#portfolio-thumbs li').hover(function () {
                $(this).find('div').stop().animate({ top: '260px' }, { queue: false, duration: 300 });
            }, function () {
                $(this).find('div').stop().animate({ top: '0px' }, { queue: false, duration: 300 });
            });
        }, 'json');
}


function activate(link_clicked) {
    $('#skill-slider-title a').removeClass('slider slider2').addClass('slider');
    $(link_clicked).removeClass('slider').addClass('slider2');
    current = ($('#skill-slider-title li a').index(link_clicked) + 1);
}

var current = 1;

function next() {
    var li_width = parseInt($('#slider ul li').width()) + 18;
    var child_li = ($('#slider ul > li').size())
    var total_width = li_width * child_li;
    if (current < (child_li - 2)) {
        $('#slider').scrollTo('#slider' + (current + 1), 800);
        current += 1;
    }
    else  {
        $('#slider').scrollTo('#slider1', 800);
        current = 1;
    }
}
function previous() {
    var child_li = ($('#slider ul > li').size())
    if (current > 1) {
        $('#slider').scrollTo('#slider' + (current - 1), 800);
        current -= 1;
    }
    else if (child_li > 3) {
        $('#slider').scrollTo('#slider' + (child_li-2), 800);
        current = child_li-2;
    }
}

function rollover(li_index, link_over) {
    var bg_pos = li_index * 244 * (-1);
    $('#photo-on-rollover').css({ 'background-position': '0px ' + bg_pos + 'px' });
    $('#content-swap p').css({ 'display': 'none' });
    $('#content-swap p:eq(' + li_index + ')').css({ 'display': 'inline' });
    $('#ul-rollover a').css({ 'color': '#000' });
    $(link_over).css({ 'color': '#A7187F' });
}

var current_staff = -1;
var clicked = 0;

function rollover_staff(li_index, link_over, link_color) {
    if (clicked == 0) {
        var top_pos = li_index * 337 * (-1);
        $('#all_pic').css({ 'top': top_pos + 'px' });
        $('#employee-ul a').css({ 'color': link_color });
        $(link_over).css({ 'color': '#A7187F' });
        current_staff = li_index;
    }
}

$.isBlank = function (object) {
    return (
            ($.isPlainObject(object) && $.isEmptyObject(object)) ||
            ($.isArray(object) && object.length == 0) ||
            (typeof (object) == "string" && $.trim(object) === "") ||
            (!object)
        );
};

function form_remover(jquery_selector) {
    if ($.isBlank(jquery_selector)) {
        jquery_selector = "input[type='text'], textarea";
    }

    $(jquery_selector).each(function (index) {
        var temp_str = this.name + '_default = "' + $(this).val() + '";';
        eval(temp_str);
    });

    $(jquery_selector).focus(function () {
        var concat_str = this.name + '_default';
        if ($(this).val() == eval(concat_str)) {
            $(this).val('');
        }
    });

    $(jquery_selector).blur(function () {
        var concat_str = this.name + '_default';
        if ($(this).val() == '') {
            $(this).val(eval(concat_str));
        }
    });
}

/*
* jQuery UI Effects @VERSION
*
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
* 
* http://docs.jquery.com/UI/Effects/
*/
; (function ($) {

    $.effects = $.effects || {}; //Add the 'effects' scope

    $.extend($.effects, {
        save: function (el, set) {
            for (var i = 0; i < set.length; i++) {
                if (set[i] !== null) $.data(el[0], "ec.storage." + set[i], el[0].style[set[i]]);
            }
        },
        restore: function (el, set) {
            for (var i = 0; i < set.length; i++) {
                if (set[i] !== null) el.css(set[i], $.data(el[0], "ec.storage." + set[i]));
            }
        },
        setMode: function (el, mode) {
            if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
            return mode;
        },
        getBaseline: function (origin, original) { // Translates a [top,left] array into a baseline value
            // this should be a little more flexible in the future to handle a string & hash
            var y, x;
            switch (origin[0]) {
                case 'top': y = 0; break;
                case 'middle': y = 0.5; break;
                case 'bottom': y = 1; break;
                default: y = origin[0] / original.height;
            };
            switch (origin[1]) {
                case 'left': x = 0; break;
                case 'center': x = 0.5; break;
                case 'right': x = 1; break;
                default: x = origin[1] / original.width;
            };
            return { x: x, y: y };
        },
        createWrapper: function (el) {
            if (el.parent().attr('id') == 'fxWrapper')
                return el;
            var props = { width: el.outerWidth({ margin: true }), height: el.outerHeight({ margin: true }), 'float': el.css('float') };
            el.wrap('<div id="fxWrapper" style="font-size:100%;background:transparent;border:none;margin:0;padding:0"></div>');
            var wrapper = el.parent();
            if (el.css('position') == 'static') {
                wrapper.css({ position: 'relative' });
                el.css({ position: 'relative' });
            } else {
                var top = el.css('top'); if (isNaN(parseInt(top))) top = 'auto';
                var left = el.css('left'); if (isNaN(parseInt(left))) left = 'auto';
                wrapper.css({ position: el.css('position'), top: top, left: left, zIndex: el.css('z-index') }).show();
                el.css({ position: 'relative', top: 0, left: 0 });
            }
            wrapper.css(props);
            return wrapper;
        },
        removeWrapper: function (el) {
            if (el.parent().attr('id') == 'fxWrapper')
                return el.parent().replaceWith(el);
            return el;
        },
        setTransition: function (el, list, factor, val) {
            val = val || {};
            $.each(list, function (i, x) {
                unit = el.cssUnit(x);
                if (unit[0] > 0) val[x] = unit[0] * factor + unit[1];
            });
            return val;
        },
        animateClass: function (value, duration, easing, callback) {

            var cb = (typeof easing == "function" ? easing : (callback ? callback : null));
            var ea = (typeof easing == "object" ? easing : null);

            return this.each(function () {

                var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || '';
                if (typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */
                if (value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; }

                //Let's get a style offset
                var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this, null) : this.currentStyle));
                if (value.add) that.addClass(value.add); if (value.remove) that.removeClass(value.remove);
                var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this, null) : this.currentStyle));
                if (value.add) that.removeClass(value.add); if (value.remove) that.addClass(value.remove);

                // The main function to form the object for animation
                for (var n in newStyle) {
                    if (typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */
				&& n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */
				&& newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */
				&& (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n], 10)))) /* Only things that can be parsed to integers or colors */
				&& (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */
				) offset[n] = newStyle[n];
                }

                that.animate(offset, duration, ea, function () { // Animate the newly constructed offset object
                    // Change style attribute back to original. For stupid IE, we need to clear the damn object.
                    if (typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr);
                    if (value.add) $(this).addClass(value.add); if (value.remove) $(this).removeClass(value.remove);
                    if (cb) cb.apply(this, arguments);
                });

            });
        }
    });

    //Extend the methods of jQuery
    $.fn.extend({
        //Save old methods
        _show: $.fn.show,
        _hide: $.fn.hide,
        __toggle: $.fn.toggle,
        _addClass: $.fn.addClass,
        _removeClass: $.fn.removeClass,
        _toggleClass: $.fn.toggleClass,
        // New ec methods
        effect: function (fx, o, speed, callback) {
            return $.effects[fx] ? $.effects[fx].call(this, { method: fx, options: o || {}, duration: speed, callback: callback }) : null;
        },
        show: function () {
            if (!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])))
                return this._show.apply(this, arguments);
            else {
                var o = arguments[1] || {}; o['mode'] = 'show';
                return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
            }
        },
        hide: function () {
            if (!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])))
                return this._hide.apply(this, arguments);
            else {
                var o = arguments[1] || {}; o['mode'] = 'hide';
                return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
            }
        },
        toggle: function () {
            if (!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])) || (arguments[0].constructor == Function))
                return this.__toggle.apply(this, arguments);
            else {
                var o = arguments[1] || {}; o['mode'] = 'toggle';
                return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
            }
        },
        addClass: function (classNames, speed, easing, callback) {
            return speed ? $.effects.animateClass.apply(this, [{ add: classNames }, speed, easing, callback]) : this._addClass(classNames);
        },
        removeClass: function (classNames, speed, easing, callback) {
            return speed ? $.effects.animateClass.apply(this, [{ remove: classNames }, speed, easing, callback]) : this._removeClass(classNames);
        },
        toggleClass: function (classNames, speed, easing, callback) {
            return speed ? $.effects.animateClass.apply(this, [{ toggle: classNames }, speed, easing, callback]) : this._toggleClass(classNames);
        },
        morph: function (remove, add, speed, easing, callback) {
            return $.effects.animateClass.apply(this, [{ add: add, remove: remove }, speed, easing, callback]);
        },
        switchClass: function () {
            return this.morph.apply(this, arguments);
        },
        // helper functions
        cssUnit: function (key) {
            var style = this.css(key), val = [];
            $.each(['em', 'px', '%', 'pt'], function (i, unit) {
                if (style.indexOf(unit) > 0)
                    val = [parseFloat(style), unit];
            });
            return val;
        }
    });

    /*
    * jQuery Color Animations
    * Copyright 2007 John Resig
    * Released under the MIT and GPL licenses.
    */

    // We override the animation for all of these color styles
    jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function (i, attr) {
        jQuery.fx.step[attr] = function (fx) {
            if (fx.state == 0) {
                fx.start = getColor(fx.elem, attr);
                fx.end = getRGB(fx.end);
            }

            fx.elem.style[attr] = "rgb(" + [
						Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
						Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
						Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
				].join(",") + ")";
        }
    });

    // Color Conversion functions from highlightFade
    // By Blair Mitchelmore
    // http://jquery.offput.ca/highlightFade/

    // Parse strings looking for color tuples [255,255,255]
    function getRGB(color) {
        var result;

        // Check if we're already dealing with an array of colors
        if (color && color.constructor == Array && color.length == 3)
            return color;

        // Look for rgb(num,num,num)
        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
            return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

        // Look for rgb(num%,num%,num%)
        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
            return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];

        // Look for #a0b1c2
        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
            return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];

        // Look for #fff
        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
            return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];

        // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
        if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
            return colors['transparent']

        // Otherwise, we're most likely dealing with a named color
        return colors[jQuery.trim(color).toLowerCase()];
    }

    function getColor(elem, attr) {
        var color;

        do {
            color = jQuery.curCSS(elem, attr);

            // Keep going until we find an element that has color, or we hit the body
            if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body"))
                break;

            attr = "backgroundColor";
        } while (elem = elem.parentNode);

        return getRGB(color);
    };

    // Some named colors to work with
    // From Interface by Stefan Petre
    // http://interface.eyecon.ro/

    var colors = {
        aqua: [0, 255, 255],
        azure: [240, 255, 255],
        beige: [245, 245, 220],
        black: [0, 0, 0],
        blue: [0, 0, 255],
        brown: [165, 42, 42],
        cyan: [0, 255, 255],
        darkblue: [0, 0, 139],
        darkcyan: [0, 139, 139],
        darkgrey: [169, 169, 169],
        darkgreen: [0, 100, 0],
        darkkhaki: [189, 183, 107],
        darkmagenta: [139, 0, 139],
        darkolivegreen: [85, 107, 47],
        darkorange: [255, 140, 0],
        darkorchid: [153, 50, 204],
        darkred: [139, 0, 0],
        darksalmon: [233, 150, 122],
        darkviolet: [148, 0, 211],
        fuchsia: [255, 0, 255],
        gold: [255, 215, 0],
        green: [0, 128, 0],
        indigo: [75, 0, 130],
        khaki: [240, 230, 140],
        lightblue: [173, 216, 230],
        lightcyan: [224, 255, 255],
        lightgreen: [144, 238, 144],
        lightgrey: [211, 211, 211],
        lightpink: [255, 182, 193],
        lightyellow: [255, 255, 224],
        lime: [0, 255, 0],
        magenta: [255, 0, 255],
        maroon: [128, 0, 0],
        navy: [0, 0, 128],
        olive: [128, 128, 0],
        orange: [255, 165, 0],
        pink: [255, 192, 203],
        purple: [128, 0, 128],
        violet: [128, 0, 128],
        red: [255, 0, 0],
        silver: [192, 192, 192],
        white: [255, 255, 255],
        yellow: [255, 255, 0],
        transparent: [255, 255, 255]
    };

    /*
    * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
    *
    * Uses the built in easing capabilities added In jQuery 1.1
    * to offer multiple easing options
    *
    * TERMS OF USE - jQuery Easing
    * 
    * Open source under the BSD License. 
    * 
    * Copyright © 2008 George McGinley Smith
    * All rights reserved.
    * 
    * Redistribution and use in source and binary forms, with or without modification, 
    * are permitted provided that the following conditions are met:
    * 
    * Redistributions of source code must retain the above copyright notice, this list of 
    * conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list 
    * of conditions and the following disclaimer in the documentation and/or other materials 
    * provided with the distribution.
    * 
    * Neither the name of the author nor the names of contributors may be used to endorse 
    * or promote products derived from this software without specific prior written permission.
    * 
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
    * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
    * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
    * OF THE POSSIBILITY OF SUCH DAMAGE. 
    *
    */

    // t: current time, b: begInnIng value, c: change In value, d: duration
    jQuery.easing['jswing'] = jQuery.easing['swing'];

    jQuery.extend(jQuery.easing,
{
    def: 'easeOutQuad',
    swing: function (x, t, b, c, d) {
        //alert(jQuery.easing.default);
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function (x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function (x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function (x, t, b, c, d) {
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function (x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function (x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function (x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function (x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function (x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function (x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function (x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function (x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function (x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function (x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function (x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function (x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function (x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function (x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
        }
    },
    easeInOutBounce: function (x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});

    /*
    *
    * TERMS OF USE - EASING EQUATIONS
    * 
    * Open source under the BSD License. 
    * 
    * Copyright © 2001 Robert Penner
    * All rights reserved.
    * 
    * Redistribution and use in source and binary forms, with or without modification, 
    * are permitted provided that the following conditions are met:
    * 
    * Redistributions of source code must retain the above copyright notice, this list of 
    * conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list 
    * of conditions and the following disclaimer in the documentation and/or other materials 
    * provided with the distribution.
    * 
    * Neither the name of the author nor the names of contributors may be used to endorse 
    * or promote products derived from this software without specific prior written permission.
    * 
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
    * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
    * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
    * OF THE POSSIBILITY OF SUCH DAMAGE. 
    *
    */

})(jQuery);

jQuery.fn.dwFadingLinks = function (settings) {
    return this.each(function () {
        var original = $(this).css('color');
        $(this).mouseover(function () { $(this).stop().animate({ color: settings.color }, settings.duration); });
        $(this).mouseout(function () { $(this).stop().animate({ color: original }, settings.duration); });
    });
};

function iterater(jquery_selector, path, handler) {
	var temp_str = '$.post(path, { ';
	$(jquery_selector).each(function (index) {
        temp_str += this.name + ': "' + this.value + '", ';
    });
	temp_str += '}, function (data) { ' + handler + '(data); });';
	eval(temp_str);
}

function submitter(jquery_selector, path, handler) {
    var concat_str = '';
    $('#click-to-call-form input[name="name"], #click-to-call-form input[name="email"], #click-to-call-form input[name="phone"]').css({'background-position':'0px 0'});
    $('#click-to-call-form input[name="name"], #click-to-call-form input[name="email"], #click-to-call-form input[name="phone"]').each(function (index) {
        concat_str = this.name + '_default';
        if (this.value == eval(concat_str)) {
            this.value = '';
        }
    });
    iterater(jquery_selector, path, handler);
};

function error_handler(data) {
	if (data.substring(0, 7) == "<script") {
		$('.error').html(data);
	}
	else {
		$('#footer-click-to-call').html('<div class="font-30px" style="width:500px; margin: 0 auto; color: white; padding-top: 200px;">We have received your request and will get back to you asap. Thanks!</div>');
	}
}

function submitter2(jquery_selector, path, handler) {
    if (($('#contact_captcha').val() == '6ne3') && ($('#sameas').val() == '6ne3')) {
        var concat_str = '';
        $('#contact_us_form input[name="contact_name"], #contact_us_form input[name="contact_email"], #contact_us_form input[name="contact_phone"], #contact_us_form input[name="contact_message"], #contact_us_form input[name="contact_captcha"]').css({ 'border': 'solid 1px #353535' });
        iterater(jquery_selector, path, handler);
    }
    else {
        $('#contact_captcha').css({ 'border': 'solid 1px red' });
    }
};

function error_handler2(data) {
    if (data.substring(0, 7) == "<script") {
        $('.error').html(data);
    }
    else {
        $('#contact-us-wrapper').css({ 'width': $('#contact-us-wrapper').width() });
        $('#contact_us_form').html('<div style="width: 300px; margin: 0 auto; color: white; padding: 40px 10px; font-size: 20px; text-align: center;">We have received your request and will get back to you asap. Thanks!</div>');
    }
}

function tester(str) {
    var str = str;
	var colon_index = str.indexOf(":");
	var input_name = str.slice(0, colon_index);
	var input_tooltip = '#' + input_name;
	var message = str.slice(colon_index + 1);
	$(input_tooltip).css({'background-position':'-444px 0'});
    if ($(input_tooltip).val() == '') {
        $(input_tooltip).val(eval(input_name + '_default'));
    }
}

function tester2(str) {
    var str = str;
    var colon_index = str.indexOf(":");
    var input_name = str.slice(0, colon_index);
    var input_tooltip = '#' + input_name;
    var message = str.slice(colon_index + 1);
    $(input_tooltip).css({ 'border': 'solid 1px red' });
}
