function formErrorDisplay(formSelector,e1_Delay){
		if ($(formSelector+" .formError").text()!=''){ 		
				$(formSelector).anchorTo();			
				setTimeout("$('"+formSelector+" .formError' ).dialog({modal: true,width: 350,stack:true}).css({'margin':'15px 0px 0px 0px', 'text-align':'center'});",e1_Delay); 				
		}
		if ($(formSelector+" .formMessage").text()!=''){ 
				$(formSelector).anchorTo();			
				setTimeout("$('"+formSelector+" .formMessage' ).dialog({modal: true,width: 350,stack:true}).css({'margin':'15px 0px 0px 0px', 'text-align':'center'});",e2_Delay); 	
		}	
}

function errorAert(formCont,e2_Delay){
	var loginErrorText='';
	$(formCont+" .error").each(function(ec){
		$(this).attr('id','error_'+ec).css({'display':'none'});
		loginErrorText = loginErrorText+$(this).text()+" => <b>"+$(this).attr('rel')+"</b><br />";	
	});	
	if (loginErrorText.length!=0){			
		$(formCont).anchorTo();
		loginErrorText_obj	="<div id='errorObj' style='display:none;'>"+loginErrorText+"</div>"; $('BODY').append(loginErrorText_obj); 
		setTimeout("$('#errorObj').css({'margin':'15px 0px 0px 0px'}).dialog({modal: true,width:350,stack:true}) ",e2_Delay); 				
	}
}

(function($){
	$.fn.extend({        	
		anchorTo: function(options) { 
			var defaults = {																
				animateDuration:300,
				animationType:'easeInSine' 				
			};             
			var options = $.extend(defaults, options);         
			return this.each(function() {
				  var o =options;
				 $('HTML, BODY').animate({
					 	scrollTop:$(this).offset().top 
						},  o.animateDuration, 
							o.animationType, 
							function() {  } 
				 );	 
			});
		}
	});
})(jQuery);   

 
/*********************************************/
/*	Kosár termek, darabszám növelése.*/
/*********************************************/
function kr_plus_minus() {
	var kr_current_val, kr_current_id;
	var jel_1 = /\[/;
	var jel_2 = /\]/;
	$('.kr_db').each(function(){
		kr_current_id=$(this).attr('id');
		kr_current_id=String(kr_current_id);	
		do {
			kr_current_id= kr_current_id.replace(/\[/i, "_");
			kr_current_id= kr_current_id.replace(/\]/i, "_");					
		} while((kr_current_id.search(jel_1)!=-1) && (kr_current_id.search(jel_2) !=-1)); 
		$(this).attr('id',kr_current_id);
	});
	$('.kr_plus').each(function(id){		
		$(this).click(function(){			
			kr_current_val=parseInt($(this).prev().val());	
			if (kr_current_val<999) {		
				$(this).prev().val(kr_current_val+1);
			}
            $('#frissit'+$(this).attr('rel')).click();			
		});	
	});	
	$('.kr_minus').each(function(id){		
		$(this).click(function(){			
			kr_current_val=parseInt($(this).next().val());	
			if (kr_current_val>1) {		
				$(this).next().val(kr_current_val-1);
			}	
            
             $('#frissit'+$(this).attr('rel')).click();	
            	
		});		
	});	   	
}


 
/*********************************************/
/*	 Kategória rendszer kinyitó-becsukó script!
	JS:: menu_toggle('  $block_id   ','  $cookie_name  ', $expires(by day)  ); 
		 <div id='kategoriak'>
			   <a href='#' class='fokategoria'>Főkategória</a> 
			   <a href='#'class='alkategoria' rel='link'>Alkategória</a> 
		  </div>*/
