﻿var _home = "";
var _content_parsed = false;
var _doCentering = true;
var _divResizeWidth = 0;
var _topFooterHeight = 115; //116
var _bottomFooterHeight = 100;
var _bothFootersHeight = 216;
var _transitionImageHeight = 800;
var _imageHeight = 593;
var _imageWidth = 1200;
var _minWidth = 500;

var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

var slideDuration = 24000;

function GetWidthAndHeight() {
    width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

    _divResizeWidth = width;
}

function GetWidthAndHeightForResize() {
    width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}

var Browser = {
    Version: function() {
        var version = 999; // we assume a sane browser
        if (navigator.appVersion.indexOf("MSIE") != -1)
        // bah, IE again, lets downgrade version number
            version = parseFloat(navigator.appVersion.split("MSIE")[1]);
        return version;
    }
}

function ShowDialogAndBoldElements(dlgId, lnkId, isFirstTime) {
    $(dlgId).jqmShow();

    //    var browser = BrowserDetection();
    //    if (browser == 'Chrome' || browser == 'Safari') {
    //        if (isFirstTime) {
    //            $(lnkId).unbind();

    //            var content_explanation_color = $('p.content_explanation').css('color');
    //            $(dlgId + ' .mainTable2Surrounding p.content_explanation span').dropShadow({ left: 1, top: 0, opacity: 1, blur: 0, color: content_explanation_color });

    //            $(lnkId).click(function() { ShowDialogAndBoldElements(dlgId, lnkId, false); });
    //        }
    //    }
}

function ResizeAndShowVideoDialog(playerContainerId, jqmClass, doShow) {    
    GetWidthAndHeight();
   
    $(playerContainerId).width($('#slidedown_top_logo').width() - 2);

    if ($('#slidedown_top_logo').width() < _imageWidth) {
        $(playerContainerId).height(height - 35);
        $(jqmClass).height(height - 15);
    }
    else {
        $(playerContainerId).height(height - 20);
        $(jqmClass).height(height);
    }
    $(jqmClass).width($('#slidedown_top_logo').width());
    $(jqmClass).css({ "top": "0", "left": "0" });

    if (doShow)
        $(jqmClass).jqmShow();
}

function ResizeMainPageWindow() {
    GetWidthAndHeight();

    $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth)

        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}

function ResizePageSliderNextPreviousHalfPageWindow(playerContainerId) {
    GetWidthAndHeight();

    $('div.mask_excerpt_content').css({ "width": _imageWidth, "top": "180px" });
    $('div.mask_gallery_right_content').css({ "height": _imageHeight });
    $('table.slider_table').css({ "width": "1000px" });
    $('table.slider_table_right').css({ "padding-top": "150px" });
    $('table.slider_table_small').css({ "width": "450px" });
    $('table.slider_table_right_small').css({ "width": "800px" });

    $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
    $('div#content, div.slider_main').css({ "width": _imageWidth, "height": _imageHeight });
    $('ul.excerpt_content').css({ "height": _imageHeight, "left": "180px", "width": _imageWidth });

    ResizeAndShowVideoDialog(playerContainerId, '.jqmWindow2', false);

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);
        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}

function ResizePageSliderNextPreviousWidePageWindow(contentLeft, contentTop, contentWidth) {
    GetWidthAndHeight();

    $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });

    $('table.slider_table').css({ "width": contentWidth });
    $('div#content, div.slider_main').css({ "width": _imageWidth, "height": _imageHeight });
    $('div.mask_gallery_right_content').css({ "width": _imageWidth, "height": _imageHeight });
    $('div.mask_excerpt_content').css({ "height": _imageHeight, "width": _imageWidth, "top": contentTop });
    $('ul.excerpt_content').css({ "height": _imageHeight / 2, "left": contentLeft, "width": contentWidth });

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);

        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}


function ResizePageSliderNextPreviousRightPageWindow(contentLeft, contentTop, contentWidth) {
    GetWidthAndHeight();

    contentLeft = contentLeft / 2;
    contentTop = _imageHeight / 7 - 4;
    contentWidth = contentWidth / 2.41;

    $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
    $('table.slider_table').css({ "width": contentWidth });
    $('div#content, div.slider_main').css({ "width": _imageWidth, "height": _imageHeight });
    $('div.mask_gallery_right_content').css({ "width": _imageWidth, "height": _imageHeight });
    $('div.mask_excerpt_content').css({ "height": _imageHeight, "width": _imageWidth, "top": contentTop });
    $('ul.excerpt_content').css({ "height": _imageHeight, "left": contentLeft, "width": contentWidth });

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);

        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}

function ResizeFixedContentPageWindow(data, playerContainerId, jqmClass) {
    GetWidthAndHeight();

    for (var i = 0; i < data.length; i++) {
        if (data[i].css != '') {
            $(data[i].selector).css(data[i].css);
        }
    }

    if (playerContainerId != null && jqmClass != null) {
        ResizeAndShowVideoDialog(playerContainerId, jqmClass, false);
    }

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);

        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}

