//***browsers
var ns4=document.layers;
var ns6=window.navigator.userAgent.toLowerCase().match(/gecko/);
var opera=window.opera && !document.all;
var ie4=(document.all && !opera);

//*** névtelen új ablak nevéhez:
var wnow = new Date(); 
var wszam = wnow.getTime();

///////////////////////////////
var honlap="www.csatorna.nagykoros.hu";
///////////////////////////////

//********
var pop_div_tohide =new Array;
//********

/////////////////////////////////////////////////////////////////////
//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;
	}
	else if(window.parent)
	{
		sw = window.parent.innerWidth;
		sh = window.parent.innerHeight;
	}
	else
	{
		sw = window.innerWidth;
		sh = window.innerHeight;
	}
}
else
{
	sw=window.screen.width;
	sh=window.screen.height;
}


////////////////////////////////////////////////////////////////////

function windowSize()
{
  	var myWidth = 0, myHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' )
  	{
    		//Non-IE
   	 	myWidth = window.innerWidth;
    		myHeight = window.innerHeight;
  	}
  	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
 	{
    		//IE 6+ in 'standards compliant mode'
    		myWidth = document.documentElement.clientWidth;
    		myHeight = document.documentElement.clientHeight;
  	}
  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  	{
    		//IE 4 compatible
    		myWidth = document.body.clientWidth;
    		myHeight = document.body.clientHeight;
  	}
  	return {w:myWidth, h:myHeight}
}

////////////////////////////////////////////////////////////////////

//***********
function NewWin(url,w,h,mb,leavethis)
{
	//mb=1 ->menubar=yes
	leavethis=!leavethis ? 0 : leavethis;
	if(leavethis)
	{
		alert('Ön most elhagyja a ' + honlap + ' honlapot!');
	}

	mb=!mb ? 1 : mb;
	
	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 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();
}

//***********
function elevel(c1,c2,s,b)
{
	if(!s && !b)
	{
		document.location.href="mailto:"+c1+"@"+c2;
	}
	else if(s && !b)
	{
		document.location.href="mailto:"+c1+"@"+c2+'?SUBJECT=' + escape(s);
	}
	else if(!s && b)
	{
		document.location.href="mailto:"+c1+"@"+c2+'?BODY=' + escape(b);
	}	
	else if(s && b)
	{
		document.location.href="mailto:"+c1+"@"+c2+'?SUBJECT=' + escape(s) + '&BODY=' + escape(b);
	}	
}

//***flash********
function CreateControl_flash(DIVID, CLASSID, CODEBASE, OBJECTID, WIDTH, HEIGHT, MOVIE, LOOP, WMODE)
{

pop_div_tohide.push(DIVID);

 if(!ns4)
 {
   document.write('<div id="' + DIVID + '" style="z-index: 0;">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();
    };
  }
}



/////////////////////////////////////////////////////////////////////////////
//TOGGLEDIVS.toggle(divToToggleId,bovLinkId,selObjId,selLnkId)
var TOGGLEDIVS={
divToToggle:"",
bovLink:"",
selObj: "",
selLnk:"",
selLnkPrefix:"",
linkValue:"",
linkText:"",

t: function(divToToggleId,bovLinkId,selObjId,selLnkId)
{
	this.divToToggle=this.obj(divToToggleId);
	this.selObj=this.obj(selObjId);
	this.bovLink=this.obj(bovLinkId);
	this.selLnk=this.obj(selLnkId);
	this.linkValue=this.getHtml(this.selLnk).lV;
	this.linkText=this.getHtml(this.selLnk).lT;
	this.divToToggle.style.display=(this.divToToggle.style.display=='none') ? '' : 'none';
	this.bovLink.style.display=(this.bovLink.style.display=='none') ? '' : 'none';	
	//this.selLnk.innerHTML=(this.linkValue=='-') ? '[+]'+this.linkText : '[-]'+this.linkText;
	this.toggleOthers(this.divToToggle,'none');
	this.toggleOthers(this.bovLink,'');
	//this.setLinks(this.selLnk);
	this.selObj.scrollIntoView(true);
},

obj: function(ID){
	if(document.getElementById)	
	{
		var o=document.getElementById(ID);
	}
	else if(document.all)
	{
		var o=document.all(ID);
	}
	else
	{
		return falls;
	}
	return o;
},

getHtml: function(link)
{
	if(link.innerHTML.substring(2,1)=='+' ||  link.innerHTML.substring(2,1)=='-')
	{
	 	  return {lV:link.innerHTML.substring(2,1),lT:link.innerHTML.substring(3)};
	}
	else
	{
		  return false;
	}
},

toggleOthers: function(so,state)
{
 	var pr=so.id.split('_')[0];
 	var divs;
 	var tagType = so.tagName;
 	if(document.getElementsByTagName)
 	{
		divs=document.getElementsByTagName(tagType);
	}
	else if(document.all)
	{
		divs=document.all.tags(tagType);
	}
	
	for(var i=0;i<divs.length;i++)
	{
		if( divs[i].id.substring(0,pr.length)==pr )
		{
			if(divs[i].id!=so.id)
			{
				this.obj(divs[i].id).style.display=state;
			}
		}
	}
},

setLinks: function(li)
{
 	var pr=li.id.split('_')[0];
 	var divs;
 	var tagType = li.tagName;
 	if(document.getElementsByTagName)
 	{
		divs=document.getElementsByTagName(tagType);
	}
	else if(document.all)
	{
		divs=document.all.tags(tagType);
	}
	for(var i=0;i<divs.length;i++)
	{
		if( divs[i].id.substring(0,pr.length)==pr )
		{
			if(divs[i].id!=li.id)
			{
				this.obj(divs[i].id).innerHTML='[+]'+this.getHtml(this.obj(divs[i].id)).lT;
			}
		}
	}
}
}//end Class

/////////////////////////////////////////////////////////////////////////////


//*****************
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 opDiv(ID,state)
{
	var o;
	if(document.getElementById)
	{
		o=document.getElementById(ID);
	}
	else if(document.all)
	{
		o=document.all[ID];
	}
	else
	{
		return;
	}
	if(state=="on")
	{
		o.className='opdivon';
	}
	else if(state=="out")
	{
		o.className='opdiv';
	}
	else
	{
		return;
	}
}

