var xmlhttp=null;
var xmlhttp_b=null;
var xmlhttp_c=null;

function xmlhttp_object() {
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
return xmlhttp;
}

function xmlhttp_object_b() {
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp_b = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp_b = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp_b = false;
  }
 }
@end @*/
if (!xmlhttp_b && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp_b = new XMLHttpRequest();
	} catch (e) {
		xmlhttp_b=false;
	}
}
if (!xmlhttp_b && window.createRequest) {
	try {
		xmlhttp_b = window.createRequest();
	} catch (e) {
		xmlhttp_b=false;
	}
}
return xmlhttp_b;
}

function xmlhttp_object_c() {
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp_c = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp_c = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp_c = false;
  }
 }
@end @*/
if (!xmlhttp_c && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp_c = new XMLHttpRequest();
	} catch (e) {
		xmlhttp_c=false;
	}
}
if (!xmlhttp_c && window.createRequest) {
	try {
		xmlhttp_c = window.createRequest();
	} catch (e) {
		xmlhttp_c=false;
	}
}
return xmlhttp_c;
}

function loadFragmentInToElement(fragment_url, element_id) {
	xmlhttp = xmlhttp_object();
    var element = document.getElementById(element_id);
    element.innerHTML = '<img src="loading.gif" /> Loading...';
    xmlhttp.open("GET", fragment_url, true);
	xmlhttp.onreadystatechange = function() {
		// ALIM added 6/15/2007
	    // the condition inside the if statement may break sometimes, just ignore if it does
	    try {
		    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
	//			if(urchinTracker) urchinTracker(fragment_url);
			element.innerHTML = xmlhttp.responseText;
		    }
		} catch (ex) {
			// do nothing
		}
	}
	xmlhttp.send(null);
}

function loadAnotherFragmentInToElement(fragment_url, element_id) {
	xmlhttp_b = xmlhttp_object_b();
    var element = document.getElementById(element_id);
    element.innerHTML = '<img src="loading.gif" /> Loading...';
    xmlhttp_b.open("GET", fragment_url, true);
	xmlhttp_b.onreadystatechange = function() {
		// ALIM added 6/15/2007
	    // the condition inside the if statement may break sometimes, just ignore if it does
	    try {
		    if (xmlhttp_b.readyState == 4 && xmlhttp_b.status == 200) {
	//			if(urchinTracker) urchinTracker(fragment_url);
			element.innerHTML = xmlhttp_b.responseText;
		    }
		} catch (ex) {
			// do nothing
		}
	}
	xmlhttp_b.send(null);
}

function async_request(url, on_finished) {
	xmlhttp = xmlhttp_object();
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = function() {
		// ALIM added 6/15/2007
	    // the condition inside the if statement may break sometimes, just ignore if it does
	    try {
		    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
	//			if(urchinTracker) urchinTracker(url);
				eval(on_finished);
		    }
		} catch (ex) {
			// do nothing
		}
	}
	xmlhttp.send(null);
}

function async_request_c(url, on_finished) {
	xmlhttp_c = xmlhttp_object_c();
	xmlhttp_c.open("GET", url, true);
	xmlhttp_c.onreadystatechange = function() {
	    // ALIM added 6/15/2007
	    // the condition inside the if statement may break sometimes, just ignore if it does
	    try {
		    if (xmlhttp_c.readyState == 4 && xmlhttp_c.status == 200) {
				// if(urchinTracker) urchinTracker(url);
				eval(on_finished);
		    }
	    } catch (ex) {
		// do nothing, just continue elegantly
	    }
	    
	}
	xmlhttp_c.send(null);
}

function async_rate(userid, rating, barID) {
	if(barID) { document.getElementById(barID).className='minirate'; }
	rating_url = 'async_rate.php?rating=' + escape(rating) + '&userid=' + escape(userid);
	if(barID) { loadFragmentInToElement(rating_url, barID); }
	else { async_request_c(rating_url, 'void(0)'); }
}

function async_correct(userid, rating, barID) {
	rating_url = 'async_correct.php?rating=' + escape(rating) + '&userid=' + escape(userid);
	if(barID) { loadFragmentInToElement(rating_url, barID); }
	else { async_request_c(rating_url, 'void(0)'); }
}