//function MovingBoxPageWindow() {
//    GetWidthAndHeight();

//    var browser = BrowserDetection();
//    
//    if (browser == 'IE7') {
//        $('div.slidedown_main_content').css({ "position": "relative" });
//        $('div#wrapper').css({ "top": "0" });
//    }
//    
//    var newWidth = parseInt((width / 3) + (width / 10), 10);
//    var panels = $('#slider1 .scrollContainer > div');
//    
//    if (width > _imageWidth) {
//        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": "100%", "height": _imageHeight });

//        $('div.panel').css({ "width": newWidth });
//        $('div.scrollContainer').css({ "width": (newWidth * panels.length), "height": _imageHeight });
//        $('img#faBackgroundImage').css({ "width": (newWidth * panels.length), "height": _imageHeight });

//        $('div.bottom_div').width("100%");
//        $('img.bottom_line').width("100%");
//    }
//    else {
//        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
//        newWidth = parseInt((_imageWidth / 3) + (_imageWidth / 10), 10);

//        $('div.panel').css({ "width": newWidth });
//        $('div.scrollContainer').css({ "width": (newWidth * panels.length), "height": _imageHeight });
//        $('img#faBackgroundImage').css({ "width": (newWidth * panels.length), "height": _imageHeight });
//        $('div#wrapper').width(_imageWidth);

//        $('div.bottom_div').width(_imageWidth);
//        $('img.bottom_line').width(_imageWidth);
//    }

//    makeOthersTransparent("panel_2");
//    
//    //movingDistance = newWidth;
//}

function MovingBoxCollectionPageWindow() {
    GetWidthAndHeight();

    var browser = BrowserDetection();
    if (browser == 'IE7') {
        $('div.slidedown_main_content').css({ "position": "relative" });
        $('div#wrapper').css({ "top": "0" });
    }

    var newWidth = width - 235;
    var panels = $('#slider1 .scrollContainer > div');
    if (width > _imageWidth) {
        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": "100%", "height": _imageHeight });

        $('div.panel').css({ "width": newWidth });
        $('div.scrollContainer').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight });
        $('img#tnpcBackgroundImage').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight });

        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
    else {
        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
        newWidth = _imageWidth - 235;

        $('div.panel').css({ "width": newWidth });
        $('div.scrollContainer').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight });
        $('img#tnpcBackgroundImage').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight });
        $('div#wrapper').width(_imageWidth);

        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);
    }

    makeOthersNotVisibleCollection("panel_1");

    movingDistance = newWidth;
}

function ResizeMovingBoxPageWindow(isWindowResized) {
    GetWidthAndHeight();

    var browser = BrowserDetection();

    if (browser == 'IE7') {
        $('div.slidedown_main_content').css({ "position": "relative" });
        $('div#wrapper').css({ "top": "0" });
    }

    var newWidth = parseInt((width / 3) + (width / 10), 10);
    var panels = $('#slider1 .scrollContainer > div');
    var left = 0;

    if (width > _imageWidth) {
        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": "100%", "height": _imageHeight });

        $('div#wrapper').width("100%");

        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
    else {
        newWidth = parseInt((_imageWidth / 3) + (_imageWidth / 10), 10);

        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });

        $('div#wrapper').width(_imageWidth);

        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);
    }

    if (isWindowResized) {
        if (curPanel > 1) {
            left = (curPanel * newWidth * -1) + (newWidth * 0.75);
        }
    }

    $('div.panel').css({ "width": newWidth });
    $('div.scrollContainer').css({ "width": (newWidth * (panels.length)), "height": _imageHeight, "left": left });
    $('img#' + _faBackgroundImage).css({ "width": (newWidth * (panels.length)), "height": _imageHeight, "left": left });

    if (!isWindowResized)
        makeOthersTransparent("panel_2");
}

function resizeMovingBoxCollectionPageWindow() {
    GetWidthAndHeight();

    var browser = BrowserDetection();

    if (browser == 'IE7') {
        $('div.slidedown_main_content').css({ "position": "relative" });
        $('div#wrapper').css({ "top": "0" });
    }

    var newWidth = width - 235;
    var panels = $('#slider1 .scrollContainer > div');
    var left = 0;

    if (width > _imageWidth) {
        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": "100%", "height": _imageHeight });

        if (curPanel > 1) {
            left = (curPanel - 1) * newWidth * -1;
        }

        $('div.panel').css({ "width": newWidth });
        $('div.scrollContainer').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight, "left": left });
        $('img#tnpcBackgroundImage').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight, "left": left });
        $('div#wrapper').width("100%");

        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
    else {
        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
        newWidth = _imageWidth - 235;

        if (curPanel > 1) {
            left = (curPanel - 1) * newWidth * -1;
        }

        $('div.panel').css({ "width": newWidth });
        $('div.scrollContainer').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight, "left": left });
        $('img#tnpcBackgroundImage').css({ "width": (newWidth * (panels.length + 1)), "height": _imageHeight, "left": left });
        $('div#wrapper').width(_imageWidth);

        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);
    }

    movingDistance = newWidth;
}

