


function create_p(type,flag,id,data,width_b,height_b)
{
    if (flag==1)
    {
        if (!width_b || width_b==''){width_b=380;}
        if (!height_b || height_b==''){height_b=100;}
        width=(screen.width-width_b)/2;
        height=(screen.height-height_b)/2-150;
        switch(type)
        {
            case 'remove':tmp=get_p_remove(id);break;
            case 'alert':tmp=get_p_alert(id,data);break;
            case 'add_photoalbum':tmp=get_chat_new_album(id,data);break;
            case 'edit_photoalbum':tmp=get_chat_new_album(id,data);break;
            default: tmp=get_p_undefined(id);
        }
        div=document.createElement('div');
        div.setAttribute('id',id);
        div.style.left=width + 'px';
        div.style.top=height + 'px';
        div.style.width=width_b + 'px';
        div.style.height=height_b + 'px';
        div.className='popup_window_bg';
        div.innerHTML=tmp;
        document.body.appendChild(div);
        if (!IE){opacity2(id,0);}
    }

    if (flag==0)
    {document.body.removeChild(document.getElementById(id));}
}

//##################################################konstruktor/destruktor popup-u








function create_popup(id,flag,width_b,height_b,data)
{
    if (flag==1)
    {
        if (!width_b || width_b==''){width_b=380;}
        if (!height_b || height_b==''){height_b=100;}
        width=(screen.width-width_b)/2;
        height=(screen.height-height_b)/2-150;
        switch(id)
        {
            case 'chat_friend_add':tmp=get_chat_friend_add(id,data);break;
            case 'chat_friend_add_result':tmp=get_chat_friend_add_result(id,data);break;
            case 'chat_friend_delete':tmp=get_chat_friend_delete(id,data);break;
            case 'chat_friend_delete_result':tmp=get_chat_friend_delete_result(id,data);break;
            case 'chat_friend_foes_add':tmp=get_chat_friend_foes_add(id,data);break;
            case 'chat_friend_foes_add_result':tmp=get_chat_friend_foes_add_result(id,data);break;
            case 'chat_friend_foes_remove':tmp=get_chat_friend_foes_remove(id,data);break;
            case 'chat_friend_foes_remove_result':tmp=get_chat_friend_foes_remove_result(id,data);break;
            case 'chat_friend_group_delete':tmp=get_chat_friend_group_delete(id,data);break;
            case 'chat_friend_group_delete_result':tmp=get_chat_friend_group_delete_result(id,data);break;
            case 'chat_friend_group_edit':tmp=get_chat_friend_group_edit(id,data);break;
            case 'enter_room':tmp=get_chat_enter_room(id,data);break;
            case 'show_smilles':tmp=get_smilles(id);break;
            default: tmp=get_p_undefined(id);
        }
        div=document.createElement('div');
        div.setAttribute('id',id);
        div.style.left=width + 'px';
        div.style.top=height + 'px';
        div.style.width=width_b + 'px';
        div.style.height=height_b + 'px';
        div.className='popup_window_bg';
        div.innerHTML=tmp;
        document.body.appendChild(div);
        if (!IE){opacity(id,0);}
    }

    if (flag==0)
    {document.body.removeChild(document.getElementById(id));}
}

//##################################################konstruktor/destruktor popup-u

