

	
	
var g_HtmlArea = null;
var g_project_name = null;
var g_structure_name = null;
var g_arrPostInits = new Array();
var g_arrResizeScripts = new Array();
	
	
var fromWindowWidth = 500;
var dialogWindowWidth = 200;
var dialogWindowHeight = 100;
	
	
window.onresize = DoResizeScripts;
	
	
function AddPostInit(strCmd)
{	
	g_arrPostInits[g_arrPostInits.length] = strCmd;
}	
	
function PostInit()
{	
	for (i = 0; i < g_arrPostInits.length; i++)
	{	
		strCmd = g_arrPostInits[i];
		
		//alert(strCmd);
		
		eval(strCmd);
	}	
}	
	
function AddResizeScript(strCmd)
{	
	g_arrResizeScripts[g_arrResizeScripts.length] = strCmd;
}	
	
function DoResizeScripts()
{	
	for (i = 0; i < g_arrResizeScripts.length; i++)
	{	
		strCmd = g_arrResizeScripts[i];
		
		//alert(strCmd);
		
		eval(strCmd);
	}	
}	
	
function createTarget(form) 
{
//http://javascript.internet.com/forms/form-target-formatting.html	
	_target = form.target;
	_colon = _target.indexOf(":");
	if(_colon != -1) 
	{
		form.target = _target.substring(0,_colon);
		form.args = _target.substring(_colon+1);
	} 
	else if(typeof(form.args)=="undefined") 
	{
		form.args = "";
	}
	if(form.args.indexOf("{")!=-1) 
	{
		_args = form.args.split("{");
		form.args = _args[0];
		for(var i = 1; i < _args.length;i++) 
		{
			_args[i] = _args[i].split("}");
			form.args += eval(_args[i][0]) + _args[i][1];
		}
	}
	form.args = form.args.replace(/ /g,"");
	form.args = form.args.replace(/\n/g,"");
	form.args = form.args.replace(/\r/g,"");
	form.args = form.args.replace(/\t/g,"");
	//http://javascript.internet.com/bgeffects/bouncing-image.html
	//alert(document.body.clientWidth);
	_win = window.open('',form.target,form.args);
	if(typeof(focus)=="function")
		_win.focus();
	return true;
}

function ClearEditPage()
{
	if (typeof(top.freMain) != "undefined" && typeof(top.freMain.freEdit) != "undefined")
		top.freMain.freEdit.document.location = '/licoms/blank.html';
	if (typeof(top.freEdit) != "undefined")
		top.freEdit.document.location = '/licoms/blank.html';
	
}

function RefreshSearchPage()
{
	top.freSearch.recallPage();
}


function SetValue(objCtl, strVal)
{	
	objCtl.value = strVal;
}	

function RemoveTags(strVal) {
  return(strVal.replace(/<[^>]*>/gi,""));
} 
	
	
function SelectItem(objCtl, strVal)
{	
	if (navigator.appName == "Netscape")
	{
		for (var i = 0; i < objCtl.options.length; i++)
		{
			if (objCtl.options[i].value == strVal)
				objCtl.options[i].selected = true;
		}
	}
	else
	{
		objCtl.value = strVal;
	}
}	
	
function SelectRadio(objCtl, strVal)
{	
	for (var i = 0; i < objCtl.length; i++)
	{
		if (objCtl[i].value == strVal)
			objCtl[i].checked = true;
	}
}	
	
function CheckRadioControlValue(objCtl)
{	
	var blnValid = false;
	
	
	for (var i = 0; i < objCtl.length && !blnValid; i++)
	{	
		blnValid = objCtl[i].checked;
	}	
	
	
	return blnValid;
}	
	
function InsertSelectValue(objTxa, objSel) {
	for (var i = 0; i < objSel.options.length && ! objSel.options[i].selected ; i++)
	{
	}
	if ( i < objSel.options.length ) {
	  if ( objSel.options[i].id == "edit"){
		} else {
			var val = objTxa.value;
			val = "," + val + ",";
			if ( val.indexOf("," + objSel.options[i].value+ ",") == -1 ) {
				if ( objTxa.value != "" ) {
					objTxa.value += ","
				}
				objTxa.value += objSel.options[i].value;
			}
		}
	}			
}

