/*
<script type="text/javascript">
    Event.observe(window, 'load', function() {
        Event.observe('featurebox-3-listen', 'click', function(){
            $('featurebox-3').toggle();
        });
    });
</script>
*/
function jump(id) {
	$(id).focus();
}
function watchkey(eventObj,code,fv) {
	var keyCode
	if (document.all){ 
		keyCode=eventObj.keyCode
	} else {
		keyCode=eventObj.which
	}
	if (keyCode==code) {
		eval(fv);
	}
}

function chr(code) {
	if (code==186)	return 'é';
	if (code==222)	return 'á';
	if (code==220)	return 'ű';
	if (code==221)	return 'ú';
	if (code==187)	return 'ó';
	if (code==191)	return 'ü';
	if (code==192)	return 'ö';
	if (code==226)	return 'í';
	return String.fromCharCode(code);
}
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
	function copy_data(from,to) {
		$(to).value=$(from).value;
	}
/*
	var timeout_=10;
	var TimeOutCounter_=-1;
	function TimeOut() {
		this.timeout=10;
		this.counter=-1;
		this.timer = function () {
			if (this.counter>-1) {
				this.counter++;
			}
			if (this.counter>this.timeout) {
				this.out();
			}
			setTimeout("this.timer()",1000);
		}
		this.out() {
			eval("msgwrite('timeout');");
		}
	}
*/
	function send_message(url,frm,error) {
		if ($('debug')!= null) {
			$('debug').innerHTML='';
		}
		var pars = Form.serialize(frm);
//		var timer=new TimeOut();
//		var timer.counter=0;
//		var timer.start();
		var myAjax = new Ajax.Request(
		url, 
			{
				method: 'post', 
				parameters: pars, 
				onComplete:function(originalRequest)	{
//					timer.counter=-1;
					if ($('debug')!= null) {
						$('debug').innerHTML=originalRequest.responseText;
						Element.show('debug');
					}
					if (originalRequest.responseText=='') {
						eval(error);
						return false;
					}
					eval(originalRequest.responseText);
					return false;
				},
				onFailure:function (originalRequest){
					eval(error);
				}
			});
		return false;
	}
	function parseScript(_source) {
		var source = _source;
		var scripts = new Array();
		// Strip out tags
		while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
			var s = source.indexOf("<script");
			var s_e = source.indexOf(">", s);
			var e = source.indexOf("</script", s);
			var e_e = source.indexOf(">", e);
			var src=source.substring(s,s_e+1);
			var scriptTag = src.match(/<script[^>]*\bsrc\b=[^>]*>/i);
			if(scriptTag!=null){
				src = scriptTag.toString().replace(/<script[^>]*src=['"]?([^'">]*)[\W\w]*/i, "$1");
				loadjscssfile(src,'js');
			} else {
				try {
					eval(source.substring(s_e+1, e));
				} catch(ex) {
					alert(ex);// do what you want here when a script fails
				}
			}
			// Strip from source
			source = source.substring(0, s) + source.substring(e_e+1);
		}
		// Return the cleaned source
		return source;
	}

	function loadpage(url,div,onLoad) {
		if (typeof onLoad=='undefined') {
			onLoad='';
		}
		var onLoad=onLoad;
		var myAjax = new Ajax.Request(
		url, 
			{
				method: 'get', 
				onComplete: function (originalRequest)	{
					var responseText=originalRequest.responseText;
					var scriptTag = responseText.match(/<link[^>]*\bhref\b=[^>]*>/i);
					if(scriptTag!=null){
						src = scriptTag.toString().replace(/<link[^>]*href=['"]?([^'">]*)[\W\w]*/i, "$1");
						loadjscssfile(src,'css');
					}					
					$(div).innerHTML=parseScript(originalRequest.responseText);
					eval(onLoad);
					return false;
				},
				onFailure:function (originalRequest){
					msgwrite('FATAL_ERROR');
				}
			});
		return false;
	}





var isOpera, isIE, isNav, isFox, isOther = false;

if (navigator.userAgent.indexOf("Opera")!=-1) {

 isOpera = true;

} else if (navigator.userAgent.indexOf("Firefox")!=-1) {

 isFox = true;

} else if (navigator.appName == "Microsoft Internet Explorer") {

 isIE = true;

} else if (navigator.appName == "Netscape") {

 isNav = true;

} else {

 isOther = true;

}

function IEtransparent() {

if (vIE()==6) {

	var all_element=$$('IMG');

	for(i=0;i<all_element.size();i++) { 

		var class_name=$(all_element[i]).className;

		var cList=class_name.split(" ");

		for(var j=0;j<cList.length;j++) {

			if (cList[j]=='transparent_img') {

				Element.hide($(all_element[i]));

				$(all_element[i]).outerHTML+='<div class="'+$(all_element[i]).className+'" style="width:'+$(all_element[i]).style.width+'px;height:'+$(all_element[i]).style.height+'px;display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+$(all_element[i]).src+'\');">&nbsp;</div>';

			}

		}

	} 

	

}

if ((vIE()==6) || (vIE()==7)) {

	var all_element=$$('IMG');

	for(i=0;i<all_element.size();i++) {

		if ($(all_element[i]).className!='noblock') {

//			$(all_element[i]).style.display='block';

		}

	}

}



}

function htmlspecialchars(ch) {

ch = ch.replace(/&/g,"&amp;")

ch = ch.replace(/\"/g,"&quot;")

ch = ch.replace(/\'/g,"&#039;")

ch = ch.replace(/</g,"&lt;")

ch = ch.replace(/>/g,"&gt;")

return ch

}

function decode_htmlspecialchars(ch) {

ch = ch.replace(/&amp;/g,"&")

ch = ch.replace(/&quot;/g,"\"")

ch = ch.replace(/&#039;/g,"\'")

ch = ch.replace(/&lt;/g,"<")

ch = ch.replace(/&gt;/g,">")

ch = ch.replace(/\n/g,"|10|13")

return ch

}

function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}



function AjaxHint(id,text, divHint) {

		var oThis = this;

		this.divHint = $(divHint);

		this.eventObject=$(id);

		this.text=text;

		Event.observe(id, 'mouseover', function(e) { oThis.getHint(e);});

		Event.observe(id, 'mouseout', function(e) { oThis.hideHint(e);});

}



	AjaxHint.prototype = {

		ajaxRequest: null,

		hintedObject:  null,

		hintTimer: null,



		cancelActivity: function () {

			if (this.hintTimer) {

				clearTimeout(this.hintTimer);

				this.hintTimer = null;

			}

			if (this.ajaxRequest) {

				this.ajaxRequest.transport.abort();

				this.ajaxRequest = null;

			}

		},



		getHint: function (event) {

			this.hintedObject=this.eventObject;

			this.hintedObject.style.cursor = 'wait';

			var oThis = this;

			this.hintTimer = setTimeout(

				function() {oThis.timerGetHint()},

				500

			);

		},



		timerGetHint: function () {

			if (! this.hintedObject) {

				return;

			}

			this.divHint.innerHTML = this.text;

			var pos = Position.cumulativeOffset(this.hintedObject);

			this.divHint.style.left = pos[0] + 'px';

			this.divHint.style.top = (pos[1] + this.hintedObject.offsetHeight) + 'px';

			this.divHint.style.display = 'block';

			this.hintedObject.style.cursor = '';

		},



		hideHint: function (event) {

			this.cancelActivity();

			this.hintedObject.style.cursor = '';

			this.hintedObject = null;

			this.divHint.style.display = 'none';



		}

	}

function sort_array(array,orders) {
		if (typeof orders!='object') {
			return array;
		}
		var ok=false;
		var i=0;
		while ((ok==false) && (i<orders.length)) {
			if (orders[i][1]!='') {
				column=orders[i][0];
				order=orders[i][1];
				ok=true;
			} else {
				i++;
			}
		}
//		alert(orders);
//		alert(orders[i]);
		if (ok==false) {
			return array;
		}
		var oszlop_index = new Array(0);
		var oszlop_array = new Array(0);
		for (var i=0; i<array.length; i++) {
			var elem=array[i][column];
			var elem_index=i;
			if (i==0) {
				oszlop_array.push(elem);
				oszlop_index.push(elem_index);
			} else {
				var megvan=true;
				var j=0;
				while ((megvan) && (j<oszlop_array.length)) {
					if (order==0) {
						if(elem<=oszlop_array[j]) {
							megvan=false;
						} else {
							j++;
						}
					} else {
						if(elem>=oszlop_array[j]) {
							megvan=false;
						} else {
						j++;
						}
					}
				}
				oszlop_array.splice(j,0,elem);
				oszlop_index.splice(j,0,elem_index);
			}
		}
		var array_new = new Array(0);
		for (var i=0; i<oszlop_index.length; i++) {
			var index=oszlop_index[i];
			array_new.push(array[index]);
		}
		return array_new;
	}


function openWindow(theURL,winName,features) 
{ 
  var _W=window.open(theURL,winName,features);
	  _W.focus();
}
function window_reload() {
	window.opener.location.reload();
}

function checkemail(input_field_id){
	var testresults
	var str=document.getElementById(input_field_id).value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	testresults=true
	else{
		testresults=false
	}
	return (testresults)
}

function validate_email(field,alerttxt)
{
	with (field) {
	apos=value.indexOf("@")
	dotpos=value.lastIndexOf(".")
	if (apos<1||dotpos-apos<2) 
	  {alert(alerttxt);return false}
	else {return true}
	}
}
function getReferrer() {
   var referrerDocument=document.referrer
   return referrerDocument
}

function window_close() {
	window.close();
}

function getPageScroll()
{
	var yScroll;

	if (self.pageYOffset) yScroll=self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) yScroll=document.documentElement.scrollTop;

	else if (document.body) yScroll=document.body.scrollTop;

	arrayPageScroll=new Array('',yScroll)
	return arrayPageScroll;
}

function getPageSize(){

	var xScroll, yScroll;

	if (document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll=document.body.scrollWidth;
		yScroll=document.body.scrollHeight;
	}

	else
	{
		xScroll=document.body.offsetWidth;
		yScroll=document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight)
	{
		windowWidth=self.innerWidth;
		windowHeight=self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		windowWidth=document.documentElement.clientWidth;
		windowHeight=document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		windowWidth=document.body.clientWidth;
		windowHeight=document.body.clientHeight;
	}

	if (yScroll < windowHeight) pageHeight=windowHeight;
	else pageHeight=yScroll;

	if (xScroll < windowWidth) pageWidth=windowWidth;
	else pageWidth=xScroll;

	arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight)

	return arrayPageSize; 
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function checknumber(eventObj, obj) {
//használata:
//onKeyPress="return checknumber(event, this)"
	var keyCode
	if (document.all){ 
		keyCode=eventObj.keyCode
	} else {
		keyCode=eventObj.which
	}
	var str=obj.value

	if((keyCode<48 || keyCode >58)   &&   (keyCode != 8)   &&   (keyCode != 0)){
		return false
	}
	return true
	
}
function checknumber_float(eventObj, obj) {
//használata:
//onKeyPress="return checknumber_float(event, this)"
	var keyCode
	if (document.all){ 
		keyCode=eventObj.keyCode
	} else {
		keyCode=eventObj.which
	}
	var str=obj.value
//	alert(keyCode);
	if (keyCode==46) {
		if (str.indexOf('.')=='-1') {
			return true;
		}
	}
	if (keyCode==45) {
		if (str.indexOf('-')=='-1') {
			return true;
		}
	}
	if((keyCode<48 || keyCode >58)   &&   (keyCode != 8)   &&   (keyCode != 0)){
		return false
	}
	return true
	
}
function checkmoney(eventObj, obj) {
//használata:
//onKeyPress="return checknumber(event, this)"
	var keyCode
	if (document.all){ 
		keyCode=eventObj.keyCode
	} else {
		keyCode=eventObj.which
	}
	var str=obj.value
	if (keyCode==46) {
		if (str.indexOf('.')=='-1') {
			return true;
		}
	}
	if((keyCode<48 || keyCode >58)   &&   (keyCode != 8)   &&   (keyCode != 0)){
		return false
	}
	return true
	
}
function check_date(eventObj, obj) {
//használata:
//onKeyPress="return check_date(event, this)"
	var keyCode
	if (document.all){ 
		keyCode=eventObj.keyCode
	} else {
		keyCode=eventObj.which
	}
	var str=obj.value
	if (keyCode==46) {
		if (str.indexOf('.')=='-1') {
			return true;
		}
	}
	if((keyCode<48 || keyCode >58)   &&   (keyCode != 8)   &&   (keyCode != 0)){
		return false
	}
	return true
	
}


function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function keycode(eventObj, obj) {
//használata:
//onKeyPress="return keycode(event, this)"
	var keyCode
	if (document.all){ 
		keyCode=eventObj.keyCode
	} else {
		keyCode=eventObj.which
	}
	var str=obj.value
/*	if (keyCode==13) {
		alert('enter');
	}
	if (keyCode==8) {
		alert('backspace');
	}*/
	alert(keyCode);
}

function clear(element) {
	element.value='';
}

function select_value_to_input(from_input_id,to_input_id) {
	document.getElementById(to_input_id).value=document.getElementById(from_input_id).options[document.getElementById(from_input_id).selectedIndex].value;
}


function jump_next(len,input_1,input_2) {
	if (document.getElementById(input_1).value.length>=len) {
		document.getElementById(input_2).focus();
	}
}
function jump_end(frm) {
	frm.value=frm.value;
}
/*
function jump(len,from,to_from,to_to) {
	if (to_from!='') {
		if (from.value.length==0) {
			document.getElementById(to_from).focus();
		}
	}
	if (from.value.length>len) {
		var str = from.value;
		from.value=str.substr(0,len);
		if (to_to!='') {
			document.getElementById(to_to).value=str.substr(len);
			document.getElementById(to_to).focus();
		}
	}
}
*/
function array_to_input(input,year,mon,mday) {
	var out='';
	if (year=='') {
		out=document.getElementById(mon).value+'-'+document.getElementById(mday).value;
	} else {
		if (mday=='') {
			out=document.getElementById(year).value+'-'+document.getElementById(mon).value;
		} else {
			out=document.getElementById(year).value+'-'+document.getElementById(mon).value+'-'+document.getElementById(mday).value;
		}
	}
//	alert(out);
	document.getElementById(input).value=out;
}


function text_format(eventObj, obj) {
//használata:
//onKeyPress="return keycode(event, this)"
	var keyCode
	if (document.all){ 
		keyCode=eventObj.keyCode
	} else {
		keyCode=eventObj.which
	}
	var str=obj.value
	alert(keyCode);
}
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function getPosition(obj){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return {x:curleft,y:curtop};
}

function getvalue(name) {
try
  {
    eval(name);
  }
  catch( err )
  {
	return name;
  }
	return eval(name);
}
function msgwrite(code,focusing,other) {
	var text=getvalue(code);
	error_msg=text;

	if ((typeof focusing !='undefined') && (focusing!='')) {
		$(focusing).focus();
	}
	if ((typeof other !='undefined') && (other!='')) {
		error_msg+="\""+other+"\"";
	}
	error_msg=error_msg.replace(/\\n/,'\n');
	error_msg=error_msg.replace(/<BR >/g,'\n');
	error_msg=error_msg.replace(/&lt;BR &gt;/g,'\n');
	error_msg=error_msg.replace(/\<BR\>/g,'\n');
	error_msg=error_msg.replace(/&lt;BR&gt;/g,'\n');
	error_msg=error_msg.replace(/<BR \/>/g,'\n');
	error_msg=error_msg.replace(/&lt;BR\/&gt;/g,'\n');
	error_msg=error_msg.replace(/<br>/g,'\n');
	error_msg=error_msg.replace(/&lt;br&gt;/g,'\n');
	error_msg=error_msg.replace(/<br\/>/g,'\n');
	error_msg=error_msg.replace(/&lt;br\/&gt;/g,'\n');
	error_msg=error_msg.replace(/<br \/>/g,'\n');
	error_msg=error_msg.replace(/&lt;br \/&gt;/g,'\n');
	alert(error_msg);
	error_msg='';
}

function mouseCoords(ev){

	if(ev.pageX || ev.pageY){

		return {x:ev.pageX, y:ev.pageY};

	}

	return {

		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,

		y:ev.clientY + document.body.scrollTop  - document.body.clientTop

	};

}



function getMouseOffset(target, ev){

	var docPos    = getPosition(target);

	var mousePos  = mouseCoords(ev);

	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};

}

function getPosition(e){

	var left = 0;

	var top  = 0;

	while (e.offsetParent){

		left += e.offsetLeft;

		top  += e.offsetTop;

		e     = e.offsetParent;

	}





	left += e.offsetLeft;

	top  += e.offsetTop;



	return {x:left, y:top};



}

function clearinput(elem,value) {
	if (value!='') {
		if (elem.value==value) {
			elem.value='';
		}
	} else {
		elem.value='';
	}
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  $$('head')[0].appendChild(fileref);
}