function get_chat_friend_add(id,user)
{
    sendRequest('groups=1');
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<h3>Pridať priateľa</h3>';
    tmp+='<div>';
    tmp+='<div style="float:left;width:75%;">';
    if (user)
    {
        sendRequest('login=' + user);
        tmp+='<input type="text" name="pw_chat_friend_add_login" id="pw_chat_friend_add_login" style="width:200px;" value="' + user + '" onkeyup="get_search_login(\'pw_chat_friend_add_login\');" />';
    }
    else
    {tmp+='<input type="text" name="pw_chat_friend_add_login" id="pw_chat_friend_add_login" style="width:200px;" value="" onkeyup="get_search_login(\'pw_chat_friend_add_login\');" />';}
    tmp+='<input type="hidden" name="pw_chat_friend_add_login_hidden" id="pw_chat_friend_add_login_hidden" value="" />';
    tmp+='<div id="pw_chat_friend_add_div_login" class="modra tucne" style="text-align:right;"></div>';
    tmp+='<div id="pw_chat_friend_add_div_age" class="index"></div>';
    tmp+='<div id="pw_chat_friend_add_div_city" class="index" style="float:left;"></div><div id="pw_chat_friend_add_div_country_flag" class="index" style="float:right;"></div>';
    tmp+='</div>';
    tmp+='<div style="float:right;width:23%;" align="right"><img src="' + link_root + 'chat/resize.php?file=muz.png&amp;w=50&amp;h=60&amp;type=p" alt="" style="margin:2px;" id="pw_chat_friend_add_src" /></div>';
    tmp+='</div>';
    tmp+='<div style="clear:both;"></div>';
    tmp+='<h3>Zaraď priateľa do skupiny</h3>';
    tmp+='<div align="left"><select name="pw_chat_friend_add_group" id="pw_chat_friend_add_group" style="width:100%;"></select></div>';
    tmp+='<div style="clear:both;"></div>';
    tmp+='<h3>Správa pre priateľa</h3>';
    tmp+='<div align="left"><textarea name="pw_chat_friend_add_message" id="pw_chat_friend_add_message" style="width:100%;height:50px;"></textarea></div>';
    tmp+='<div style="clear:both;">&nbsp;</div>';
    tmp+='<div align="right">';
    tmp+='<a href="javascript:close_p(\'' + id + '\');">zrusit</a>';
    tmp+='<input type="button" name="pw_chat_friend_add_submit" value="Pridať" class="submit" style="margin-left:30px;" onclick="f_chat_friend_add();" />';
    tmp+='</div>';
    tmp+='</div>';

    return tmp;
}