function makeOthersNotVisible(id) {    
    if (_content_parsed) {
        //        var browser = BrowserDetection();
        //        if (browser == 'Chrome' || browser == 'Safari') {
        //            var main_content_white_color = $('div.main_next_div p.p_black_small').css('color');
        //            $('div.main_next_div p.p_black_small span').dropShadow({ left: 1, top: 0, opacity: 1, blur: 0, color: main_content_white_color });
        //        }
        //        else {
        //            $('div.main_next_div p.p_black_small span').css({ "font-weight": "bold" });
        //        }
        if ($("div[id*=panel_]").length > 0) {
            $("div[id*=panel_]").each(function(i) {
                var attrId = $(this).attr("id");
                if (attrId != id) {
                    $(this).find('img[id*="next_image_button_black"], h2, p').each(function() {
                        $(this).css({ "visibility": "hidden" });
                    });                    
                }
                else {
                    $(this).find('img[id*="next_image_button_black"], h2, p').each(function() {
                        $(this).css({ "visibility": "visible" });
                    });                    
                }
            });
        }
    }
    else {
        setTimeout("makeOthersNotVisible('panel_1')", 50);
    }
}

function makeOthersNotVisibleCollection(id) {
    if ($("div[id*=panel_]").length > 0) {
        $("div[id*=panel_]").each(function(i) {
            var attrId = $(this).attr("id");
            if (attrId != id) {
                $(this).find('img[id*="previous_image_button_black"]').css({ "visibility": "hidden" });                
            }
            else {
                $(this).find('img[id*="previous_image_button_black"]').css({ "visibility": "visible" });                
            }
        });
    }
}

function makeOthersTransparent(id) {
    if (_content_parsed) {
        if ($("div[id*=panel_]").length > 0) {
            $("div[id*=panel_]").each(function(i) {
                var attrId = $(this).attr("id");
                if (attrId == id || attrId == "panel_1") {

                    $(this).find('img[id*="previous_image_button_black"]').unbind();                        
                    $(this).find('img[id*="next_image_button_black"]').click(function() { change(true); });
                    if (attrId == id) {
                        $(this).find('h2').removeClass("mb_h2_inside_gray");
                        $(this).find('h2').addClass("mb_h2_inside");
                        $(this).find('p').removeClass("gray");
                        $(this).find('p').addClass("black");

                        var next_img_src = _baseUrl + "img/arrow_right_black.png";
                        var previous_img_src = _baseUrl + "img/arrow_left_gray.png";

                        $(this).find('img[id*="previous_image_button_black"]').attr("src", previous_img_src);
                        $(this).find('img[id*="next_image_button_black"]').attr("src", next_img_src);

                        $(this).find('td#border_bottom_left').removeClass("border_bottom_left_gray");
                        $(this).find('td#border_bottom_left').addClass("border_bottom_left");
                        $(this).find('td#border_bottom').removeClass("border_bottom_gray");
                        $(this).find('td#border_bottom').addClass("border_bottom");
                        $(this).find('td#border_left').removeClass("border_left_gray");
                        $(this).find('td#border_left').addClass("border_left");
                        $(this).find('td#border_bottom_all').removeClass("border_bottom_all_gray");
                        $(this).find('td#border_bottom_all').addClass("border_bottom_all");
                    }
                } else {

                    $(this).find('img[id*="previous_image_button_black"]').click(function() { change(false); });
                    $(this).find('img[id*="next_image_button_black"]').unbind();

                    $(this).find('h2').removeClass("mb_h2_inside");
                    $(this).find('h2').addClass("mb_h2_inside_gray");
                    $(this).find('p').removeClass("black");
                    $(this).find('p').addClass("gray");

                    var next_img_src = _baseUrl + "img/arrow_right_gray.png";
                    var previous_img_src = _baseUrl + "img/arrow_left_black.png";

                    $(this).find('img[id*="previous_image_button_black"]').attr("src", previous_img_src);
                    $(this).find('img[id*="next_image_button_black"]').attr("src", next_img_src);

                    $(this).find('td#border_bottom_left').removeClass("border_bottom_left");
                    $(this).find('td#border_bottom_left').addClass("border_bottom_left_gray");
                    $(this).find('td#border_bottom').removeClass("border_bottom");
                    $(this).find('td#border_bottom').addClass("border_bottom_gray");
                    $(this).find('td#border_left').removeClass("border_left");
                    $(this).find('td#border_left').addClass("border_left_gray");
                    $(this).find('td#border_bottom_all').removeClass("border_bottom_all");
                    $(this).find('td#border_bottom_all').addClass("border_bottom_all_gray");
                }
            });
        }
    }
    else {
        setTimeout("makeOthersTransparent('panel_2')", 50);
    }
}

