// JavaScript Document
function getBaseURL() {
    var url = window.location.href;  // entire url including querystring;
    var baseURL = url.substring(0, url.indexOf('/', 14));
    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + "/";
    }

}
function createQMObject(){
var http = false;
try  {
	http = new XMLHttpRequest(); /* e.g. Firefox */
  }
catch(err1)  {
  try    {
    http = new ActiveXObject("Msxml2.XMLHTTP");
  /* some versions IE */
    }
  catch(err2)    {
    try {
      http = new ActiveXObject("Microsoft.XMLHTTP");
  /* some versions IE */
      }
      catch(err3){
        http = false;
        }
    }
  }
return http;
}


function FetchEvent(str){
	var base_url=getBaseURL();
	var browse= str;
	var http=createQMObject();
	var ran_no=+ new Date().getTime();
	http.open("GET", ''+base_url+'fetchevent.php?browse='+browse+'&ran='+ran_no, true);
   	http.onreadystatechange = function() {
		document.getElementById("showevent").innerHTML ='';
		if(http.readyState < 4) {
			document.getElementById("showevent").innerHTML = "<img src='"+base_url+"images/loading.gif' class='imger' />";
		}
		if(http.readyState == 4) {
        // if server HTTP response is "OK"
        if(http.status == 200) {
             document.getElementById("showevent").innerHTML = http.responseText;
        } else {
            // issue an error message for any
            // other HTTP response
            alert("An error has occurred: " + http.statusText);
        }
    }
	}; 
   	http.send(null); 
}