function openWindow( link, width, height )
{
 var wnd = window.open(link,'','scrollbars=yes,height='+height+',width='+width+',toolbar=no, menubar=no,location=no,scrollbars=yes,personalbar=no,status=no,resizable=yes');
 return wnd;
}
function user_delete(user_id,user_mail)
{
   var r=confirm("Czy napewno chcesz usunąć użytkownika?\n Adres email: "+ user_mail + " ID: "+ user_id);
if (r==true)
  {
    document.forms['form::del'].elements["user_id"].value = user_id;
    document.forms['form::del'].submit();
  }
}

function register() {

  var mail = document.getElementById( "user_login" );
  var mail1 = document.getElementById( "user_login1" );



  if(mail.value != mail1.value || mail.value == "" )
     alert("Podaj poprawny adres email");
  else
     document.forms['reg'].submit();


}
function chngpwd() {

  var pwd = document.getElementById( "new_pwd" );
  var pwd1 = document.getElementById( "new_pwd1" );



  if(pwd.value != pwd1.value || pwd.value == "" )
     alert("Nowe hasła nie zgadzają się");
  else
     document.forms['pwd'].submit();


}
function save() {
     document.forms['edit'].submit();
}
function delacc() {
     document.forms['del'].submit();
}
function login() {

  var user_login = document.getElementById( "user_login" );
  var user_password = document.getElementById( "user_password" );



  if(user_login.value == "" || user_password.value == "" )
     alert("Podaj login i hasło");
  else
     document.forms['login_form'].submit();


}

function loadInfoBox( myid , param, act )
{
 advAJAX.get({
 url: "?act="+myid+"&id=2&mode=ajax&do="+param+"&action="+act,
 onLoading : function(obj) { document.getElementById( "box" ).innerHTML = '<div class="wait" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onError : function(obj) { document.getElementById( "box" ).innerHTML = '<div class="error" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onSuccess : function(obj) { document.getElementById( "box" ).innerHTML = obj.responseText; }
 });
}
function delete_old( myid )
{
 advAJAX.get({
 url: "?act="+myid+"&id=2&mode=ajax&do=1&action=1",
 onLoading : function(obj) { document.getElementById( "del_old" ).innerHTML = '<div class="wait" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onError : function(obj) { document.getElementById( "del_old" ).innerHTML = '<div class="error" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onSuccess : function(obj) { document.getElementById( "del_old" ).innerHTML = obj.responseText; }
 });
}
function sendForm( id )
{
   advAJAX.submit(document.getElementById(id), {
    onSuccess : function(obj) { document.getElementById( 'box' ).innerHTML = '' + (obj.responseText) + ''; },
    onLoading : function(obj) { document.getElementById( 'box' ).innerHTML = '<div class="wait" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
    onError : function(obj) { document.getElementById( 'box' ).innerHTML = '<div class="error" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; }
   });
}
function showUsers( where, myid )
{
   advAJAX.get({
    url: "?act="+myid+"&id=2&mode=ajax&do=4&action=" + where,
    onSuccess : function(obj) { document.getElementById( 'database' ).innerHTML = '' + (obj.responseText) + ''; },
    onLoading : function(obj) { document.getElementById( 'database' ).innerHTML = '<div class="wait" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
    onError : function(obj)   { document.getElementById( 'database' ).innerHTML = '<div class="error" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; }
   });
}

function AddGroup( myid )
{
 advAJAX.submit(document.getElementById('form::allgroups'), {
 onLoading : function(obj) { document.getElementById( "group_button" ).innerHTML = '<div class="wait" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onError : function(obj) { document.getElementById( "group_button" ).innerHTML = '<div class="error" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onSuccess : function(obj) {
   document.getElementById( "active_groups" ).innerHTML = obj.responseText;
   document.getElementById( "group_button" ).innerHTML = '<input class="button" type="button" onclick="DelGroup( '+myid+' ); return false;" name="del" value=">>" /><br /><input onclick="AddGroup( '+myid+' ); return false;" class="button" type="button" name="add" value="<<" />';
    }
 });
}
function DelGroup( myid )
{
 advAJAX.submit(document.getElementById('form::usergroups'), {
 onLoading : function(obj) { document.getElementById( "group_button" ).innerHTML = '<div class="wait" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onError : function(obj) { document.getElementById( "group_button" ).innerHTML = '<div class="error" style="margin-bottom: 10px; margin-top: 10px;"><!-- --></div>'; },
 onSuccess : function(obj) {
   document.getElementById( "active_groups" ).innerHTML = obj.responseText;
   document.getElementById( "group_button" ).innerHTML = '<input class="button" onclick="DelGroup( '+myid+' ); return false;" type="button" name="del" value=">>" /><br /><input class="button" onclick="AddGroup( '+myid+' ); return false;" type="button" name="add" value="<<" />';
    }
 });
}
function openCtgEditor(_myid, _target)
{
   _size = ',width=750,height=500';

   var _link = 'myadmin.php?act=' + _myid + '&id=3&target=' + _target;

   var _config = 'toolbar=no,location=no,directories=no,status=no,menubar=no' + _size + ',scrollbars=yes,resizable=yes';
   window.open (_link,"",_config);

}
function openwindow(what,where,form_number){

 if(what=='filebrowser')
 window.open("./myadmin.php?cmd=insertfile&field="+where+"&form_number="+form_number,what, "location=no, scrollbars=yes, resizable=yes, toolbar=no, menubar=no, width=545, height=483" );
 if(what=='pagebrowser')
 window.open("./myadmin.php?cmd=insertlink&field="+where+"&form_number="+form_number,what, "location=no, scrollbars=yes, resizable=yes, toolbar=no, menubar=no, width=545, height=483" );
 if(what=='pluginbrowser')
 window.open("./myadmin.php?cmd=linktoplug&field="+where+"&form_number="+form_number,what, "location=no, scrollbars=yes, resizable=yes, toolbar=no, menubar=no, width=545, height=483" );

}
function change_go_type($select_field)
{
  go_div = document.getElementById('go_page');
  if($select_field.value==1)
     go_div.style.display = "block";
  else
     go_div.style.display = "none";
}
