﻿jQuery(document).ready(function () {

    img = new Image();
    img.src = "images/style/ajax-loader-small.gif";

    var pageUrl = window.location.href.split("/");

    $("a[rel^='gb_pageset']").prettyPhoto({ theme: 'facebook' });

    if (window.location.href.toLowerCase().indexOf("style.aspx") > -1) {
        $('#mycarousel').jcarousel({ vertical: true, scroll: 2 });
        $('#mycarousel').css('height', 'auto');
        if (window.location.href.toLowerCase().indexOf("imgid") > -1) {
            var imgID = gup("imgID") + '.jpg';
            $('.small_images').each(function (index, element) {
                if ($(element).attr("src").indexOf('/' + imgID) > -1) {
                    $(element).click();
                }
            });
        }


        //$('.jcarousel-prev').css("top", "0 px");
    }
    else if (window.location.href.toLowerCase().indexOf("index.aspx") > -1 || window.location.href.toLowerCase().indexOf(".aspx") == -1) {
        jQuery('#mycarousel').jcarousel();
        //SetCaruselButtons();
    }

    $("#right").css('background-color', '#EBEBEB');
        



    $(".sub_links").hover
    (
        function () {
            if ($(this).children().children().length > 0) {
                $(this).addClass('sub_linksOver');
                $(this).children().next(".sub_links_down").css('display', 'block');
            }
           // $(this).children().css("color", "#4FB94A");
        },
        function () {
            $(this).removeClass('sub_linksOver');
            $(this).children().next(".sub_links_down").css('display', 'none');
            //$(this).children().css("color", "#A7A7A7");
        }
    );

    $(".menuLinkLI").hover
   (
        function () {
            $(this).removeClass('sub_links_down').addClass('sub_links_downOver');
            $(this).children().css("text-decoration", "underline");
        },
        function () {
            $(this).removeClass('sub_links_downOver').addClass('sub_links_down');
            $(this).children().css("text-decoration", "none");
        }
   );

    var pageUrl = window.location.href.split("/");
    $(".sub_links>.menuLink").each(function (index, element) {
        $(element).css("width", $(element).width() + "px");
        $(element).parent().css("width", ($(element).width() + 20) + "px");

        var linkUrl = $(element).attr("href");

        if (jQuery.inArray(linkUrl, pageUrl) > -1) {
            $(this).css("background-color", "#ffffff");
        }
    }
    );

    var widthTemp1 = 0;
    $(".menuLinkLI>.menuLink2").each(function (index, element) {
        var widthTemp2 = $(element).width();
        $(element).css("width", $(element).width() + "px");
        $(element).parent().css("width", ($(element).width() + 20) + "px");

        if (widthTemp1 < widthTemp2) {
            widthTemp1 = widthTemp2;
        }

        $(element).parent().parent().parent().css("width", (widthTemp1 + 32) + "px");
        $('.sub_linksOver').children().css("color", "#4FB94A");

        //$(".menuLinkLI").css("width", (widthTemp1 + 30) + "px");
        $(element).parent().parent().children().css("width", (widthTemp1 + 30) + "px");
        //$(element).parent().parent().children().children().css("color", "#929292");

    }
    );
    $(".sub_links_down").css('display', 'none');
    $(".sub_links_down").css('visibility', 'visible');
}
);


function SetCaruselButtons() {
    var offset = $(".jcarousel-container").offset();
    var lBtn = $(".jcarousel-prev");
    var rBtn = $(".jcarousel-next");
    $(lBtn).css("left", (offset.left - 28) + "px");
    $(lBtn).css("top", (offset.top + $(".jcarousel-container").height() / 2 - lBtn.height() / 2) + "px");

    $(rBtn).css("top", $(lBtn).css("top"));
    $(rBtn).css("left", (offset.left + $(".jcarousel-container").width() - 3) + "px");
}


