function pongoTitulo(archivo,color1,color2,ancho,alto) {
	document.write ("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+ancho+"' height='"+alto+"'>");
	document.write ("<param name='movie' value='titulos/"+archivo+"?tituColor1="+color1+"&tituColor2="+color2+"' />");
	document.write ("<param name='quality' value='high' />");
	document.write ("<param name='menu' value='false' />");
	document.write ("<param name='wmode' value='transparent' />");
	document.write ("<embed src='titulos/"+archivo+"' flashVars='tituColor1="+color1+"&tituColor2="+color2+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='transparent' width='"+ancho+"' height='"+alto+"'></embed>");
	document.write ("</object>");
}

function barraestado(str){
	window.status=str;
}

function transparente(){
	var pepe = document.getElementById("main");
	pepe.className="aviso_rojo"
}

function validoSeteoGral(){
	theform = document.frmSetTam;
	pass=false;
	for(i=0; i<theform.elements.length;i++){
		if(theform.elements[i].name.substring(0,10) == "seteocant_" && theform.elements[i].selectedIndex != 0){
			pass=true;
		}
	}
	if(!pass){
		salida = "Debe seleccionar al menos una cantidad";
		scrollTo(0,0)
		alerta('Error en Registración de Usuario', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');
		//alert("Debe seleccionar una cantidad para setear")
		return false;	
	}	
	return true;
}

function seleccionados() {

	if (!OneChecked()) {
		alert("Debe seleccionar al menos un articulo");
		return (false);
	}
	document.form0.varchecks.value = "";
		
	var aaa = VerChecks();
	
	direccion="<?echo($actupath);?>" + direccion;
	document.form0.action = direccion;
	document.form0.submit();

}

function VerChecks() {
	
	ml = document.form0;
	len = ml.elements.length;
	
	for(var i = 0 ; i < len ; i++) {
		if ((ml.elements[i].name == "chkpp") && (ml.elements[i].checked)) {
			document.form0.varchecks.value = document.form0.varchecks.value + ml.elements[i].value + ",";
		}
	}
	return (true);
	
}

function OneChecked(){

	ml = document.form0;
	len = ml.elements.length;
	
	for(var i = 0 ; i < len ; i++) {
		if ((ml.elements[i].name == "chkpp") && (ml.elements[i].checked)) {
			return true;
		}
	}
	return false;
	
}

function show_help(){
	ocu = document.getElementById("ayuda_ocu");
	vis = document.getElementById("ayuda_exp");
	if(ocu.className == "visible"){
		ocu.className="oculto";
		vis.className="visible";
	}else{
		ocu.className="visible";
		vis.className="oculto";	
	}
}

function Redondear(dblTemp){

	var intPosEsta 	= 0 ;
	var intLen 	= 0 ;
	var intFin 	= 0 ;
	var strTempo 	= "" ;
	
	strTempo = "" + dblTemp + "" ;
	
	intPosEsta = strTempo.indexOf(".");

	if(intPosEsta>0){
		intPosEsta += 1;
		intLen = strTempo.length;
		intFin = intPosEsta + 2 ;
		
		if(intLen < intFin){
			intFalta = intFin - intLen;
			for(i=0;i<intFalta;i++){
				strTempo = strTempo + '0' ;
			}
		}else{
			strTempo = strTempo.substring(0,intFin);
		}
	}else{
		strTempo = strTempo + '.00' ;
	}
	return(strTempo);
	
}

function FinalizarCarga(strForm,strPage){
	var TheForm 	= eval("document." + strForm );
	TheForm.action 	= "" + strPage + "" ;
	TheForm.submit();
}

function SeguirCargando(nameForm,strPage){
	var TheForm = eval("document." + nameForm);
	TheForm.action 	= "" + strPage + "" ;
	sSubmitear(nameForm);
}

function CerrarWindows(){
	parent.close();
}

function validaMail(nameForm){
	
	TheForm = eval("document." + nameForm);
				
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
	
	if (eval(TheForm.strEmail.value.length)){    
	  if(! b.test(TheForm.strEmail.value)){
	  	salida = "La dirección de email ingresada es inválida.<br>Por favor corríjala e intente nuevamente.";
			scrollTo(0,0)
			alerta('Error en Registración de Usuario', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');
	  	//alert("Dirección de Email inválida. Verifíquela.");
	  	return false;	  	
	  };   
	};
	return true;   
	      
}

function hacerSubmit(nameForm){
	var TheForm;	
	TheForm = eval("document." + nameForm);
	TheForm.submit();	
}

function registrar(nameForm){
	
	if (!validaMail(nameForm)){
		//alert("Dirección de Email inválida. Verifíquela.");				
	}else{
			TheForm = eval("document." + nameForm);
			
			if(isRegistrar(TheForm)){
				TheForm.submit();
			};
		};
		
}

function isRegistrar(TheForm){	
	
	var strValue = "" ;
	var dblTemp = 0 ;
	var dbltempo = 0 ;
	var strError = "";
	var strTitulo = "";
	var strTituloSimple = "<b>El siguiente campo debe completarse</b>:\n";
	var strTituloCompuesto = "<b>Los siguientes campos deben completarse</b>:\n";

	var i = 0 ;
	var cont = 0;
	var j= 0;
	
	if (TheForm.strPass.value != TheForm.strPass2.value){
		if(dbltempo==0){
		strError+="<br>Las claves que ha ingresado no son iguales.";
		cont++;
		};
	};
	
	for (i=0; i<TheForm.elements.length; i++) {
	
		if (TheForm.elements[i].type == "text" || TheForm.elements[i].type == "password" ){
			dbltempo = eval(TheForm.elements[i].value.length);
	  	} 

		if (TheForm.elements[i].name == "strUser"){
			if(dbltempo==0){
			strError+="<br>Usuario";
			cont++;
			};
		};

		if (TheForm.elements[i].name == "strPass"){
			if(dbltempo==0){
			strError+="<br>Clave";
			cont++;
			};
		};
		
		if (TheForm.elements[i].name == "strNombre"){
			if(dbltempo==0){
			strError+="<br>Nombre";
			cont++;
			};
		};
		if (TheForm.elements[i].name == "strApellido"){
			if(dbltempo==0){
			strError+="<br>Apellido";
			cont++;
			};
		};
		if (TheForm.elements[i].name == "strEmail"){
			if(dbltempo==0){
			strError+="<br>Email";
			cont++;
			};
		};
		
		if (TheForm.elements[i].name == "strUser") {
		
			erroneos = "áíóúñéÑ/ÁÉÍÓÚ: ";
			cant = erroneos.length;
			usuario = TheForm.strUser.value;

			for (j=0 ; j < cant ; j++) {
   			erroneo = erroneos.charAt(j);
				if (usuario.indexOf(erroneo) != -1) {
					strError+="El nombre de usuario contiene caracteres inválidos.<br>";
					cont++;
				};
			};
		};
	};
		
	if(cont!=0){
		if(cont==1){
		salida = strTituloSimple + strError ;
		}else{
		salida = strTituloCompuesto + strError ;
		};
		scrollTo(0,0)
		alerta('Error en Registración de Usuario', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');
		//alert(strTitulo);
		return(false);
	};
	return(true);
	
}

function dblPonerTotal(intForm){
	var TheForm 	= document.forms[intForm];
	var strValue 	= "" ;
	var dblTemp 	= 0 ;
	var dbltempo 	= 0 ;
	var iCont	= 0 ;
	var strTempo	= "" ;
	
	for (i=0; i<TheForm.elements.length; i++) {
		if (TheForm.elements[i].type == "text"){
			strValue = TheForm.elements[i].name.substring(0,11);

			if (strValue == "dblSubtotal"){
				dbltempo = eval(TheForm.elements[i].value) ;
				dblTemp	= eval(dblTemp + dbltempo) ;
			}
		}
	}

	strTempo = Redondear(dblTemp);	
	TheForm.dblTotal.value="" + strTempo + "";

}

function ponerValorSubtotal(intForm,intCopias,dblPrecios,intImg){
	
	var TheForm 	= document.forms[intForm];
	var dblTemp 	= 0 ;
	var dbltempo 	= 0 ;
	var strTempo 	= "";
	var i 		= 0 ;
	var strValue = "" ;

	dblTemp	= intCopias * dblPrecios ;

	strTempo = Redondear(dblTemp);

	for (i=0; i<TheForm.elements.length; i++) {
			if(TheForm.elements[i].name == "dblSubtotal_" + intImg + "" ){
				TheForm.elements[i].value = strTempo ;
			}
	}

	TheForm.strMarca.value = TheForm.strMarca.value + "," +  intImg ;
	dblPonerTotal(intForm);

}

function ponerValorSubtotal(intForm,intCopias,dblPrecios,intImg){
	
	var TheForm 	= document.forms[intForm];
	var dblTemp 	= 0 ;
	var dbltempo 	= 0 ;
	var strTempo 	= "";
	var i 		= 0 ;
	var strValue = "" ;


	dblTemp	= intCopias * dblPrecios ;

	strTempo = Redondear(dblTemp);


	for (i=0; i<TheForm.elements.length; i++) {
		if(TheForm.elements[i].name == "dblSubtotal_" + intImg + "" ){
			TheForm.elements[i].value = strTempo ;
		}
	}

	TheForm.strMarca.value = TheForm.strMarca.value + "," +  intImg ;
	dblPonerTotal(intForm);
}

function verJs(intForm){
	var TheForm = document.forms[intForm];
	var strValue = "" ;
	var i = 0 ;
	for (i=0; i<TheForm.elements.length; i++) {
			strValue += "Tipo =>" + TheForm.elements[i].type + "Name =>" + TheForm.elements[i].name + "Value =>" + TheForm.elements[i].value + "\n";
	}
	alert(strValue);
}

function openWindowsImg(strNameImg,strAlias){
	var Propiedades = "alwaysRaised=yes, height=300, width=300, resizable=yes, screenX=100 , screenY=100 ,toolbar=no";
	window.open("verdetailfiles.php?strImg=" + strNameImg + "&strAlias=" + strAlias + "","Visualizar_Imagenes",Propiedades);
}

function Submitear(intForm){
	TheForm.submit();
}

function valSubmitear(){
	var TheForm = document.forms[1];
	for (i=0; i<TheForm.elements.length; i++) {
		alert(  " (Name)=> " + TheForm.elements[i].name + " (Tipo) => " + TheForm.elements[i].type + " (Valor)=> " + TheForm.elements[i].value );
	}
}

function intContarFiles(nameForm){
	
	var TheForm = eval("document." + nameForm);
	var intCount 	= 0;

	for (i=0; i<TheForm.elements.length; i++) {
		if (TheForm.elements[i].type == "file"){
			if (TheForm.elements[i].value != "") {
			intCount++;
			}		
		}
	}
	return intCount;
}

function isOkEnviar(nameForm){		
	
	var strFilesValid = ".bmp.gif.jpeg.jpg"; 
	var bnlValor 	= "";	
	var TheForm = eval("document." + nameForm);	

	bnlValor = isTipoFilesValid(nameForm,strFilesValid);
	
	if(bnlValor){
		TheForm.bnlEnviar.value = "1";
		TheForm.submit();
		document.getElementById("loading").className = "loading-visible";

	}
	
}

function isTipoFilesValid(nameForm,strExtensionesValidar){
	var bnlError 		= true;
	var intTempo 		= 0;
	var strValue 		= "";
	var intPosEsta  	= 0;
	var strExtension	= "";
	var strTempo		= ""
  
	intTempo = intContarFiles(nameForm); 

	var TheForm = eval("document." + nameForm);

	if(intTempo==0){
		salida = "Debe seleccionar al menos una foto para enviar." ;
		scrollTo(0,0)
		alerta('Error en Registración de Usuario', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');
		
		//alert("\nDebe seleccionar al menos un archivo.\n");
		return(false);
	}

	intTempo = 0 ;
	
	for (i=0; i<TheForm.elements.length; i++) {
		if (TheForm.elements[i].type == "file"){
			
			strValue = TheForm.elements[i].value;
			
			if (strValue != "") {
				intPosEsta = strValue.lastIndexOf(".");

				if (intPosEsta == -1) {
					salida = "El archivo seleccionado como Foto \""+strValue+"\" no posee extensión.\n" ;
					scrollTo(0,0)
					alerta('Error en Tipo de Archivo', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');
					//alert("\nEl archivo seleccionado como Foto \""+strValue+"\" no posee extensión.\n");
					TheForm.elements[i].focus();
					return(false);
				}else{

					strExtension = strValue.slice(intPosEsta+1, strValue.length)
					strExtension = strExtension.toLowerCase();
					strExtensionesValidar = strExtensionesValidar.toLowerCase();
					
					intPosEsta = strExtensionesValidar.lastIndexOf("."+strExtension+"");

					if (intPosEsta == -1) {
						salida = "El archivo seleccionado como Foto \""+strValue+"\" no posee extensión.\n" ;
						scrollTo(0,0)
						alerta('Error en Tipo de Archivo', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');			
						//alert("\nEl archivo seleccionado como Foto \""+strValue+"\" no posee extensión valida.\n");
						TheForm.elements[i].focus();
						intTempo++;
						return(false);
					}else{

						if (TheForm.elements[i+1].value.length >= 50) {
							salida = "La descripción ingresada para la Foto \""+strValue+"\" es demasiado larga.\n Puede contener como máximo hasta 50 caracteres." ;
							scrollTo(0,0)
							alerta('Error en Registración de Usuario', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');
							//alert("\nLa descripción ingresada para la Foto \""+strValue+"\" es demasiado larga.\n Puede contener como máximo hasta 50 caracteres.\n");
							document.fmFiles.elements[i+1].focus();
							intTempo++;
							return(false);
						}
					}
				}
			}		
		}
	}

	if(intTempo!=0){
		bnlError = false;
	}
	return(bnlError);
	
}

function sSubmitear(nameForm){

	var TheForm = eval("document." + nameForm);
	TheForm.submit();

}


function EliminarSeleccionados(nameForm,nameField,strPage){

	if(isValEliminados(nameForm,nameField)){
		if(confirm("¿Está seguro de borrar las fotos seleccionadas?")){
			var TheForm = eval("document." + nameForm);
			TheForm.action 	= "" + strPage + "" ;
			sSubmitear(nameForm);
		}

	}
}

function EliminarTodos(nameForm,strPage){
	if(confirm("¿Está seguro de borrar todas las fotos de su pedido?"))
	var TheForm = eval("document." + nameForm);
	TheForm.action 	= "" + strPage + "" ;
	sSubmitear(nameForm);

}


function isValEliminados(nameForm,nameField){

	if(CheckAllSum(nameForm,nameField)==0){
		
		salida = "Debe seleccionar al menos una foto para borrar";
		scrollTo(0,0)
		alerta('Error en borrado de fotos', 350, '#f0f0f0', 1, 0, 240, 165,salida,'alerta.gif');
		//alert("\n Debe elegir un elemento.");
		return(false);
	}
	return(true);
}

function CheckAllSum(nameForm,nameField){
	var total=0;
	var TheForm = eval("document." + nameForm);
	var len = TheForm.elements.length;

	for(i=0;i<len;i++){
		if(TheForm.elements[i].name==nameField){			
			if(eval("TheForm.elements["+i+"].checked")==true){
				total += 1;
			}
		}
	}	
	return total;
}

//function validarCantidadFotos(arrayNombres){
	
	/*
	valido que todas las imágenes tengan al menos 1 como cantidad seleccionada en alguna
	de sus instancias
	*/
/*
	arrayNombres2 = arrayNombres.split(":");
	isOk = true;
			
	
	for(i=0; i < arrayNombres2.length; i++){
		
		pass=false;
		
		
		for (j=0; j < document.frmFiles.elements.length; j++){
		  
		  if(document.frmFiles.elements[j].name.substring(0,(12+arrayNombres2[i].length)) == "selCantidad_"+arrayNombres2[i]){
				if(document.frmFiles.elements[j].options[document.frmFiles.elements[j].selectedIndex].value != 0){
						pass=true;
						break;
				}
			}		
				
		}
		
		if(!pass){
			isOk = false;
			break;	
		}
	}
	if(!isOk){
		alert("Hay imágenes con cantidad igual a 0.\nPor favor corríjalo e intente nuevamente.");
		return false;
	}


	return true;	
	
}

function FinalizarCargaFotos(intForm,strPage){
	var TheForm 	= document.forms[intForm];
	TheForm.action 	= "" + strPage + "" ;

	if (validarCantidadFotos("<? echo $strCarrito ?>") == true){
		Submitear(intForm);	
	}	
	
}
*/
function ActualizarDatos(selObj,intArtic,lineaFoto){
	// cantidad, idtamanio, idtipopapel
	var valor;
	
	var theForm = "document.frmFiles" ;

	theObj_Cantidad = eval(theForm + ".selCantidad_" + intArtic + "_" + lineaFoto + ".value");
	theObj_Tamanio = eval(theForm + ".selTamanio_" + intArtic + "_" + lineaFoto + ".value");
	theObj_Papel = eval(theForm + ".selPapel_" + intArtic + "_" + lineaFoto + ".value");
	theObj_Subtotal = eval(theForm + ".dblSubtotal_" + intArtic + "_" + lineaFoto + "");
	
	
	if ((eval(theForm + ".dataprecio_" + theObj_Tamanio + "_" + theObj_Papel + "")) == undefined ){
		alert("Medida no disponible momentáneamente.");
		
		theObj_Tamanio2 = eval(theForm + ".selTamanio_" + intArtic + "_" + lineaFoto + "");
		theObj_Tamanio2.options[0].selected = true	 		
		theObj_Papel2 = eval(theForm + ".selPapel_" + intArtic + "_" + lineaFoto + "");
		theObj_Papel2.options[0].selected = true	
		
	}else{
	
		theObj_PrecioUnitario = eval(theForm + ".dataprecio_" + theObj_Tamanio + "_" + theObj_Papel + ".value");
	
	};
	
		if ( theObj_PrecioUnitario.value != "" ) { 
	 		theObj_Subtotal.value = Redondear(theObj_Cantidad * theObj_PrecioUnitario);
	 	}
	 	
	 	calcularTotal(12);
	 
	
}

function calcularTotal(sumaDesdeSQL){
	
	var theFormXX = "document.frmFiles" ;
	TheForm = document.frmFiles;
	descuento = 0 ;
	sumaDesc = parseFloat(0);
	sumaCompleta = parseFloat(0);
	TotalTipoFoto = parseFloat(0);
	
	arrayClaveTipoFoto = new Array(40);
	arrayCantLocalTipoFoto = new Array(40);
	arrayCantTotalTipoFoto = new Array(40);
	arrayPrecioTipoFoto = new Array(40);

	for (i = 0 ; i < 40 ; i++) {
		arrayCantLocalTipoFoto[i] = parseFloat(0);
		arrayCantTotalTipoFoto[i] = parseFloat(0);
		arrayPrecioTipoFoto[i] = parseFloat(0);
	}
	
	var arrPos = -1 ;
	var posPrec = -1 ;

	for (i = 0 ; i < TheForm.elements.length ; i++) {

		/*
		<input type="hidden" name="dataprecio_1_1_50" value="0.80" >
		<input type="hidden" name="dataprecio_1_51_100" value="0.75" >
		<input type="hidden" name="dataprecio_1_101_150" value="0.65" >
		<input type="hidden" name="dataprecio_1_151_200" value="0.60" >
		<input type="hidden" name="dataprecio_1_201_100000" value="0.60" >
		
		<input type="hidden" name="dataprecio_2_1_50" value="0.80" >
		<input type="hidden" name="dataprecio_2_51_100" value="0.00" >
		<input type="hidden" name="dataprecio_2_101_150" value="0.00" >
		<input type="hidden" name="dataprecio_2_151_200" value="0.00" >
		<input type="hidden" name="dataprecio_2_201_100000" value="0.00" >
		*/

		if ( TheForm.elements[i].name.substring(0,10) == "dataprecio" ){
			var arrayClaves = TheForm.elements[i].name.split("_"); 
			theObj_Clave = arrayClaves[1] ;
		
			var apos = buscaClave(arrayClaveTipoFoto, theObj_Clave ) ;

			if ( apos == -1 ) {
				arrPos ++ ;
				
				arrayClaveTipoFoto[arrPos] = theObj_Clave ;
				arrayCantLocalTipoFoto[arrPos] = parseFloat(0) ;
				
				var xxx = eval( theFormXX + ".cantfueratipofoto_" + theObj_Clave ) ;
				
				if( xxx != undefined){
					arrayCantTotalTipoFoto[arrPos] = parseFloat(xxx.value) ;
				}else{
					arrayCantTotalTipoFoto[arrPos] = parseFloat(0) ;
				}

			}
		}

		var elemento =  TheForm.elements[i].name ;

		if (elemento.substring(0,11) == "selCantidad" ){
			var arrayCampos = elemento.split("_"); var idArticulo = arrayCampos[1]; var idLinea = arrayCampos[2];

			theObj_Cantidad = parseFloat(TheForm.elements[i].value) ;
			//alert("cantidad: " + elemento + " - " + theObj_Cantidad);

			theObj_Tamanio = eval(theFormXX + ".selTamanio_" + idArticulo + "_" + idLinea + ".value");
			theObj_Papel = eval(theFormXX + ".selPapel_" + idArticulo + "_" + idLinea + ".value");
			var theObj_TipoFoto = eval(theFormXX + ".tipoFoto_" + theObj_Tamanio + "_" + theObj_Papel);
			
			if( theObj_TipoFoto != undefined ) {
				var apos = buscaClave(arrayClaveTipoFoto, theObj_TipoFoto.value ) ;
				arrayCantLocalTipoFoto[apos] += parseFloat(theObj_Cantidad) ;
			}
			//alert("pos cant: " + apos);alert("cant: " + arrayCantLocalTipoFoto[apos]);
		}

	}

	var precioCompleto = parseFloat(0);
	var precioDesc = parseFloat(0);
	
	for (var i = 0 ; i < arrayClaveTipoFoto.length ; i++) {
		if( arrayClaveTipoFoto[i] != undefined ) {

			var cantidad = parseFloat(arrayCantLocalTipoFoto[i]);
			TotalTipoFoto = parseFloat( cantidad + arrayCantTotalTipoFoto[i] ) ;

			var strObjectInicial = "dataprecio_" + arrayClaveTipoFoto[i] + "_" + claveRangoCantidad(1) ;
			var strObjectCantidad = "dataprecio_" + arrayClaveTipoFoto[i] + "_" + claveRangoCantidad(parseFloat(TotalTipoFoto)) ;
			
			//alert("cant: " + cantidad); alert("total out: " + TotalTipoFoto);
			//alert("strObjectInicial: " + strObjectInicial);alert("strObjectCantidad: " + strObjectCantidad);
			
			var strPrecioCompleto = eval( theFormXX + "." + strObjectInicial ) ; 
			var strPrecioDesc = eval( theFormXX + "." + strObjectCantidad ) ;
			
			if( strPrecioDesc != undefined ){
				if( strPrecioDesc.value != 0 ){
					sumaDesc += parseFloat(TotalTipoFoto * strPrecioDesc.value) ;
				}else{
					sumaDesc += parseFloat(TotalTipoFoto * strPrecioCompleto.value) ;
				}
			}else{
				sumaDesc += parseFloat(TotalTipoFoto * strPrecioCompleto.value) ;
			}
			
			//alert("strPrecioCompleto: " + strPrecioCompleto ); alert("strPrecioDesc: " + strPrecioDesc );

			sumaCompleta += parseFloat(TotalTipoFoto * strPrecioCompleto.value) ;

		}
	}
	
	var dest_total = document.getElementById("total");
	var dest_total_desc = document.getElementById("totalDesc");
	
	dest_total.innerHTML = "$ " + Redondear(sumaCompleta);
	dest_total_desc.innerHTML = "$ " + Redondear(sumaDesc);

	//total.innerHTML = "$ " + Redondear(sumaCompleta);
	//totalDesc.innerHTML = "$ " + Redondear(sumaDesc);	
		
}

function buscaClave(arrayClaveTipoFoto, theObj_Clave){

	var encontro = -1 ;
	var xx = 0 ;
	
	for (xx = 0 ; xx < arrayClaveTipoFoto.length ; xx++) { 
		if ( arrayClaveTipoFoto[xx] != undefined ) {
			if( arrayClaveTipoFoto[xx] == theObj_Clave ) {
				encontro = xx ;
			}
		}
	}
	
	return encontro ;
}


function claveRangoCantidad(cantidad){
	var salida = "1_50";
	
	if( ( 1 <= cantidad ) && ( cantidad <= 50 ) ) {
			salida = "1_50";
	}
	if( ( 51 <= cantidad ) && ( cantidad <= 100 ) ) {
			salida = "51_100";
	}
	if( ( 101 <= cantidad ) && ( cantidad <= 150 ) ) {
			salida = "101_150";
	}
	if( ( 151 <= cantidad ) && ( cantidad <= 200 ) ) {
			salida = "151_200";
	}
	if( ( 201 <= cantidad ) && ( cantidad <= 100000 ) ) {
			salida = "201_100000";
	}

	return salida ;
}

function checkeaTodos(){

theForm = document.frmFiles;
var estado = false; 	
	if( theForm.checkear.checked == true) estado = true;
	for (i = 0; i < theForm.elements.length; i++){
		if (theForm.elements[i].type == "checkbox" && theForm.elements[i].name.substring(0,3) == "che"){
			theForm.elements[i].checked = estado;
		}
	}
};

function cc(cual,color){
	cual.bgColor = color;
}

function ce(obj,evt,est){
	if(evt){
		obj.className =	est;
	}else{
		obj.className = est;	
	}
}
function ce2(){
		
}

function mostrarDetallePedido(inValor,det){
	var item;
	var div = "div"+inValor
	item = document.getElementById(div);
	if(item.className == "visible"){
		item.className = "oculto";
	}else{
		item.className = "visible";	
	}
}





function popprecios(){
	window.open ("precios.html","precios","top=20 left=20 width=420 height=185 scrollbars=no statusbar=no toolbars=no")
}

  // ancho de imagen
var maxWidth=70;
  // alto de imagen
var maxHeight=70;
  
  // Tipos de archivo
var fileTypes=["bmp","gif","png","jpg","jpeg"];
  // id de la imagen de preview
var outImage="previewField";
  // imagen para mostrar en archivos no validos
var defaultPic="dot.gif";


function preview(what,cual){
  var source=what.value;
  var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
  for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
  globalPic=new Image();
  if (i<fileTypes.length) globalPic.src=source;
  else {
    globalPic.src=defaultPic;
    //alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
  }
  
  setTimeout("applyChanges("+cual+")",200);
}
var globalPic;

function applyChanges(cual){
	var item;
	item = "preview"+cual

	//alert(item)
  var field=document.getElementById(item);

  var x=parseInt(globalPic.width);
  var y=parseInt(globalPic.height);
  if (x>maxWidth) {
    y*=maxWidth/x;
    x=maxWidth;
  }
  if (y>maxHeight) {
    x*=maxHeight/y;
    y=maxHeight;
  }
  field.style.display=(x<1 || y<1)?"none":"";
  field.src=globalPic.src;
  field.width=x;
  field.height=y;
}

function validaSucursales(){
	
	theForm = document.frmFiles;

	for (i = 0; i < theForm.elements.length;i++){	
		if (theForm.elements[i].checked == true && theForm.elements[i].name == "radSucursal"){
			hacerSubmit('frmFiles')
			return true;	
		};
	};	
	alert("Debe seleccionar un punto de entrega");
	return false;	
}

