﻿$(document).ready(function() {
    if ($('#rrrock').length > 0)
        $('#rrrock').load($('#rrrock').html() + '#content_center .newsContentFront');
});

//-Karusellin osien sijoittaminen ja nimeäminen--------------------------------------
function bannercarousel() {

    $('.bannerItem').each(function(i) {
        $(this).attr('name', i);
        if ($(this).attr('name') == '0') {
            $(this).show();
            $(this).addClass('current');
        }
        else {
            $(this).hide();
            $(this).removeClass('current');
        }
    });

    $('.bannerText').each(function(i) {
        $(this).attr('name', i);
        if ($(this).attr('name') == '0') {
            $(this).show();
            $(this).addClass('current');
        }
        else {
            $(this).hide();
            $(this).removeClass('current');
        }
    });

    $('.bannerItem:first').addClass('first');
    $('.bannerItem:last').addClass('last');
    $('.bannerText:first').addClass('first');
    $('.bannerText:last').addClass('last');
};

//-Bannerin keskittäminen-----------------------------------------------
function bannercenter() {

    var windowWidth = $(window).width();

    if (windowWidth < 1860) { // jos ikkuna on kapeampi kuin bannerItemArea
        var margin = (windowWidth - 1860) / 2;
        $('#bannerContainer').css('margin-left', margin);
    }
    else // jos ikkuna on leveämpi kuin bannerItemArea
    {
        var margin = (windowWidth - 1860) / 2;
        $('#bannerContainer').css('margin-left', margin);
    }

    var margin = (windowWidth - 970) / 2;
    $('#bannerCenterArea').css('margin-left', margin);

    var heightTop = $('#bannerItemArea .current center').height();
    var ua = $.browser;
    if (heightTop < 500) {
        if(ua.msie == true && ua.version.slice(0,1) == "7"){
            $('.current').css('margin-top', '57px');
        }
        else{
            $('.current').css('margin-top', '53px');
        }
        $('.bannerItem').css('z-index', '9999');
        $('.bannerItem').css('height', '400px');
        $('.bannerItem center').css('height', '400px');
    }

};


var busy = false;

//-Seuraava-painikkeen funktio----------------------------------------------------
function bannerNextItem() {
    if (busy) {
        return;
    } 
    busy = true;
    var next;

    $('#bannerItemArea .bannerItem').each(function() {
        if ($(this).hasClass('current') == true) {
            if ($(this).hasClass('last') == true) {
                next = 0;
            }
            else {
                var current = parseInt($(this).attr('name'));
                next = current + 1;
            }
        };
        
    });

    $('#bannerItemArea .bannerItem').each(function() {
        if ($(this).attr('name') == next) {
            $(this).addClass('newcurrent');
            $(this).css('left', '1860px');
            $(this).show();
            $('#bannerItemArea .current').animate({ left: '-1860px' }, 1000);
            $(this).animate({ left: '0px' }, 1000, function() {
                $('#bannerItemArea .bannerItem').each(function() {
                    if ($(this).hasClass('newcurrent')) {
                        $(this).removeClass('newcurrent');
                        $(this).addClass('current');
                    }
                    else {
                        $(this).removeClass('current');
                        $(this).hide();
                    }
                });
            });
        }
    });

    //-Bannerin kontrollin osalta-------------------------------------------------------
    $('#bannerTextArea .bannerText').each(function() {
        if ($(this).hasClass('current') == true) {
            if ($(this).hasClass('last') == true) {
                next = 0;
            }
            else {
                var current = parseInt($(this).attr('name'));
                next = current + 1;
            }
        };

    });

    $('#bannerTextArea .bannerText').each(function() {
        if ($(this).attr('name') == next) {
            $(this).addClass('newcurrent');
            $(this).css('left', '370px');
            $(this).show();
            $('#bannerTextArea .current').animate({ left: '-370px' }, 1000);
            $(this).animate({ left: '0px' }, 1000, function() {
                $('#bannerTextArea .bannerText').each(function() {
                    if ($(this).hasClass('newcurrent')) {
                        $(this).removeClass('newcurrent');
                        $(this).addClass('current');
                    }
                    else {
                        $(this).removeClass('current');
                        $(this).hide();
                    }
                    busy = false;
                });
                
            });
        }
    });
    
};

