// JavaScript Document
function download(ruta)
{
	x=500;
	y=500;
	t=(screen.availHeight-y)/2;
	l=(screen.availWidth-x)/2;
	win=window.open(ruta,'download_win','status=yes,scrollbars=yes,resizable=yes,left='+l+',top='+t+',width='+x+',height='+y);
}
function changeInputType(oldObject, oType) {
  var newObject = document.createElement('input');
  newObject.type = oType;
  if(oldObject.size) newObject.size = oldObject.size;
  if(oldObject.value) newObject.value = oldObject.value;
  if(oldObject.name) newObject.name = oldObject.name;
  if(oldObject.id) newObject.id = oldObject.id;
  if(oldObject.className) newObject.className = oldObject.className;
  oldObject.parentNode.replaceChild(newObject,oldObject);
 
  
  return newObject;
}

startList = function() {
	/*
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }*/
 
 	
	 if(id_area)
	 {
		if(document.getElementById("id_area").value!=id_area)
		{
			document.getElementById("id_area").value=id_area
			ajaxpage(apps_url+"?action=ART_families&no_index=true&id_area="+id_area,"families")
			desplega(id_area)
		}
	}
	setTimeout(engega_ofertes,40000)
	setTimeout(engega_destacats,60000)
}
function engega_ofertes()
{
	ajaxpage(apps_url+"?action=parse_content&plantilla=PUBLIC/PLANTILLAS/ofertes.html&no_index=true","ofertes");
	setTimeout(engega_ofertes,40000)
}
function engega_destacats()
{
	ajaxpage(apps_url+"?action=parse_content&plantilla=PUBLIC/PLANTILLAS/destacats.html&no_index=true","destacats");
	setTimeout(engega_destacats,60000)
}
window.onload=startList;
var last_content=false;
var prelast_content=false;
var last_id_item=false;
var id_area=false;
function cercar()
{
	url="?action=cercar&no_index=true&tipus[0]=id_article&desc="+document.getElementById("desc_cercar").value;
	if(document.getElementById("id_area"))
	{
		url+="&botiga[area]="+document.getElementById("id_area").value;
	}
	if(document.getElementById("id_familia"))
	{
		ids=document.getElementById("id_familia").value.split("-");
		url+="&botiga[familia]="+ids[0];
	}
	return url;
}

var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];var xmlDoc;for (var i = 0; i < prefixes.length; i++) {try {xmlDoc = new ActiveXObject(prefixes[i] + ".XMLDOM");	}catch (ex) 	{};}
function canvia_adreca(id)
{
	
	xmlDoc.async = false;
	xmlDoc.load(apps_url+"?action=ART_xml_modifica_adreca_entrega&id_adreca_entrega="+id);
	xmlObj = xmlDoc.documentElement;
	if(xmlObj.childNodes(0).getAttribute("value"))
	{
		//alert(xmlObj.childNodes(0).getAttribute("value"));
	}
}	
function ves_pagina(num,id)
{
	
	ajaxpage(apps_url+"?id="+id+"&no_index=true&next="+num,"content");
}

function preview(ruta)
{

	x=100;
	y=100;
	t=(screen.availHeight-y)/2;
	l=(screen.availWidth-x)/2;
	win=window.open(http_url+'preview.php?src='+ruta,'preview','status=yes,scrollbars=no,left='+l+',top='+t+',width='+x+',height='+y);
}
function tornar()
{
if(prelast_content){ajaxpage(prelast_content,'content');}else{history.back(0)}
}
function modifica_quantitat(id,valor)
{
	ajaxpage(apps_url+'?action=ART_modify_cart&id='+id+'&no_index=true&quantitat='+valor,'content');				ajaxpage(apps_url+'?action=ART_go_to_cart&plantilla=carro_simple.html&no_index=true','cistella');
}
function modifica_quantitat_pres(id,id_detall,valor)
{
	ajaxpage(apps_url+'?action=CLI_pressupostos_modifica_pres&id='+id+'&id_detall='+id_detall+'&no_index=true&quantitat='+valor,'detalls_pres_'+id);
}

function add_to_carro(id_sub,id_item,promo,tipus)
{

	if(promo=="Y"  && tipus=="G")
	{
		if(confirm(veure_promocions_associades))
		{
			ajaxpage(apps_url+'?action=ART_promocions&id_subarticle='+id_sub+'&no_index=true','content');
			return false;
		}
	}
	ajaxpage(apps_url+'?action=ART_add_to_cart&id_subarticle='+id_sub+'&id_item='+id_item+'&plantilla=carro_simple.html&no_index=true&quantitat='+document.getElementById('qty_'+id_sub+'').value,'cistella');
}





