function initxmlhttp() {
	var xmlhttp ;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	} catch (e) {
		try {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		} catch (E) {
			xmlhttp=false
		}
	}
	@else
	xmlhttp=false
	@end @*/
	if ( !xmlhttp && typeof XMLHttpRequest!='undefined' ) {
		try {
			xmlhttp = new XMLHttpRequest() ;
		}
		catch (e) {
			xmlhttp = false ;
		}
	}
	return xmlhttp ;
}


contentArray = new Array();
var visible_div;
var hidden_id = "anim_hidden";
var hidden_div = '<div id="' + hidden_id + '" style="width:1px;height:1px;visibility:none;display:none;overflow:hidden;"></div>';


function ajaxanim (clip, div, frame) {

	visible_div = div;
	
	if (typeof frame == 'undefined') {
		frame = 1;
	}

	if (contentArray[frame]) {
		div_el = document.getElementById(visible_div); // get the element that is to be updated
		div_el.innerHTML = contentArray[frame] + hidden_div;
		
		if (!contentArray[frame+1] && document.getElementById(hidden_id)) {
			getFrameContent(clip, hidden_id, frame+1, false);
		}
		
	} else {
		getFrameContent(clip, visible_div, frame, true);

	}
}


function getFrameContent(clip, div, frame, preload) {

	var ajaxOb = initxmlhttp() ;
	var url = "/ajaxanim/update.php?c="+clip+"&f="+frame+"&d="+visible_div;

	ajaxOb.open( "GET", url, true ) ;
	var changed = 0;

	ajaxOb.onreadystatechange=function() {
		
		if (ajaxOb.readyState==4) {
			var response = ajaxOb.responseText;
			
			contentArray[frame] = response;
			
			div_el = document.getElementById(div); // get the element that is to be updated
			div_el.innerHTML = response + hidden_div;
			
			if (preload && !contentArray[frame+1]) {
				getFrameContent(clip, hidden_id, frame+1, false);
			}
		}
	}
	ajaxOb.send(null) ;
}