//-Edellinen-painikkeen funktio----------------------------------------------------
function bannerPreviousItem() {
    if (busy) {
        return;
    }
    busy = true;
    var prev;
    $('#bannerItemArea .bannerItem').each(function() {
        if ($(this).hasClass('current') == true) {
            if ($(this).hasClass('first') == true) {
                prev = parseInt($('#bannerItemArea .last').attr('name'));
            }
            else {
                var current = parseInt($(this).attr('name'));
                prev = current - 1;
            }
        };

    });

    $('#bannerItemArea .bannerItem').each(function() {
        if ($(this).attr('name') == prev) {
            $(this).addClass('newcurrent');
            $(this).css('left', '-1860px');
            $(this).show();
            $('#bannerItemArea .current').animate({ left: '1860px' }, 1000);
            $(this).animate({ left: '0px' }, 1000, function() {
                $('#bannerItemArea .bannerItem').each(function() {
                    if ($(this).hasClass('newcurrent')) {
                        $(this).removeClass('newcurrent');
                        $(this).addClass('current');
                    }
                    else {
                        $(this).removeClass('current');
                        $(this).hide();
                    }
                });
            });
        }
    });

    //-Bannerin kontrollin osalta-------------------------------------------------------
    $('#bannerTextArea .bannerText').each(function() {
        if ($(this).hasClass('current') == true) {
            if ($(this).hasClass('first') == true) {
                next = parseInt($('#bannerTextArea .last').attr('name'));
            }
            else {
                var current = parseInt($(this).attr('name'));
                next = current - 1;
            }
        };

    });

    $('#bannerTextArea .bannerText').each(function() {
        if ($(this).attr('name') == next) {
            $(this).addClass('newcurrent');
            $(this).css('left', '-370px');
            $(this).show();
            $('#bannerTextArea .current').animate({ left: '370px' }, 1000);
            $(this).animate({ left: '0px' }, 1000, function() {
                $('#bannerTextArea .bannerText').each(function() {
                    if ($(this).hasClass('newcurrent')) {
                        $(this).removeClass('newcurrent');
                        $(this).addClass('current');
                    }
                    else {
                        $(this).removeClass('current');
                        $(this).hide();
                    }
                    busy = false;
                });
            });
        }
    });

};

//-Bannerin automaattisen kierron funktio-------------------------
function timeoutcall() {
    var count = 0;
    $('#bannerItemArea .bannerItem').each(function(i) {
        count += 1;
    });

    if (count > 1) {
        bannerNextItem();
        var duration = 8000;
        window.setTimeout(timeoutcall, duration);
    }
}


