﻿var awad_link_color = "#01b350";
var maki_link_color = "#01a248";
var yama_link_color = "#019141";
var   ai_link_color = "#018039";
var tana_link_color = "#016f31";
var maro_link_color = "#015e2a";

$(document).ready(function () {

    $(".awad_prof_link").colorHover( { color : awad_link_color } );
    $(".maki_prof_link").colorHover( { color : maki_link_color } );
    $(".yama_prof_link").colorHover( { color : yama_link_color } );
    $(".ai_prof_link"  ).colorHover( { color :   ai_link_color } );
    $(".tana_prof_link").colorHover( { color : tana_link_color } );
    $(".maro_prof_link").colorHover( { color : maro_link_color } );

});

(function ($) {

    var name_space = 'replaceTargetHTML';

    $.fn[name_space] = function () {

        var i = 0;

        return function (options) {

            options = $.extend({
                'target': "",
                'contents': ""
            }, options);

            var fadeSpeed = 100;
            var newcontents = $(options.contents).html();
            
            this.click(function () {
                $(options.target).fadeTo(fadeSpeed, 0, function(){$(options.target).empty();$(options.target).append(newcontents);} );
                $(options.target).fadeTo(fadeSpeed, 1);
                alert(i);
                i++;
            });

            return this;
        };

    }();

})(jQuery);

(function ($) {

    var name_space = 'ContentsHandler';

    $.fn[name_space] = function () {

        var currentSelectionKey = "top";

        var contentsMap = {
            "top"            : ".all_prof",
            "awad_prof_link" : ".awad_prof",
            "maki_prof_link" : ".maki_prof",
            "yama_prof_link" : ".yama_prof",
            "ai_prof_link"   : ".ai_prof",
            "tana_prof_link" : ".tana_prof",
            "maro_prof_link" : ".maro_prof"        
        };

        var selectorParent = ".mem_list";

        var htmlMap = {
            "top"            : "",
            "awad_prof_link" : "",
            "maki_prof_link" : "",
            "yama_prof_link" : "",
            "ai_prof_link"   : "",
            "tana_prof_link" : "",
            "maro_prof_link"   : ""
        };

        return function (options) {

            currentSelectionKey = "top";

            var fadeSpeed = 800;
            var selectors = $(selectorParent).children();

            htmlMap["top"]            = $(".all_prof" ).html();
            htmlMap["awad_prof_link"] = $(".awad_prof").html();
            htmlMap["maki_prof_link"] = $(".maki_prof").html();
            htmlMap["yama_prof_link"] = $(".yama_prof").html();
            htmlMap["ai_prof_link"]   = $(".ai_prof"  ).html();
            htmlMap["tana_prof_link"] = $(".tana_prof").html();
            htmlMap["maro_prof_link"] = $(".maro_prof").html();

            $(".awad_prof").empty();
            $(".maki_prof").empty();
            $(".yama_prof").empty();
            $(".ai_prof"  ).empty();
            $(".tana_prof").empty();
            $(".maro_prof").empty();

            
            selectors.each(function() {

                var thisKey = $(this).attr("class");
                $(contentsMap[thisKey]).css("opacity", 0);
                
                $(this).click(function () {
                    var newSelectionKey = $(this).attr("class");

                    if ( newSelectionKey == currentSelectionKey )
                        return;

                    var newContentsObjectName = contentsMap[newSelectionKey];         
                    var oldContentsObjectName = contentsMap[currentSelectionKey];
                    
                    $(newContentsObjectName).append(htmlMap[newSelectionKey]);
                             
                    $(newContentsObjectName).animate({opacity : 1.0}, fadeSpeed, function(){$(".prettyPhoto").prettyPhoto({theme: 'facebook'});}); // , /* light_rounded / dark_rounded / light_square / dark_square / facebook */
                    $(oldContentsObjectName).animate({opacity : 0.0}, fadeSpeed, function(){$(oldContentsObjectName).empty()});

                    currentSelectionKey = newSelectionKey;
                });            
            });

            $('.memimg').click(function () {currentSelectionKey = "top"});
            $('#Members').click(function () {currentSelectionKey = "top"});

            return this;
        };

    }();

})(jQuery);


(function ($) {

    var name_space = 'replaceTargetHTML2';

    $.fn[name_space] =
    function (options) {

        options = $.extend({
            'target': "",
            'contents': ""
        }, options);

        var fadeSpeed = 100;
        var newcontents = $(options.contents).html();
        
        $(options.contents).css({"opacity": 0, "position": "absolute", "top": "0px", "left": "0px"}).appendTo(options.target);
            
        this.click(function () {
            var childrens = $(options.target).children();
            $(options.contents).css({"opacity": 0, "position": "absolute", "top": "0px", "left": "0px"}).appendTo(options.target);
            var newElement = $(options.target).children(options.contents);
            childrens.fadeOut(fadeSpeed);
            newElement.fadeIn(fadeSpeed);           
        });

        return this;
    };

})(jQuery);

(function ($) {

    var name_space = 'colorHover';

    $.fn[name_space] =
    function (options) {

        options = $.extend({
            'color': "#bbb",
            'defopacity': 1.0,
            'inopacity': 1.0,
            'outopacity': 1.0
        }, options);

        $(this).css("opacity", options.defopacity);
        
        this.hover(
            function () {
                $(this).css("color", options.color);
                $(this).css("cursor", "pointer");
                $(this).css("opacity", options.inopacity);
            },
            function () {
                $(this).css("color", "#bbb");
                $(this).css("cursor", "default");
                $(this).css("opacity", options.outopacity);
             }
        );

        return this;
    };

})(jQuery);


