﻿
$(document).ready(function() {
    //start fuctions(onload)//

    //Binders
    m.WallRebind();
    m.VoteRebind();
    m.Messages();
    m.inlineEditIni();
    m.iniPhoto();
    m.iniFriends();
    m.iniWpPublic();

    //songs
    $(".del_from_songs").click(function() {
        var strId = $(this).attr("id");
        var arrS = strId.split("-");
        $("#si-" + arrS[1]).addClass("alpha");
        var r = confirm("smazat?");
        if (r == true) {
            m.GPost("del_from_songs", arrS[1]);
            $("#si-" + arrS[1]).fadeOut("fast");
        }
        else
        { $("#si-" + arrS[1]).removeClass("alpha"); }
        return false;
    });

    //other
    $("#sendPw").click(function() { $("#send_mail_wrp").fadeIn(); return false; });
    $("#send_mail_wrp a").click(function() { m.ReSendPw($("#send_mail_wrp input").val()); return false; });
    $("#join_school").click(function() { var strHref = $(this).attr("href"); var arrS = strHref.split("#"); m.GPost("join_school", arrS[1]); return false; });
    $(".GoTo").click(function() { window.location = $(this).attr("href"); return false; });
    $("#detail_tabs a").click(function() { var strTabId = this.title; $(".tab_content").hide(); $("#" + strTabId).show(); $("#detail_tabs a").removeClass("current"); $(this).addClass("current"); return false; });
    $(".empty_input").focus(function() {$(this).val("");return false;});
    $("#inv_friend .button").click(function() {m.GPost("InviteFriend", $("#inv_name").val(), $("#inv_email").val(), $("#inv_message").val()); $("#inv_friend").empty(); $("#inv_friend").append("<div class='message_call'>poslal jsem email...</div>"); $("#inv_friend").fadeIn("fast"); return false; });
    $(".link_com a").click(function() {var url = $(this).attr("href"); var arrS = url.split("#");  m.GPost("PostLinkComment", $("#link_com_wrp_" + arrS[1] + " textarea").val(), arrS[1]); $("#link_com_wrp_" + arrS[1]).fadeOut("fast"); $("#link_com_wrp_" + arrS[1] + " textarea").val(""); return false;});
    $(".show_com").click(function() {var url = $(this).attr("href"); var arrS = url.split("#"); $("#link_com_wrp_" + arrS[1]).fadeIn("fast"); return false;});


    $(".close_message").click(function() {
        $("#alert_call").hide();
        return false;
    });

    $("#status_btn").click(function() {
        $(this).fadeOut("fast");
        m.GPost("UpdateUserStatus", $("#status_text").val());
        $("#updated_user_status").empty().append($("#status_text").val());
        return false;
    });

});  //end doc.ready



// Class Library
function UI(id) {this._id = id;}
UI.prototype._id;
UI.prototype.getName = function() {return this._n;}
var m = new UI();

//messages class
UI.prototype.Messages = function(str, n) {
    $("#messageForm a#send").click(function() { 
        m.SendMessage($("#messageForm #mTo").val(), $("#messageForm #mSubject").val(), $("#messageForm #mMessage").val()); $("#messageW").slideUp("fast"); $(".user").show(); $("#messages_table").show(); 
        return false; });
    $(".ping").click(function() { var strId = $(this).attr("href"); var arrS = strId.split("#"); m.SendMessage(arrS[1], "Ping od " + arrS[2], "" + arrS[3]); $(this).fadeOut("slow"); return false; });
    $("#messageForm a#cancel").click(function() { $("#messageW").slideUp("fast"); $("#messages_table").show(); return false; });

    $(".SendMessage").click(function() {
        $("#messageW").slideDown("slow");
        $(".user").hide();
        var strTo = this.title;
        $("#mTo").val("");
        $("#mSubject").val("");
        $("#mMessage").val("");
        $("#mTo").val(strTo);
        return false;
    });

    $(".del_message").click(function() {
        var strHref = $(this).attr("href");
        var arrS = strHref.split("#");
        $("#l" + arrS[1]).addClass("alpha");
        var delMsg = m.deleteMessage(arrS[1]);
        if (delMsg == "yes")
        { $("#l" + arrS[1]).hide(); }
        else
        { $("#l" + arrS[1]).removeClass("alpha"); }
        return false;
    });

    $("#show_message1").click(function() {
        $(this).hide();
        $("#message1_body").slideDown("fast");
        return false;
    });

    $(".m_l").hover(function() {
        $(this).children('td').addClass("msg_hover");
    }, function() {
        $(this).children('td').removeClass("msg_hover");
    });

    $(".m_l").click(function() {
        var strMT
        var strId = $(this).attr("id");
        strId = strId.slice(1);
        var strClass = m.Right($(this).attr("class"), 4);

        //creating string for updating message# session
        if (strClass == " new") {
            var url = "ajax_get.aspx?m=GetMessageBody&p=" + strId + "&p2=new";
        }
        else {
            var url = "ajax_get.aspx?m=GetMessageBody&p=" + strId + "&p2=old";
        }

        if (strClass == "open") {
            $("#ax_tr_" + strId).hide();
            $(this).removeClass("open");
        }
        else {
            //loader image
            $("#l" + strId + " .status").empty();
            $("#l" + strId + " .status").append("<img src='images/progress.gif' alt='progress' />");
            $(this).addClass("read");
            $(this).addClass("open");
            $.get(url, function(data) {
                if (data.toString() == "chyba!") {
                    alert(data);
                }
                else {
                    $("#l" + strId).after("<tr id='ax_tr_" + strId + "' class='ex_tr'><td colspan='5'>" + data + "</td></tr>");
                    $("#l" + strId + " .status").empty();
                }
            });
        }
        $(this).removeClass("m_nr");
        return false;
    });
}

