/*

	XML banner rotator script by Anton Pitak, Intuitive s.r.o.
	
	Date: 26.06.2009
	anton.pitak@softpae.com

*/

var xmlhttp;

function getBanners(num, type, system, lang) {

	var resp = "";
	lang = typeof(lang) != 'undefined' ? lang : "en";
	var myurl = "http://www.yogaindailylife.org/esystem/banners.php?num="+num+"&type="+type+"&system="+system+"&lang="+lang;

	//doc = loadXML(myurl);
	doc = loadXMLDoc(myurl);
	if (window.ActiveXObject)
		resp = doc.getElementsByTagName("banner").item(0).text;
	else 
		resp = doc.getElementsByTagName("banner").item(0).textContent;
	
	document.write(resp);
	
	//var xmlDoc = loadXMLDoc(myurl);
	//alert (xmlDoc.getElementsByTagName("banner").item(0).text);

	/*xmlhttp = new myXMLHttpRequest();
	xmlhttp.onreadystatechange = myWriteBanner;
	xmlhttp.open ("GET", myurl, false);
	xmlhttp.send (null);*/
	
	//alert("START DOM");
	
}

function myWriteBanner () {

	if (xmlhttp.readyState != 4)
    return;
    
	alert (xmlhttp.responseText);
	
	var xmlDoc = new myXMLDom(); 
	xmlDoc.load(xmlhttp.responseText);
	
	alert(xmlDoc.xml);
	
	document.write(xmlDoc.getElementsByTagName("banner").item(0).text);
}

/* funkcie */

/*
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",xmlsrc,false);
xmlhttp.send(null);
var xmlDoc = xmlhttp.responseXML.documentElement;
*/

function loadXMLDoc(url) 
{
	var doc;
	
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        doc = new window.XMLHttpRequest();
        doc.open("GET", url, false);
        doc.send(null);
        return doc.responseXML.documentElement;
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        doc = new ActiveXObject("MSXML2.DOMDocument");
        if (doc) {
			doc.async = false;
            doc.load(url);
            return doc;
        }
    }
}

function getDom(iXmlStr) 
{ 
	if(window.XMLHttpRequest)
	{
		var xmlDoc = new XMLHttpRequest();
		xmlDoc.load(iXmlStr); 
		return xmlDoc; 
	}
	else if (window.ActiveXObject) 
	{ 
		var xmlDoc = new ActiveXObject("MSXML2.DOMDocument"); 
		xmlDoc.load(iXmlStr); 
		return xmlDoc; 
	} 
	return (new DOMParser()).parseFromString(iXmlStr, "text/xml");
}

function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}


function loadXML(url) {
    var xmldoc = newXMLDocument();
    xmldoc.async = false;  
    xmldoc.load(url);
    return xmldoc;  
};


function newXMLDocument() {

    if (document.implementation && document.implementation.createDocument) {
        // This is the W3C standard way to do it
        return document.implementation.createDocument("", "", null);
    }
    else { // This is the IE way to do it
        // Create an empty document as an ActiveX object
        // If there is no root element, this is all we have to do
        var doc = new ActiveXObject("MSXML2.DOMDocument");

        // If there is a root tag, initialize the document
        return doc;
    }
}; 

