//***browsers
var ns4=document.layers;
var ns6=window.navigator.userAgent.toLowerCase().match(/gecko/);
var opera=window.navigator.userAgent.toLowerCase().indexOf('opera') != -1;
var ie4=(document.all && !opera);

//*** névtelen új ablak nevéhez:
var wnow = new Date(); 
var wszam = wnow.getTime();

///////////////////////////////
var honlap="www.korostetetlen.hu";
///////////////////////////////

//********
var pop_div_tohide =new Array;
//********

////////////////////////////////////////////////////////////////////////
//Elemek elrejtése IE alatt, ha a menü ráhajlik:
//az elrejtendő elem ID-je: pl. <select name="test1" id="test1">
//az elrejtendő elemek tömbje: pl. <body onload="ie_menu_tohide =['test1', 'test2'];">
var ie_menu_tohide=new Array();
//////////////////////////////////////////////////////////////////////////

//************
function almenu_mutat(s)
{
	if(ie4)
	{
		document.all[s].style.visibility="visible";
		if(ie_menu_tohide.length>0)
		{
			for (i=0;i<ie_menu_tohide.length;i++)
			{
				if(document.all[ie_menu_tohide[i]])
				{
				   document.all[ie_menu_tohide[i]].style.visibility="hidden";
				}
			}
		}
	}
	else
	{
		document.getElementById(s).style.visibility = "visible";
	}
}

//************
function almenu_rejt(s)
{
	if(ie4)
	{
		document.all[s].style.visibility="hidden";
		if(ie_menu_tohide.length>0)
		{
			for (i=0;i<ie_menu_tohide.length;i++)
			{
				if(document.all[ie_menu_tohide[i]])
				{
				   document.all[ie_menu_tohide[i]].style.visibility="visible";
				}
			}
		}
	}
	else
	{
		document.getElementById(s).style.visibility = "hidden";
	}
}

//****** link image ****
function imgover(imgname)
{
	var img_on = new Image;
	img_on.src  = "img/on.gif";
	imgname.src = img_on.src ;
}
function imgout(imgname)
{
	var img_off = new Image;
	img_off.src  = "img/off.gif";
	imgname.src = img_off.src ;
}

//****** vissza image ****
function backover(id)
{
	var vissza_on = new Image;
	vissza_on.src = "img/vissza2.gif";
	id.src = vissza_on.src;
}

function backout(id)
{
	var vissza_off = new Image;
	vissza_off.src = "img/vissza.gif";
	id.src = vissza_off.src;
}

//*** kezelői ablak********
function a()
{
	window.open('adm','mywin'+wszam);
}

/////////////////////////////////////////////////////////////////////
//***** hasznos képernyő méret
var sw,sh;

if( (opera||ns4) && (typeof( window.innerWidth ) == 'number'))
{
	if(opener)
	{
		sw = window.opener.innerWidth;
		sh = window.opener.innerHeight;
		//alert('Nem IE opener ' +sw+' * '+sh);
	}
    		
	else if(window.parent)
	{
		sw = window.parent.innerWidth;
		sh = window.parent.innerHeight;
		//alert('Nem IE window.parent ' +sw+' * '+sh);
	}

	else
	{
		sw = window.innerWidth;
		sh = window.innerHeight;
		//alert('Nem IE ' +sw+' * '+sh);
	}
}
else
{
	sw=window.screen.width;
	sh=window.screen.height;
	//alert('IE ' +sw+' * '+sh);
}

////////////////////////////////////////////////////////////////////

//*****Resize opera és ns4 *****
function reload_opera_ns4(init,sw,sh)
{
	if (init==true)
	{
		if (ns4)
		{
    			document.pgW=sw;
    			document.pgH=sh;
    			onresize=reload_opera_ns4;
    		}
	}
	else if (sw!=document.pgW || sh!=document.pgH)
	{
		location.reload()
	}
}//end func reload_opera_ns4

reload_opera_ns4(true,sw,sh);

////////////////////////////////////////////////////////////////////

//*****PopUpWin*****
// Fontos: A TARGET MEGHATÁRZHATÓ !
 function PopUpWin(URL,NAME,w,h,sb)
 {
 sb=sb ? sb : 0;
 var MX, MY;
 
 if(opera)
 {
 if(sw<=w){sw=w;}
 if(sh<=h){sh=h;}
 }	
 
 MX = (sw) ? (sw-w)/2 : 0;
 MY = (sh) ? (sh-h)/2 : 0;
 settings ='height='+h+',width='+w+',top='+MY+',screenY='+MY+',left='+MX+',screenX='+MX+',scrollbars='+sb+',resizable'
 var win = window.open(URL,NAME,settings)
 win.focus();
}