//----------------------------------------------------------------
//----------------------------------------------------------------
$(document).ready(function() {
    bannercarousel();

    bannercenter();

    $(window).bind('resize', function() {
        bannercenter();
    });


    $('#bannerPreviousItem a').click(function() {
        bannerPreviousItem();
    });

    $('#bannerNextItem a').click(function() {
        bannerNextItem();
    });

    //-Jos bannerissa on vain yksi elementti, bannerin kontrolleja ei näytetä-----
    var i = 0;
    $('#bannerTextArea .bannerText').each(function() {
        i = i + 1;
    });
    if (i <= 1) {
        $('#bannerItemArea .current').css('position', 'relative');
        $('#bannerControl').css('display', 'none');
    }

    //-Bannerin automaattisen kierron kutsunta------------------------------------
    var duration = 8000;
    window.setTimeout(timeoutcall, duration);


    //------------------------------------------------------------------
    //------------------------------------------------------------------

    // Cufon -tekstimuunnos
    // Määritellään elementit, joihin Cufon vaikuttaa
    Cufon.replace('h1, .FooterHeaderLink');

    //------------------------------------------------------------------

    // Tekstin koko
    var minSize = 10;           // Tekstin minimikoko
    var maxSize = 14;           // Tekstin maksimikoko
    var target = '#stuff';      // Millä alueella tekstin muutos vaikuttaa
    var container = '#zoom';    // Millä alueella suurennus- ja pienennys-painikkeet ovat

    // Katsotaan cookiesta onko tälle sivulle määritelty aiemmin muutettua tekstin kokoa, jos on otetaan se käyttöön
    // HUOM! Teksin koko täytyy käydä muuttamassa jokaisella sivulla erikseen
    if ($.cookie != undefined) {
        var cookie = target.replace(/[#. ]/g, '');

        var value = $.cookie(cookie);
        if (value != null) {
            $(target).css('font-size', parseInt(value));
        }
    }

    // Määritellään, mitä tapahtuu kun klikataan tekstin pienennys-painikkeesta
    $(container + " .smallFont").click(function() {
        curSize = parseInt($(target).css("font-size"));
        newSize = curSize - 1;
        if (newSize >= minSize) {
            $(target).css('font-size', newSize);
        }
        if (newSize <= minSize) {
            $(container + " .smallFont").addClass("sdisabled");
        }
        if (newSize < maxSize) {
            $(container + " .largeFont").removeClass("ldisabled");
        }
        updatefontCookie(target, newSize); //set the cookie
    });

    // Määritellään, mitä tapahtuu kun klikataan tekstin suurennus-painikkeesta
    $(container + " .largeFont").click(function() {
        curSize = parseInt($(target).css("font-size"));
        newSize = curSize + 1;
        if (newSize <= maxSize) {
            $(target).css('font-size', newSize);
        }
        if (newSize > minSize) {
            $(container + " .smallFont").removeClass("sdisabled");
        }
        if (newSize >= maxSize) {
            $(container + " .largeFont").addClass("ldisabled");
        }
        updatefontCookie(target, newSize); // Käsketään päivittää tekstikoon muutokset cookieen
    });

    // Päivitetään tekstikoon muutokset cookieen
    function updatefontCookie(target, size) {
        if ($.cookie != undefined) { //If cookie plugin available, set a cookie
            var cookie = target.replace(/[#. ]/g, '');
            $.cookie(cookie, size);
        }
    }

    //------------------------------------------------------------------

    // Etusivun palstojen tasaus (täysin dynaaminen)
    // Lasketaan kunkin palstan korkeus ja annetaan kaikille sama korkeus kuin korkeimmalla palstalla
    var highestCol = Math.max($('#content #content_left .content').height(), $('#content #content_center .content').height(), $('#content #content_right .content').height());
    $('#content .content').height(highestCol);

    var highestFoot = Math.max($('#footer .container #foot_left ').height(), $('#footer .container #foot_center').height(), $('#footer .container #foot_right').height());
    $('#footer #foot_left').height(highestFoot);
    $('#footer #foot_center').height(highestFoot);
    $('#footer #foot_right').height(highestFoot);

    //------------------------------------------------------------------

    // ol-elementin li-elementtien eteen lisätään numero.
    $('ol li').each(function(i) {
        var strinki = $(this).text();
        a = i + 1;
        $(this).replaceWith('<li><span class="numberClass">' + a + '.</span>' + strinki + '</li>');
    });

    //------------------------------------------------------------------

    // Sivutuksen kopiointi sivun alalaidasta ylälaitaan silloin kun sivulla on sivutus käytössä
    $('.paginationUpper').replaceWith($('.pagination').html());

    //------------------------------------------------------------------

    // Sivutuksen tyylien asettaminen
    $('a[title="First page"]').text('');
    $('a[title="Previous page"]').text('');
    $('a[title="Next page"]').text('');
    $('a[title="Last page"]').text('');

    $('a[title="Ensimm&auml;inen sivu"]').text('');
    $('a[title="Edellinen sivu"]').text('');
    $('a[title="Seuraava sivu"]').text('');
    $('a[title="Viimeinen sivu"]').text('');
    // Laitetaan sivutuksessa käytetyt elementit asettumaan nätisti paikoilleen
    $('.PagingContainer').before('<div class="separator"></div>');

    //------------------------------------------------------------------

    // Sivutuksen numerointi
    $('a.UnselectedPagingItem').css('display', 'none');

    $('[title~=First]').css('display', 'inline');
    $('[title~=Previous]').css('display', 'inline');
    $('[title~=Next]').css('display', 'inline');
    $('[title~=Last]').css('display', 'inline');

    $('[title~=Ensimmäinen]').css('display', 'inline');
    $('[title~=Ensimmäinen]').css('margin', ' 0 6px 0 8px');
    $('[title~=Ensimmäinen]').css('padding', ' 0 8px !important');
    //$('[title~=Ensimmäinen]').css('background', 'url("/Templates/Nurminen/Images/arrow_l4.png") no-repeat 0 3px');
    $('[title~=Ensimmäinen]').html('<img src="/Templates/Nurminen/Images/arrow_l4.png" alt="<<"/>');
    $('[title~=Edellinen]').css('display', 'inline');
    $('[title~=Seuraava]').css('display', 'inline');
    $('[title~=Viimeinen]').css('display', 'inline');

    $('a.SelectedPagingItem').next().next().css('display', 'inline');
    $('a.SelectedPagingItem').next().next().next().next().css('display', 'inline');

    $('a.SelectedPagingItem').prev().prev().css('display', 'inline');
    $('a.SelectedPagingItem').prev().prev().prev().prev().css('display', 'inline');

    //------------------------------------------------------------------

    // Julkaisuiden ja uutiskirjeiden rivitys
    $('.publicationInformation').each(function(i) {
        if (i % 2 == 0) {
            $(this).addClass('publicationLeft');
        }
        else {
            $(this).addClass('publicationRight');
            $(this).after('<div class="separator"></div>')
        }
    });

    //------------------------------------------------------------------

    // Lomakkeiden vaaditut kentät
    $("#id_matrix").each(function() {
        $(".xformvalidator").each(function() {

            if ($(this).text() == 'Tämä kenttä on pakollinen' && $(this).parent().find(":first-child legend").text() != '') {
                $(this).parent().find(":first-child legend").append('<span class="requiredOnForm">&nbsp;*</span>');
            }
            else if ($(this).text() == 'Tämä kenttä on pakollinen') {
                $(this).parent().children(":first-child").append('<span class="requiredOnForm">&nbsp;*</span>');
            }
            else if ($(this).text() == 'This field is required' && $(this).parent().find(":first-child legend").text() != '') {
                $(this).parent().find(":first-child legend").append('<span class="requiredOnForm">&nbsp;*</span>');
            }
            else if ($(this).text() == 'This field is required') {
                $(this).parent().children(":first-child").append('<span class="requiredOnForm">&nbsp;*</span>');
            }
        });
    });

    $('.radiobuttons').before('<div class="errorNote" style="display:none;"></div>');
    $('.errorNote').html($('.superErrorNote').html());
    //$('.errorNote').hide();
    $('.superErrorNote').hide();


    //------------------------------------------------------------------

    // Kenttien tarkastus
    $('.send').click(function() {
        $("#id_matrix .xformvalidator").each(function() {
            if ($(this).text() == 'This field is required' || $(this).text() == 'Tämä kenttä on pakollinen') {
                if ($(this).parent().children(':text').val() == "") {
                    $(this).parent().children(':text').addClass('unfilled');
                }
                else if ($(this).parent().children('textarea').val() == "") {
                    $(this).parent().children('textarea').addClass('unfilled');
                }
            }
            $('.errorNote').show();
        });
    });

    $('.unfilled').click(function() {
        $('.unfilled').removeClass('unfilled');
    });

    //------------------------------------------------------------------

    // Lomakkeiden karttalinkit
    // Tämä asettaa linkin GoogleMapPickeriin halutun kentän viereen. Ko. kentälle täytyy määritellä luokka "mapMe".
    $("#id_matrix td .gmap").each(function() {
        $(this).parent().append('<a href="/Templates/Nurminen/Utils/GoogleMapsPicker.aspx?returnControl=' + $(this).attr('id') + '" rel="ColorboxMap" class="mapMeLink" >Valitse kartalta</a>');
    });

    //------------------------------------------------------------------

    // Lomakkeen pudotusvalikko (ei toimi IE:llä)
    $("#id_matrix select").each(function() {

        $(this).addClass('mySelectBoxClass');

    });

    //------------------------------------------------------------------

    // Lomakkeiden peruuta-painikkeet
    // Korvataan "cancel"-luokkaiset spanit reset-painikkeella
    var arvo = $('#id_matrix span.cancel').text();
    $('#id_matrix span.cancel').replaceWith('<input type="reset" class="cancel" value=' + arvo + '></input>');

    $('#id_matrix tr').each(function() {
        if ($(this).find('input').hasClass('cancel') == true) {
            $(this).css('width', '75px');
            $(this).css('float', 'left');
        }
        if ($(this).find('input').hasClass('send') == true) {
            $(this).css('width', '400px');
            $(this).find('td').css('width', '400px');
            $(this).css('float', 'right');

        }
    });

    //------------------------------------------------------------------

    // Lomakkeiden kalenterilinkit 
    $('.calendarMe').datePicker({ clickInput: true });

    //------------------------------------------------------------------

    // Lomakkeiden kenttien esimerkkitekstit
    var DefaultValue = $('#MapPlaceTranslate').text();
    $('.mapMe').each(function() {
        if ($(this).val() == '') {
            $(this).val(DefaultValue);
        }

        $(this).click(function() {
            if ($(this).val() == DefaultValue) {
                $(this).val('');
            }
        });

    });

    $('.mapMe').blur(function() {
        if ($(this).val() == '') {
            $(this).val(DefaultValue);
        }
    });


    //------------------------------------------------------------------

    // PageListTablen korkeus ja pitäminen ruodussa
    $('.PageListName').after('<div class="separator"></div>');

    //------------------------------------------------------------------

    // Referenssien henkilötyietoihin rivinvaihto pilkun kohdalle
    $("p.authorInfo").each(function() {
        var str1 = $(this).html().replace(",", "<br />");
        $(this).html(str1)
        var str2 = $(this).html().replace(",", "<br />");
        $(this).html(str2)
    });

    //------------------------------------------------------------------

    $('#content_right25 img').each(function() {
        if ($(this).attr('src') == "") {
            $(this).hide();
        }
    });


    //------------------------------------------------------------------

    //Colorbox

    $('img').each(function() {
        if ($(this).hasClass('image')) {
            var src = $(this).attr('src').replace('img_T', 'img_L');
            var a = $('<a/>').attr('href', src);
            $(this).wrap(a.attr('class', 'image'));
        }

        else if ($(this).hasClass('video')) {
            var src = $(this).attr('src').replace('img_T', 'img_L');
            var a = $('<a/>').attr('href', src);
            $(this).wrap(a.attr('class', 'video'));
        }

        else if ($(this).hasClass('slideshow')) {
            var src = $(this).attr('src').replace('img_T', 'img_L');
            var a = $('<a/>').attr('href', src);
            $(this).wrap(a.attr('class', 'slideshow'));
        }

        else if ($(this).hasClass('wwwpage')) {
            var src = $(this).attr('src').replace('img_T', 'img_L');
            var a = $('<a/>').attr('href', src);
            $(this).wrap(a.attr('class', 'wwwpage'));
        }

        else if ($(this).hasClass('hiddenImage')) {
            var src = $(this).attr('src').replace('img_T', 'img_L');
            var a = $('<a/>').attr('href', src);
            $(this).wrap(a.attr('class', 'hiddenImage'));
        }

        else if ($(this).hasClass('videoframe')) {
            var src = $(this).attr('src').replace('img_T', 'img_L');
            var a = $('<a/>').attr('href', src);
            $(this).wrap(a.attr('class', 'videoframe'));
        }

        else if ($(this).hasClass('sigimage')) {
            var src = $(this).attr('src').replace('img_T', 'img_L');
            var a = $('<a/>').attr('href', src);
            $(this).wrap(a.attr('class', 'sigimage'));
        }
    });


    $('a').each(function() {
        if ($(this).hasClass('image')) {
            $(this).attr('rel', 'image');
        }

        else if ($(this).hasClass('video')) {
            $(this).attr('rel', 'video');
        }

        else if ($(this).hasClass('slideshow')) {
            $(this).attr('rel', 'slideshow');
        }

        else if ($(this).hasClass('wwwpage')) {
            $(this).attr('rel', 'wwwpage');
        }

        else if ($(this).hasClass('hiddenImage')) {
            $(this).attr('rel', 'hiddenImage');
            var a = $(this).next('a').attr('href');
            $(this).attr('href', a);
        }

        else if ($(this).hasClass('videoframe')) {
            $(this).attr('rel', 'videoframe');
        }

        else if ($(this).hasClass('sigimage')) {
            $(this).attr('rel', 'sigimage');
        }
    });

    $("a[class='image']").attr("rel", "image");
    $("a[class='sigimage']").attr("rel", "sigimage");
    $("a[class='wwwpage']").attr("rel", "wwwpage");
    $("a[class='video']").attr("rel", "video");
    $("a[class='slideshow']").attr("rel", "slideshow");
    $("a[class='hiddenImage']").attr("rel", "hiddenImage");
    $("a[class='videoframe']").attr("rel", "videoframe");

    $("[rel='ColorboxMap']").colorbox({ width: "650px", iframe: true, height: "500px", scrolling: false });
    $("[rel='image']").colorboxa({ photo: true, title: true });
    $("[rel='sigimage']").colorboxa({ photo: true, maxWidth: "960", title: true });
    $("[rel='wwwpage']").colorboxa({ height: "80%", width: "80%", iframe: true });
    $("[rel='video']").colorboxa({ width: 650, height: 500 });
    $("[rel='slideshow']").colorboxa({ slideshow: true });
    $("[rel='hiddenImage']").colorboxa({ photo: true, title: true });

    if ($.browser.msie && $.browser.version.substr(0, 1) < 8) {
        $("[rel='videoframe']").colorboxa({ width: 778, height: 506 });
    }
    else {
        $("[rel='videoframe']").colorboxa({ width: 778, height: 477 });
    }

    //------------------------------------------------------------------

    $(".contactInformationImage img").each(function() {
        if ($(this).attr("src") == "") {
            //alert($(this).attr("src"));
            $(this).css("display", "none");
        }
    });


    $(".PageListImage").each(function() {
        if ($(this).attr("src") == "") {
            //alert($(this).attr("src"));
            $(this).attr("src", "/templates/Nurminen/Images/dummy.gif");
            $(this).height(100);
            $(this).width(140);
        }
    });

    $('.referencePersonImage img').each(function() {
        if ($(this).attr("src") == "") {
            $(this).parent().css('display', 'none');
        }
    });

    $('.customerIngress').each(function() {
        if ($(this).find('.referenceSitate').height() < ($(this).find('.referencePersonImage').height()) + 75) {
            $(this).find('.referenceSitate').width(290);
            $(this).find('.referenceSitate').css('float', 'right');
        }
    });

    $('.supplierIngress').each(function() {
        if ($(this).find('.referenceSitate').height() < ($(this).find('.referencePersonImage').height()) + 75) {
            $(this).find('.referenceSitate').width(290);
            $(this).find('.referenceSitate').css('float', 'right');
        }
    });

    //------------------------------------------------------------------

    // Poistetaan tyhjät sivutuspalkit
    $('.paginationBar p').each(function() {
        if ($(this).text() == $(this).html()) {
            $(this).parent().css('display', 'none');
        }
    });

    //------------------------------------------------------------------

    $('#content_center50').before('<div class="printed logo"><img src="/templates/Nurminen/Images/print_nurminen.png" alt="Nurminen Logistics" /></div>');

    //------------------------------------------------------------------

    //Taulukoiden muotoiluja
    $('table').each(function() {

        $(this).find('tr:first').addClass('taulukko_header');

        $(this).find('tr').each(function(i) {
            $('tr:even').addClass('evenRow');
            $('tr:odd').addClass('oddRow');
        });

    });


    $('.vapaakalusto').each(function() {

        $(this).removeClass('taulukko');
        $(this).find('tr:first').addClass('vapaakalusto_header');

        $(this).find('tr').each(function(i) {
            $(this).attr('title', 'Klikkaa ja kysy sähköpostitse')
            $('tr:even').addClass('evenRow');
            $('tr:odd').addClass('oddRow');
        });

    });

    //------------------------------------------------------------------


    if (window.location.href.split("/")[3] == 'en') {
        $('#aux .en').addClass('SelectedLanguage');
    }
    else if (window.location.href.split("/")[3] == 'fi') {
        $('#aux .fi').addClass('SelectedLanguage');
    }
    else if (window.location.href.split("/")[3] == 'ru') {
        $('#aux .ru').addClass('SelectedLanguage');
    }

    //------------------------------------------------------------------

    $('#logistics td p').each(function() {
        if ($(this).html() == "&nbsp;") {
            $(this).replaceWith('<span></span>');
        }
    });
    
    //------------------------------------------------------------------

    var i = 0
    $('.content_nsq h1 cufon').each(function() {
        i = i + 1;
        if (i > 1) {
            $(this).parent().width('100%');
        }
        else {
            $(this).parent().width($(this).width());
        }
    });

});

$(document).ready(function() {
    $('.mySelectBoxClass').customStyle();
});

$(function() {

    $("input").keypress(function(e) {
        if (($(this).attr('id') == 'SearchQueryText') && ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))) {
            $('input.defaultSearchButton').click();
        }
        else if (($(this).attr('id') != 'SearchQueryText') && ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))) {
            $('input[type=submit]').each(function() {
                var isDefaultButton = $(this).hasClass('defaultSearchButton');
                if (!isDefaultButton) {
                    $('input.defaultSearchButton').attr('onclick', '');
                    $('input.defaultSearchButton').click(function() { return false; });
                    $(this).click();
                }
            });
        }
    });

});

