
// check browser version
var isNC	= (document.layers)?1:0;
var isNC4   = (isNC && parseInt(navigator.appVersion) < 6 ) ? 1 : 0;
var isOPERA = (navigator.userAgent.indexOf('Opera') >= 0)?1:0;
var isIE	= (document.all && !isOPERA)?1:0;
var isDOM	= (document.getElementById && !isIE && !isOPERA)?1:0;
var isWIN	= (navigator.platform == 'Win32')?1:0;
var isMAC	= (navigator.platform == 'MacPPC')?1:0;
if(isNC){ isNC = 0; isDOM = 1; }

// isIE  || isDOM || isOPERA
if( 1 ){ window.onresize = resizes; }

function init()
{
	menu_init();
}

function resizes()
{
	var min_main_content_box_h = 290;
	var no_main_contents_all_h = 278;
	var main_content_right_box_right_margin = 38
	document.getElementById('main_content_box').style.width = '100%'
	// get doc width, height
	if(isIE || isOPERA) { DW = document.body.clientWidth; DH = document.body.clientHeight; }
	if(isNC || isDOM){ DW = window.innerWidth; DH = window.innerHeight; }
	// set main content height xxxx modifer
	var height_modifer = ( isDOM ) ? 35 : 10;
	var main_content_box_h = (DH-no_main_contents_all_h-height_modifer < min_main_content_box_h) ? min_main_content_box_h : DH-no_main_contents_all_h-height_modifer;
	if(document.getElementById('main_table'))
	{
		if( 1024 < DW )	document.getElementById('main_table').style.width = '950px';
		else			document.getElementById('main_table').style.width = '90%';
		document.getElementById('main_content_box').style.height = main_content_box_h; // ;
	}
	var ml_p = parseInt(document.getElementById('main_content_right_box').style.marginRight);
	var mc_h1 = parseInt(document.getElementById('main_content_box').style.height);
	var mc_h1 = ( isDOM ) ? (mc_h1 + parseInt(document.getElementById('main_content_box').style.paddingTop)) : mc_h1;
	var mc_h2 = document.getElementById('main_content_box').scrollHeight
	// alert(mc_h2+' < '+(mc_h1))
	if( mc_h2 <= (mc_h1) )
	{
		// get scroll width
		document.getElementById('js_helper').style.width = '50px';
		var mc_cw1 = parseInt(document.getElementById('js_helper').clientWidth);
		document.getElementById('js_helper').style.overflow = 'scroll';
		var mc_cw2 = parseInt(document.getElementById('js_helper').clientWidth);
		document.getElementById('js_helper').style.overflow = 'auto';
		var scroll_width = (mc_cw1-mc_cw2);
		// alert(scroll_width)
		document.getElementById('main_content_right_box').style.marginRight = (main_content_right_box_right_margin + scroll_width)+'px';
	}else{
		document.getElementById('main_content_right_box').style.marginRight = (main_content_right_box_right_margin + 0)+'px';
	}
}

function setValue(id, val)
{
	document.getElementById(id).value = val;
}

function clearIfVal(obj, val)
{
	if(obj.value == val) obj.value='';
}

function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

function show_hide(id, h1, h2)
{
	obj = document.getElementById(id);
	h = parseInt(obj.style.height);
	if(!h || h <= h1)
		obj.style.height = h2
	else
		obj.style.height = h1
}

function tr_rollover(trobj, colorto, colorfrom)
{
	trobj.style.background = colorto
	trobj.onmouseout = function(){
	this.style.background = colorfrom
	}
}

function swap_display(id)
{
	s = document.getElementById(id).style;
	if(s.display == 'none') s.display = 'block';
	else  s.display = 'none';

}

function set_display(id)
{
	s = document.getElementById(id).style;
	if(s.display == 'none') s.display = 'block';
	else  s.display = 'none';
}

function fmover(obj, level)
{
	// var obj = document.getElementById(id);
	if( level == 3 || level == 4 )
	{
		c1 = '#7FB11F';
		c2 = '#CFE968';
		obj.style.borderBottomColor = c1;
		obj.onmouseout = function() { obj.style.borderBottomColor = c2; }
	}else{
		c1 = '#7FB11F';
		c2 = '#FEE06C';
		obj.style.color = '#FFFFFF';
		obj.style.borderBottomColor = c1;
		obj.style.backgroundColor = c1;
		obj.onmouseout = function()
		{
			obj.style.borderBottomColor = c2;
			obj.style.backgroundColor = c2;
			obj.style.color = '#3D1401';
		}
	}
}

function hmover(id, id2)
{
	var obj = document.getElementById(id);
	var obj2 = document.getElementById(id2);
	// var img = document.getElementById('img_'+id);
	// img.src = "/test/magita/www/images/"+id+"_akt.gif"
	obj.style.background = "url(/test/magita/www/images/hm_bg_over.gif)";
	obj.style.borderLeftColor = '#FAF5E1';
	obj.style.borderRightColor = '#FAF5E1';
	obj2.style.color = '#FFFFFF';
	obj.onmouseout = function()
	{
		// img.src = "/test/magita/www/images/"+id+".gif"
		obj.style.background = "url(/test/magita/www/images/hm_bg_out.gif)";
		obj.style.borderLeftColor = '#F7B700';
		obj.style.borderRightColor = '#F7B700';
		if( id == 'hm_bemutatkozunk' )
		{
			obj.style.borderLeftColor = '#FAF5E1';
		}
		if( id == 'hm_kapcsolat' )
		{
			obj.style.borderRightColor = '#FAF5E1';
		}
		obj2.style.color = '#3D1401';
	}
}


function getImageTop(myImage) {
	// Netscape 4.x call getElementTop(myImage) to get the y co-ordinates
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		if (img.container != null)
			return img.container.pageY + img.y;
		else
			return img.y;
	} else {
		return getElementTop(myImage);
	}
	return -1;
}
function getImageLeft(myImage) {
	// Netscape 4.x call getElementLeft(myImage) to get the x co-ordinates
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
    	if (img.container != null)
			return img.container.pageX + img.x;
		else
			return img.x;
  	} else {
		return getElementLeft(myImage);
	}
	return -1;
}
function getElementLeft(Elem) {
	if (isNC4) {
		var elem = getObjNN4(document, Elem);
		return elem.pageX;
	} else {
		var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;
	}
}
function getElementTop(Elem) {
	if (isNC4) {
		var elem = getObjNN4(document, Elem);
		return elem.pageY;
	} else {
		if(document.getElementById) {	
			var elem = document.getElementById(Elem);
		} else if (document.all) {
			var elem = document.all[Elem];
		}
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return yPos;
	}
}
function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

function change_szerep_img(img, txt)
{
	document.getElementById('szerep_image').src = 'file/szerepek/szinhaz/'+img;
	document.getElementById('szerep_image_text').innerHTML = txt;
}

