/*

JAVASCRIPT LIBRARY

*/


// BUTTONCLICK: oldal betöltése
function ButtonClick(url) {
  window.location = url;
  }

// CONFIRMDELETE: a rekord törlését megerősítő kérdést követően megnyitja a megadott oldalt
function ConfirmDelete(url,text) {
  if (text==undefined) errMsg='Valóban törölni szeretné a kiválasztott elemet?'; else errMsg=text;
  if (window.confirm(errMsg)) window.location=url;
  }
  
function miniablak_nyit(kiirando_szoveg, cim){
alert('a');
  var inlinewin=dhtmlwindow.open("broadcastbox", "inline", kiirando_szoveg, cim, "width=500px,height=400px,left=150px,top=10px,resize=1,scrolling=1", "recal")
  inlinewin.show();
}  

function miniablak_nyit_iframe(kiirando_szoveg, cim, left, top, width, height){
  var inlinewin2=dhtmlwindow.open("broadcastbox2", "iframe", kiirando_szoveg, cim, "width="+width+"px,height="+height+"px,left="+left+"px,top="+top+"px,resize=1,scrolling=0", "recal")
  inlinewin2.show();
} 

function miniablak_nyit_ajax(meghivando_php_url, cim, left, top, width, height){
	ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", meghivando_php_url, cim, "width="+width+"px,height="+height+"px,left="+left+"px,top="+top+"px,resize=1,scrolling=1")
	//ajaxwin.onclose=function(){return window.confirm("Close window 3?")} //Run custom code when window is about to be closed
	ajaxwin.show();
}


// Compare two options within a list by VALUES
function compareOptionValues(a, b) { 
  var sA = parseInt( a.value, 36 );  
  var sB = parseInt( b.value, 36 );  
  return sA - sB;
  }

// Compare two options within a list by TEXT
function compareOptionText(a, b) { 
  var sA = parseInt( a.text, 36 );  
  var sB = parseInt( b.text, 36 );  
  return sA - sB;
  }
  
// Dual list move function
function moveDualList( from_id, to_id, moveAll ) {
  srcList = document.getElementById(from_id);
  destList = document.getElementById(to_id);

  // Do nothing if nothing is selected
  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   ) {
    return;
    }
  newDestList = new Array( destList.options.length );
  var len = 0;

  for( len = 0; len < destList.options.length; len++ ) {
    if ( destList.options[ len ] != null ) {
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
      }
    }
	
  for( var i = 0; i < srcList.options.length; i++ ) { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {		
      // Statements to perform if option is selected
      // Incorporate into new list	  
      newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
      len++;
      }
    }
	
  // Sort out the new destination list
  newDestList.sort( compareOptionValues );   // BY VALUES
  //newDestList.sort( compareOptionText );   // BY TEXT
  // Populate the destination with the items from the new array
  
  for ( var j = 0; j < newDestList.length; j++ ) {	
    if ( newDestList[ j ] != null ) {
      destList.options[ j ] = newDestList[ j ];
      }
    }
  // Erase source list selected elements
  for( var i = srcList.options.length - 1; i >= 0; i-- ) { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
      // Erase Source
      //srcList.options[i].value = "";
      //srcList.options[i].text  = "";
      srcList.options[i]       = null;
      }
    }
  } // End of moveDualList()


function selectallDualList(list_id) {
  lst = document.getElementById(list_id);
  for (i=0; i<lst.length; i++) lst.options[i].selected=true;
  }
