/******************************************************************************/
/**********                   AJAX  SCRIPT                      ***************/
/**********    coded by Hubert Frey, FT Systems programmer      ***************/
/**********                    01-09-2007                       ***************/
/**********            e-mail: frey@ft-systems.net              ***************/
/**********            website: www.ft-systems.net              ***************/
/******************************************************************************/
	        
			function gid(id)
			{
				return document.getElementById(id);
			}
			
			function gname(id)
			{
				return document.getElementByTagName(id);
			}			

			// We create the HTTP Object
			var ajax = new Array(4);
			var i = 0;
			// The server-side scripts
			var sendUrl = "includes/contact-form.php?"; 			

			function handleHttpResponse()
			{
				switch (ajax[i].readyState)
				{
					case 1 :  	gid("contact-form").style.visibility = "visible";
								gid("contact-form").innerHTML = "<img src=\"../graphics/spinner.gif\" width=\"16\" height=\"16\" />&nbsp;&nbsp; zpracovávám, čekejte, prosím...";
								break;

					case 4		 :	gid("contact-form").style.visibility = "visible"
									gid("contact-form").innerHTML=ajax[i].responseText;
									break;
				}
			}
			
	        function sendForm()
			{
				form = gid("contactForm");
				i++;
				ajax[i] = getHTTPObject();
		        ajax[i].open("GET", sendUrl + "contact_name=" + encodeURI(form.contact_name.value) + "&contact_phone=" + escape(form.contact_phone.value) + "&contact_email=" + form.contact_email.value + "&contact_company=" + form.contact_company.value + "&contact_note=" + encodeURI(form.contact_note.value) + "&send=1", true);
				ajax[i].onreadystatechange = handleHttpResponse;
	        	ajax[i].send(null);
	        	return false;
	        }
			var getUrl = "includes/contact-form.php?";
	        function getForm()
			{
				form = gid("contactForm");
				i++;
				ajax[i] = getHTTPObject();
		        ajax[i].open("GET", getUrl, true);
				ajax[i].onreadystatechange = handleHttpResponse;
	        	ajax[i].send(null);
	        	return false;
	        }	        
	        
	        function getHTTPObject()
			{
				if (window.XMLHttpRequest) 
				{
   					http_request = new XMLHttpRequest();
 				} 
 				else if (window.ActiveXObject) 
 				{
    				try
    				{
					    http_request = new ActiveXObject("Msxml2.XMLHTTP");
    				} 
    				catch (e) 
    				{
      					http_request = new ActiveXObject("Microsoft.XMLHTTP");
    				}
 				}				
				return http_request;
        	}


function loadPhoto(event,imageID,imageTitle,width,height)
{
	thumbPath = gid(imageID).src;
	imageWidth = gid(imageID).width;
	imageHeight = gid(imageID).height;
	imagePath = thumbPath.replace("/thumbs","");
	imageOffset = 330;
	/*
    if (document.all && !window.opera) {//ie
       y = event.clientY;//document.dosumentElement.scrollTop;
    }
    else {
       y =  document.documentElement.scrollTop;
    }
    */
	if (document.documentElement) //ie strict
	{
		var y = event.clientY + document.documentElement.scrollTop - ((height+56)/2);
		var documentY = document.documentElement.scrollHeight;

	}
	else if (document.body) // all other Explorers
	{
		var y = event.clientY + document.body.scrollTop - ((height+56)/2);
		var documentY = document.body.scrollHeight;
	}

	if ((y + (height+56)) > documentY) 
	{
		y = y - ((y + (height+56)-documentY));
	}

    if (document.all && !window.opera) {
       gid('imagecontainer').style.pixelTop = y;
    }
    else {
       gid('imagecontainer').style.top = y + "px";
    }
	gid('imagecontainer').style.margin = '0 0 0 -' + imageOffset + 'px';
	gid('imagecontainer').style.display = 'block';
	gid('imagecontainer').innerHTML = '<img src="' + imagePath + '" alt="Kliknut�m na fotku okno zav�ete" onclick="gid(\'imagecontainer\').style.display = \'none\';" /><div class="cleaner">&nbsp;</div><div class="imageclose"><img src="./graphics/close.gif" width="26" height="26" alt="close" onclick="gid(\'imagecontainer\').style.display = \'none\';" /><div>';
}

function showhide(id)
{
	if (gid(id).style.display == "none")
	{
		gid(id).style.display = "block";
	}
	else
	{
		gid(id).style.display = "none";
	}
}