/*
Shadebird Software Solutions
Ajax Library
file: ajaxLibrary.js
folder: SITEROOT/javascript/

This source file is property of Shadebird Software Solutions.
All right reserved. 
Please contact us for further use.
*/
function initializeAjax()
{
	 http_request = false;	
	 
	 if (window.XMLHttpRequest) // Mozilla, Safari,...
	 { 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{	
			http_request.overrideMimeType('text/xml');
		} 
	 } else 
		if (window.ActiveXObject) // IE
		{ 
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) 
						{
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
							} catch (e) 
									{
									}
						}
		}
	
	 if (!http_request) 
		return null;

	return http_request;
}

function createObject(){
}
var browserDimensions;
browserDimensions=new createObject();
browserDimensions.x=0;
browserDimensions.y=0;

var imgObject=new Image();
imgObject.id="popupImg";

function closeDiv()
{
	this.style.visibility="hidden";
}

function getBrowserDimensions()
{
	if (self.innerHeight) // all except Explorer
	{
		browserDimensions.x = self.innerWidth;
		browserDimensions.y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)	// Explorer 6 Strict Mode
	{
		browserDimensions.x = document.documentElement.clientWidth;
		browserDimensions.y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		browserDimensions.x = document.body.clientWidth;
		browserDimensions.y = document.body.clientHeight;
	}
}

function showImage(filename)
{
	getBrowserDimensions();
	http_request=initializeAjax();
		if(http_request!=null)
		{
			http_request.onreadystatechange = function() 
												{ 
												if (http_request.readyState == 4) 
													{
													if (http_request.status == 200) 
														{
															if(http_request.responseText!="Shadebird-noData")
															{
															   dimensionArray=http_request.responseText.split("|",2);
															   imgWidth=dimensionArray[0];
															   imgHeight=dimensionArray[1];														
															  
window.open("showimage.php?filename=" + filename,'showPic','width=' + imgWidth +',height=' + imgHeight +',left=' + (browserDimensions.x-imgWidth)/2 + ',top=' + (browserDimensions.y-imgHeight)/2 + ',screenX=' + (browserDimensions.x-imgWidth)/2 + ',screenY=' + (browserDimensions.y-imgHeight)/2) + 'resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no';														
															} else 
															{
																
															}
														} else 
															{													
																alert('Hiba történt a kérés kiszolgálása során.');
															}
													}
												}
		}

    http_request.open('GET', "getimagedimensions.php?filename=" + filename, true);
    http_request.send(null);
}

function showIntro()
{
	getBrowserDimensions();
	http_request=initializeAjax();
		if(http_request!=null)
		{
			http_request.onreadystatechange = function() 
												{ 
												if (http_request.readyState == 4) 
													{
													if (http_request.status == 200) 
														{																
															introDivObj=document.getElementById("introDiv");															
															introDivObj.innerHTML=http_request.responseText;
															//introDivObj.innerHTML="hello";
															getBrowserDimensions();
															introDivObj.style.top=(browserDimensions.y-parseInt(introDivObj.style.height))/2+"px";															
															introDivObj.style.left=(browserDimensions.x-parseInt(introDivObj.style.width))/2+"px";																
															introDivObj.style.visibility="visible";	
															introDivObj.onclick=closeDiv;
														} else 
															{													
																alert('Hiba történt a kérés kiszolgálása során.');
															}
													}
												}
		}

    http_request.open('GET', "intro.html", true);
    http_request.send(null);
}
