// ÷ 2010-01-25 11:05:36
function pause(seconde){
      
	  milliseconde = seconde * 1000;
	  var now = new Date();
      var exitTime = now.getTime() + milliseconde;
       
      while(true){
		  now = new Date();
		  if(now.getTime() > exitTime) return;
      }
}

function selectText( id ){
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function addToOnload(object,func) {  
  var oldonload = object.onload;
  if (typeof object.onload != 'function') {
    object.onload = func;
  } else {
    object.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


// Utility function to add an event listener
function wpAddEvent(o,e,f){
	if (o.addEventListener){ o.addEventListener(e,f,true); return true; }
	else if (o.attachEvent){ return o.attachEvent("on"+e,f); }
	else { return false; }
}


function validEmail( email, nincsUzenet, hibasUzenet ) {
	if (email=="" || email== null) {
		if ( ! nincsUzenet ) nincsUzenet='Az email cím nincs megadva!';
		alert(nincsUzenet);
		return false;
	} else {
		var emailReg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var emailReg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/; // valid
		if (!(!emailReg1.test(email) && emailReg2.test(email))) { // if syntax is valid
			if ( ! hibasUzenet ) hibasUzenet='Az email cím formailag hibás!';
			alert(hibasUzenet);
			return false;
		}
		return true;
	}
}

function validDatum( strValue ) {

		// nullát nem ellenőrzi
	if ( strValue == "0000-00-00" || strValue == "" ) return true;


		// év ellenőrzése
	var intYear = strValue.substring(0,4);
	if ( ! isNumeric(intYear) || strValue.length == 0 ) {
		alert("Hibás év, kérjük az 'éééé-hh-nn' dátum formát használja ");
		return false;
	}

		// hónap ellenőrzése
	var intMonth = strValue.substring(5,7);
	if ( ! isNumeric(intMonth) || parseInt( intMonth, 10 ) > 12 ) {
		alert("Hibás hónap, kérjük az 'éééé-hh-nn' dátum formát használja ");
		return false;
	}

		// nap ellenőrzése
	var intDay = strValue.substring(8,10);
	if ( ! isNumeric(intDay) || parseInt( intDay, 10 ) > 31 ) {
		alert("Hibás nap, kérjük az 'éééé-hh-nn' dátum formát használja ");
		return false;
	}

   		//create a lookup for months not equal to Feb.
    var honapNap = {'01' : 31,
					'03' : 31,
                    '04' : 30,
					'05' : 31,
                    '06' : 30,
					'07' : 31,
                    '08' : 31,
					'09' : 30,
                    '10' : 31,
					'11' : 30,
					'12' : 31};



	var intNap = parseInt(intDay,10);
	var intHo = parseInt(intMonth,10);
	var intEv = parseInt(intYear,10);

    //alert (intNap + " <=  " + honapNap[intMonth]);

    	//check if month value and day value agree
    if( honapNap[intMonth] != null ) {
      	if( intNap <= honapNap[intMonth] && intNap != 0 ) {
	  		return true; //found in lookup table, good date
		}
    }


    if (intHo == 2) {
       if (intNap > 0 && intNap < 29) {
           return true;

	   }else if (intNap == 29) {

	   			// year div by 4 and ((not div by 100) or div by 400) ->ok
			if ((intEv % 4 == 0) && (intEv % 100 != 0) ||
				 (intEv % 400 == 0)) {

				 return true;
			}
       }
    }


	alert("A dátum nem helyes" + strValue);

	return false;
}

function checkTimeKeyPressed( e, id ){
    if (e.keyCode) keycode=e.keyCode;
    else keycode=e.which;
    ch=String.fromCharCode(keycode);

    var textfield = document.getElementById(id);
    var txt = textfield.value;

    if ( txt == '00:00' ) txt = '';
    if ( txt.length == 2 ) txt = txt + ':';
    if ( txt.length > 5 ) txt = txt.substr(0, 5);

    var doIt = true;
    while ( txt.length > 0 && doIt ){
        doIt = false;
        switch( txt.length ){
            case 1:
                if ( ! txt.match(/^[0-2]$/) ) doIt = true;
                break;
            case 2:
                if ( ! txt.match(/^[0-2][0-9]$/) ) doIt = true;
                if ( txt > '23' ) doIt = true;
                break;
            case 3:
                if ( ! txt.match(/^[0-2][0-9]:$/) ) doIt = true;
                if ( txt > '23:' ) doIt = true;
                break;
            case 4:
                if ( ! txt.match(/^[0-2][0-9]:[0-5]$/) ) doIt = true;
                if ( txt > '23:5' ) doIt = true;
                break;
            case 5:
                if ( ! txt.match(/^[0-2][0-9]:[0-5][0-9]$/) ) doIt = true;
                if ( txt > '23:59' ) doIt = true;
                break;
        }

        if ( doIt ) txt = txt.substr(0, txt.length-1);
    }

        // ha közben törölni kellett rossz adat miatt
    if ( txt.length == 2 ) txt = txt + ':';

    textfield.value = txt;
}

function validTime( strValue ) {
	var hibas = false;

		// számok átkonvertálása
	if ( isNumeric( strValue ) ) {
		if ( strValue.length == 1 ) strValue = "0" + strValue + ":00";
		if ( strValue.length == 2 && strValue < 25 ) strValue = strValue + ":00";
		if ( strValue.length == 3 ) strValue = "0" + strValue.substring(0,1) + ':' + strValue.substring(1,3);
		if ( strValue.length == 4 ) strValue = strValue.substring(0,2) + ':' + strValue.substring(2,4);
	}


		// érvénytelen hosszú stringeket visszadobja
	if ( strValue.length > 5 || strValue.length < 3 ) {
		hibas = true;
	}else{
			// óra ellenőrzése
		var intHour = strValue.substring(0,2);
		if ( ! isNumeric(intHour) || parseInt( intHour, 10 ) > 24 ) {
			hibas = true;
		}

			// perc ellenőrzése
		var intMinute = strValue.substring(3,5);
		if ( ! isNumeric(intMinute) || parseInt( intMinute, 10 ) > 59 ) {
			hibas = true;
		}
	}

	if ( hibas ) {
		alert("Hibás idő, kérjük az 'óó:pp' formát használja ");
		strValue = '00:00';
	}

	return strValue;
}

var numbers="0123456789";
function isNumeric(x) {
    // is x a String or a character?
    if(x.length>1) {
      // remove negative sign
      x=Math.abs(x)+"";
      for(j=0;j<x.length;j++) {
        // call isNumeric recursively for each character
        number=isNumeric(x.substring(j,j+1));
        if(!number) return number;
      }
      return number;
    }
    else {
      // if x is number return true
      if(numbers.indexOf(x)>=0) return true;
      return false;
    }
}


function validInteger( strValue ){
	if ( isNumeric( strValue ) ) return strValue;

	alert("Nem egész szám: " + strValue);

	return 0;
}

function validDouble( strValue ){

	strValue = replaceChars( ",", ".", strValue );

	var numberParts = strValue.split(".", 1 );

	if ( isNumeric( numberParts[0] ) && numberParts[1] == null ) return strValue;
	if ( isNumeric( numberParts[0] ) && isNumeric( numberParts[1] ) ) return strValue;

	alert("Nem szám: " + strValue);

	return 0;
}

///////////////////////////////////
//keigészített
//indexOf pozició növelés, nem fagy be
//ha hozzáfűzésre van használva
function replaceChars( replaceThis, withThis, source ) {
	temp = "" + source;
	var pos = 0;
	
	while ( temp.indexOf( replaceThis, pos  ) >-1 ) {
		pos= temp.indexOf( replaceThis );
		temp = "" + ( temp.substring(0, pos) + withThis + temp.substring( (pos + replaceThis.length), temp.length) );
		pos = pos+1;
	}

	return temp;
}

/*  ellenőrzi az oldal választás joghoz kötött submitolhatóságát */
function checkChangePage( oldalRight, userRight, requiredPageName ){
	if ( oldalRight == 0 || userRight/oldalRight == Math.round( userRight/oldalRight ) ) {
		document.page.pageChooser.value = requiredPageName;
		//alert('New page requested: '+document.page.pageChooser.value);
		console.error('New page requested: '+document.page.pageChooser.value);
		document.page.submit();
	}
}

/* sbmitol egy control gomb formot */
function controlSubmitButton( submitValue, form, button ){
	button.value = submitValue;
	form.submit();
}

function writeIntoElement( id, text ){
	if (document.getElementById != null){
		x = document.getElementById(id);
		if ( x != null ){
			x.innerHTML = '';
			x.innerHTML = text;
		}
	}else if (document.all){
		x = document.all[id];
		if ( x != null ){
			x.innerHTML = text;
		}
	}else if (document.layers){
		x = document.layers[id];
		if ( x != null ){
			text2 = '<P CLASS="testclass">' + text + '</P>';
			x.document.open();
			x.document.write(text2);
			x.document.close();
		}
	}
}

function printText(elem) {
    popup = window.open('','popup','toolbar=no,menubar=no,width=200,height=150');
    popup.document.open();
    popup.document.write("<html><head></head><body onload='print()'>");
    popup.document.write(elem);
    popup.document.write("</body></html>");
    popup.document.close();
} 

function getElementPosition(obj){
    var topValue= 0,leftValue= 0;
    while(obj){
        leftValue+= obj.offsetLeft;
        topValue+= obj.offsetTop;
        obj= obj.offsetParent;
    }

    return [leftValue, topValue];
}

function createDiv( id, html, width, height, left, top, background, border ){
   var newdiv = document.createElement('div');

   newdiv.setAttribute('id', id);
   newdiv.style.width = width;
   newdiv.style.height = height;
   newdiv.style.position = 'absolute';
   newdiv.style.left = left;
   newdiv.style.top = top;
   newdiv.style.background = background;
   newdiv.style.border = border;
   newdiv.style.filter = 'alpha(opacity=100)';
   newdiv.style.zIndex = 1;

   if (html) {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = "nothing";
   }

   document.body.appendChild(newdiv);
}

function changeOpacity( obj, opacity ){
    if (typeof obj.style.opacity == "string"){
        obj.style.opacity = opacity/100;
    }else{
        obj.filters.alpha.opacity = opacity;
    }
/*
    if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5){
        obj.style.MozOpacity=opacity/100
    }else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4){
        obj.filter = 'alpha(opacity=' + opacity + ')';
    }
*/
}

/*
 *  animált mozgással és átméretezéssel átrak egy element-et
 *  obj: az element
 *  var animPropsDiv = {
    left: {start: 5, end: 100},
    top: {start: 55, end: 20},
    height: {start: 100, end: 400},
    width: {start: 300, end: 800}
};
    anim: true, false - kell-e animálni
 */

function moveElement( obj, animProps, anim ){
    
    if ( ! anim ){
            // Az eredeti finkció futtatása
        obj.style.top = animProps.left.end + "px";
        obj.style.left = animProps.top.end + "px";
    }else{
        //Az animáció futtatása
        var moveArgs = {
            node: obj,
            easing: dojo.fx.easing.linear,
            duration: 60,
            properties:{}
        };

        //Az egyes mozgások beállítása
        if (animProps.left!=null){
            moveArgs.properties.left = {start: animProps.left.start, end: animProps.left.end, unit: "px"};
        }

        if (animProps.top!=null){
            moveArgs.properties.top = {start: animProps.top.start, end: animProps.top.end, unit: "px"};
        }

        if (animProps.width!=null){
            moveArgs.properties.width = {start: animProps.width.start, end: animProps.width.end, unit: "px"};
        }

        if (animProps.height!=null){
            moveArgs.properties.height = {start: animProps.height.start, end: animProps.height.end, unit: "px"};
        }

        dojo.fx.chain([dojo.animateProperty(moveArgs)]).play();
    }
}

function resizeElement( obj, width, height ){
    obj.style.width = width + "px";
    obj.style.height = height + "px";
}

function setInProgressAndJumpToPage( oldal, aloldal, inProgressIdName, inProgressID, extraParameters ){
	var url = oldal + '/control.php?aloldal=' + aloldal + '&' + inProgressIdName + '=' + inProgressID;
	if ( extraParameters.length > 0 ) url = url + '&' + extraParameters;

	window.location = url;
}

function openWindow( windowWidth, windowHeight, url, windowName, passedParameters ) {

	var OpenSubX = (screen.width/2)-(windowWidth/2);
	var OpenSubY = (screen.height/2)-(windowHeight/2);
	var pos = ', left='+OpenSubX+', top='+OpenSubY;
	var features = 'toolbar=no, menubar=yes, resizable=no, scrollbars=yes, status=no, location=no, width=' + windowWidth + ', height=' + windowHeight + pos;

	window.open( url + passedParameters, windowName, features);
}

function printWindow( nyomtatGombNeve ) {
	document.getElementById( nyomtatGombNeve ).style.visibility = 'hidden';

	window.print();
	window.onAfterPrint();
}

function showDolgozom( left, top ){
	document.getElementById('dolgozom_div').style.visibility = 'visible';
	document.getElementById('dolgozom_div').style.left = left + 'px';
	document.getElementById('dolgozom_div').style.top = top + 'px';
}

function hideDolgozom(){
	document.getElementById('dolgozom_div').style.visibility = 'hidden';
}

function setSelectedOption( select, selectedValue ){
    for (var i = 0; i < select.options.length; i++) {
        if ( select.options[i].value == selectedValue ){
            select.options[i].selected = true;
            break;
        }
    }
}

function getAjaxObject(){
    var xmlhttp;

        // browser based object setting
    if (window.XMLHttpRequest){
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    }else if (window.ActiveXObject){
      // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }else{
      alert("Your browser does not support XMLHTTP!");
    }

    return xmlhttp;
}

function ajaxControl( httpControl, variablesAll ){

	var loading = document.getElementById("dolgozom_div");
	if (loading){
		loading.style.visibility = "visible";			
		loading.style.left = (iWidth-132)/2 + "px";
		loading.style.top = (iHeight-168)/2 + "px";
	}

	// tömb elküldése és a válasz feldolgozás elindítása
    dojo.xhrPost({
        url: httpControl + "?ajaxControl=1",
        postData : dojo.toJson( variablesAll ),
        handleAs: "text",
        load: function( response, ioArgs ) {
                try {
                  ajaxView( response );
					
					
				  var loading = document.getElementById("dolgozom_div");
    			  if ( loading.style.visibility == "visible" ){
					loading.style.visibility = "hidden";
				  }
                } catch (e) {
                  alert("An exception occurred in the script. Error name: " + e.name 
                  + ". Error message: " + e.message); 
				  var loading = document.getElementById("dolgozom_div");
    			  if ( loading.style.visibility == "visible" ){
					loading.style.visibility = "hidden";
				  }
                }                
                return response; },
        error: function(response, ioArgs) {
                console.error("HTTP status code: ", ioArgs.xhr.status);
                return response; }
    });
}

function ajaxView( response ){
    //console.error(response);
    var responseArray = JSON.parse( response );
    //console.error(responseArray);

    for ( wpIndex=0; wpIndex<responseArray.length; wpIndex++ ){
        var sceID = responseArray[wpIndex]['sceID'];

        switch( responseArray[wpIndex]['type'] ){
			case 'mce_div':
				//getContent nélkül nem updateli az mce-t
				tinyMCE.getContent('mce_editor_txa_'+sceID);
				tinyMCE.execCommand('mceFocus', false, 'mce_editor_txa_'+sceID);
				tinyMCE.setContent(responseArray[wpIndex]["tartalom"]);
				tinyMCE.getContent('mce_editor_txa_'+sceID);
				break;
			case 'table':
				var table = document.getElementById('tableDiv_' + sceID);
				if ( table != null ){
					table.innerHTML = responseArray[wpIndex]['tartalom'];
				}
				break;
			case 'button':
				writeIntoElement( 'btn_' + responseArray[wpIndex]['sceDiv'], responseArray[wpIndex]['felirat'] );
				break;
			case 'label':
			  writeIntoElement( 'felirat_' + sceID, responseArray[wpIndex]['felirat'] );
			  break;
            case 'named_textfield':
              writeIntoElement( 'felirat_' + sceID, responseArray[wpIndex]['felirat'] );
              document.getElementById( 'textfield_' + sceID ).value = responseArray[wpIndex]['tartalom'];
              break;

            case 'named_txa':
              document.getElementById( 'txa_' + sceID ).value = responseArray[wpIndex]['tartalom'];
              break;

			case 'named_checkbox':
              writeIntoElement( 'felirat_' + sceID, responseArray[wpIndex]['felirat'] );
              if ( responseArray[wpIndex]['tartalom'] == '' ){
                document.getElementById( 'checkBox_check_' + sceID ).checked = false;
              }else{
                document.getElementById( 'checkBox_check_' + sceID ).checked = true;
              }
              refreshDsgnChckBoxView( sceID, "http://www.woodpecker.hu/WPGenerator/css/WPGenerator/named_checkbox/");
              break;

            case 'named_combo':
			  //régi, dizájn elötti
              //writeIntoElement( 'combo_' + responseArray[wpIndex]['formName'], responseArray[wpIndex]['tartalom'] );
              //új, dizánjos
			  writeIntoElement( responseArray[wpIndex]['formName'] + '_sel', responseArray[wpIndex]['tartalom'] );
			  //új, ez kell a kiválasztásnál
			  eval('setComboFakeTxt_'+ sceID + '();');
              break;

            case 'new_button_list':
              writeIntoElement( 'list_' + responseArray[wpIndex]['sce_wpadatName'] + 'All_sel', responseArray[wpIndex]['tartalom'] );
              break;

            case 'combo_local_controller':
			  //régi, dizájn elötti
              //writeIntoElement( 'select_' + responseArray[wpIndex]['formName'], responseArray[wpIndex]['tartalom'] );
              //új, dizánjos
              writeIntoElement( responseArray[wpIndex]['formName'] + '_sel', responseArray[wpIndex]['tartalom'] );
			  //új, ez kell a kiválasztásnál
			  eval('setComboFakeTxt_'+ sceID + '();');
              break;
              
            case 'messageForViewAlert':
                alert( responseArray[wpIndex]['tartalom'] );
        }


            // SCE-k elrejtése és megjelenítése
        if ( responseArray[wpIndex]['sceDiv'] ){
            document.getElementById( responseArray[wpIndex]['sceDiv'] ).style.visibility = responseArray[wpIndex]['visibility'];
        }

		/*
        if ( responseArray[wpIndex]['sceDiv'] ){
            document.getElementById( responseArray[wpIndex]['sceDiv'] ).style.visibility = responseArray[wpIndex]['visibility'];
        }
		*/
    }
}

function refreshAfter_connection_popup() {
    return true;
}

var index;
var win;
var betoltes_count;

function connection_popup( httpConnectionPopup ) {

	jsInclude(httpConnectionPopup,  '/js/prototype.js', true);
	jsInclude(httpConnectionPopup,  '/js/effects.js', true);
	jsInclude(httpConnectionPopup, '/js/window.js', true);
	cssInclude(httpConnectionPopup, '/css/popup/default.css', true);

    win = new Window(
    "connection_popup_" + index,
    {
      width: 400,
      height: 400,
      zIndex:150,
      opacity:1,
      resizable: false,
      closable: true,
      showEffect: Element.show,
      hideEffect: Element.hide,
      title: "Connection ablak",
      url: httpConnectionPopup + '/graphic_pages/wp_connection_popup/control.php'
    }
  );
    win.setCloseCallback( refreshAfter_connection_popup );
    win.showCenter(true);
    index++;
}

/*DOJO alapú dnd függvények**************************/

function makeDndSource( nodeID, param ){
	return dndSource = new dojo.dnd.Source( nodeID, param );
}

function getNode( param, where ){
	return dojo.query( param, where );
}

function getNodeById( id ){
	return dojo.byId( id );
}

function getNodeAttr( node, attr ){
	return dojo.attr( node, attr );
}

function jsonEncode( adat ){
	return dojo.toJson( adat );
}

///////////////////////////////
//ajaxos hívás post-al küldhető paraméterrelm és string-el visszatérésnél
function runAjax( phpURL, onLoad, onError ){
	//dolgozom kép bekapcsolása (dolgozom_div)
	var loading = document.getElementById("dolgozom_div");
	if ( loading ){
		var time = setTimeout(function(){loading.style.visibility = "visible";},1000);
		loading.style.left = "450px";
		loading.style.top = "250px";
	}
	
	if ( (typeof onError) == 'undefined' ){
		dojo.xhrGet( {
			// Ezt a php file-t hívja meg.
			url: phpURL,
			handleAs: "text",

			timeout: 5000, // Ennyi ideig vár a válaszra

			// a LOAD függvény lesz meghívva sikeres válasz esetén.
			//load: onLoad,
			load: function(respond, ioArgs){
					if ( onLoad != null ){
						onLoad(respond, ioArgs);
					}
					clearTimeout(time);
					if ( loading ){
						loading.style.visibility = "hidden";
					}
					return respond;
				  },

			// Hiba esetén az ERROR függvény lesz meghívva.
			error: function(response, ioArgs) {
			  console.error("HTTP status code: ", ioArgs.xhr.status);
			  console.error("Error text: ", response);
			  return response;
			  }
		});
	}else{
		dojo.xhrGet( {
			// Ezt a php file-t hívja meg.
			url: phpURL,
			handleAs: "text",

			timeout: 5000, // Ennyi ideig vár a válaszra

			// a LOAD függvény lesz meghívva sikeres válasz esetén.
			//load: onLoad,
			load: function(respond, ioArgs){
					if ( onLoad != null ){ 
						onLoad(respond, ioArgs);
					}
					clearTimeout(time);
					if ( loading ){
						loading.style.visibility = "hidden";
					}
					return respond;
				  },

			// Hiba esetén az ERROR függvény lesz meghívva.
			error: onError
		});
	}
}


///////////////////////////////////////////////
//ajaxos hívás post-ban json kódolt adattal!!
function runAjaxJsonToJson( phpURL, post, onLoad, onError, showDolgozom ){
	//dolgozom kép bekapcsolása (dolgozom_div)
	if ( ( typeof showDolgozom ) == "undefined"  || showDolgozom == null ){
		showDolgozom = true;
	}
	
	if( showDolgozom ){
		var loading = document.getElementById("dolgozom_div");
		if (loading){
			var time = setTimeout(function(){loading.style.visibility = "visible";},1000);
			loading.style.left = "450px";
			loading.style.top = "250px";
		}
	}
	
	if ( (typeof onError) == 'undefined' ){
		dojo.xhrPost( {
			// Ezt a php file-t hívja meg.
			url: phpURL, 
			postData : post,
			handleAs: "json",

			timeout: 5000, // Ennyi ideig vár a válaszra

			// a LOAD függvény lesz meghívva sikeres válasz esetén.
			//load: onLoad,
			load: function(respond, ioArgs){
					if ( onLoad != null ){
						onLoad(respond, ioArgs);
					}
					if( showDolgozom ){
						clearTimeout(time);
						if ( loading ){
							loading.style.visibility = "hidden";
						}
					}
					return respond;
				  },

			// Hiba esetén az ERROR függvény lesz meghívva.
			error: function(response, ioArgs) {
			  console.error("HTTP status code: ", ioArgs.xhr.status);
			  console.error("Error text: ", response);
			  return response;
			  }
		});
	}else{
		dojo.xhrPost( {
			// Ezt a php file-t hívja meg.
			url: phpURL, 
			postData : post,
			handleAs: "json",

			timeout: 5000, // Ennyi ideig vár a válaszra

			// a LOAD függvény lesz meghívva sikeres válasz esetén.
			//load: onLoad,
			load: function( respond, ioArgs){
					if ( onLoad != null ){
						onLoad(respond, ioArgs);
					}
					if( showDolgozom ){
						clearTimeout(time);
						if ( loading ){
							loading.style.visibility = "hidden";
						}
					}
					return respond;
				  },

			// Hiba esetén az ERROR függvény lesz meghívva.
			error: onError
		});
	}
}

///////////////////////////
//post-ban küldhet paramétert json kódolt adat jön vissza
function runAjaxJson( phpURL, onLoad, onError, showDolgozom ){
	//dolgozom kép bekapcsolása (dolgozom_div)
	if ( ( typeof showDolgozom ) == "undefined"  || showDolgozom == null ){
		showDolgozom = true;
	}

	if( showDolgozom ){
		var loading = document.getElementById("dolgozom_div");
		if (loading){
			var time = setTimeout(function(){loading.style.visibility = "visible";},1000);
			loading.style.left = "450px";
			loading.style.top = "250px";
		}
	}

	if ( (typeof onError) == 'undefined' ){
		jQuery.noConflict();
		jQuery.ajax({
		url : phpURL,
		dataType : "json",

		timeout : 5000,

		success : function(respond){
			if ( onLoad != null ){
				onLoad( respond );
			}
			if ( showDolgozom ){
				clearTimeout(time);
				if ( loading ){
					loading.style.visibility = "hidden";
				}       
			}
		},

		error : function( XMLHttpRequest, textStatus, errorThrown ){
				console.error("errorThrown: ", errorThrown);
				console.error("textStatus: ", textStatus);
			}
		});

	}else{
		jQuery.noConflict();
		jQuery.ajax({
			url : phpURL,
			dataType : "json",

			timeout : 5000,

			success : function(respond){
				if ( onLoad != null ){
					onLoad( respond );
				}
				if ( showDolgozom ){
					clearTimeout(time);
					if ( loading ){
						loading.style.visibility = "hidden";
					}       
				}
			},

			error : onError
		});
	}
}

function forEach( nodes, nodeFgv ){
	dojo.forEach( nodes, nodeFgv );
}

function connectToEvent( node, event, fgv ){
	dojo.connect( node, event, fgv);
}

/*
jsInclude funkció

Leírás:
Include funkciót hajt végre az ?url? argumentumban
megdott *.js fájlra. Azaz betölti az oldalra.

Argumentumok:
? url: a fájl elérési útja, amit be akarunk húzni,
? useOnce: true kell, hogy legyen, ha csak egyszer akarjuk, hogy megjelenjen
az aktuális script a weblapon belül.

Visszatérés:
? true, ha hozzáfűződött a javascript
*/
function jsInclude( host, url, useOnce)
{

	if( httpBase == 'undefined' || host != httpBase + '/' ){

		alert( 'Rossz hosztnév vagy nincs telepítve a config_js.js' );
		return false;
		
	} else {
		
		// a fejléc elem megkeresése
		var head = document.getElementsByTagName("head").item(0);
		//kiolvassuk az összes objektumot a fejlécből
		var jss = head.getElementsByTagName("script");
		// tag számláló
		var index = 0;

		//Csak egyszer használható?
		if(useOnce == true){
			//Ha csak egyszer akarjuk használni, akkor kell keresni, hogy megvan-e
		
			//Végigfutunk, hogy van-e már ilyen script behúzva
			for(; (index < jss.length) && (jss.item(index).getAttribute("src") != host + url); index++);
		}
		//Megtaláltuk (azaz nem futott túl az ?index?) vagy többször is be akarjuk húzni?
		if(index == jss.length || useOnce == false){
			//Nem létezik vagy többször is használható, ezért létrehozhatjuk
		
			//Egy új elem létrehozása és felparaméterezése
			var js = document.createElement("script");
			js.setAttribute("language", "javascript");
			js.setAttribute("type", "text/javascript");
			js.setAttribute("src", host + url);

			//A elem hozzáadása a fejléc elemhez
			head.appendChild(js);

			//Hozzáfűztük szóval true-t kell visszaadni
			return true;
		}

		//Nem adódott hozzá a megadott javascript
		return false;
	}

	//Nem adódott hozzá a megadott javascript
	return false;
}
/*
jsInclude funkció

Leírás:
Include funkciót hajt végre az ?url? argumentumban
megdott *.js fájlra. Azaz betölti az oldalra.

Argumentumok:
? url: a fájl elérési útja, amit be akarunk húzni,
? useOnce: true kell, hogy legyen, ha csak egyszer akarjuk, hogy megjelenjen
az aktuális script a weblapon belül.

Visszatérés:
? true, ha hozzáfűződött a javascript
*/
function cssInclude( host, url, useOnce)
{
	if( httpBase == 'undefined' || host != httpBase + '/' ){

		alert( 'Rossz hosztnév vagy nincs telepítve a config_js.js' );
		return false;
		
	} else {
		// a fejléc elem megkeresése
		var head = document.getElementsByTagName("head").item(0);
		//kiolvassuk az összes objektumot a fejlécből
		var css = head.getElementsByTagName("link");
		// tag számláló
		var index = 0;

		//Csak egyszer használható?
		if(useOnce == true){
			//Ha csak egyszer akarjuk használni, akkor kell keresni, hogy megvan-e

			//Végigfutunk, hogy van-e már ilyen script behúzva
			for(; (index < css.length) && (css.item(index).getAttribute("src") != host + url); index++);
		}

		//Megtaláltuk (azaz nem futott túl az ?index?) vagy többször is be akarjuk húzni?
		if(index == css.length || useOnce == false){

			//Nem létezik vagy többször is használható, ezért létrehozhatjuk

			//Egy új elem létrehozása és felparaméterezése
			var cssNode = document.createElement("link");
			cssNode.type = 'text/css';
			cssNode.rel = 'stylesheet';
			cssNode.media = 'screen';
			cssNode.href =  host + url;

			//A elem hozzáadása a fejléc elemhez
			head.appendChild(cssNode);

			//Hozzáfűztük szóval true-t kell visszaadni
			return true;
		}

		//Nem adódott hozzá a megadott javascript
		return false;
	}
    
	//Nem adódott hozzá a megadott javascript
    return false;
}


/*	design checkbox vizuális frissítése	*/
function refreshDsgnChckBoxView (sceID, imgsPath) {
//	alert('refreshDsgnChckBoxView');
	sceID += "";	/// force to create a string
	if (sceID.substring(0, 15) == "checkBox_check_") {
		sceID = sceID.substring(15);
	} else {
		sceID = sceID;
	}
	var chkElement = document.getElementById('checkBox_check_'+sceID);
//	alert(' chkElement = ' + chkElement + ' :: sceID: ' +sceID);
	if ( chkElement != null ) {
    var chkImg = document.getElementById('checkBox_img_'+sceID);
    if ( chkImg != null ) {
      if (chkElement.checked) {
        chkImg.src = imgsPath+"wp_named_checkbox_checked.png";	
      } else {
        chkImg.src = imgsPath+"wp_named_checkbox_normal.png";
      }
    }
  }
}

/* fejléc menü functions */

// menu init
var inMenu = 0;
var menuActive = '';
var timeOn = null;

// show menu
function wpShowMenu(menuName) {
    if (document.getElementById(menuName)) {
        if (timeOn != null) {
            clearTimeout(timeOn);
            wpHideMenu(menuActive);
        }
        document.getElementById(menuName).style.visibility = 'visible';
        menuActive = menuName;
    }
}

// hide menu
function wpHideMenu(menuName) {
    if (inMenu == 0) {
        document.getElementById(menuName).style.visibility = 'hidden';
    }
}

// mouse out timer
function wpMenuTimer(lastMenuName) {
    if (document.getElementById(lastMenuName)) {
        timeOn = setTimeout("wpMenuTimeout()", 150);
    }
}

// hide button on mouse out
function wpMenuTimeout() {
    if (inMenu == 0) {
        wpHideMenu(menuActive);
    }
}

// menu mouseover
function wpMenuOver(menuButton) {
    clearTimeout(timeOn);
    inMenu = 1;
    if ( document.getElementById('menuButton_'+menuButton) && menuButton.length ) {
        document.getElementById('menuButton_'+menuButton).className = 'header_page_name_menu_over';
    }
}

// menu mouse out
function wpMenuOut(menuButton, className) {
    inMenu = 0;
    timeOn = setTimeout("wpHideMenu(menuActive)", 50);
    if ( document.getElementById('menuButton_'+menuButton) && menuButton.length ) {
        document.getElementById('menuButton_'+menuButton).className = className;
    }
}

////////////////////////////////////////////////////////////////////////////////

function initSessionFrissit(url,refreshSec) {

  if ( ( typeof url != "undefined" ) && (url != null) ){

      sessionFrissitUrl=url;


      if ( ( typeof refreshSec != "undefined" ) && (refreshSec != null) ){
        sessionFrissitSecs=refreshSec;
      } else {
        refreshSec = 60;
        sessionFrissitSecs=refreshSec;
      }

      beginSessionFrissit(sessionFrissitSecs,sessionFrissitUrl,sessionFrissitSecs);
  }
}

function beginSessionFrissit(secsToRefesh,sessionUrl,sessionSecs){
  if (secsToRefesh==1) {

    runAjaxJson( sessionUrl, null, null, false );
    secsToRefesh=sessionSecs;
    setTimeout('beginSessionFrissit('+secsToRefesh+',\''+sessionUrl+'\','+sessionSecs+')',1000)

  } else{

    secsToRefesh-=1;
    setTimeout('beginSessionFrissit('+secsToRefesh+',\''+sessionUrl+'\','+sessionSecs+')',1000);

  }

}


function tableScrollJump( div_id, sor_id ){

	if( sor_id.length > 0 ){
		var rows = document.getElementById(div_id).getElementsByTagName('tr');
		var i = 0;
		var magassag = 0;
		var tablamagassag = document.getElementById(div_id).clientWidth;
		
		while( i < rows.length && rows[i].id != sor_id ) {
			if( rows[i].id.length > 0 ) magassag = magassag + rows[i].clientHeight + 0;
			++i;
		}

		scrollHelyzet = magassag - ( tablamagassag/2 );
		document.getElementById(div_id).scrollTop = scrollHelyzet;
	}
	return true;
}

//benne van-e a class?
function hasClass(elem,clas) {
	return elem.className.match(new RegExp('(\\s|^)'+clas+'(\\s|$)'));
}

//class hozzáadása az elemhez
function addClass(elem,clas) {
	if (!this.hasClass(elem,clas)) elem.className += " "+clas;
}

//class leszedése
function removeClass(elem,clas) {
	if (hasClass(elem,clas)) {
		var reg = new RegExp('(\\s|^)'+clas+'(\\s|$)');
		elem.className=elem.className.replace(reg,' ');
	}
}


