function productoIberojet(name, campanya){
	this.name = name;
	this.listObject = null;
	this.campanya = campanya;
	this.pathContenidos = "/contenidos";
	
	this.xmlDestinos = new ActiveXObject("Microsoft.XMLDOM");
	
	this.load = p_load;
	this.init = p_init;
}

function p_load(){
	if (this.xmlDestinos.readyState != 4) 
		return;
		
	var rs, rs2, nom, nodo, str;
	str = "<xml>";
	
	if (this.campanya != "")
	{
	    rs = this.xmlDestinos.selectNodes("xml/arbol/agr")
	    for (var i=0;i<rs.length;i++){
		    str += "<des cod='' nom='"+ rs[i].getAttribute("no") +"' dtt='' />"
		    rs2 = rs[i].selectNodes("nodo");
    		
		    for (var j=0;j<rs2.length;j++){
			    nom = " - " + rs2[j].getAttribute("value");
				nom = nom.substring(0,20)
    			
			    str += "<des cod='"+ rs2[j].getAttribute("codigo") +"' nom='"+ nom +"' />";
		    }
	    }
	}
	else
	{
	    var rs = this.xmlDestinos.selectNodes("xml/agrupaciones/agru")
	    var esborra = false
	    for (var i=0;i<rs.length;i++)
	    {
	        if (rs.item(i).getAttribute("niv") == "1")
	        {
	            nom = rs.item(i).getAttribute("nom")
				str += "<des cod='' nom='"+ nom +"' />";
	        }
			else
			{
				nom = rs.item(i).getAttribute("nom")
				cod = rs.item(i).getAttribute("cod")
				cod = cod.replace("D","")
				nom = "   - " + nom
				nom = nom.substring(0,20)
				str += "<des cod='"+ cod +"' nom='"+ nom +"' />";
			}
	    }	  
	}
	str += "</xml>";
	
	this.listObject.loadXML(str,"des","nom","cod");
}

function p_init(){
	var ficheroDestinos;
	
	if (this.campanya != "")
    		ficheroDestinos = this.pathContenidos + "/xml_minorista/arbolesDestino/"+ this.campanya +"/agrDestinos.xml"
    	else
    		ficheroDestinos = this.pathContenidos + "/minoristaVI/destinosProgramas/7/destinos.xml"
        	//ficheroDestinos = this.pathContenidos + "/xmlDatosPaginasProducto/agrupaciones/MINagrupaciones.xml"
	
	this.xmlDestinos.async = true;
	this.xmlDestinos.onreadystatechange = new Function(this.name + ".load()");
	this.xmlDestinos.load(ficheroDestinos);
}