//***NewWin*********************
//mb=1 ->menubar=yes
function NewWin(url,w,h,mb,a)
{
	if(!mb){mb=1}
	if(!a){a=0}

	if(opera)
 	{
 		if(sw<=w){sw=w;}
 		if(sh<=h){sh=h;}
 	}
 
	var MX = (sw) ? (sw-w)/2 : 0;
	var MY = (sh) ? (sh-h)/2 : 0;

	if(a==1)
	{
		if(confirm('Ön most elhagyja a ' + honlap + ' honlapot!'))
		{
			var SW = window.open(url,"NewWin"+wszam,"height="+h+",width="+w+",left="+MX+",top="+MY+",screenX="+MX+",screenY="+MY+",menubar="+mb+",resizable=1,scrollbars=1");
			SW.focus();
		}
	}
	else
	{
		var SW = window.open(url,"NewWin"+wszam,"height="+h+",width="+w+",left="+MX+",top="+MY+",screenX="+MX+",screenY="+MY+",menubar="+mb+",resizable=1,scrollbars=1");
		SW.focus();
	}
}//end func


//***NewWinMax*********************
//mb=1 ->menubar=yes
function NewWinMax(url,mb)
{
var w, h, MX, MY;
if(ie4&&!opera)
{
	w=window.screen.availWidth; 
	h=window.screen.availHeight;
}
else if(opera)
{
	w=window.screen.width;
	h=window.screen.height;
}
else if(ns4)//ns4
{
	w=window.innerWidth;
	h=window.innerHeight;
}
else if(ns6)//gecko/mozilla
{
	w=window.screen.availWidth; 
	h=window.screen.availHeight;
}
else
{
	w=window.screen.width;
	h=window.screen.height;
}
settings ='height='+h+',width='+w+',top='+MY+',screenY='+MY+',left='+MX+',screenX='+MX+',scrollbars=1,resizable=1,menubar='+mb
var win = window.open(url,"NewWinMax"+wszam,settings)
win.focus();
}

//*****PUF*****
//Fotoknak
// Fontos: A TARGET MEGHATÁRZHATÓ !
function PUF(URL,NAME,w,h){
if(w<240){w=240}
var MX, MY;
 if(opera)
 {
 if(sw<=w){sw=w;}
 if(sh<=h){sh=h;}
 }	
 MX = (sw) ? (sw-w)/2 : 0;
 MY = (sh) ? (sh-h)/2 : 0;
var prop = "";
prop += "top="+MY+",";
prop += "screenY="+MY+",";
prop += "left="+MX+",";
prop += "screenX="+MX+",";
prop += "directories=no,";
prop += "height="+h+",";
prop += "location=no,";
prop += "menubar=no,";
prop += "resizable=no,";
prop += "scrollbars=no,";
prop += "status=no,";
prop += "statusbar=no,";
prop += "toolbar=no,";
prop += "width="+w;
var win = window.open(URL,NAME,prop)
win.focus();
}

//***********
function elevel(c1,c2){
document.location.href="mailto:"+c1+"@"+c2;
}

//***** textaera max charakter ******
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}

//*****Enter tiltása********
function handleEnter (field, event)
{
	var validity=true;
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13)
	{
		var i, j;
		for (j = 0; j < field.form.elements.length; j++)
		{
			if (field == field.form.elements[j])
			{
				break;
			}
		}	
		for (i = (j+1); i < field.form.elements.length; i++)
		{
			with(field.form.elements[i])
			{
				//alert(name);
				if(type=="hidden" || disabled==true || style.display=="none" || style.visibility=="hidden" || type=='checkbox')				
				{
					continue;
				}
				else
				{
					focus();
					return false;
				}
			}
		}
	} 
	else
	{
		validity=true;
	}
	return	validity;
}   

//************************
var el_px = "3px";
var vissza_px = "-3px";

function kepel(x)
{
if(ie4)
  {
  	y=document.all[x].style;
  }
else
  {
  	y=document.getElementById(x).style;
  }
y.left=el_px;
}
//*************************
function kepvissza(x)
{
if(ie4)
  {
  	y=document.all[x].style;
  }
else
  {
  	y=document.getElementById(x).style;
  }
//y.left=vissza_px;
y.left=0;
}






//***video********
function CreateControl_video(DIVID, CLASSID, OBJECTID, WIDTH, HEIGHT, FILENAME, AUTOSTART)
{
 if(!ns4)
 {
   document.write('<div id="' + DIVID + '">xxx</div>');
   if(ie4)
   {
	var obj= '<object classid="' + CLASSID + '" ';
	obj += 'id="' + OBJECTID + '" ';
	obj += 'width="' + WIDTH + '" ';
	obj += 'height="' + HEIGHT +'" >';
   }
   else
   {
	var obj= '<object ';
	obj += 'id="' + OBJECTID + '" ';
	obj += 'width="' + WIDTH + '" ';
	obj += 'height="' + HEIGHT +'" ';   
   	obj += 'type="application/x-mplayer2" >';  
   	obj += '<param name="pluginurl" value="http://www.microsoft.com/Windows/MediaPlayer/" />';
   }
	obj += '<param name="AnimationAtStart" value="0" />';
	obj += '<param name="AutoSize" value="0" />';
	obj += '<param name="autoStart" value="' + AUTOSTART + '" />';
	obj += '<param name="ClickToPlay" value="0" />';
	obj += '<param name="ControlType" value="1" />';
	obj += '<param name="DisplayMode" value="0" />';
	obj += '<param name="DisplaySize" value="4" />';
	obj += '<param name="EnableContextMenu" value="0" />';
	obj += '<param name="FileName" value="' + FILENAME + '" />';
	obj += '<param name="PlayCount" value="1" />';
	obj += '<param name="PreviewMode" value="0" />';
	obj += '<param name="SelectionEnd" value="-1" />';
	obj += '<param name="SelectionStart" value="-1" />';
	obj += '<param name="SendMouseClickEvents" value="1" />';
	obj += '<param name="ShowControls" value="1" />';
	obj += '<param name="ShowDisplay" value="0" />';
	obj += '<param name="ShowStatusBar" value="1" />';
	obj += '<param name="ShowTracker" value="1" />';
	obj += '<param name="TransparentAtStart" value="0" />';
	obj += '<param name="VideoBorderWidth" value="0" />';
	obj += '<param name="VideoBorderColor" value="0" />';
	obj += '<param name="VideoBorder3D" value="0" />';
	obj += '<param name="Volume" value="-500" />';
	obj += '<param name="WindowlessVideo" value="0" />';
	obj += '</object>';
	document.getElementById(DIVID).innerHTML=obj;
 }
}

