d = document;


function AskDelete(){
 return confirm('Naozaj chcete vykonať zmazanie?');
}

function AskLogout(){
 return confirm('Chcete odísť zo svojho konta?');
}


function openWin(str, w, h){
  HN_popupWin = window.open(str,'HN_popupWin','width='+w+', height='+h+', top=100, left=150, minimizable=no, dialog=no, modal=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes');
}


function switchLayer(OBJ){
  if(d.getElementById(OBJ).style.display=="none"){
     d.getElementById(OBJ).style.display = "block";
  }else{
     d.getElementById(OBJ).style.display = "none";
  }
}

function hide(OBJ){
 d.getElementById(OBJ).style.display = "none";
}

function show(OBJ){
 d.getElementById(OBJ).style.display = "block";
}

function hideAll(PREFIX,NUM){
 for(var i=1; i<=NUM; i++){
    OBJ = PREFIX + '_' + i;
    d.getElementById(OBJ).style.display = "none";
 }
}



// Naplni delete formular a odposle ho

function delForm(objId){
  d.objDelForm.id.value = objId;
  if(AskDelete()){ d.objDelForm.submit(); }
}



// select + unselect all in <select> form

function setSelectOptions(the_form, the_select, do_check){
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    }

    return true;
}


// Max Length of textarea

function CheckLen( Target, MaxChars, Showtab ){

 StrLen   = Target.value.length;

 if (StrLen > MaxChars) {
   Target.value = Target.value.substring (0,MaxChars);
   CharsLeft    = 0;
 }else{
   CharsLeft = MaxChars - StrLen;
 }

 Showtab.value = "Zostáva " + CharsLeft + " znakov";

}


// Start chat

function chatWithMe( User_name ){

  User_link = ( User_name=="_blank" ? '' : '?NewCat=' + User_name );
  HN_chatWin = window.open('/Chat.php' + User_link, 'HN_chatWin', 'width=490, height=590, top=50, left=50, minimizable=no, dialog=no, modal=yes, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no');

}