function InicCheckBoxValue(objCtlCb, objCtl, strVal, strTrueVal, strFalseVal)
{
	if ( strVal == strTrueVal ){
		objCtlCb.checked = true;
		objCtl.value = strTrueVal;
	} else {
		objCtlCb.checked = false;
		objCtl.value = strFalseVal;	
	}
}

function ChangeCheckBoxValue(objCtlCb, objCtl, strTrueVal, strFalseVal) 
{
	if ( objCtlCb.checked ){
		objCtl.value = strTrueVal;
	} else {
		objCtl.value = strFalseVal;	
	}
}
	
function SetDateControlsValue(strDate, ctlYear, ctlMonth, ctlDay)
{	
	var success = false;
	if (strDate.length == 10)
	{	
		strYear = strDate.substring(0, 4);
		strMonth = strDate.substring(5, 7);
		strDay = strDate.substring(8, 10);
		success = true;
	} else if ( strDate.indexOf("-") == -1 && strDate.length == 8 ) {
		strYear = strDate.substring(0, 4);
		strMonth = strDate.substring(4, 6);
		strDay = strDate.substring(6, 8);
		success = true;
	}
	if ( success ) {
		ctlYear.value = strYear;
		SelectItem(ctlMonth, strMonth);
		SelectItem(ctlDay, strDay);
	}
}	
	
function SetDateTimeControlsValue(strDate, ctlYear, ctlMonth, ctlDay, ctlHour, ctlMin)
{	
	var success = false;
	if (strDate.length > 15)
	{	
		strYear = strDate.substring(0, 4);
		strMonth = strDate.substring(5, 7);
		strDay = strDate.substring(8, 10);
		strHour = strDate.substring(11, 13);
		strMin = strDate.substring(14, 16);
		success = true;
	} else if ( strDate.indexOf("-") == -1 && strDate.length > 13 ) {
		strYear = strDate.substring(0, 4);
		strMonth = strDate.substring(4, 6);
		strDay = strDate.substring(6, 8);
		strHour = strDate.substring(8, 10);
		strMin = strDate.substring(10, 12);
		success = true;
	}
	if ( success ) {
		ctlYear.value = strYear;
		SelectItem(ctlMonth, strMonth);
		SelectItem(ctlDay, strDay);
		SelectItem(ctlHour, strHour);
		SelectItem(ctlMin, strMin);
	}
}	

function CheckSelectControlValue(objForm)
{
	for (var i = 0; i < objForm.options.length && ! objForm.options[i].selected ; i++)
	{
	}
	if ( i < objForm.options.length ) {
	  if ( objForm.options[i].id == "edit"){
			alert("A mező kitöltése kötelező!");
			objForm.focus();
			return false;
		} else {
			return true;
		}
	} else {
		alert("Hiba! Nincs elem választva.");
		objForm.focus();
		return false;
	}			
}
	