/*********************************************/
 function menu_toggle(block, c_val, c_exp) {
		$("#"+block+" .fokategoria").each(function(e2){
			var menu_id =c_val+'_'+parseInt(e2+1);
			$(this).attr('id',menu_id);
		
			$(this).click(function(){
					$("#"+block+" .fokategoria").removeClass("aktiv");
					$(this).addClass("aktiv");						
					$("#"+block+" A[rel='link']").css('display','none');
					var kov_menu_li = $(this).next();
					if ( kov_menu_li.attr('rel')=='link' ){ 													
						while(kov_menu_li.attr('rel')=='link'){										
							kov_menu_li.css('display','block');										
							kov_menu_li = kov_menu_li.next();					
						}											
					}
					cookName = c_val;
					cookVal = c_val+"_"+( e2+1);
					date = new Date(); 	date.setTime(date.getTime()+86400000*c_exp);
					expireDate = date.toGMTString();					
					myCookie = cookName + "=" + cookVal + ";expires=" + expireDate+"; javahere=yes; path=/;";					
					document.cookie = myCookie;			
					myCookie = myCookie.substring(0, myCookie.indexOf(';'));								
			});	
		});
		var myCookie_text =document.cookie;					
		cookie_array=document.cookie.split(';');
		cnt=cookie_array.length;				
		for(i=0; i<cnt; i++){
			  index=cookie_array[i].indexOf(c_val+"_");	
			  if (index==-1){
					$("#"+block+" A[rel='link']").css('display','none');					
			  }					  
			  if (index!=-1){						  	
					 menuId=cookie_array[i].substr(index);							
					 $('#'+menuId).click();							
				 break;	
			  };	
		}
}
 

 
 
 
/*********************************************/
/*	Login validátor script.*/
/*********************************************/
function validate(input_mezo, kotelezo) {	
	input_mezo=String(input_mezo);
	input_mezo=input_mezo.split(',');
	cnt=input_mezo.length;
	var input_mezo_r='';
	var input_label_text='';
	for(i=0; i<cnt; i++){		
		if ( document.getElementById(input_mezo[i]).value=='' ){			
			input_mezo_r+=input_mezo[i];			
			input_label_text+='\n['+$('#'+input_mezo[i]).parent().find('label').text()+']';				
		}			
	}
	if (input_label_text.length>0){			
		alert('A következő mezőt kötelező kitölteni: '+input_label_text);
	}else { $('form.login').submit();}		
}
	



/*********************************************/
/*	Random text-space kitöltő -(Karakter számláláshoz) */
/*********************************************/
function createRandomNumber(varLength) {
	var sourceArr = new Array("a","b"," ","c","d","e"," ","f","g","h"," ","i","j"," ","k","l","m","n","o"," ","p","q","r","s","t"," ","u","v"," ","w","x","y"," ","z");
	var randomKey;
	var randomCode = "";
	
	for (i=0; i<varLength; i++) {
	randomKey = Math.floor(Math.random()*sourceArr.length);
	randomCode = randomCode + sourceArr[randomKey];
	}
return randomCode;
}



/*********************************************/
/*	Target blank */
/*********************************************/
function externalLinks() {  
 if (!document.getElementsByTagName) return;  
 var anchors = document.getElementsByTagName("a");  
 for (var i=0; i<anchors.length; i++) {  
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  
       anchor.getAttribute("rel") == "external")  
     anchor.target = "_blank";  
 }  
} 
/*
function externalLinks() {
	$('A[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});
}
*/
$(document).ready(function(){			
	externalLinks();			
});
	


	




/***********************************************/
// Lista tábla style definiálása!
/***********************************************/	
function table_colorize(selector) {
	$("TABLE."+selector).each(function(){
		$(this).find("tr.body:even").addClass('even');
		$(this).find("tr.body:odd").addClass('odd');
		$(this).find("tr.body").mouseover(function(){
			$(this).addClass('mouseover');				
		}).mouseout(function(){			
			$(this).removeClass('mouseover');						
		});
		$(this).find("tr.megjeloles").mouseover(function(){
			$(this).addClass('mouseover');			
		}).mouseout(function(){			
			$(this).removeClass('mouseover');								
		});			
	});	
}
$(document).ready(function(){			
	table_colorize('.entity');
	table_colorize('.kosar_table');			
});
/***********************************************/	
	
	
			
		
						
/***********************************************/
// Form error style definiálása!
/***********************************************/	
		
$(document).ready(function() {			
	$('p.error').each(function () {
	var errorCss = String('background:#fdc2b8 url('+domain+'/images/munkafelulet/icons/admin_error.jpg) no-repeat left top; color:#6B0404;'); 				
	var labelError = String('background:#a40001; color:#FFF;');
	var inputError = String('border:1px solid #a40001; background:#fbf2f2; color:#a40001;'); 	 				
	
		  $('.entity').find('.error').attr('style', errorCss);
		  var $curr = $(this);		
		  $curr = $curr.prev();
		  $curr.find('label').attr('style',labelError);	   
		
	});		
									
$('<span>&nbsp;</span>').appendTo('.formMessage');
$('<span>&nbsp;</span>').appendTo('.formError');							
});
 				  	
		
		



/***************************************************/
//  Tooltip script - A tpl-ben az adott html elemre
//	egy alt="" attributumban kell megadni a  
//	tooltip szöveglt! 
/***************************************************/			
		
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = -10;
		yOffset = 15;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */
	$(".tooltip").hover(function(e){		
		$("body").append("<div id='tooltip'>"+ this.alt +"<\/div>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
	},
	function(){
		$("#tooltip").remove();
	});	
	$(".tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};		
// starting the script on page load
$(document).ready(function(){	
	tooltip();
});



	

/***************************************************/
// Tartalom nyomtatása!
/***************************************************/
function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=850, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("print_content").innerHTML;   
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write("<html><head><title>"+domain+"</title> <link rel='stylesheet' type='text/css'  media='all' href='"+domain+"/css/print.css'>"); 
   docprint.document.write('</head><body onLoad="self.print()"><div id="print_content">');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</div></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}



	



