// Check if is MSIE

function isIE()

{

var userAgent = navigator.userAgent.toLowerCase();

if (userAgent.indexOf("msie") != -1)

{ return true; }

else

{ return false; }

}



// Create the XMLHttpRequest object

function createXMLHttpRequest()

{

try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}

try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}

try { return new XMLHttpRequest(); } catch(e) {}

alert("XMLHttpRequest is not supported");

return null;

}



var _theImage = new Image;

_theImage.src = "ajaxloader.gif";

// <summary>

// target - the element which will contain the requested document;

// documentUrl - the url to the requested document;

// imageSrc - the url to the animated gif.

// </summary>

function createAjaxRequest(target, documentUrl, imageSrc)

{

var myRequestGet = createXMLHttpRequest();

this.imageSrc = _theImage.src;

if (myRequestGet != null)

{

// Add the image

target.appendChild(_theImage);

// Set the request timeout

target._timer = setTimeout( 

function()

{

//myRequestGet.abort();

//myRequestFailed("The server timed out while making the request.");

//removeLoaderImage(); 

},

10000 // The request will timeout in 10 seconds

);

myRequestGet.open("GET", documentUrl, true);

myRequestGet.onreadystatechange = function()

{

if (myRequestGet.readyState == 4)

{

clearTimeout(target._timer);

if (myRequestGet.status == 200)

{

// Remove the image.

removeLoaderImage();

// Show content.

myRequestCompleted();

}

else

{

// Remove the image.

removeLoaderImage();

// Display error message.

myRequestFailed("Message returned, but with error status. \n" + "Server error: " + myRequestGet.status); 

clearTimeout(target._timer);

}

}

}

function myRequestCompleted() { return target.innerHTML = myRequestGet.responseText; }

function myRequestFailed(errorMessage) { return alert(errorMessage); }

function removeLoaderImage() { while (target.firstChild) {target.removeChild(target.firstChild);} }

}

myRequestGet.send(null);

}



// Execute the request

function ajaxRequestWithImage(he,he2)

{
adres = new String("");
zmienna2 = new String(he);
zmienna3 = new String(he2);
//zmienna1 = new String("http://www.floramedia.pl/legutko/infoLoader.php?lang=en&show=");
zmienna1 = new String("http://www.floramedia.pl/legutko/infoLoader.php?show=");
adres = zmienna1.concat(zmienna2);
adres = adres.concat("&lang=");
adres = adres.concat(zmienna3);

var senderID = document.getElementById("openConnectionButton");

var container = document.getElementById("ajaxRequestContainer");

var DocUrl;

var imageSrc = _theImage.src;

if ( isIE() )

{ DocUrl = adres }
else

{ DocUrl = adres }

return createAjaxRequest(container, DocUrl, imageSrc);

}




function ajaxClear(){
var empty_char = '';
var myDiv = document.getElementById('ajaxRequestContainer');
myDiv.innerHTML = empty_char;
} 

