var isIE=(navigator.appName=='Microsoft Internet Explorer');
imageWindow=false;
imageWindowObj=window;
imageWindowImage='';
imageWindowTitle='';

function viewImage(imageSrc,title)
{
	if (typeof(title)=='undefined')
	{
		title='';
	}

	newImageSrc=imageSrc.substr(0,imageSrc.lastIndexOf('.'))+'_large'+imageSrc.substr(imageSrc.lastIndexOf('.'),imageSrc.length-imageSrc.lastIndexOf('.'));
	imageWindowTitle=title;
	imageWindowObj=window;
	imageWindowImage=new Image;
	imageWindowImage.onload=function () { openImage(); }
	imageWindowImage.src=newImageSrc;
}

function viewGaleryImage(imageSrc,title)
{
	if (typeof(title)=='undefined')
	{
		title='';
	}

	imageWindowTitle=title;
	imageWindowObj=window;
	imageWindowImage=new Image;
	imageWindowImage.onload=function () { openImage(); }
	imageWindowImage.src=imageSrc;
}

function openImage()
{
	windowScroll='no';
	imageWindowImage.onload=function () { }
	if (imageWindowImage.width>screen.width)
	{
		windowWidth=screen.width-20;
		windowScroll='yes';
	}
	else
	{
		windowWidth=imageWindowImage.width;
	}

	if (imageWindowImage.height>screen.height)
	{
		windowHeight=screen.height-20;
		windowScroll='yes';
	}
	else
	{
		windowHeight=imageWindowImage.height;
	}

	if (imageWindow)
	{
		imageWindow.close();
	}
	windowX=(screen.width-windowWidth)/2;
	windowY=(screen.height-windowHeight)/2;

	imageWindow=window.open("","imageWindow","width="+windowWidth+",height="+windowHeight+",top="+windowY+",left="+windowX+",toolbar=no,location=no,resizable="+windowScroll+",status=no,menubar=no,scrollbars="+windowScroll+",fullscreen=no");
//	imageWindow=imageWindowObj.open("","imageWindow","width=100,height=100,top=2,left=2,toolbar=no,location=no,resizable=no,status=no,menubar=no,scrollbars=no,fullscreen=no");
	if (imageWindow==null)
	{
		alert('Sajnos nem tudom megjeleníteni a kívánt képet mert a böngészőprogramja blokkolja az ablak létrehozást!');
		return;
	}
	imageWindow.document.open();
	imageWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
	imageWindow.document.write('<html><head><title>'+imageWindowTitle+'</title></head>');
	imageWindow.document.write('<body style="margin:0px;">');
	imageWindow.document.write('<a href="javascript:window.close();"><img src="'+imageWindowImage.src+'" border="0" alt="'+imageWindowTitle+'" title="'+imageWindowTitle+'"></a>');
	imageWindow.document.write('</body></html>');
	imageWindow.document.close();
}

function addWindowOnLoad(functionName)
{
}

function getStyleAttributeValue(obj,attributeName)
{
	var attributeValue;

	if (isIE)
	{
		attributeValue=obj.currentStyle[attributeName];
	}
	else
	{
		attributeValue=eval('obj.style.'+attributeName);
	}
	return attributeValue;
}

function getObjXY(Obj)
{
	var Cord,leftpos,toppos,aTag,IE;

	if (typeof(Obj)!='object')
	{
		Obj=document.getElementById(Obj);
	}

	var IE=(typeof(Obj.currentStyle)!='undefined');
	var Cord=new Array();
	var leftpos=Obj.offsetLeft;
	var toppos=Obj.offsetTop;
	
	if ((IE?Obj.currentStyle['position']:Obj.style.position)!='absolute')
	{
		aTag=Obj;
		do
		{
			aTag=aTag.offsetParent;
			leftpos += aTag.offsetLeft;
			toppos += aTag.offsetTop;
			if (aTag.style.position=='absolute')
			{
				leftpos -= aTag.offsetLeft;
				toppos -= aTag.offsetTop;
				break;
			}
		} while(aTag.tagName!="BODY" && aTag.tagName!="HTML" && (IE?aTag.currentStyle['position']:aTag.style.position) == 'static');
	}
	Cord[0]=leftpos;
	Cord[1]=toppos;
	return Cord;
}

function getDocHeight()
{
	return (typeof(window.innerHeight)!='undefined'?window.innerHeight:document.body.clientHeight);
}

function $(id)
{
	return document.getElementById(id);
}

function attachToEvent(event,func)
{
	if (window.attachEvent)
	{
		window.attachEvent(event,func);
	}
	else
	{
		if ((typeof(func)).toLowerCase()!='function')
		{
			return;
		}
		if ((typeof(document.event_handlers)).toLowerCase()=='undefined')
		{
			document.event_handlers=new Array();
		}
		if ((typeof(document.event_handlers[event])).toLowerCase()=='undefined')
		{
			document.event_handlers[event]=new Array();
		}
		if ((typeof(eval('window.'+event))).toLowerCase()!='function')
		{
			eval('window.'+event+"=function() {if ((typeof(document.event_handlers['"+event+"'])).toLowerCase()!='undefined') {for (var i=document.event_handlers['"+event+"'].length-1;i>=0;i--) {document.event_handlers['"+event+"'][i]();}}}");
		}
		document.event_handlers[event][document.event_handlers[event].length]=func;
	}
}

function addFlash(contentId,content)
{
	var index;

	if (typeof(__objectContent)=='undefined')
	{
		__objectContent=new Array();
	}
	index=__objectContent.length;
	__objectContent[index]=new Array();
	__objectContent[index]['id']=contentId;
	__objectContent[index]['content']='type="application/x-shockwave-flash" '+content;
}

function addObject(contentId,content)
{
	var index;

	if (typeof(__objectContent)=='undefined')
	{
		__objectContent=new Array();
	}
	index=__objectContent.length;
	__objectContent[index]=new Array();
	__objectContent[index]['id']=contentId;
	__objectContent[index]['content']=content;
}

function putObject()
{
	var i;

	if (typeof(__objectContent)=='undefined' || __objectContent.length<1)
	{
		return;
	}
	for (i=0;i<__objectContent.length;i++)
	{
		document.getElementById(__objectContent[i]['id']).innerHTML='<object " '+__objectContent[i]['content']+'</object>';
	}
}

attachToEvent('window.onload',putObject);
