var IE = document.all?true:false;

function openWin(ake)
{
    var url=link_root + 'chat/chat/';
    if (ake=='qm')
    {
        url+='qm.php?shownew=1';
        qmnewTimer=setTimeout("check_online();",5000);
    }
    else
    {return;}
    var width=550;
    var height=480;
    var params='';
    params+='left=' + ((screen.width-width)/2.1) + ',top=' + ((screen.height-height)/2);
    params+=',resizable=yes,menubar=no,scrollbars=yes,status=no,width=' + width + ', height=' + height;
    var newWin=window.open(url,'pchat_win_' + ake,params);
    newWin.focus();
}

//##################################################new qm

function showQmArchive()
{
    var width=550;
    var height=480;
    var url=link_root + 'chat/chat/qm.php?section=archive';
    var params='left=' + ((screen.width-width)/2.1) + ',top=' + ((screen.height-height)/2);
    params+=',resizable=yes,menubar=no,scrollbars=yes,status=no,width=' + width + ', height=' + height;
    var newWin=window.open(url,'pchat_win_qm',params);
    newWin.focus();
}

function showQmArchiveWith(nick)
{
    var width=550;
    var height=480;
    var url=link_root + 'chat/chat/qm.php?section=archive&with=' + nick;
    var params='left=' + ((screen.width-width)/2.1) + ',top=' + ((screen.height-height)/2);
    params+=',resizable=yes,menubar=no,scrollbars=yes,status=no,width=' + width + ', height=' + height;
    var newWin=window.open(url,'pchat_win_qm',params);
    newWin.focus();
}

function showMArchive()
{
    var url=link_root + 'chat/chat/messages.php?section=recieved';
    var newWin=window.open(url);
    newWin.focus();
}

function sendQmFor(name)
{
    var width=550;
    var height=480;
    var url=link_root + 'chat/chat/qm.php?section=sendto&for=' + name;
    var params='left=' + ((screen.width-width)/2.1) + ',top=' + ((screen.height-height)/2);
    params+=',resizable=yes,menubar=no,scrollbars=yes,status=no,width=' + width + ', height=' + height;
    var newWin=window.open(url,'pchat_win_qm',params);
    newWin.focus();
}

//##################################################praca s qmkami

function tooltip_udrz(prvok)
{
    prvok='tooltip_'+prvok;
    document.getElementById(prvok).style.height=140 + 'px';
    document.getElementById(prvok).style.display='inline';
}

function tooltip_on(prvok)
{
    prvok_1='tooltip_'+prvok;
    prvok_2='tooltip_2_'+prvok;
    var existuje=document.getElementById(prvok_1);
    if (existuje!=null)
    {
        document.getElementById(prvok_1).style.height=140 + 'px';
        document.getElementById(prvok_2).style.height=140 + 'px';
        document.getElementById(prvok_1).style.display='inline';
        if (!IE){opacity(prvok_1,0,140);}
    }
}

function tooltip_off(prvok)
{
    prvok='tooltip_'+prvok;
    document.getElementById(prvok).style.height='140px';
    document.getElementById(prvok).style.display='none';
}

//##################################################praca s tooltipmy

function opacity(item,opacity)
{
    ratio=opacity / 100;
    if (opacity > 100)
    {opacity=100; }
    document.getElementById(item).style.opacity=ratio;
    document.getElementById(item).style.filter='alpha(opacity=' + (ratio * 100) + ')';
    visibility_timer=window.setTimeout("opacity('" + item + "'," + (opacity + 2) + ");",10)
    if (opacity==100)
    {window.clearTimeout(visibility_timer);}
}

//##################################################postupne zviditelnovanie prvku

function item_album_on(item)
{
    var item='item-' + item;
    document.getElementById(item).style.background='#DAEEFD';
}

function item_album_off(item)
{
    var item='item-' + item;
    document.getElementById(item).style.background='transparent';
}

function item_message_on(item)
{
    var item_tr='item_' + item;
    document.getElementById(item_tr).style.background='#DAEEFD';
}

function item_message_off(item)
{
    var item_tr='item_' + item;
    document.getElementById(item_tr).style.background='transparent';
}

