function loadProduct(URL, category, product)
{
// alert (URL);  // Create the XML request  
	xmlReq2 = null;
	if(window.XMLHttpRequest) 		xmlReq2 = new XMLHttpRequest();
	else if(window.ActiveXObject) 	xmlReq2 = new ActiveXObject("Microsoft.XMLHTTP");
	if(xmlReq2==null) return; // Failed to create the request
// Anonymous function to handle changed request states
	xmlReq2.onreadystatechange = function()
	{
		switch(xmlReq2.readyState)
		{
		case 0:	// Uninitialized
			break;
		case 1: // Loading
			break;
		case 2: // Loaded
			break;
		case 3: // Interactive
			break;
		case 4:	// Done!
		// Retrieve the data between the <quote> tags
		  var p_label0 = new Array();
			var p_label1 = new Array();
			var p_label2 = new Array();
			//label2 = new Array();
			//alert("tag=" +tag + " category=" + category);
			//alert(xmlReq.responseXML.getElementsByTagName(lan).length);
			var catElems = xmlReq2.responseXML.getElementsByTagName(category);
			var ilen = catElems.length;
			for(i=0; i<ilen; i++) {
			  //alert(xmlReq.responseXML.getElementsByTagName(lan)[i].firstChild.data)
			  if(product.length>0){
				  for(j=0; j<product.length; j++){					   
					  if(catElems[i].attributes.getNamedItem("pid").value==product[j]){
				       p_label0.push(catElems[i].attributes.getNamedItem("tagline").value);
					     p_label1.push(catElems[i].firstChild.data);
							 p_label2.push(catElems[i].attributes.getNamedItem("views").value);
					  if (j==product.length-1) writeInProductDetail(p_label0,p_label1,p_label2);
				    }						 		 
				  }
				} else {
				    p_label0.push(catElems[i].attributes.getNamedItem("tagline").value);
					  //p_label1.push(catElems[i].firstChild.data);
						if (i==catElems.length-1) writeInProduct(p_label0); 
				}
			}			
			break;
		default:
			break;
		}
	}
// Make the request
	xmlReq2.open ('GET', URL, true);
	xmlReq2.send (null);
}



function preLoadXML(URL, callback)
{
 //alert (URL);  // Create the XML request  
	xmlReq4 = null;
	if(window.XMLHttpRequest) 		xmlReq4 = new XMLHttpRequest();
	else if(window.ActiveXObject) 	xmlReq4 = new ActiveXObject("Microsoft.XMLHTTP");
	if(xmlReq4==null) return; // Failed to create the request
// Anonymous function to handle changed request states
  
	xmlReq4.onreadystatechange = function()
	{
		switch(xmlReq4.readyState)
		{
		case 0:	// Uninitialized
			break;
		case 1: // Loading
			break;
		case 2: // Loaded
			break;
		case 3: // Interactive
			break;
		case 4:	// Done!
		// Retrieve the data between the <quote> tags
		  //alert(xmlReq4.responseXML);
		 
			eval(callback + "()");
			//document[invData]=xmlReq4.responseXML;
			break;
		default:
			break;
		}
	}
// Make the request
	xmlReq4.open ('GET', URL, true);
	xmlReq4.send (null);
	return xmlReq4;
}



function ProductDesc( XMLObj, category, pid ) {

	this.XMLObj = XMLObj;
	this.category = category;
	this.pid = pid;

	this._features = new Array();
	this._tagline = "";
	this._preStyledDescription = new Array();
	this._itemDescription = "";
	this._views = new Array();

	var catElems = XMLObj.getElementsByTagName(category);
	
	var ilen = catElems.length;
	for (i=0; i<ilen; i++) {

	   if (catElems[i].attributes.getNamedItem("pid").value == pid) {
		   	
		   if (catElems[i].attributes.getNamedItem("lang").value.toUpperCase() == lang) {
			 
			    this._tagline = catElems[i].attributes.getNamedItem("tagline").value;
						//  PRESTYLED CONTENT
					if(catElems[i].firstChild.data.indexOf("|")>= 0){
					   this._preStyledDescription = catElems[i].firstChild.data.split("|").join("<br/><br/>");
					   this._itemDescription = this._preStyledDescription;
				
					} else {
							//  SINGLE PRODUCT CONTENT
							  this._itemDescription = catElems[i].firstChild.data;
						}
										 
					// BULLETS
					this._features = catElems[i].attributes.getNamedItem("features").value.split("|");
					
					// VIEWS , THUMBS 
					this._views = catElems[i].attributes.getNamedItem("views").value.split(",");		
			
				}
		 }
	}
	
		
}
