function normalize(css_values){
	return eval(css_values.replace('px', '').replace('pt', ''));
}

function popup(id,w,h){
	var x = ((screen.width-w)/2);
	var y = ((screen.height-y)/2);
	var popup = window.open(''+id,'','width='+w+',height='+h+',hotkeys=0,dependent=1,alwaysRaised=1,location=0,resizable=1,status=0,titlebar=0,toolbar=0,directories=0,menubar=0,scrollbars=1,left=' +x+',top=150');
}

function popup_ns(id,w,h) {
	var x = ((screen.width-w)/2);
	var y = ((screen.height-h)/2);
	var popup = window.open(''+id,'','width='+w+',height='+h+',hotkeys=0,dependent=1,alwaysRaised=1,location=0,resizable=0,status=0,titlebar=0,toolbar=0,directories=0,menubar=0,scrollbars=0,left=' +x+',top='+y+'');
}
function confirmRequest(msg, url) {
	if (confirm(msg)) {
		location = url;
	}	
}

function exclude_nodes(obj, nodename){

	if(obj){
		for(var i=0;obj.childNodes.length>i;i++){
			if(obj.childNodes[i].nodeName == nodename){
				obj.removeChild(obj.childNodes[i]);
			}
		}
		return obj;
	} else {
		alert(error_message(1));
	}
}

function slide_object(object, startpos, endpos,l,s,p,i){

	if(object.motion == undefined){
		
		object.motion = true;
		motion_sense = true;
		if (object.timeout_memory_flag) window.clearInterval(object.timeout_memory_flag);
		
		var length = (l) ? l : 25;			
		var step = (s) ? s : 1;
		var power = (p) ? p : 1;
		var interval = (i) ? i : 10;

		object.timeout_memory_flag = window.setInterval(
			function(){
				// dummy ... minValue,maxValue,totalSteps,actualStep,powr
				object.style.left = easeInOut(startpos,endpos,length,step,power) + 'px';
				step++;
				if(step>length){
					window.clearInterval(object.timeout_memory_flag);
					motion_sense = false;
					object.motion = undefined;
				}
		}, i);

	}
}

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}

function hscroll(id, stepsize){
	
	var object = $i(id);
	var items = exclude_nodes(object, "#text").childNodes;
	var items_width = items[0].offsetWidth * items.length;
	var position = (object.style.left) ? normalize(object.style.left) : 0;
	var new_position = position+stepsize;
	disableSelection(object);
	
	if((Math.abs(new_position) < items_width) && (new_position <= 0)){
		if(client == 'ie'){
			slide_object(object, position, new_position, 5,5,5,50);
		} else {
			slide_object(object, position, new_position);
		}
	}
	
}

var active_object;

function use(object){
	active_object = object;
}

function clear_inputs(obj){

	switch(obj.value){
		case 'Felhasználónév':
			obj.value='';
			break;
		case 'Jelszó':
			obj.value='';
			obj.type='password';
			break;
		case 'keresett kifejezés ...':
			obj.value='';
			break;
	}

}
function toggle_bkmenu_opacity(obj){

	obj.className = 'item';
	obj.onmouseout = function(){ obj.className = 'item opacity50'; }
}

function count_chars(obj){

	var max_char = 1000;
	var char_len = obj.value.length;
	if(char_len > max_char){

		obj.value = obj.value.substr(0,max_char);

	}
	char_len = obj.value.length;
	$i('chars').innerHTML = char_len + '/' +max_char + ' karakter';
}


