modalablak = function(neve,w,h,z,tartalomdiv_id){
	this.divnev=neve;
	this.boxwidth=w;
	this.boxheight=h;
	this.bg_z_index=z;
	this.tartalomdiv_id=tartalomdiv_id;
}
modalablak.prototype = {
	//a divek létrehozása
	createDivs : function(){
		// el kell tünteteni a reklámokat és azt a miben flash van, ha van ilyen
		if(typeof( window[ "modal_alatt_hidden" ] ) != "undefined"){
			for(i=0;i<modal_alatt_hidden.length;i++){
				$(modal_alatt_hidden[i]).style.display="none";
			}
		}
		// a háttér
		var bgnev=this.divnev+"_bg";
		var boxnev=this.divnev+"_box";
		var bg_zindex=this.bg_z_index;
		this.modal_bg = document.createElement('DIV');
		this.modal_bg.style.left = '0px';
		this.modal_bg.style.top = '0px';
		this.modal_bg.id=bgnev;
		this.modal_bg.style.zIndex=bg_zindex;
		this.modal_bg.className='modal_bg_style';
		document.body.appendChild(this.modal_bg);
		// a tartalom
		this.modal_div_box = document.createElement('DIV');
		this.modal_div_box.className = 'modal_div_box';
		this.modal_div_box.id = boxnev;
		this.modal_div_box.style.width=this.boxwidth+"px";
		this.modal_div_box.style.height=this.boxheight+"px";
		this.modal_div_box.style.zIndex=bg_zindex;
		document.body.appendChild(this.modal_div_box);
		var xxxx=this.divnev+"_obj";
		window[xxxx]= this;
		this.modal_div_box.innerHTML="<input align='right' type='image' src='/images/modal_bezar_gomb.jpg' onclick='window."+this.divnev+"_obj"+".close()'/><br/>";
		tmp=document.getElementById(this.tartalomdiv_id);
		this.modal_div_box.innerHTML+=tmp.innerHTML;
		//ki kell üríteni, hogy ne legyen konfliktus
		tmp.innerHTML="";
		this.resize();
		
		this.addEvent(window,'scroll',function(e){ window[xxxx].scroll_event() });
		this.addEvent(window,'resize',function(e){ window[xxxx].resize()});
	}
	,
	resize : function(){
		var meretek = this.getPageSize();
		var yertek=this.get_pagescroll();
		this.modal_bg.style.width = meretek[0]+"px";
		this.modal_bg.style.height = meretek[1]+"px";
		this.modal_div_box.style.left = ((meretek[2]-this.boxwidth)/2)+'px';
		this.modal_div_box.style.top = ((meretek[3]-this.boxheight)/2)+yertek[1]+'px';
	}
	,
	scroll_event : function(){
		var meretek = this.getPageSize();
		var yertek=this.get_pagescroll();
		this.modal_div_box.style.top = ((meretek[3]-this.boxheight)/2)+yertek[1]+'px';
	}
	,
	//események
	addEvent : function(whichObject,eventType,functionName,suffix){ 
	  if(!suffix)suffix = '';
	  if(whichObject.attachEvent){ 
	    whichObject['e'+eventType+functionName+suffix] = functionName; 
	    whichObject[eventType+functionName+suffix] = function(){whichObject['e'+eventType+functionName+suffix]( window.event );} 
	    whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName+suffix] ); 
	  } else 
	    whichObject.addEventListener(eventType,functionName,false); 	    
	} 
	,
	
	getPageSize : function(){
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){

			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		//alert(pageWidth+":"+pageHeight+":"+windowWidth+":"+windowHeight); 
		return arrayPageSize;		
		
	}
	,
	get_pagescroll : function(){
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		arrayPageScroll = new Array('',yScroll) 
		return arrayPageScroll;
	}
	,
	close : function()
	{
		document.body.removeChild(this.modal_bg);
		document.body.removeChild(this.modal_div_box);
		if(typeof( window[ "modal_alatt_hidden" ] ) != "undefined"){
			for(i=0;i<modal_alatt_hidden.length;i++){
				$(modal_alatt_hidden[i]).style.display="block";
			}
		}
	}
}