function get_chat_friend_add_result(id,data)
{
    switch (data)
    {
        case '1':var hlaska='Užívateľ bol úspešne pridaný medzi priateľov';break;
        case '2':var hlaska='Priateľ bol už pridaný';break;
        case '3':var hlaska='Nemôžete byť priateľom sám sebe';break;
        case '4':var hlaska='Užívateľ neexistuje';break;
    }
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3>' + hlaska + '</h3>';
    tmp+='<input type="button" name="pw_chat_friend_add_submit" value="Ok" class="submit" style="margin-left:30px;" onclick="close_p(\'' + id + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_delete(id,data)
{
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3>Ste si istý, že chcete priateľa odstrániť ?</h3>';
    tmp+='<a href="javascript:close_p(\'' + id + '\');">Zrušiť</a>';
    tmp+='<input type="button" name="pw_chat_friend_delete_submit" value="Odstrániť" class="submit" style="margin-left:30px;" onclick="f_chat_friend_delete(\'' + data + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_delete_result(id,data)
{
    switch (data)
    {
        case '1':var hlaska='Priateľ bol úspešne vymazaný zo zoznamu Vaších priateľov';break;
        case '2':var hlaska='Priateľa sa nepodarilo vymazať';break;
    }
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3 style="margin-top:0px;">' + hlaska + '</h3>';
    tmp+='<input type="button" name="pw_chat_friend_delete_submit" value="Ok" class="submit" style="margin-left:30px;" onclick="close_p(\'' + id + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_foes_add(id,data)
{
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3 style="margin-top:0px;">Ste si istý, že chcete priateľa označiť za nepriateľa ?</h3>';
    tmp+='<a href="javascript:close_p(\'' + id + '\');">Zrušiť</a>';
    tmp+='<input type="button" name="pw_chat_friend_foes_add_submit" value="Označiť" class="submit" style="margin-left:30px;" onclick="f_chat_friend_foes_add(\'' + data + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_foes_add_result(id,data)
{
    switch (data)
    {
        case '1':var hlaska='Priateľ bol označený za nepriateľa';break;
        case '2':var hlaska='Priateľa sa nepodarilo označiť za nepriateľa';break;
    }
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3 style="margin-top:0px;">' + hlaska + '</h3>';
    tmp+='<input type="button" name="pw_chat_friend_foes_add_submit" value="Ok" class="submit" style="margin-left:30px;" onclick="close_p(\'' + id + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_foes_remove(id,data)
{
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3 style="margin-top:0px;">Ste si istý, že chcete nepriateľa označiť za priateľa ?</h3>';
    tmp+='<a href="javascript:close_p(\'' + id + '\');">Zrušiť</a>';
    tmp+='<input type="button" name="pw_chat_friend_foes_remove_submit" value="Označiť" class="submit" style="margin-left:30px;" onclick="f_chat_friend_foes_remove(\'' + data + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_foes_remove_result(id,data)
{
    switch (data)
    {
        case '1':var hlaska='Nepriateľ bol označený za priateľa';break;
        case '2':var hlaska='Nepriateľa sa nepodarilo označiť za priateľa';break;
    }
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3 style="margin-top:0px;">' + hlaska + '</h3>';
    tmp+='<input type="button" name="pw_chat_friend_foes_remove_submit" value="Ok" class="submit" style="margin-left:30px;" onclick="close_p(\'' + id + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_group_delete(id,data)
{
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3 style="margin-top:0px;">Ste si istý, že chcete skupinu odstrániť ?</h3>';
    tmp+='<a href="javascript:close_p(\'' + id + '\');">Zrušiť</a>';
    tmp+='<input type="button" name="pw_chat_friend_group_delete_submit" value="Odstrániť" class="submit" style="margin-left:30px;" onclick="f_chat_friend_group_delete(\'' + data + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_group_delete_result(id,data)
{
    switch (data)
    {
        case '1':var hlaska='Skupina bola úspešne odstránená';break;
        case '2':var hlaska='Skupinu sa nepodarilo odstrániť';break;
    }
    var tmp='';
    tmp+='<div class="popup_window_top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div align="center" style="text-align:center;">';
    tmp+='<h3 style="margin-top:0px;">' + hlaska + '</h3>';
    tmp+='<input type="button" name="pw_chat_friend_group_delete_submit" value="Ok" class="submit" style="margin-left:30px;" onclick="close_p(\'' + id + '\');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_friend_group_edit(id,group)
{
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<h3>Nový názov skupiny</h3>';
    tmp+='<div><input type="text" name="pw_chat_friend_group_edit_name" id="pw_chat_friend_group_edit_name" style="width:200px;" value="" /></div>';
    tmp+='<div align="right">';
    tmp+='<a href="javascript:close_p(\'' + id + '\');">zrusit</a>';
    tmp+='<input type="button" name="pw_chat_friend_group_edit_submit" value="Uložiť" class="submit" style="margin-left:30px;" onclick="f_chat_friend_group_edit(' + group + ');" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_smilles(id,data)
{
    sendRequest('get_smilles=1');
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<h3>Smajlíci</h3>';
    tmp+='<div id="add_smilles"></div>';
    tmp+='</div>';
    return tmp;
}

function get_chat_enter_room(id,room)
{
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<form action="" method="post">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<h3>Chránený prístup</h3>';
    tmp+='<div align="center"><input type="password" name="room_pwd" value="" style="width:90%;" /></div>';
    tmp+='<div align="center"><input type="submit" value="Vstúpiť" name="room_submit" /></div>';
    tmp+='<div><input type="hidden" name="join" value="' + room + '" /></div>';
    tmp+='</form>';
    tmp+='</div>';
    return tmp;
}

function get_chat_new_album(id,data)
{
    sendRequest('album-categories=1');
    if (data!=0)
    {
        var e=document.getElementById('item-' + data);
        sendRequest('type=' + e.getAttribute('name') + '&action=get-album-data&id=' + data);
        title='Editovať fotoalbum';
        button='Uložiť zmeny';
    }
    else
    {
        title='Vytvoriť nový fotoalbum';
        button='Vytvorť fotoalbum';
    }
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<form action="' + link_root + 'chat/gallery/my-albums/" method="post" id="create_album">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<h3>' + title + '</h3>';
    tmp+='<div class="right" style="margin-right:10px;">| <a href="javascript: show_smilles();" class="underline_green">Smajlíci</a> | <a href="#" class="underline_green">?</a> |</div>';
    tmp+='<div style="width:150px;float:left;">Názov albumu</div>';
    tmp+='<div style="float:left;"><input tabindex="1" type="text" name="album_name" id="smille_add" value="" size="20" style="width: 460px;" /></div>';
    tmp+='<div class="clear"></div>';
    tmp+='<div style="width:150px;float:left;">Kategória</div>';
    tmp+='<div style="float:left;"><select id="album_category" name="album_category" tabindex="2" style="width: 460px;"></select></div>';
    tmp+='<div class="clear"></div>';
    tmp+='<div style="width:150px;float:left;">Druh albumu</div>';
    tmp+='<div style="float:left;">';
    tmp+='<ul style="padding-left:0px;margin-left:0px;">';
    tmp+='<li style="width:30px;float:left;list-style:none;"><input tabindex="6" type="radio" name="album_type" value="public" id="public" /></li>';
    tmp+='<li style="width:30px;float:left;list-style:none;text-align:center;"><img src="' + link_root + 'public/img/public.gif" alt="" /></li>';
    tmp+='<li style="width:100px;float:left;list-style:none;"><label for="public">Verejný</label></li>';
    tmp+='<li style="width:30px;float:left;list-style:none;"><input tabindex="7" type="radio" name="album_type" value="password" id="password" /></li>';
    tmp+='<li style="width:30px;float:left;list-style:none;text-align:center;"><img src="' + link_root + 'public/img/password.gif" alt="" /></li>';
    tmp+='<li style="width:100px;float:left;list-style:none;"><label for="password">Zamknutý</label></li>';
    tmp+='<li style="float:left;list-style:none;"><input tabindex="8" type="password" id="album_password" name="album_password" size="20" value="" style="width: 140px;" /></li>';
    tmp+='</ul>';
    tmp+='<div class="clear"></div>';
    tmp+='<ul style="padding-left:0px;margin-left:0px;">'
    tmp+='<li style="width:30px;float:left;list-style:none;"><input tabindex="9" type="radio" name="album_type" value="only_friends" id="only_friends" /></li>';
    tmp+='<li style="width:30px;float:left;list-style:none;"><img src="' + link_root + 'public/img/only_friends.gif" alt="" /></li>';
    tmp+='<li style="width:100px;float:left;list-style:none;"><label for="only_friends">Len pre priateľov</label></li>';
    tmp+='<li style="width:30px;float:left;list-style:none;"><input tabindex="10" type="radio" name="album_type" value="only_me" id="only_me" /></li>';
    tmp+='<li style="width:30px;float:left;list-style:none;"><img src="' + link_root + 'public/img/only_me.gif" alt="" /></li>';
    tmp+='<li style="width:100px;float:left;list-style:none;"><label for="only_me">Len pre mňa</label></li>';
    tmp+='</ul>';
    tmp+='<div class="clear"></div>';
    tmp+='</div>';
    tmp+='<div class="clear" style="margin-bottom:10px;"></div>';
    tmp+='<div style="width:150px;float:left;text-align:center;"><img src="' + link_root + 'public/img/warning.gif" alt="Upozornenie" title="Upozornenie" /></div>';
    tmp+='<div style="width:450px;float:left;font-size:9px;color:red;">Vážený užívateľ, množstvo fotoalbumov, ktoré si môžete vytvoriť nie je obmedzené, a taktiež nie je obmedzený počet fotografií v každom albume, preto Vás žiadame, aby ste nevytvárali obrovské množstvo fotoalbumov len preto, že je to povolené, v opačnom prípade budeme nútení Vám Vaše konto zablokovať, ak sa nájde takýchto užívateľov neprimerané množstvo, budeme nútení fotoalbumy obmedziť</div>';
    tmp+='<div class="clear"></div>';
    tmp+='<div class="right"><input tabindex="11" type="button" name="" value="' + button + '" id="" onclick="create_photoalbum(' + data + ');" style="width: 200px;" /></div>';
    tmp+='</form>';
    tmp+='</div>';
    return tmp;
}

function get_p_remove(id,type)
{
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div><h3>Naozaj chcete položku vymazať ?</h3></div>';
    tmp+='<div align="center">';
    tmp+='<a href="javascript:close_p(\'' + id + '\');">zrusit</a>';
    tmp+='<input type="button" value="Odstrániť" onclick="ajax_remove(' + id + ');" style="margin-left:30px;" />';
    tmp+='</div>';
    tmp+='</div>';
    return tmp;
}

function get_p_alert(id,data)
{
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<div><h3>' + data + '</h3></div>';
    tmp+='<div align="center"><input type="button" value="Ok" onclick="close_p(\'' + id + '\');" /></div>';
    tmp+='</div>';
    return tmp;
}

function get_p_undefined(id,data)
{
    var tmp='';
    tmp+='<div class="popup_window_top" valign="top">';
    tmp+='<div style="position:relative;top:-10px;right:-20px;" align="right"><a href="javascript:close_p(\'' + id + '\');"><img src="' + link_root + 'public/img/clear.gif" alt="" /></a></div>';
    tmp+='<h3>Nedefinovany popup</h3>';
    tmp+='<div align="center"><input type="button" value="Ok" onclick="close_p(\'' + id + '\');" /></div>';
    tmp+='</div>';
    return tmp;
}

function close_p(id)
{
    create_popup(id,0);
}

//##zavriet oknno