function ResizeBlogPageWindow() {
    GetWidthAndHeight();

    var left_offset = 0;
    var left_sh_offset = 600;

    if (width > _imageWidth) {
        left_offset = left_offset + (width - _imageWidth) / 2;
        left_sh_offset = left_sh_offset + (width - _imageWidth) / 2;

        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": "100%", "height": _imageHeight * 2 });
        $('img[id*="bpmainImage"]').css({ "height": _imageHeight * 2, "left": "0", "top": _topFooterHeight, "width": "100%" });
    }
    else {
        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight * 2 });
        $('img[id*="bpmainImage"]').css({ "height": _imageHeight * 2, "left": "0", "top": _topFooterHeight, "width": _imageWidth });
    }

    $('div#wrapper_first_right').css({ "width": (_imageWidth / 2), "left": left_sh_offset });
    $('div#wrapper_first_left').css({ "width": (_imageWidth / 2), "left": left_offset });

    $('div.bottom_div').width($('div.slidedown_main_content').width());
    $('img.bottom_line').width($('div.slidedown_main_content').width());
}

function MovingBoxHalfPageWindow() {
    GetWidthAndHeight();

    var newWidth = (width / 2.25);
    var browser = BrowserDetection();

    if (browser == 'IE7') {
        $('div.slidedown_main_content').css({ "position": "relative" });
        $('div#wrapper1').css({ "top": "0" });
        $('div#wrapper_first_text').css({ "top": "165px" });
        $('div#wrapper_first').css({ "top": "0" });
    }

    if (width > _imageWidth) {
        var panels = $('#slider1 .scrollContainer > div');

        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": "100%", "height": _imageHeight });

        $('div.inside_img').css({ "width": (width / 6), "height": "245px" });
        $('div.inside_img_first').css({ "width": (width / 6), "height": "245px" });
        $('div#wrapper1 div.panel').css({ "width": newWidth, "height": _imageHeight });
        $('div#wrapper1 div.inside').css({ "height": _imageHeight - 30 });
        $('div.scrollContainer').css({ "width": (newWidth * panels.length), "background": "none" });
        $('div#wrapper1').css({ "left": "50%" });
        $('img#' + _cccmainImage).css({ "height": _imageHeight, "left": "0", "top": _topFooterHeight, "width": "100%" });
    }
    else {
        newWidth = (_imageWidth / 2.25);
        var panels = $('#slider1 .scrollContainer > div');

        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });

        $('div.inside_img').css({ "width": (_imageWidth / 6), "height": "245px" });
        $('div.inside_img_first').css({ "width": (_imageWidth / 6), "height": "245px" });
        $('div#wrapper1 div.panel').css({ "width": newWidth, "height": _imageHeight });
        $('div#wrapper1 div.inside').css({ "height": _imageHeight - 30 });
        $('div.scrollContainer').css({ "width": (newWidth * panels.length), "background": "none" });
        $('div#wrapper1').css({ "width": (_imageWidth / 2), "left": (_imageWidth / 2) });
        $('div#wrapper_first_text').css({ "width": (_imageWidth / 2) });
        $('div#wrapper_first').css({ "width": (_imageWidth / 2) });
        $('img#' + _cccmainImage).css({ "height": _imageHeight, "left": "0", "top": _topFooterHeight, "width": _imageWidth });

        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);
    }
    
    $('div#wrapper_first img[id*="previous_image_button_black"]').hide();

    makeOthersNotVisible('panel_1');
    movingDistance = newWidth;
}

