﻿$(document).ready(function () {
    site_search();
    side_panel();
    content_bar();
    image_view();
    home_tabs();
    error_style();
});

function error_style() {
    $('.sb_reg .errorMsg:not(:empty)').addClass('errorBox');
}

function site_search() {
    $(".site_search input[type='text']").focus(function (srcc) {
        if ($(this).val() == $(this)[0].title) {
            $(this).val("");
        }
    });

    $(".site_search input[type='text']").blur(function () {
        if ($(this).val() == "") {
            $(this).val($(this)[0].title);
        }
    });

    $(".site_search input[type='text']").blur();
}

function home_tabs() {
    $('#tabs').tabs({
        fx: {
            opacity: 'toggle',
            duration: 'slow'
        }
    });
    $('#tabs2').tabs({
        fx: {
            opacity: 'toggle',
            duration: 'slow'
        }
    });
}

function side_panel() {
    $(".sidepanel").children("h2").click(function () {
        //only open/close item if a closed item was clicked
        if ($(this).hasClass("closed")) {

            //change the class on the item that was just clicked
            $(this).addClass("open");
            $(this).removeClass("closed");

            //change class of the div we should open
            $(this).parent().children("div").addClass("open");

            //finally slide down the content
            $(this).parent().children("div").slideDown();
        } else {

            //change the class on the item that was just clicked
            $(this).addClass("closed");
            $(this).removeClass("open");

            //change class of the div we should open
            $(this).parent().children("div").addClass("open");

            $(this).parent().children("div").slideUp();
        }
    });
}

function content_bar() {
    $(".contentbar").children("h2").click(function () {
        //only open/close item if a closed item was clicked
        if ($(this).hasClass("closed")) {
            //slide up the open element
            $(".contentbar").children("div.open").slideUp();
            //change the h2 class of the currently open panel
            $(".contentbar").children("h2.open").addClass("closed");
            $(".contentbar").children("h2.open").removeClass("open");

            //change the class on the item that was just clicked
            $(this).addClass("open");
            $(this).removeClass("closed");

            //change class of the div we should open
            $(this).parent().children("div").addClass("open");

            //finally slide down the content
            $(this).parent().children("div").slideDown();
        }
    });
}

function image_view() {
    $("a[rel^='prettyPhoto']").prettyPhoto({
        animation_speed: 'normal',
        /* fast/slow/normal */
        slideshow: false,
        /* false OR interval time in ms */
        autoplay_slideshow: false,
        /* true/false */
        opacity: 0.80,
        /* Value between 0 and 1 */
        show_title: false,
        /* true/false */
        allow_resize: true,
        /* Resize the photos bigger than viewport. true/false */
        //default_width: 500,
        //default_height: 344,
        theme: 'pp_default',
        /* light_rounded / dark_rounded / light_square / dark_square / facebook */
        autoplay: false,
        /* Automatically start videos: True/False */
        callback: function () { } /* Called when prettyPhoto is closed */
    });
}
