/* This version of JavaScript Calendar can be used by anyone who is not intented
to do profit directly with this code, it means you can not sale the code as is, 
you can use it ont your web or php project, or put in a CD Magazine, if you really
do profit with your project and my code consider sharing them :P.
If you want to include the calendar in some web editor, do not remove this legend.
The lastest version can be found at
http://www.compunauta.com/forums/linux/programacion/java/gus_browser.html

This is Open and Free Software, madgus@gmail.com, gustavo@compunauta.com
*/

var CLAVE=0;
var DESCR=1;
var COMEN=2;
var PRICE=3;

var gus_Listado = new Array();
var array_pointer = 0;

function addObject(Clave,Descripcion,Comentario,Precio){
var newObject=new Array(3);
newObject[CLAVE]=Clave;
newObject[DESCR]=Descripcion;
newObject[COMEN]=Comentario;
//newObject[PRICE]=Precio;
gus_Listado[array_pointer++]=newObject;
}

function doSearch(FormName,LayerName,FieldName){
var innerTMP="";
var layer = document.getElementById(LayerName);
var query = document.forms[FormName].elements[FieldName].value.toUpperCase();
layer.innerHTML="";

if (query.length==0){
layer.innerHTML+="<H3>BUSQUEDA VACIA</H3>";
return false;}
var items=0;
var mcols=2;
var pcols=(Math.round(100/mcols));
var cols=0;
var res=0;
innerTMP+="<table align=\"center\" cellpadding=\"5\" width=\"95%\">";
for (var i=0; i<array_pointer; i++){
	if((gus_Listado[i][DESCR].toUpperCase().indexOf(query)!=-1) || (gus_Listado[i][CLAVE].toUpperCase().indexOf(query)!=-1) ||
	(gus_Listado[i][COMEN].toUpperCase().indexOf(query)!=-1)){
		res++;
		if(cols==0){innerTMP+="<tr>";}
		if(cols==mcols){cols=0;innerTMP+="</tr>\n";}
		cols++;
		innerTMP+="<td width=\""+pcols+"%\" align=\"center\" border='2'>";
		innerTMP+="<b><H3>"+gus_Listado[i][COMEN]+"</H3></b>";
		innerTMP+="<A href='img/"+gus_Listado[i][CLAVE].toLowerCase()+".jpg' target='_blank'><IMG SRC='img/"+gus_Listado[i][CLAVE].toLowerCase()+".jpg' width='50' height='50' border='1' alt='"+gus_Listado[i][CLAVE].toLowerCase()+".jpg'></A><br>";
		innerTMP+="<i>"+gus_Listado[i][DESCR]+"</i><br>";
		innerTMP+="C:<b>"+gus_Listado[i][CLAVE]+"</b>";
		innerTMP+="</td>";
	
	}
}
innerTMP+="</table>";
if(res>0){layer.innerHTML=innerTMP;}
else{layer.innerHTML="<H3>BUSQUEDA SIN RESULTADOS</H3>";}
return false;
}