UI.prototype.Right = function(str, n){
    //trims right
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

UI.prototype.Left = function(str, n){
    //trims left
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else
        return String(str).substring(0,n);
}

UI.prototype.replySend = function(strTo, strId){
    var subj = $("#re_sub_" + strId).val();
    var reMsg = $("#re_msg_" + strId).val();
    m.SendMessage(strTo, subj, reMsg); 
    $("#ax_tr_re" + strId + " div").slideUp("fast", function () {
        $("#ax_tr_re" + strId).remove();
    });
    return false; 
}

UI.prototype.replyCancel = function(strId){
    $("#ax_tr_re" + strId).remove();
    return false; 
}

UI.prototype.reply = function(strTo, strId){
    var subj = $("#sub_" + strId).text();
    $("#ax_tr_" + strId).after("<tr id=\"ax_tr_re" + strId + "\" class=\"message_re_wrp\"><td colspan=\"5\"><div><label>Předmět:</label><input id=\"re_sub_" + strId + "\" value=\"RE: " + subj + "\"><br /><label>Zpráva:</label><textarea id=\"re_msg_" + strId + "\" rows=\"5\"></textarea><div class=\"clearfix\"><a class=\"button left\" onclick=\"m.replySend('" + strTo + "', '" + strId + "');\">odeslat!</a><a onclick=\"m.replyCancel('" + strId + "');\" class=\"button right\">zrušit!</a></div></div></td></tr>")
    return false; 
//    //set link
//    $("#messageW").slideDown("fast");
//    $("#messages_table").hide();
//    
//    //clears form
//    $("#mTo").val("");
//    $("#mSubject").val("");
//    $("#mMessage").val("");
//    //pouplatest TO        
//    $("#mTo").val(strTo);
}

UI.prototype.InsertLog = function(strLink, strHeader, strText, strImgLing){
    $.post("ajax_post.aspx",
    { m: "InsertLog", 
    p: strLink, 
    p2: strHeader, 
    p3: strText, 
    p4: strImgLing}, 
    function(data){
            m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.ChangeWpSt = function(strWpRId, strChTo, strPageId){
            $.post("ajax_post.aspx",
            { m: "ChangeWpSt", 
            p: strWpRId, 
            p2: strChTo,
            p3: strPageId}, 
            function(data){
                //m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.DeleteFolder = function(strFlId){
            $.post("ajax_post.aspx",
            { m: "DeleteFolder", 
            p: strFlId}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.ReSendPw = function(strEmail){
            $.post("ajax_post.aspx",
            { m: "ReSendPw", 
            p: strEmail}, 
            function(data){
                m.AlertMessage(data);
                if (data == "poslal ti jsem helso!")
                {
                    $("#send_mail_wrp").fadeOut();
                }
        }
    );
 return false;
}

UI.prototype.InserIntoFolder = function(strImgId, strAlbId){

            $.post("ajax_post.aspx",
            { m: "InserIntoFolder", 
            p: strImgId, 
            p2: strAlbId}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.DeleteFromFolder = function(strImgId, strAlbId){
            $.post("ajax_post.aspx",
            { m: "DeleteFromFolder", 
            p: strImgId, 
            p2: strAlbId}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.approveFriend = function(strId){
            $.post("ajax_post.aspx",
            { m: "ApproveFriend", 
            p: strId}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.AddFriend = function(strUserName){
            $.post("ajax_post.aspx",
            { m: "AddFriend", 
            p: strUserName}, 
            function(data){
                $("#i-" + strUserName).fadeOut("slow");
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.ChangePhotoAcess = function(strChTo, strId){
            $.post("ajax_post.aspx",
            { m: "ChangePhotoAcess", 
            p: strChTo, 
            p2: strId}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.JoinGroup = function(GroupId, gAccess, gAdmin, gName){

            $.post("ajax_post.aspx",
            { m: "joinGroup", 
            p: GroupId, 
            p2: gAccess, 
            p3: gAdmin, 
            p4: gName}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}
UI.prototype.JoinCity = function(CityId){

            $.post("ajax_post.aspx",
            { m: "JoinCity", 
            p: CityId}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.GPost = function(strMethod, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10){
            $.post("ajax_post.aspx",
            { m: strMethod, p: p1, p2: p2, p3: p3, p4: p4, p5: p5, p6: p6, p7: p7, p8: p8, p9: p9, p10: p10}, 
            function(data){m.AlertMessage(data);}
    );
 return false;
}

UI.prototype.AGM = function(GroupId, userId){

            $.post("ajax_post.aspx",
            { m: "AGM", 
            p: GroupId, 
            p2: userId}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.postEdit = function(intid, intTId){
    var strChTX = $("#i" + intid).val();
    var arrS = strChTX.split(" ");
    if (arrS[1] == "zadej")
    {m.AlertMessage("hotovo!");}
    else
    {
        $.post("ajax_post.aspx",
        { m: "UpdateField", 
            p: intid, 
            p2: strChTX,
            p3: intTId}, 
            function(data){
                m.AlertMessage(data);
            }
        );
    }
    
    $("#w" + intid).remove();
    $("#" + intTId + "-" + intid).empty();
    $("#" + intTId + "-" + intid).append(strChTX);
    $("#" + intTId + "-" + intid).show();

    
 return false;
}

UI.prototype.WriteToWall = function(refId, strMessage, strType){

            $.post("ajax_post.aspx",
            { m: "WriteToWall", 
            p: refId,
            p2: strMessage,
            p3: strType}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.DeleteImage = function(strImgId, strImgPath){
            $.post("ajax_post.aspx",
            { m: "DeleteImage", 
            p: strImgId,
            p2: strImgPath}, 
            function(data){
                m.AlertMessage(data);
        }
    );
 return false;
}

UI.prototype.SendMessage = function(strSendTo, strSubject, strMessage){

    $.post("ajax_post.aspx",
        {   m: "SendMessage", 
            p: strSendTo, 
            p2: strSubject,
            p3: strMessage}, 
                function(data){
                    m.AlertMessage(data);
                }
    );       
 return false;
}

UI.prototype.deleteMessage = function(strId){
//delete confirmation
var r=confirm("smazat?");
if (r==true)
    {
        //loader image
        $("#l" + strId + " .status").empty();
        $("#l" + strId + " .status").append("<img src='images/progress.gif' alt='progress' />");
        $("#ax_tr_" + strId).hide();
        $("#l" + strId).hide();
        var url = "ajax_get.aspx?m=DeleteMessage&p=" + strId
        $.get(url, function(data){
            $("#l" + strId + " .status").empty();
            m.AlertMessage(data);
        });
        return "yes";
    }
    else
    {return "no";}
    
}

UI.prototype.AlertMessage = function(strMessage){
    //displays message
    if (strMessage == "chyba!"){
        $("#right_col").prepend("<div class='message_call' style='position:absolute;'><p><strong>" + strMessage + "</strong></p>  </div>");
    }
    else{
        
        $("#alert_call").remove();
        $(".main_3").prepend("<div id='alert_call' style='display:none;'><div class='r_al_b1'><div class='r_al_b2'><div class='r_al_b3'><div class='r_al_b4'><strong>" + strMessage + "</strong><a href='#close' onclick='return(m.closeMBox())' class='close_message'></a></div></div></div></div><hr /></div>");
        //$("#st").empty()
        //var strMessageHTML
        //strMessageHTML = "<p><strong>" + strMessage + "</strong></p>"
        //$("#st").append(strMessageHTML);
        $("#alert_call").fadeIn("slow");
        //$("#st").fadeOut("slow");
    }
}

UI.prototype.closeMBox = function(){
    $("#alert_call").fadeOut("fast");
}


UI.prototype.Loader = function(WPId, PWState, p1, p2, p3, p4, p5, pgId){
    if (PWState == 1)
    {
        $.get("ajax_web_part.aspx?i=" + WPId + "&s=" + PWState + "&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&pi=" + pgId, function(data){
            $("#wp-" + WPId + " .wp_body").append(data);
            $("#wp-" + WPId + " .progress").hide()
            if(WPId == 8){wp.UpdtSchId();} //rebind schid clk
            if(WPId == 10){m.WallRebind();}//rebind wall click clk
            if(WPId == 7){m.UpdtRSSLink();} //rebind RSS linker
            if(WPId == 15){m.UpdtMp3Link();}//rebind media clk
            if(WPId == 3){m.VoteRebind();}//rebind log voter
            if(WPId == 14){m.VoteRebind();}//rebind log voter
            //if(WPId == 5){m.VoteRebind();}//rebind log voter
            
        });
    }
    else
    {$("#wp-" + WPId + " .progress").hide();}
    
 return false;
}

UI.prototype.PopulateWp = function(url, strId1, strId2){
    $("#wp-" + strId1 + " .progress").show();
    $("#wp-" + strId1 + " .wp_body").empty();
    $.get(url, function(data){
        $("#wp-" + strId1 + " .wp_body").show();
        $("#wp-" + strId1 + " .wp_body").append(data);
        $("#wp-" + strId1 + " .progress").hide();
        
    });
   return false;
}

UI.prototype.VoteRebind = function(){
    $(".vote").click(function(){
        var strHref = $(this).attr("href")
        var arrS = strHref.split("#"); 
        var intNumb = parseInt(arrS[2]);
		if(arrS[1] == "plus")
		{
			if ($("#v_vrp_" + arrS[3] + " .v1").text() == arrS[2])
			{
			    m.GPost(arrS[4], arrS[1], intNumb, arrS[3]);
			    $("#v_vrp_" + arrS[3] + " .v1").addClass("alpha");
			    $("#dg_vrp_" + arrS[3] + "").addClass("alpha");
			}
			else
			{alert("co co?")}
			    $("#v_vrp_" + arrS[3] + " .v1").empty(); 
			    $("#dg_vrp_" + arrS[3] + " .dg_v1").empty();
			if (arrS[2] == 0)
			{$("#v_vrp_" + arrS[3] + " .v1").append(1);}
			else
			{   
			    $("#v_vrp_" + arrS[3] + " .v1").append(intNumb + 1); 
			    $("#dg_vrp_" + arrS[3] + " .dg_v1").append(intNumb + 1); 
			}
		}
		else
		{
			if ($("#v_vrp_" + arrS[3] + " .v2").text() == intNumb)
			{
			    m.GPost(arrS[4], arrS[1], intNumb, arrS[3]);
			    $("#v_vrp_" + arrS[3] + " .v2").addClass("alpha");
			}
			else
			{alert("co co?")}
			$("#v_vrp_" + arrS[3] + " .v2").empty();
			if (intNumb == 0)
			{$("#v_vrp_" + arrS[3] + " .v2").append(1);}
			else
			{$("#v_vrp_" + arrS[3] + " .v2").append(intNumb + 1);}
		}
        return false;
    });
}

UI.prototype.WallRebind = function(){
//send wall User message
    $("#wallMessageBox .sendToWall").click(function(){
        var strId = $(this).attr("href")
        var arrS = strId.split("#"); 
        strId = arrS[1]
        var strBtnId = $(this).attr("id");
        var strWallType = ""
        
        //wall type selector
        if (strBtnId == "btn_")
        {
            strWallType = "user";
        }
        if  (strBtnId == "btn_group")
        {
            strWallType = "group";
        }
        if (strBtnId == "btn_image")
        {
            strWallType = "image";
        }
        
        //zero value checker
        if ($("#WallMessage").val() == "")
        {
            m.AlertMessage("co?");
        }
        
        else
        {
            m.WriteToWall(strId, $("#WallMessage").val(), strWallType);
            $("#wallMessageBox").fadeOut("slow");
            $("#WallMessage").val("");
        }
        return false;
    });
}

UI.prototype.UpdtRSSLink = function(){
    $("#RSS_link_wrp a").click(function(){
        var strVal = $("#RSS_link_wrp input").val()
        m.GPost("UpdtRSSLink", strVal);
        $("#wp-7 .wp_body").empty();
        wp.PopulateWp("ajax_web_part.aspx?i=7&s=1&p1=5&p3=" + strVal, 7, 1);
        return false;
    });
}

UI.prototype.UpdtMp3Link = function(){
    $("#media_link_wrp a").click(function(){
        var strVal = $("#media_link_wrp input").val()
        var strMediaType = ""
        var arrS = strVal.split("."); 
        
        if(arrS[arrS.length - 1] == "mp3")
        {strMediaType = "audio"}
        else
        {strMediaType = "video"}
        
        m.GPost("UpdtMediaLink", strVal, strMediaType);
        $("#wp-15 .wp_body").empty();
        wp.PopulateWp("ajax_web_part.aspx?i=15&s=1&p1=" + strVal + "&p3=" + strMediaType, 15, 1);
        return false;
    });
}

UI.prototype.HotOrNot = function(){
    $("#hon li").click(function(){
        $("#HotOrNot_wrps").fadeOut("slow");
        var strid = $(this).attr("id");
        var arrS = strid.split("-");

        if (arrS[3] == "2")
        {}
        else
        {
            $.post("ajax_post.aspx",
                {m: "HotOrNot", p: arrS[1], p2: arrS[2]}, 
                function(d1){
            });

            var rand_no = Math.random();
            rand_no = rand_no * 50;
            rand_no = Math.ceil(rand_no);
            var getUrl = "ajax_HotOrNot.aspx?h=" + rand_no;
            
            $.get(getUrl, function(d2){
                $("#HotOrNot_wrps").html(d2);
                $("#HotOrNot_wrps").fadeIn("slow");
            });
        }
        return false;
    });
}

UI.prototype.VotePhoto = function(){
    $("#VotePhoto li").click(function(){
        $("#HotOrNot_wrps").fadeOut("slow");
        var strid = $(this).attr("id");
        var arrS = strid.split("-");

        if (arrS[3] == "2")
        {}
        else
        {
            $.post("ajax_post.aspx",
                {m: "VotePhoto", p: arrS[1], p2: arrS[2]}, 
                function(d1){
            });

            var rand_no = Math.random();
            rand_no = rand_no * 30;
            rand_no = Math.ceil(rand_no);
            var getUrl = "ajax_get.aspx?m=GetVoteImage&p=" + rand_no;
            
            $.get(getUrl, function(d2){
                $("#HotOrNot_wrps").html(d2);
                $("#HotOrNot_wrps").fadeIn("slow");
            });
        }
        return false;
    });
}

UI.prototype.RebindsShare = function(){
    
    $(document).ready(function(){
        $(".m_popup_wrp fieldset").prepend("<img class='thumb_image' src='img/?f=" + strPhShUrl + "&amp;w=220' alt='fotka' />");
        $("#share_send").click(function(){
            if($("#share_email").val() == "")
            {
                alert("email?");
            }
            else
            {
                $(".m_popup_wrp").hide();
                $("#share_pop_wrp").append("<img src='images/loader2.gif' alt='loading' />");
                $.post("ajax_post.aspx",
                    { m: "SharePhoto", 
                    p: $("#share_name").val(), 
                    p2: $("#share_email").val(),
                    p3: strPhShId, 
                    p4: $("#share_msg").val(), 
                    p5: strPhShUrl}, 
                    function(data){
                       $("#share_pop_wrp img").hide();
                       $("#share_pop_wrp").append("<p class='p_msg'><strong>" + data + "</strong></p>");
                });  
            }
        return false;
        });
    });
}

UI.prototype.inlineEditIni = function(){
    
   //inline editing
    $(".edit").click(function() {
        var strId = $(this).attr("id");
        var strfCode = strId.slice(0, 2);
        strId = strId.slice(3);
        var strEditText = $(this).text();
        $(this).after("<span id='w" + strId + "' class='inEditW'><input class='edit' id='i" + strId + "' type='text' value='" + strEditText + "' /><a onclick='m.postEdit(" + strId + ", " + strfCode + ");' class='editSave'>hotovo</a></span>")
        $(this).hide()
        return false;
    });

    $(".edit").hover(function() {
        $(this).addClass("edit_hover");
    }, function() {
        $(this).removeClass("edit_hover");
    });

    $(".edit_TA").click(function() {
        var strId = $(this).attr("id");
        var strfCode = strId.slice(0, 2);
        strId = strId.slice(3);
        var strEditText = $(this).text();
        $(this).after("<span id='w" + strId + "' class='inEditW'><textarea class='edit' id='i" + strId + "' type='text'>" + strEditText + "</textarea><a onclick='m.postEdit(" + strId + ", " + strfCode + ");' class='editSave'>hotovo</a></span>")
        $(this).hide()
        return false;
    });

    $(".edit_TA").hover(function() {
        $(this).addClass("edit_TA_hover");
    }, function() {
        $(this).removeClass("edit_TA_hover");
    });
}

UI.prototype.iniPhoto = function(){
    
    $(".foto_link").hover(function() {
        var strId = $(this).attr("id");
        strId = strId.slice(1);
        $("#i" + strId + " span").fadeIn("fast");
    }, function() {
        var strId = $(this).attr("id");
        strId = strId.slice(1);
        $("#i" + strId + " span").fadeOut("fast");
    });


    $(".DeleteImage").click(function() {
        var strId = $(this).attr("id");
        strId = strId.slice(1);
        var strHref = $(this).attr("href")
        var arrS = strHref.split("#");
        strHref = arrS[1]
        $("#o" + strId).addClass("alpha");
        var r = confirm("smazat?");
        if (r == true)
        { m.DeleteImage(strId, strHref); $("#o" + strId).fadeOut("fast"); }
        else { $("#o" + strId).removeClass("alpha"); }
        return false;
    });
    
    //photos
    $(".access_change a").click(function() {
        var strHref = $(this).attr("href")
        var arrS = strHref.split("#");
        var strId = arrS[1]

        m.ChangePhotoAcess(arrS[2], strId);
        $("#chid_" + strId).hide();
        $("#chid_" + strId).empty();
        if (arrS[2] == "public") {
            $("#chid_" + strId).append("<strong>Hotovo!</strong>").removeClass("icon_privat").addClass("icon_public");
        }
        else
        { $("#chid_" + strId).append("<strong>Hotovo!</strong>").addClass("icon_privat").removeClass("icon_public"); }
        $("#chid_" + strId).fadeIn("fast");
        return false;
    });
}

UI.prototype.iniFriends = function(){
    //Friends
    $(".del_friend").click(function() {
        var strHref = $(this).attr("href")
        var arrS = strHref.split("#");
        $("#u-" + arrS[1]).addClass("alpha");
        var r = confirm("smazat?");
        if (r == true) {
            m.GPost("delete_friend", arrS[1]);
            $("#u-" + arrS[1]).fadeOut("fast");
        }
        else
        { $("#u-" + arrS[1]).removeClass("alpha"); }
        return false;
    });

    $(".del_from_friends").click(function() {
        var strId = $(this).attr("id");
        var arrS = strId.split("-");
        $("#u-" + arrS[1]).addClass("alpha");
        var r = confirm("smazat?");
        if (r == true) {
            m.GPost("delete_from_friend", arrS[1]);
            $("#u-" + arrS[1]).fadeOut("fast");
        }
        else
        { $("#u-" + arrS[1]).removeClass("alpha"); }
        return false;
    });
}

UI.prototype.iniWpPublic = function(){
    //WP
    $(".add_wp").click(function() {var strHref = $(this).attr("href"); var arrS = strHref.split("#"); m.GPost("addWebPart", arrS[1], arrS[2]); $("#wp_l_" + arrS[1]).fadeOut("fast"); return false;});
    
    $(".web_part a.wp_cx_fr").click(function() {
        var strCssClass = $(this).attr("class");
        var url = $(this).attr("href");
        var arrS = url.split("#");
        if (strCssClass == "wp_cx_fr wp_stc_0") {
            m.PopulateWp("ajax_web_part.aspx?" + arrS[1], arrS[2], arrS[3])
            $(this).removeClass("wp_stc_0");
            $(this).addClass("wp_stc_1");
            return false;
        }
        else {
            $("#wp-" + arrS[2] + " .wp_body").hide();
            $(this).removeClass("wp_stc_1");
            $(this).addClass("wp_stc_0");
        }
        return false;
    });
}