function CheckDateControlsValue(ctlYear, ctlMonth, ctlDay, blnNeeded)
{	
	
	if ( ctlYear.value != "" )
	{	
		if ( isNaN(ctlYear.value) )
		{
			alert("Az év mezőbe csak számot lehet írni.");
			
			ctlYear.focus();
			
			return	false;
		}
	
		if ( ctlMonth.value < 1 || ctlMonth.value > 12 ) 
		{	
			alert("Érvénytelen hónap.");
			
			ctlMonth.focus();
			
			return	false;
		}	
		
		if ( ctlDay.value < 1 ) 
		{	
			alert("Érvénytelen nap.");
			
			ctlDay.focus();
			
			return false;
		}	
		
		if ( (	ctlMonth.value == 1 || ctlMonth.value == 3 || ctlMonth.value == 5 || ctlMonth.value == 7 ||
				ctlMonth.value == 8 || ctlMonth.value == 10 || ctlMonth.value == 12 ) && ctlDay.value > 31 )
		{	
			alert("Érvénytelen nap.");
			
			ctlDay.focus();
			
			return false;
		}	
		
		if ( (	ctlMonth.value == 4 || ctlMonth.value == 6 || ctlMonth.value == 9 || ctlMonth.value == 11 ) 
				&& ctlDay.value > 30 )
		{	
			alert("Érvénytelen nap.");
			
			ctlDay.focus();
			
			return false;
		}	
		
		isLeap = false;
		
		if ( ctlYear.value % 400 == 0 ) 
		{	
			isLeap = true;
		}	
		else
		{	
			if ( ctlYear.value % 100 == 0 ) 
			{	
	        	isLeap = false;
	      	}	
	      	else
	      	{	
				if ( ctlYear.value % 4 == 0 ) 
				{	
					isLeap = true;
				}	
			}	
		}	
		if (	(  isLeap && ctlMonth.value == 2 && ctlDay.value > 29 ) ||
				( !isLeap && ctlMonth.value == 2 && ctlDay.value > 28 ) ) 
		{	
			alert("Érvénytelen nap.");
			ctlDay.focus();
			
			return false;
		}	
		
		
	    return true;
 	}	
 	else 
 	{	
		if ( blnNeeded ) 
		{	
			alert("A dátumot ki kell tölteni.");
			
			ctlYear.focus();
			
			return false;
    	}	
    	else 
    	{	
      		return true;
		}	
	}	
	
	return true;
}	

function CheckDateTimeControlsValue(ctlYear, ctlMonth, ctlDay, ctlHour, ctlMin, blnNeeded)
{	
	var blnValid = CheckDateControlsValue(ctlYear, ctlMonth, ctlDay, blnNeeded);
	
	if (blnValid)
	{	
		if ( ctlHour.value < 0 || ctlHour.value > 23 ) 
		{	
			alert("Érvénytelen óra.");
			
			ctlHour.focus();
			
			blnValid = false;
		}	
	
		if ( blnValid && (ctlMin.value < 0 || ctlMin.value > 59) ) 
		{	
			alert("Érvénytelen perc.");
			
			ctlMin.focus();
			
			blnValid = false;
		}	
	}	
 	
 	
	return blnValid;
}
	
function SetDateHiddenValue(ctlHidden, ctlYear, ctlMonth, ctlDay)
{	
	ctlHidden.value = 
		ctlYear.value + "-" + ctlMonth.value + "-" + ctlDay.value;
}	
	
function SetDateTimeHiddenValue(ctlHidden, ctlYear, ctlMonth, ctlDay, ctlHour, ctlMin)
{	
	ctlHidden.value = 
		ctlYear.value + "-" + ctlMonth.value + "-" + ctlDay.value + " " + ctlHour.value + ":" + ctlMin.value + ":00";
}	
	
function TextAreaLength(fctCurrentLength, fctTextArea, intMaxLenght)
{	
 	if (fctTextArea.value.length > intMaxLenght)
 	{	
		fctTextArea.value = fctTextArea.value.substring(0, intMaxLenght);
		fctCurrentLength.value = 0;
	}	
	else
	{	
    	fctCurrentLength.value = intMaxLenght - fctTextArea.value.length;
	}	
	
	
  	return true;
}	
	
function PositionUp(strID, intPosition)
{	
	document.frmPosition.old_position.value = intPosition;
	document.frmPosition.new_position.value = intPosition - 1;
	document.frmPosition.id.value = strID;
	
	createTarget(document.frmPosition);
	
	document.frmPosition.submit();
}	
	
function PositionDown(strID, intPosition)
{	
	document.frmPosition.old_position.value = intPosition;
	document.frmPosition.new_position.value = intPosition + 1;
	document.frmPosition.id.value = strID;
	
	createTarget(document.frmPosition);
	
	document.frmPosition.submit();
}	
		
function CreateNewChild(strID)
{	
	document.frmNewChild.tree_id.value = strID;
	
	document.frmNewChild.submit();
}	
	
function ModifyTreeNode(strTreeID, objID, strID)
{	
	document.frmModTree.tree_id.value = strTreeID;
	objID.value = strID;
	
	document.frmModTree.submit();
}	
	
