window.onload = function(){
/*	
	document.body.innerHTML += 
		'<div id="overlayFB" style="'+
		'background: #000;'+ 
		'position: absolute;'+
		'top: 0; '+
		'left: 0;'+
		'width:100%;'+ 
		'display: none;'+ 
		'z-index:998; '+
		'filter:alpha(opacity=60);'+ 
		'-moz-opacity:0.6; opacity: 0.6;"></div>'+
	'<div id="floatBox" style="'+
		'display: none;'+
		'position: absolute;'+ 
		'z-index: 999; '+
//		'width: '+width+'px;'+ 
//		'height: '+height+'px; '+
		'background: #fff; '+
		'border: 1px solid #fff;'+ 
		'top: 50%; '+
		'left: 50%; '+
//		'margin-top: -'+(height/2)+'px; '+
//		'margin-left: -'+(width/2)+'px; '+
		'color: #000;'+ 
		'padding: 0px;'+
	'" >	'+
	'		<div id="title" style="position: relative; background: #eee; line-height: 20px; padding: 5px; ">'+
	'			<span id="titleFB" style="font-weight: bold;"></span>'+
	'			<span style="position: absolute; right: 5px; cursor: pointer;" onclick="close_box()">bezár</span>'+
	'		</div>'+
	'		<div id="contentFB" style="padding: 5px;"></div>'+
	'	</div>';
*/	
}

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




var xmlHttp;
function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
 		 xmlHttp=new XMLHttpRequest();
 	 }
	catch (e) {
  		try {
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e) {
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}



	function myGetPageScroll(){
	
		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;
	}


function myGetPageSize(){
	
	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) 
	return arrayPageSize;
}

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}


var _alert = function(text,title, width, height) {
	var box = document.getElementById("floatBox");
	var content = document.getElementById("contentFB");
	var overlay = document.getElementById("overlayFB");
	var titleFB = document.getElementById("titleFB");
	var page_size=myGetPageSize();
	var page_scroll=myGetPageScroll();
	
	titleFB.innerHTML=title;
	content.innerHTML=text+"<br><center><span onclick='close_box()' style='cursor: pointer; padding: 3px 5px; border: 1px solid #ccc; background: #eee;'>Bezár</span></center>";
	content.style.background="none";
	box.style.width=width+"px";
	box.style.height=height+"px";
	box.style.marginTop="-"+(height/2)+"px";
	box.style.marginLeft="-"+(width/2)+"px";
	
	overlay.style.height=page_size[1]+"px";
	box.style.top=(((page_size[3]/2)-50) + page_scroll[1])+"px";

	toggle("floatBox");
	toggle("overlayFB");

}


function openBox(url,title, width, height){
	var box = document.getElementById("floatBox");
	var overlay = document.getElementById("overlayFB");
	var titleFB = document.getElementById("titleFB");
	var page_size=myGetPageSize();
	var page_scroll=myGetPageScroll();
	
	titleFB.innerHTML=title;
	box.style.width=width+"px";
	box.style.height=height+"px";
	box.style.marginTop="-"+(height/2)+"px";
	box.style.marginLeft="-"+(width/2)+"px";
	
	overlay.style.height=page_size[1]+'px';
	box.style.top=(((page_size[3]/2)-50) + page_scroll[1])+'px';

	xmlHttp1=GetXmlHttpObject();
	if (xmlHttp1==null) {
  		alert ("A böngészője nem támogatja az AJAX-ot!");
  		return;
  	} 

	//	url+="?product="+ product +"&item="+item;
	xmlHttp1.onreadystatechange=getForm;
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send('');
	
	toggle("floatBox");
	toggle("overlayFB");
		
}


function close_box(){
	toggle("floatBox");
	toggle("overlayFB");
}

function getForm() {
	var box = document.getElementById("contentFB");
	if (xmlHttp1.readyState==4) { box.innerHTML=xmlHttp1.responseText; }
}


function validate(email) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   
	   if(reg.test(email) == false) {
	      return false;
	   }
	   else {
		 return true;  
	   }
}

function check_sender(){
	var nev = document.getElementById('from');
	var to = document.getElementById('to');
	var msg = document.getElementById('msgdiv');
	if( nev.value=='' || to.value=='' ){
		msg.innerHTML="A 'Nevem' és a 'Címzett' mező kitöltése kötelező!<br><br>";
	}
	else if (validate(to.value)==false) {
		msg.innerHTML="A érvénytelen E-mail cím a  'Címzett' mezőben!<br><br>";
	}
	else document.forms['sender'].submit() 
}
	

