var req;
function loadXMLDoc(url){
if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    req.onreadystatechange = processReqChange;
    req.open("GET", url, true);
    req.send(null);
} else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req) {
    req.onreadystatechange = processReqChange;
    req.open("GET", url, true);
    req.send();
        }
    }
}

function processReqChange() 
{
    if (req.readyState == 4)
    {
        if (req.status == 200)
        {
        response  = req.responseXML.documentElement;
        A_Method  =    response.getElementsByTagName('method')[0].firstChild.data;
        A_Result    = response.getElementsByTagName('result')[0].firstChild.data;
        if (A_Method!='addNew')
            {
            eval(A_Method + '(\'\', A_Result)');
            }else{
            eval(A_Method + '(\'\',\'\', A_Result)');
            }
            }else{
alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}

function CreateObject()
{
    var http;
    var browser = navigator.appName; 
    if(browser == "Microsoft Internet Explorer"){
    http = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
    http = new XMLHttpRequest();
    }
      return http;
}

var xmlhttp = CreateObject();
if(!xmlhttp) alert('Sorry we can not create an ActiveX on your browser');

function loading(action,pagename) {
    xmlhttp.open("GET", action, true);
    xmlhttp.onreadystatechange = function() {DOWAT(pagename);} //changed so parameter can be assigned to function.
    xmlhttp.send(null);
}

function DOWAT(pagename) {
    if(xmlhttp.readyState == 1 || xmlhttp.readyState == 2) {
		document.getElementById("content-panel-right").innerHTML = 'Loading ...'; //edit div id
    }
	else if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		if (pagename=='video') {
			loadSWFObject();
			loadPlayer();
		} //gallery fuction on index.php to load simplegallery
		document.getElementById("content-panel-right").innerHTML = xmlhttp.responseText;    //edit div id 
		if (pagename=='home') {showgal();} //gallery fuction on index.php to load simplegallery  
    }   
}

function iwant2(action){
    loading('ajax.php?do='+action+'&js=true',action); //js is set for ajax.php to pick up where the query is coming from
}
//---------------------------------------------
function vid_loading(action,vidnum) {
    xmlhttp.open("GET", action, true);
    xmlhttp.onreadystatechange = function() {vid_DOWAT(vidnum);} //changed so parameter can be assigned to function.
    xmlhttp.send(null);
}

function vid_DOWAT(vidnum) {
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		loadSWFObject();
		vid_loadPlayer(vidnum);
		document.getElementById("swf-video-wrap").innerHTML = xmlhttp.responseText;    //edit div id 
    }   
}

function showVid(vidnum) {	
	vid_loading('includes/swf-video.php?vid='+vidnum,vidnum);
}