function SelectRecord(strShowValue, strCodeValue, strCallerName)
{	
	var strEval = "window.opener.SelectItem_" + strCallerName 
		+ "(RemoveTags(URLDecode('" + strShowValue + "')), URLDecode('" + strCodeValue + "'));";
	
	eval(strEval);
	
	window.close();
}	
	
function VisibilityControl(objForm, strName, strType, blnEnable)
{	
	if (strType == "textbox")
	{	
		strCmd = "objForm.txt_" + strName + ".disabled = !blnEnable";
		
		eval(strCmd);
	}	
	else if (strType == "codeset" || strType == "select")
	{	
		strCmd = "objForm.sel_" + strName + ".disabled = !blnEnable";
		
		eval(strCmd);
	}
	else if (strType == "simple-codename") 
	{
		selBtn = document.getElementById("scn_" + strName + "_selbtn");
		resetBtn = document.getElementById("scn_" + strName + "_resetbtn");
		if ( blnEnable ) {
			selBtn.style.visibility='visible';
			if ( resetBtn ) {
				resetBtn.style.visibility='visible';
			}
		} else {
			selBtn.style.visibility='hidden';
			if ( resetBtn ) {
				resetBtn.style.visibility='hidden';
			}
		}
	}
}	
	
/*		
	Multi Copy supported Select Record
*/		
function SelectRecordWithMC(strShowValue, strCodeValue, strCallerName, arrMultiCopy)
{	
	var strEval = "window.opener.SelectItem_" + strCallerName 
		+ "(RemoveTags(URLDecode('" + strShowValue + "')), URLDecode('" 
		+ strCodeValue + "'), arrMultiCopy);";
	
	eval(strEval);
	
	window.close();
}	
	
function SetMultiCopyValues(objForm, arrMultiCopy)
{	
	var objProperty = null;
	var strValue = "";
	var strCmd = "";
	
	
	for (i=0; i < arrMultiCopy.length; i++)
	{	
		objProperty = arrMultiCopy[i];
		
		
		if (objProperty._proptype == "textbox")
		{	
			for (var strColumn in objProperty)
			{	
				if (strColumn.indexOf("_") != 0)
				{	
					strValue = objProperty[strColumn];
					strValue = RemoveTags(URLDecode(strValue));
					
					strCmd = "objForm.txt_" + objProperty._propname + ".value = '" + strValue + "'";
					
					eval(strCmd);
				}	
			}	
		}	
		else if (objProperty._proptype == "codeset")
		{	
			for (var strColumn in objProperty)
			{	
				if (strColumn.indexOf("_") != 0)
				{	
					strValue = objProperty[strColumn];
					strValue = RemoveTags(URLDecode(strValue));
					
					strCmd = "SelectItem(objForm.sel_" + objProperty._propname + ", '" + strValue + "');";
					
					eval(strCmd);
				}	
			}	
		}	
		else
		{	
			alert("Not supported control type for MultiCopy!");
		}	
	}	
}	
	
function LocateParentNode(objCurrent, strNodeName)
{	
	var blnFound = false;
	var objFound = null;
	
	
	while (!blnFound)
	{	
		objCurrent = objCurrent.parentNode;
//		alert(objCurrent);
//		alert(objCurrent.nodeName);
		
		if (objCurrent.nodeName == strNodeName)
		{	
			objFound = objCurrent;
			blnFound = true;
		}	
	}	
	
	
	return objFound;
}	
	
function LocateParentForm(objCurrent)
{	
	return LocateParentNode(objCurrent, 'FORM');
}	
	
function SaveHtmlArea(strContent)
{	
	g_HtmlArea.value = strContent;
	g_HtmlArea.onkeyup();
}	

function LoadHtmlArea()
{	
	return(g_HtmlArea.value);
}	

function GetProjectName()
{	
	return(g_project_name);
}	

function GetStructureName()
{	
	return(g_structure_name);
}	


function ShowHtmlArea(objTextArea, strProjectName, strStructureName)
{	
	g_HtmlArea = objTextArea;	
	g_project_name = strProjectName;
	g_structure_name = strStructureName;

	window.open('/licoms/htmlarea/wysiwyg.html','chblokk','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,scrollbars=yes,width=620,height=500');
}	
	