function resizeMovingBoxHalfPageWindow() {
    GetWidthAndHeight();

    var newWidth = (width / 2.25);
    var browser = BrowserDetection();

    if (browser == 'IE7') {
        $('div.slidedown_main_content').css({ "position": "relative" });
        $('div#wrapper1').css({ "top": "0" });
        $('div#wrapper_first_text').css({ "top": "165px" });
        $('div#wrapper_first').css({ "top": "0" });
    }

    if (width > _imageWidth) {
        var left = 0;
        if (curPanel > 1) {
            left = (curPanel - 1) * newWidth * -1;
        }
        var panels = $('#slider1 .scrollContainer > div');

        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": "100%", "height": _imageHeight });

        $('div.inside_img').css({ "width": (width / 6), "height": "245px" });
        $('div.inside_img_first').css({ "width": (width / 6), "height": "245px" });
        $('div#wrapper1 div.panel').css({ "width": newWidth, "height": _imageHeight });
        $('div#wrapper1 div.inside').css({ "height": _imageHeight - 30 });
        $('div.scrollContainer').css({ "width": (newWidth * panels.length), "background": "none", "left": left });
        $('div#wrapper1').css({ "width": "50%", "left": "50%" });
        $('div#wrapper_first_text').css({ "width": "50%" });
        $('div#wrapper_first').css({ "width": "50%" });
        $('img#' + _cccmainImage).css({ "height": _imageHeight, "left": "0", "top": _topFooterHeight, "width": "100%" });

        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
    else {
        newWidth = (_imageWidth / 2.25);
        var left = 0;
        if (curPanel > 1) {
            left = (curPanel - 1) * newWidth * -1;
        }
        var panels = $('#slider1 .scrollContainer > div');

        $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });

        $('div.inside_img').css({ "width": (_imageWidth / 6), "height": "245px" });
        $('div.inside_img_first').css({ "width": (_imageWidth / 6), "height": "245px" });
        $('div#wrapper1 div.panel').css({ "width": newWidth, "height": _imageHeight });
        $('div#wrapper1 div.inside').css({ "height": _imageHeight - 30 });
        $('div.scrollContainer').css({ "width": (newWidth * panels.length), "background": "none", "left": left });
        $('div#wrapper1').css({ "width": (_imageWidth / 2), "left": (_imageWidth / 2) });
        $('div#wrapper_first_text').css({ "width": (_imageWidth / 2) });
        $('div#wrapper_first').css({ "width": (_imageWidth / 2) });
        $('img#' + _cccmainImage).css({ "height": _imageHeight, "left": "0", "top": _topFooterHeight, "width": _imageWidth });

        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);
    }

    movingDistance = newWidth;
}

function ResizePageSliderWithRightContent() {
    GetWidthAndHeight();

    $('div.mask_excerpt_content').css({ "left": "500px", "width": "700px", "height": "500px" });
    $('ul.excerpt_content').css({ "height": "500px", "padding-top": "200px" });

    $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
    $('div#content, div.slider_main').css({ "width": _imageWidth, "height": _imageHeight });
    $('div.mask_gallery_right_content').css({ "height": _imageHeight });

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);

        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}

function ResizeSliderCssWithMiddleLeftContent() {
    GetWidthAndHeight();

    $('div.mask_excerpt_content').css({ "width": _imageWidth, "top": _imageHeight / 2, "height": "250px" });
    $('ul.excerpt_content').css({ "left": "200px", "width": _imageWidth - 200, "height": "250px" });
    $('table.slider_table_right').css({ "width": _imageWidth - 400 });

    $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
    $('div#content, div.slider_main, div.mask_gallery_right_content').css({ "width": _imageWidth, "height": _imageHeight });

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);

        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}

function ResizeSliderCssWithUpLeftContent() {
    GetWidthAndHeight();

    $('div.mask_excerpt_content').css({ "left": "200px  ", "width": _imageWidth - 400, "height": "350px", "top": _imageHeight / 3 });
    $('ul.excerpt_content').css({ "width": _imageWidth - 400, "left": "0px", "height": "350px" });
    $('table.slider_table_left').css({ "width": _imageWidth - 400 });
    $('td.main_content').css({ "width": "50%", "vertical-align": "top" });

    $('div.slidedown_main_content').css({ "margin-top": _topFooterHeight, "width": _imageWidth, "height": _imageHeight });
    $('div#content, div.slider_main, div.mask_gallery_right_content').css({ "width": _imageWidth, "height": _imageHeight });

    if (width <= _imageWidth) {
        $('div.bottom_div').width(_imageWidth);
        $('img.bottom_line').width(_imageWidth);

        if (_doCentering)
            $('div.slidedown_main_content').css({ "margin-left": 0 });
    }
    else {
        if (_doCentering) {
            var marginLeft = (width - _imageWidth) / 2;
            $('div.slidedown_main_content').css({ "margin-left": marginLeft });
        }
        $('div.bottom_div').width("100%");
        $('img.bottom_line').width("100%");
    }
}

function CreateBothMenu() {
    //'window._title' is used instead of '_title' cause all variables are also defined as properties of the window object.
    //if we want to use '_title' it must be declared as 'var _title' somewhere in code for this to work,
    //so 'window._title' usage is safer
    if (window._title != undefined && window._title) {
        SetSelectedClass(_title);
    }
}

function SetSelectedClass(title) {
    $('.top_logo_menu ul li a').each(function(i) {
        if ($(this).text() == title) {
            $(this).removeClass("li_a");
            $(this).addClass("clicked_li_a");
        } else {
            $(this).removeClass("clicked_li_a");
            $(this).addClass("li_a");
        }
    });
    ;
}

function SectionClick(id, typeOfSlider, withHeight) {
    $('a#' + id).click();
    InitializeSlider(id, typeOfSlider, withHeight);
    $("#slider" + id).addClass("clicked");
}

