var mouseX = 0;
var mouseY = 0;
var NS = (document.layers || (document.getElementById&&!document.all))?true:false;

if (NS) 
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getCursor; 

function getCursor(e)
{
		 if (e)
		 {
		 	mouseX = e.pageX;
		 	mouseY = e.pageY;
		 }
		 else
		 {
		  	mouseX = event.clientX + document.documentElement.scrollLeft;
		 	mouseY = event.clientY + document.documentElement.scrollTop;
		 }
		 return true;
}


function help (i)
{ 		
	y =	mouseX - 320;
	if (i == 0)
	{
		x = mouseY - 260;	
	}
	else
	{
		x = mouseY + 30;		
	}
	document.getElementById("help_layer").style.top = x + "px";
	document.getElementById("help_layer").style.left = y + "px";		
	document.getElementById("help_layer").style.display="block";	 
}

function hide()
{
 	document.getElementById("help_layer").style.display="none";
}
//alert(document.login.elements.length);
function add_focus()
{
	if (document.forms.length > 1)
	{		
		if (document.login != null)
		{			
			document.login.user.focus();	
		}
		if (document.termek_EDIT != null)
		{
			if (document.termek_EDIT.kod.disabled)
			{
				document.termek_EDIT.leiras.focus();		
			}
			else
			{
				document.termek_EDIT.kod.focus();
			}
		}
		if (document.szabvany_torzs_EDIT != null)
		{			
			document.szabvany_torzs_EDIT.nev.focus();	
		}
		if (document.tipus_torzs_EDIT != null)
		{			
			document.tipus_torzs_EDIT.nev.focus();	
		}
		if (document.szabvany != null)
		{			
			for (i=0; i<document.szabvany.elements.length; i++)
			{
				if (document.szabvany.elements[i].value == "" )
				{
					document.szabvany.elements[i].focus();
					break;	
				}	
			}				
		}
		if (document.meretek_EDIT != null)
		{
			if (window.location.search.indexOf("event=NEWLINE") != -1)
			{
				document.meretek_EDIT.elements[document.meretek_EDIT.elements.length-5].focus();
			}
			else
			{
				document.meretek_EDIT.elements[5].focus();
			}	
		}
		if (document.jelszo != null)
		{
			document.jelszo.regipass.focus();	
		}
	}
	else
	{
		document.forms[0].keres.focus();	
	}		
}

function ellenorzes(form_name)
{
	//alert(form_name.name);
	r_color = "#A2CAA2";
	u_color = "#FF6501"
	switch(form_name.name)
	{		
		case "szabvany_torzs_EDIT":
			if (document.szabvany_torzs_EDIT.nev.value == "")
			{				
				alert("A megnevezés nem lehet üres!");
				document.szabvany_torzs_EDIT.nev.style.borderColor = u_color;													
			}
			else
			{
				document.szabvany_torzs_EDIT.nev.style.borderColor = r_color;
			}
		break;
		case "tipus_torzs_EDIT":
			if (document.tipus_torzs_EDIT.nev.value == "")
			{				
				alert("A termékcsoport neve nem lehet üres!");
				document.tipus_torzs_EDIT.nev.style.borderColor = u_color;													
			}
			else
			{
				document.tipus_torzs_EDIT.nev.style.borderColor = r_color;
			}			
		break;
		/*case "jelszo":
			if (document.jelszo.regipass.value == "" || document.jelszo.ujpass1.value == "" || document.jelszo.ujpass2.value == "")
			{				
				alert("A jelszó mezőket kötelező kitölteni!");
				document.jelszo.regipass.style.borderColor = u_color;
				document.jelszo.ujpass1.style.borderColor = u_color;
				document.jelszo.ujpass2.style.borderColor = u_color;																					
			}			
			else
			{
				document.jelszo.regipass.style.borderColor = r_color;
				document.jelszo.ujpass1.style.borderColor = r_color;
				document.jelszo.ujpass2.style.borderColor = r_color;		
			}						
		break;*/
		case "termek_EDIT":
			if (document.termek_EDIT.kod.value == "")
			{				
				alert("A termékkód nem lehet üres!");
				document.termek_EDIT.kod.style.borderColor = u_color;													
			}
			else
			{
				document.termek_EDIT.kod.style.borderColor = r_color;
			}			
		break;
			
	}
}

function terkep()
{
	win = window.open("","about","width=700,height=591");
	win.document.write("<html><body style='margin:0;padding:0;'>");
	win.document.write("<a href='javascript:window.close();' title='Ablak bezárása'><img src='pict/g_terkep.jpg' border='0' /></a>");
	win.document.write("</body></html>");
	win.moveTo(0,0);	
}