function item_user_on(item)
{
    var item_tr='item_' + item;
    document.getElementById(item_tr).style.background='#DAEEFD';
}

function item_user_off(item)
{
    var item_tr='item_' + item;
    document.getElementById(item_tr).style.background='transparent';
}

function item_friend_on(item)
{
    var item_tr='item_' + item;
    var item_status='item_status_' + item;
    var item_func='item_func_' + item;
    document.getElementById(item_tr).style.background='#DAEEFD';
    document.getElementById(item_status).style.display='none';
    document.getElementById(item_func).style.display='block';
}

function item_friend_off(item)
{
    var item_tr='item_' + item;
    var item_status='item_status_' + item;
    var item_func='item_func_' + item;
    document.getElementById(item_tr).style.background='transparent';
    document.getElementById(item_status).style.display='block';
    document.getElementById(item_func).style.display='none';
}

function item_group_on(item)
{
    var item='item_' + item;
    document.getElementById(item).style.background='#DAEEFD';
}

function item_group_off(item)
{
    var item='item_' + item;
    document.getElementById(item).style.background='transparent';
}

function item_photo_on(item)
{
    var item='item_photo_' + item;
    var el_s=document.getElementById(item);
    var el_e=document.getElementById('item_photo_view');
    el_e.src=el_s.src;
    el_e.className='ramcekphoto';
    el_e.style.visibility='visible';
}

function item_photo_off(item)
{
    var el=document.getElementById('item_photo_view');
    el.style.visibility='hidden';
}

//##################################################aktivne/neaktivne riadky tabuliek

function inzer_openWin(photo,width,height)
{
    var url=link_root + 'inzercia/photo.php?photo=' + photo;
    var params='left=' + ((screen.width-width)/2.1) + ',top=' + ((screen.height-height)/2);
    params+=',resizable=yes,menubar=no,scrollbars=yes,status=no,width=' + width + ', height=' + height;
    var newWin=window.open(url,'inzercia',params);
    newWin.focus();
}

//##################################################nove okno pre inzerciu

function blog_openWin(theme)
{
    var width=1150;
    var height=700;
    var url=link_root + 'blog/theme.php?theme=' + theme;
    var params='left=' + ((screen.width-width)/2.1) + ',top=' + ((screen.height-height)/2);
    params+=',resizable=yes,menubar=no,scrollbars=yes,status=no,width=' + width + ', height=' + height;
    var newWin=window.open(url,'blog',params);
    newWin.focus();
}

//##################################################nove okno pre blog

function chat_friend_add(user)
{create_popup('chat_friend_add',1,300,350,user);}

//##################################################pridat priatela

function show_smilles()
{create_popup('show_smilles',1,700,305);}

//##################################################zobrazit smajle

function enter_room(id)
{create_popup('enter_room',1,200,120,id);}

//##################################################vstup do miestnosti

function isNumeric(co)
{
    var RegExp=/^(-)?(\d*)(\.?)(\d*)$/;
    var res=co.toString().match(RegExp);
    return res;
}

function trim(str){return str.replace(/^\s+|\s+$/g,'');}

function SelectAll(id)
{
    for (var index=0;index<document.form.elements.length;index++)
    {
        if (document.form.elements[index].type=='checkbox')
        {document.form.elements[index].checked=document.getElementById(id).checked;}
    }
}

//##################################################globalne funkcie

function keyPress(e)
{
var code = 0;
if(window.event){code = e.keyCode;}
else if(e.which){code = e.which;}
if (code == 13){submitFormNew();}
}

function show_help(zobrazit,aky,width,height)
{
if (zobrazit=='block')
{
sirka=(screen.width-width)/2;
vyska=(screen.height-height)/2-100;
document.getElementById(aky).style.left = sirka + 'px';
document.getElementById(aky).style.top = vyska + 'px';
document.getElementById(aky).style.width = width + 'px';
document.getElementById(aky).style.height = height + 'px';
}
document.getElementById(aky).style.display = zobrazit;
}

//##################################################funkcie na prehodnotenie