function ScrollWithFixedContent(id, prev) {

    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#gallery' + id + ' li.selected').length ? $('#gallery' + id + ' li.selected') : $('#gallery' + id + ' li:first');

    //if prev is set to 1 (previous item)
    if (prev) {

        //Get previous sibling
        if (current_image.prev().length) {
            var next_image = current_image.prev();
        }
        //if prev is set to 0 (next item)
    } else {

        //Get next sibling
        if (current_image.next().length) {
            var next_image = current_image.next();
        }
    }

    if (next_image != undefined) {
        //clear the selected class
        $('#gallery' + id + ' li').removeClass('selected');

        //reassign the selected class to current items
        next_image.addClass('selected');

        //Scroll the items
        $('#mask-gallery' + id).scrollTo(next_image, 1000);
    }
}

function ScrollWithSeparateContent(id, prev) {
    //debugger;
    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#gallery' + id + ' li.selected').length ? $('#gallery' + id + ' li.selected') : $('#gallery' + id + ' li:first');
    var current_excerpt = $('#excerpt' + id + ' li.selected').length ? $('#excerpt' + id + ' li.selected') : $('#excerpt' + id + ' li:first');

    //if prev is set to 1 (previous item)
    if (prev) {

        //Get previous sibling
        if (current_image.prev().length) {
            var next_image = current_image.prev();
            var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#excerpt' + id + ' li:last');
        }
        //if prev is set to 0 (next item)
    } else {

        //Get next sibling
        if (current_image.next().length) {
            var next_image = current_image.next();
            var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#excerpt' + id + ' li:first');
        }
    }

    if (next_image != undefined) {
        //clear the selected class
        $('#excerpt' + id + ' li, #gallery' + id + ' li').removeClass('selected');

        //reassign the selected class to current items
        next_image.addClass('selected');
        next_excerpt.addClass('selected');

        //Scroll the items
        //$('#mask-gallery' + id).scrollTo(current_image, 1);
        $('#mask-gallery' + id).scrollTo(next_image, 1000);

        $('#excerpt' + id + ' li').each(function(i) {
            if ($(this).hasClass('selected')) {
                $(this).show();
                //                var browser = BrowserDetection();
                //                if (browser == 'Chrome' || browser == 'Safari') {
                //                    var main_div_a_color = $('#content a').css('color');
                //                    $('#content a span').dropShadow({ left: 1, top: 0, opacity: 1, blur: 0, color: main_div_a_color });
                //                }
                //                else {
                //                    $('#content a span').css({ "font-weight": "bold" });
                //                }
            } else {
                $(this).hide();
            }
        });
    }
}


function ScrollWithFixedContentAuto(id, prev) {
    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#gallery' + id + ' li.selected').length ? $('#gallery' + id + ' li.selected') : $('#gallery' + id + ' li:first');

    //if prev is set to 1 (previous item)
    if (prev) {
        //Get previous sibling
        if (current_image.prev().length) {
            var next_image = current_image.prev();
        }
        //if prev is set to 0 (next item)
    } else {

        //Get next sibling
        if (current_image.next().length) {
            var next_image = current_image.next();
        }
    }

    if (next_image != undefined) {
        while (next_image.next().length) {
            next_image = next_image.next();
        }
        //clear the selected class
        $('#gallery' + id + ' li').removeClass('selected');

        //reassign the selected class to current items
        next_image.addClass('selected');

        //Scroll the items
        $('#mask-gallery' + id).scrollTo(next_image, slideDuration);
    }
    else {
        //current_image.addClass('selected');
        $('#mask-gallery' + id).scrollTo(current_image, 10);
    }
}



function InitializeAutoSlider(id) {    
    //debugger;
    //Speed of the slideshow
    //var speed = 5000;

    //You have to specify width and height in #slider CSS properties
    //After that, the following script will set the width and height accordingly
    $('#mask-gallery' + id).width($('#slider' + id).width());
    $('#gallery' + id + ' li').width($('#gallery' + id + ' li img').width());
    $('#gallery' + id).width($('#gallery' + id + ' li img').width() * $('#gallery' + id + ' li').length);

    $('#mask-gallery' + id + ', #gallery' + id + ' li').height($('#slider' + id).height());

    //Assign a timer, so it will run periodically
    //var run = setInterval('ScrollWithFixedContent(' + id + ', 0)', speed);
    //clearInterval(run);

    $('#gallery' + id + ' li:first, #excerpt' + id + ' li:first').addClass('selected');
}


