// vodwizard.com
// vw_ajax.js

// note: before using this script, make sure you also included 'mm.js' (macromedia functions for rollover button) 

var req, enable_requests = true, ajax_led_id = '', callback_function = '', ajax_result = '';

function loadXMLDoc(url,callback) {
	if (enable_requests) {
		req = false;
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
			try { req = new XMLHttpRequest(); } catch(e) { req = false; }
		} else if(window.ActiveXObject) {
			try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { 
				try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; }
			}
		}
		if(req) {
			if (ajax_led_id != '' && ajax_led_id != null) {	if (elem=MM_findObj(ajax_led_id)) { elem.style.display = 'block'; } }
			enable_requests = false;
			callback_function = callback;
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send("");
		}
	}
}

function loadXMLDocEx(url,data,callback) {
	if (enable_requests) {
		req = false;
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
			try { req = new XMLHttpRequest(); } catch(e) { req = false; }
		} else if(window.ActiveXObject) {
			try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { 
				try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; }
			}
		}
		if(req) {
			if (ajax_led_id != '' && ajax_led_id != null) {	if (elem=MM_findObj(ajax_led_id)) { elem.style.display = 'block'; } }
			enable_requests = false;
			callback_function = callback;
			req.onreadystatechange = processReqChange;
			req.open('POST', url);
			// many server-side scripts require the Content-Type to be set:
			req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		    req.send(data);
		}
	}
}

function processReqChange() 
{
    if (req.readyState == 4) {
      	if (req.status == 200) {
			if (ajax_led_id != '' && ajax_led_id != null) {	if (elem=MM_findObj(ajax_led_id)) { elem.style.display = 'none'; } }
			ajax_result = req.responseText;
			enable_requests = true;
			if (callback_function != '' && callback_function != null) { eval(callback_function); }
        } else {
			if (ajax_led_id != '' && ajax_led_id != null) {	if (elem=MM_findObj(ajax_led_id)) { elem.style.display = 'none'; } }
			enable_requests = true;
        //    alert("There was a problem retrieving the XML data:\n ["+req.status+"]" + req.statusText);
	  alert("There was a problem retrieving the XML data:\n ["+req.status+"]" + req.statusText + '\n-------------------------\n' + req.responseText);
			/* submit this error */
			postdata = 'vw_action=vw_log_js_error';	
			postdata += '&desc=' + escape("There was a problem retrieving the XML data:\n ["+req.status+"]" + req.statusText + '\n' + req.responseText+'\nBrowser info: \n'+navigator.userAgent);
			postdata += '&page=' + escape(callback_function);
			postdata += '&line=0';
			var r = Math.random(1000000); postdata += '&r=' + r;
			var url = page.toLowerCase();
			if (url.substring(0,7)=='http://') {
				if (url.substring(0,11)=='http://www.') { url = 'http://www.vodwizard.com/vw_action.php?'; }
						else { url = 'http://vodwizard.com/vw_action.php?'; }
			} else if (url.substring(0,8)=='https://') {
				if (url.substring(0,12)=='https://www.') { url = 'https://www.vodwizard.com/vw_action.php?'; }
						else { url = 'https://vodwizard.com/vw_action.php?'; } }	
			var agt=navigator.userAgent.toLowerCase();
			if (agt.indexOf("firefox") != -1 || agt.indexOf("mozilla/5.0") != -1) {
				// alert('firefox');
				try {
					netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
				} finally {
					loadXMLDoc(url+postdata,'js_error_callback()');		
				}
			} else {
				loadXMLDoc(url+postdata,'js_error_callback()');	
			}
        }
    }
}