function GroupCodeNameShowSearcher(objCallerForm, objParmForm, strStructureName)
{	
	objCallerForm.comm_structure_name.value = strStructureName;
	objCallerForm.req_session.value = 
		strStructureName + ".selector:" + objCallerForm.component_path.value;
	createTarget(objCallerForm);
	objCallerForm.submit();
}	
	
function SelectMainColumn(strFormName, strID)
{	
	eval('document.' + strFormName + '.id.value = strID');
	createTarget(eval('document.' + strFormName));
	eval('document.' + strFormName + '.submit()');
}	
	
function DeleteRecord(strID, strStructName, strTreeID)
{	
	var objForm = null;
	
	
	eval("objForm = document.frmDeleteRecord_" + strStructName + ";");
	eval("objForm." + strStructName + "_id.value = '" + strID + "'");
	
	objForm.tree_id.value = strTreeID;
	
	objForm.submit();
}	

function CheckPassword( ctlPwd1, ctlPwd2, blnNeeded	) 
{
	if ( ctlPwd1.value == ctlPwd2.value )
	{
		if ( ctlPwd1.value == "" && blnNeeded ) {
			alert("A két jelszó mezőt ki kell tölteni!");
			ctlPwd1.focus();
			return false;			
		}
	} else {
		alert("A két jelszónak meg kell egyeznie!");
		ctlPwd1.focus();
		return false;
	}
	
	return true;
	 
}	
	
function WebImageConvertFrom(objCaller, objForm, strConvert)
{	
	var strFilePath = "";
	
	
	eval("strFilePath = objForm.wim_" + strConvert + ".value");
	
	if (strFilePath == "")
	{	
		alert("Nincs feltöltve kép az adott tulajdonsághoz!");
	}	
	else
	{	
		objCaller.prop_name.value = strConvert;
		objCaller.file_path.value = strFilePath;
		
		objCaller.comm_action_key.value = "convert-from";
		
		objCaller.submit();
	}	
}	
	
function WebImageConvertAll(objCaller, objForm, strFilePath)
{	
	if (strFilePath == "")
	{	
		alert("Nincs feltöltve kép az adott tulajdonsághoz!");
	}	
	else
	{	
		objCaller.prop_name.value = "";
		objCaller.file_path.value = strFilePath;
		
		objCaller.comm_action_key.value = "convert-all";
		
		objCaller.submit();
	}	
}	
	
function ShowWebImage(strWebPath, strPath)
{	
	if (strPath == "")
	{	
		alert("Nincs hozzá rendelve kép!");
	}	
	else
	{	
		window.open(strWebPath + strPath, 
			'_blank', 
			'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,scrollbars=yes,width=640,height=480'
			);
	}	
}	

// ====================================================================
//       URLEncode and URLDecode functions
//
// Copyright Albion Research Ltd. 2002
// http://www.albionresearch.com/
// http://www.albionresearch.com/misc/urlencode.htm
// You may copy these functions providing that 
// (a) you leave this copyright notice intact, and 
// (b) if you use these functions on a publicly accessible
//     web site you include a credit somewhere on the web site 
//     with a link back to http://www.albionresarch.com/
//
// If you find or fix any bugs, please let us know at albionresearch.com
//
// SpecialThanks to Neelesh Thakur for being the first to
// report a bug in URLDecode() - now fixed 2003-02-19.
// ====================================================================
function URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +
				        "(URL encoding only supports 8-bit characters.)\n" +
						"A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function URLDecode(encoded)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				if ( encoded.substr(i,3) == "%F5") {
					plaintext += "ő";
				} else if ( encoded.substr(i,3) == "%FB" ) {
					plaintext += "ű";
				} else if ( encoded.substr(i,3) == "%D5" ) {
					plaintext += "Ő";
				} else if ( encoded.substr(i,3) == "%DB" ) {
					plaintext += "Ű";
				} else {
					plaintext += unescape( encoded.substr(i,3) );
				}
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
};	
	
	