//***flash********
function CreateControl_flash(DIVID, CLASSID, CODEBASE, OBJECTID, WIDTH, HEIGHT, MOVIE, LOOP, WMODE)
{
 if(!ns4)
 {
   document.write('<div id="' + DIVID + '">xxx</div>');
   if(ie4)
   {
	var obj= '<object classid="' + CLASSID + '" ';
	obj += 'codebase="' + CODEBASE + '" ';
	obj += 'id="' + OBJECTID + '" ';
	obj += 'width="' + WIDTH + '" ';
	obj += 'height="' + HEIGHT +'" >';
	
	obj += '<param name="movie" value="' + MOVIE + '" />';
	obj += '<param name="quality" value="high" />';
	obj += '<param name="loop" value="' + LOOP + '" />';
	obj += '<param name="wmode" value="' + WMODE + '" />';
	obj += '</object>';
   }
   else
   {
	var obj= '<object data="' + MOVIE + '" ';
	obj += 'id="' + OBJECTID + '" ';
	obj += 'width="' + WIDTH + '" ';
	obj += 'height="' + HEIGHT + '" ';
	obj += 'type="application/x-shockwave-flash" >';
	obj += '<param name="quality" value="high" />';
	obj += '<param name="loop" value="' + LOOP + '" />';
	obj += '<param name="wmode" value="' + WMODE + '" />';
	obj += '<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />';	
	obj += '</object>';
   }
   document.getElementById(DIVID).innerHTML=obj;
 }
}

//*****************
function addLoadEvent(func)
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
    window.onload = function()
    {
      if (oldonload)
      {
        oldonload();
      }
      func();
    };
  }
}

//*****************
function toggleBottomElements(table, BottomElementsDiv)
{
	var tableTop=getY(document.getElementById(table));
	var tableHeight=document.getElementById(table).offsetHeight;
	var helyigeny=(tableHeight+tableTop);

	var myHeight = 0;
	if( typeof( window.innerHeight ) == 'number' )//Non-IE
	{
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )//IE 6+ in 'standards compliant mode'
	{
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )//IE 4 compatible
	{
		myHeight = document.body.clientHeight;
	}

	if(helyigeny>myHeight)
	{
		document.getElementById(BottomElementsDiv).style.display='block';
	}
	else
	{
		document.getElementById(BottomElementsDiv).style.display='none';
	}
}//end func

//******
function getY(oElement)//get top position of an element...
{
	var iReturnValue = 0;
	while( oElement != null )
	{
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}

//*************************
function AJAX_updateMysql(file,req,reqTip)
{
	reqTip=(reqTip && reqTip!="") ? reqTip.toUpperCase()  : "GET"; ;
	
	var xmlHttp;
	var mimetyp='text/html'; //'text/xml'
  	xmlHttp = GetXmlHttpObject(mimetyp);
  	
  	if(xmlHttp!=null)
	{
      		var post_req="";
		
		if(arrLenAss(req)>0)
		{
			for(var x in req)
			{
	  			if(reqTip=='POST')
  				{
  					post_req+= "&" + x + "=" + req[x];
  				}
  				else
  				{
  					post_req+= "&" + x + "=" + encodeURIComponent(req[x]);
  				}
			}
			post_req=post_req.replace(/&/,'');
		}
		
		if(reqTip=='POST')
		{
			xmlHttp.open(reqTip,file,true);
			xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-2 ');
			if(post_req!="")
			{
				xmlHttp.send(post_req);
			}
			else
			{
				xmlHttp.send(null);
			}
		}
		else
		{
			if(post_req!="")
			{
				xmlHttp.open(reqTip,file+'?'+post_req,true);
			}
			else
			{
				xmlHttp.open(reqTip,file,true);
			}			
			xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-2');			
			xmlHttp.send(null);
		}
  	}
  	else
  	{
  		alert('No AJAX-support!/nPlease use FireFox, Opera or Internet Explorer.');
  		//return false;
  	}
}