//Style photos
var imgBig, sMid, sFilename;
function LoadBigImage(mid, filename) {
    sMid = mid;
    sFilename = filename;
    //$('#BigImage').attr('src', img.src);
    //$('#BigImage').attr('class', 'small_preloader');
    imgBig = new Image();
    imgBig.src = 'images/style/' + mid + '/big/' + filename;
    //$('#BigImageLink').attr('href', 'images/style/' + mid + '/large/' + filename);
    imgBig.onload = imageLoad;
}

function imageLoad() {
    document.getElementById('BigImage').src = this.src;
    $('#BigImage').hide();
    $('#BigImage').attr('class', 'full-size-photo');
    $('#BigImage').fadeIn();
}


function LoadIndexImage(filename) {
  
    imgBig = new Image();
    imgBig.src = 'images/index_images/main_photos/' + filename;
    imgBig.onload = imageLoad;
}





function CreateFlashObject(LangID, FilePath, Width, Height, ClassName) {

    document.write("<object " + (ClassName != "" ? "class='" + ClassName + "'" : "") + " classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + Width + "' height='" + Height + "' align='middle'>");
    document.write("<param name='allowScriptAccess' value='sameDomain'>");
    if (LangID != "") document.write("<param name='flashvars' value='LangID=" + LangID + "'>");
    document.write("<param name='wmode' value='transparent'>");
    document.write("<param name='movie' value='" + FilePath + "'>");
    document.write("<param name='quality' value='high'>");
    document.write("<embed src='" + FilePath + "' quality='high' flashvars='LangID=" + LangID + "' width='" + Width + "' height='" + Height + "' align='middle' wmode='transparent' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
    document.write("</object>");
}

function changeDescr(num, name) {
    if ($('#' + name + num).css('display') == 'none') {
        for (var i = 1; i <= 6; i++) {
            $('#' + name + i).css('display', 'none');
            
        }
        $('#' + name + num).fadeIn('slow');
        
        
    }

    $('#card_' + num).prevAll().attr('class', 'bank_cont');
    $('#card_' + num).nextAll().attr('class', 'bank_cont');
    $('#card_' + num).attr('class', 'bank_cont_curent');
    $('#card_' + num).prevAll().children("div").attr('class', 'bank_icons');
    $('#card_' + num).nextAll().children("div").attr('class', 'bank_icons');
    $('#card_' + num).children("div").attr('class', 'bank_icons_over');

    $('#clubS_' + num).prevAll().attr('class', 'bank_cont');
    $('#clubS_' + num).nextAll().attr('class', 'bank_cont');
    $('#clubS_' + num).attr('class', 'bank_cont_curent');
    $('#clubS_' + num).prevAll().children("div").attr('class', 'bank_icons');
    $('#clubS_' + num).nextAll().children("div").attr('class', 'bank_icons');
    $('#clubS_' + num).children("div").attr('class', 'bank_icons_over');


    $('#sertA_' + num).prevAll().attr('class', 'bank_cont');
    $('#sertA_' + num).nextAll().attr('class', 'bank_cont');
    $('#sertA_' + num).attr('class', 'bank_cont_curent');    
    $('#sertA_' + num).prevAll().children("div").attr('class', 'bank_icons');
    $('#sertA_' + num).nextAll().children("div").attr('class', 'bank_icons');
    $('#sertA_' + num).children("div").attr('class', 'bank_icons_over');

    return false;
}

function ChangeIcoPhoto(photo) {
    if ($('#' + photo).attr('class') == 'bank_cont') {
        $('#' + photo).attr('class', 'bank_cont_over');
        $('#' + photo).children().next().attr('class', 'bank_icons_over')
    }
}

function ChangeIcoPhotoBack(photo) {
    if ($('#' + photo).attr('class') == 'bank_cont_over') {
        $('#' + photo).attr('class', 'bank_cont');
        $('#' + photo).children().next().attr('class', 'bank_icons')
    }
}

function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}
