// JavaScript Document
function mostrar(id){	
	//$('dv_'+id).show();	
	document.getElementById('dv_'+id).style.display = "block";
}

function ocultar(id){	
	document.getElementById('dv_'+id).style.display = "none";
}
 
function checkorder(){
	
	quant = 0;
	browser = document.getElementById('ProductBrowser-1');	
	tables = browser.getElementsByTagName('table');	
			
	for(i=0;i<tables.length;i++){		
		table = tables[i];
		tableclass = table.className;		
		tableclassarr = tableclass.split(" ")
		
		for(arr=0;arr<tableclassarr.length;arr++){
			
			if(tableclassarr[arr] == "ecwid-productBrowser-cart-itemsTable"){
				divs = table.getElementsByTagName('div');
			}
		}		
	} // end for i
	
	counter1 = 0; // otros
	counter2 = 0; // vinos
	flag = 0;
	
	for(b=0;b<divs.length;b++){		
		div = divs[b];				  
		
		// CHECK IF 'VINO'		
		divclass = div.className;		
		divclassarr = divclass.split(" ");
		
		for(arr=0;arr<divclassarr.length;arr++)
		{		
		  if(divclassarr[arr] == "ecwid-productBrowser-productNameLink"){ 						
			  as = div.getElementsByTagName('a');
			  a = as[0];
			  atext = a.innerHTML;			
			  srcresult = atext.search(/Vino/i);		
			  counter1++;
			  if(srcresult == 0){ // Vino is at position 0  
				  flag = 1;
				  counter2++;
			  } 		 						
		  }	
		}
		
		divclassarr2 = divclass.split(" ");
		
		for(arr=0;arr<divclassarr2.length;arr++)
		{
		  if(divclassarr2[arr] == "ecwid-fieldEnvelope-around" && flag == 1){			
			  inputs = div.getElementsByTagName('input');
			  input = inputs[0];
			  quant = quant + parseInt(input.value);
			  flag = 0;						
		  }
		}		  
	} // end for b
	
	
	if(document.getElementById('pnl_cart') != null){		
		if(counter2 == 0){
			document.getElementById('pnl_cart').style.visibility = "visible";
			document.getElementById('info').style.visibility = "collapse";
			//console.log("vinos 0");
		} else {	
		//console.log(counter2);
			if(quant >= 6){
				document.getElementById('pnl_cart').style.visibility = "visible";
				document.getElementById('info').style.visibility = "collapse";
				//console.log(">6");			
			} else {
				document.getElementById('pnl_cart').style.visibility = "hidden";
				document.getElementById('info').style.visibility = "visible";
				//console.log("<6");
			}
		}
	}
}						
