var ajax = false;

function AjaxRequest() {
	ajax = false;
	if ( window.XMLHttpRequest ) {
		ajax = new XMLHttpRequest();
	} else if ( window.ActiveXObject ) {
		try {
			ajax = new ActiveXObject("Msxm12.XMLHTTP");
		} catch(e){
			try{
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e){}
		}
	}
	if (!ajax) { 
        alert('Unfortunatelly you browser doesn\'t support this feature.'); 
        return false; 
    } 
}

/**********************
* Products Selector
***********************/
function showResult(category){
	var url;
	url = 'inc-flash.asp?category='+category;
	AjaxRequest();
	ajax.onreadystatechange = processChange;
	ajax.open('GET', url, true);
	ajax.send(null);
}


function processChange() {
	if ( ajax.readyState == 4 ){
		if ( ajax.status == 200 ){
			var products = eval(ajax.responseText);
			var prod_id;
			var flash_name;
			var div;
			var so;
			
			var e = document.getElementById('flashs');
			if (e.hasChildNodes())
			{
				var nos = e.childNodes;
				while (nos.length > 0)
				{
					var no = nos[nos.length-1];
					e.removeChild(no);
				}
			}
			
			if(products.length > 0) {
				for(var i = 0 ; i < products.length ; i++) {
					prod_id = products[i][0];
					flash_name = products[i][1];
					
					div = document.createElement('div');
					div.id = 'flash' + prod_id;

					document.getElementById('flashs').appendChild(div);
					
					so = new SWFObject('swf/' + flash_name + '?i=' + new Date(), "flash", "137", "111", "8");
					so.addParam ('wmode', 'transparent');
					so.write(div.id);
				}
			}
		}
	}
}




