/////////////////////
// AJAX FUNCTIONS
/////////////////////

function ajaxOpenObject() {
    var req = "";
	req = false;
	// branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	/*
	if(req) {
		req.onreadystatechange=function() {
			if (req.readyState==4) {
				updateAJAXVar(req.responseText);
		 	}
		}
		req.open("GET", url, true);
		req.send(null);
	} else {
		updateAJAXVar('');
	}
	*/	
	return req;
}

function loadCFResults(url,type,div,funcStart,funcEnd) { //url = string, div = element id, type = "loadData" or "getValue"
	if (type == 'loadData') {
		//Loading text
		var startHTML = '<p style="margin:15px 0px 15px 0px">';
		var endHTML = '</p>';
		var loadHTML = '<img src="/images/ajax_loading.gif" align="absmiddle" style="margin-right:5px"><strong>Loading video list...</strong>';
		var errHTML = '<strong>We\'re sorry</strong> -- this info is not available.';
		
		containerDIV = document.getElementById(div);
		containerDIV.innerHTML = startHTML + loadHTML + endHTML;
	}
	//AJAX request call
	var req = ajaxOpenObject();
	if(req) {
		req.onreadystatechange=function() {
			if (req.readyState==4) {
				data = req.responseText;
				if (type == 'loadData') {
					updatepage(data,div);
				} else if (type == 'getValue') {
					eval(funcStart+'\''+data+'\''+funcEnd);
				}
				req = null;
		 	}
		}
		req.open("GET", url, true);
		req.send(null);
	} else {
		if (type == 'loadData') {
			containerDIV.innerHTML = startHTML + errHTML + endHTML;
		} else if (type == 'getValue') {
			return false;
		}
		req = null;
	}
}

function updatepage(str,div){
	//alert(str);
	document.getElementById(div).innerHTML = str;
	afterUpdate();
}

function afterUpdate() {

}