window.oninit = function() {
}

launchInit = function() {
	if (document.getElementsByTagName && typeof(window.oninit)=='function') {
		if (document.getElementsByTagName('body').length>0) window.oninit();
		else setTimeout('launchInit()',30);
	}
}
launchInit();

function _xml(){var xmlhttp=false;
/*@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;}

function parseQuery(qs) {
	if (qs.indexOf('?')==0) qs = qs.substr(1);
	var kv = qs.split('&');
	var o = {};
	for (var i=0,j=kv.length;i<j;i++) {
		kv[i] = kv[i].split('=');
		o[kv[i][0]] = kv[i].slice(1).join('=');
	}
	return o;
}

function strip(text) {
	var ws = " \t\n";
	while (ws.indexOf(text.substr(0,1))>=0) text = text.substr(1);
	while (ws.indexOf(text.substr(text.length-1))>=0) text = text.substr(0,text.length-1);
	return text;
}

function subChild(html) {
	var root = document.createElement('span');
	root.innerHTML = strip(html);
	while (!root.firstChild) {lag = Math.sin(Math.cos(Math.random()));}
	var o = {};
	o.id = root.firstChild.id;
	o.html = root.firstChild.innerHTML;
	root = null;
	return o;
}

function replaceProduct(link,id,ignoreold) {
	var ajax = _xml();
	var f = function() {
		if (ignoreold && window.ajax_f!=f) return;
		if (ajax.readyState == 4) {
			if (ajax.status == 200) {
				var res = ajax.responseText;
				var o = subChild(res);
				var elm = document.getElementById(id);
				if (elm) elm.innerHTML = (o.id==id)? o.html : res;
			}
		}
	}
	window.ajax_f = f;
	link = '/products_ajax.cp2?pid='+parseQuery(link.substr(link.indexOf('?')+1)).pid;
	ajax.open("GET", link, true);
	ajax.onreadystatechange = f;
	ajax.send(null);
}