function InitializeSlider(id, typeOfSlider, withHeight) {
    if (!$('#slider' + id).is('.clicked')) {

        if (typeOfSlider == "separate") {
            $('li.mask_slider img.next_div').each(function(i) {
                $(this).click(function() {
                    ScrollWithSeparateContent(id, 0);
                });
            });

            $('li.mask_slider img.prev_div').each(function(i) {
                $(this).click(function() {
                    ScrollWithSeparateContent(id, 1);
                });
            });

        } else {
            $('#gallery' + id + ' li img').drag(function(ev, dd) {

                if (dd.deltaX != 0) {
                    if (dd.deltaX > 0) {
                        if (typeOfSlider == "separate") {
                            ScrollWithSeparateContent(id, 1);
                        } else {
                            ScrollWithFixedContent(id, 1);
                        }
                    } else {
                        if (typeOfSlider == "separate") {
                            ScrollWithSeparateContent(id, 0);
                        } else {
                            ScrollWithFixedContent(id, 0);
                        }
                    }
                } else {
                    if (dd.deltaY != 0) {
                        var tempId = id;
                        if (dd.deltaY > 0) {
                            if ($('a#' + tempId).parent().prev(".sup").length) {
                                tempId = $('a#' + tempId).parent().prev(".sup").find('a').attr("id");
                            }
                            SectionClick(tempId, typeOfSlider, withHeight);
                        } else {
                            if ($('a#' + tempId).parent().next(".sup").length) {
                                tempId = $('a#' + tempId).parent().next(".sup").find('a').attr("id");
                            }
                            SectionClick(tempId, typeOfSlider, withHeight);
                        }
                    }
                }
                return false;
            });

            $('#mask-excerpt' + id).drag(function(ev, dd) {

                if (dd.deltaX != 0) {
                    if (dd.deltaX > 0) {
                        if (typeOfSlider == "separate") {
                            ScrollWithSeparateContent(id, 1);
                        } else {
                            ScrollWithFixedContent(id, 1);
                        }
                    } else {
                        if (typeOfSlider == "separate") {
                            ScrollWithSeparateContent(id, 0);
                        } else {
                            ScrollWithFixedContent(id, 0);
                        }
                    }
                } else {
                    if (dd.deltaY != 0) {
                        var tempId = id;
                        if (dd.deltaY > 0) {
                            if ($('a#' + tempId).parent().prev(".sup").length) {
                                tempId = $('a#' + tempId).parent().prev(".sup").find('a').attr("id");
                            }
                            SectionClick(tempId, typeOfSlider, withHeight);
                        } else {
                            if ($('a#' + tempId).parent().next(".sup").length) {
                                tempId = $('a#' + tempId).parent().next(".sup").find('a').attr("id");
                            }
                            SectionClick(tempId, typeOfSlider, withHeight);
                        }
                    }
                }
                return false;
            });
        }

        //Speed of the slideshow
        var speed = 5000;

        //You have to specify width and height in #slider CSS properties
        //After that, the following script will set the width and height accordingly
        $('#mask-gallery' + id + ', #gallery' + id + ' li').width($('#slider' + id).width());
        $('#gallery' + id).width($('#slider' + id).width() * $('#gallery' + id + ' li').length);

        if (withHeight) {
            $('#mask-gallery' + id + ', #gallery' + id + ' li, #mask-excerpt' + id + ', #excerpt' + id + ' li').height($('#slider' + id).height());
        } else {
            $('#mask-gallery' + id + ', #gallery' + id + ' li').height($('#slider' + id).height());
        }

        //Assign a timer, so it will run periodically
        var run = setInterval('ScrollWithFixedContent(' + id + ', 0)', speed);
        clearInterval(run);

        $('#gallery' + id + ' li:first, #excerpt' + id + ' li:first').addClass('selected');
        var tempId = id;
        $(document).keydown(function(e) {
            switch (e.keyCode) {
                case 40:
                    if ($('a#' + tempId).parent().next(".sup").length) {
                        tempId = $('a#' + tempId).parent().next(".sup").find('a').attr("id");
                    }
                    SectionClick(tempId, typeOfSlider, withHeight);
                    break;
                case 38:
                    if ($('a#' + tempId).parent().prev(".sup").length) {
                        tempId = $('a#' + tempId).parent().prev(".sup").find('a').attr("id");
                    }
                    SectionClick(tempId, typeOfSlider, withHeight);
                    break;
                case 37:
                    if (typeOfSlider == "separate") {
                        ScrollWithSeparateContent(id, 1);
                    } else {
                        ScrollWithFixedContent(id, 1);
                    }
                    break;
                case 39:
                    if (typeOfSlider == "separate") {
                        ScrollWithSeparateContent(id, 0);
                    } else {
                        ScrollWithFixedContent(id, 0);
                    }
                    break;
                default:
            }
        });
    }
}

