var xmlHttp
var arr_items=new Array();
function GetResult(id)
{

    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Browser does not support HTTP Request")
	  return
	  } 
		var url="dataserver.php"
		url=url+"?id="+id
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		} 



function GetXmlHttpObject()
{
    var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 // Internet Explorer
			 try
			  {
			  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  }
			 catch (e)
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
	 }
return xmlHttp;
}




function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 	 
	  parseResult(xmlHttp.responseText)
	 } 
}







function parseResult(str)
{
	eval(str);
	var message_no_result="No result";
	//Get Dynamic Template
	var final_string=' '; 
	//alert(arr_items.length+ " Rows");
	 for (i=0;i<(arr_items.length-1);i++){
		var my_template=document.getElementById("tempate_dynamic").innerHTML;
	 	    my_template=my_template.replace(/id_items/g,arr_items[i][0]);
	        my_template=my_template.replace(/title/g,arr_items[i][1]);
	        my_template=my_template.replace(/description/g,arr_items[i][2].substring(0,70));
	        my_template=my_template.replace(/priceadd/g,arr_items[i][3]);
	        my_template=my_template.replace(/images/g,arr_items[i][4]);
	        my_template=my_template.replace(/date_add/g,arr_items[i][5]);
	        my_template=my_template.replace(/category_name/g,arr_items[i][6]);
	        my_template=my_template.replace(/type_add/g,arr_items[i][7]);
	        
	        final_string=final_string+my_template;
	        
        }
        if(arr_items.length==0){
		     document.getElementById("dynamicContent").innerHTML=message_no_result;
	      }else{
		    document.getElementById("dynamicContent").innerHTML=final_string;
	    }
}