function initPageContentFadeEfects(id) {

    var navBtns = "<div class='fade_nav'><span class='fade_back'>Back</span><span class='fade_next'>Next</span></div>";
    $("#mask_fade" + id + " .stage").hide().append(navBtns);

    $("#mask_fade" + id + " .stage:first .fade_back").hide();
    $("#mask_fade" + id + " .stage:last .fade_next").hide();
    $("#mask_fade" + id + " .stage:first").show();

    $(".fade_next").click(function() {
        $(this).closest("#mask_fade" + id + " .stage").hide();
        $(this).closest("#mask_fade" + id + " .stage").next("#mask_fade" + id + " .stage").fadeIn('slow');
    });

    $(".fade_back").click(function() {
        $(this).closest("#mask_fade" + id + " .stage").hide();
        $(this).closest("#mask_fade" + id + " .stage").prev("#mask_fade" + id + " .stage").fadeIn('slow');
    });
}

function SetMainContentFadeEffect() {
    $('li.sup a').each(function(i) {
        if ($(this).attr("id")) {
            var attrId = $(this).attr("id");
            var count = 1;
            if ($("div[id*=mask_fade" + attrId + "]").length > 0) {
                $("div[id*=mask_fade" + attrId + "]").each(function(i) {
                    var subAttrId = $(this).attr("id").split('-')[1];
                    initPageContentFadeEfects(attrId + "-" + subAttrId);
                    count++;
                });
            }
        }
    });
}

function ShowSubMenu(title) {
    SetToMenuSelected(title);
    SetVisibility(title);
    $('.slidedown_top_menu_content, img#sub_menu_bg').css({ "zIndex": "1998", "position": "fixed" });
    $('.slidedown_top_menu_content, img#sub_menu_bg').slideDown("fast");

    $('.slidedown_top_menu_content, img#sub_menu_bg').css({ "zIndex": "1998", "position": "fixed" });
    $('.slidedown_top_menu_content, img#sub_menu_bg').focus();
    $('div#main_content').unbind("mouseenter");

    $('.slidedown_top_menu_content').bind("mouseenter", function() {
        $('div#main_content').bind("mouseenter", function() {
            SetToMenuUnSelected();
            $('.slidedown_top_menu_content, img#sub_menu_bg').slideUp("fast");
        });
    });

    $('img#sub_menu_bg').bind("mouseenter", function() {
        $('div#main_content').bind("mouseenter", function() {
            SetToMenuUnSelected();
            $('.slidedown_top_menu_content, img#sub_menu_bg').slideUp("fast");
        });
    });

}

function SetVisibility(title) {
    $('.slidedown_top_menu_content ul').each(function(i) {
        if ($(this).attr("id")) {
            var attrId = $(this).attr("id");
            if (attrId == title) {
                $(this).css("display", "block");
            } else {
                $(this).css("display", "none");
            }
        }
    });
}

function SetToMenuSelected(title) {
    $('.top_logo_menu ul li a').each(function(i) {
        if ($(this).text() == title) {
            $(this).css({ "color": "#12522a" });
        } else {
            $(this).css({ "color": "#c08c34" });
        }
    });
}

function SetToMenuUnSelected() {
    $('.top_logo_menu ul li a').each(function(i) {
        if ($(this).hasClass("clicked_li_a")) {
            $(this).css({ "color": "#10542A" });
        } else {
            $(this).css({ "color": "#c08c34" });
        }
    });
}

function SetSelectedSubMenu(subTitle) {
    $('.slidedown_top_menu_content ul li a').each(function(i) {
        if ($(this).text() == subTitle) {
            _title = $(this).parent().parent().attr("id");
            SetSelectedClass(_title);
            SetToMenuSelected(_title);
            $(this).removeClass("sub_li_a");
            $(this).addClass("clicked_sub_li_a");
        } else {
            $(this).removeClass("clicked_sub_li_a");
            $(this).addClass("sub_li_a");
        }
    });
}

function SetCssByBrowser() {
    var browserName = navigator.appName;
    if (browserName == "Netscape") {
        $('h2.mb_h2_first').css({ "padding-top": "11px" });
    }
}



function BrowserDetection() {
    var detect = navigator.userAgent.toLowerCase();
    var browser, version, thestring;

    if (checkIt('chrome')) browser = "Chrome"
    else if (checkIt('safari')) browser = "Safari"
    else if (checkIt('firefox')) browser = "Mozilla"
    else if (checkIt('opera')) browser = "Opera"
    else if (checkIt('msie 7')) browser = "IE7"
    else if (checkIt('msie 8')) browser = "IE8"
    else if (checkIt('msie 9')) browser = "IE9"
    else if (checkIt('msie')) browser = "Internet Explorer"
    else if (!checkIt('compatible')) {
        browser = "Netscape Navigator"
        version = detect.charAt(8);
    }
    else browser = "An unknown browser";

    if (!version) version = detect.charAt(place + thestring.length);

    return browser;

    function checkIt(string) {
        place = detect.indexOf(string) + 1;
        thestring = string;
        return place;
    }
}

function HtmlEncode(value) {
    if (value) {
        return jQuery('<div />').text(value).html();
    } else {
        return '';
    }
};

function HtmlDecode(value) {
    if (value) {
        return $('<div />').html(value).text();
    } else {
        return '';
    }
};
