


function cargarDestacado(id,destino){
	
	
	document.getElementById("destacado").checked=true;
	document.getElementById("destino")[0]=new Option(destino,id, true)
	ImaCarga();
	}



function borra(){

if (document.FrmDestino.titulo.value=='Título Programa')
document.FrmDestino.titulo.value='';

}

function PaisForm(){

if (document.frmpais.paises.value == "" ){
     
	   alert("Seleccione el pais de destino")   
	   return false;
		}else{
		return true;}
}

function ImaCarga(id){

top.frames['frmimagenes'].location.href = 'imgpaqueres.asp?id='+document.FrmDestino.destino.value; 
document.getElementById("destacado").disabled=false;
}


function handleHttpResponse() { 
    if (http.readyState == 4) { 
       if (http.status == 200) { 
          if (http.responseText.indexOf('invalid') == -1) {
             // Armamos un array, usando la coma para separar elementos
             results = http.responseText.split(","); 
             document.getElementById("campoMensaje").innerHTML = results[0];
             enProceso = false;
          }
       }
    }
}


function eliminaDestacado(img) {

if( document.getElementById("destacado").checked){
      if(document.getElementById("destacado").checked){
	  var valor = escape(document.getElementById("destino").value);}
	  else{
	  valor=0; }
	   if (!enProceso && http  ) {
       var url = 'selectimg.asp?renew=true&id='+valor+'&img='+img+'&tipo=eliminar';	   

       http.open("GET", url, true);
       http.onreadystatechange = handleHttpResponse;
       enProceso = true;
       http.send(null);
    }
	
	}}

function verificaDestacado() {
if( document.getElementById("destacado").checked){
      if(document.getElementById("destacado").checked){
	  var valor = escape(document.getElementById("destino").value);}
	  else{
	  valor=0;
	  }

    if (!enProceso && http  ) {
		
       var url = "selectimg.asp?renew=true&id="+valor;
//alert(url);
       http.open("GET", url, true);
       http.onreadystatechange = handleHttpResponse;
       enProceso = true;
       http.send(null);
    }
	}else{
	
	    if (!enProceso && http  ) {
		
       var url = "selectdstacado.asp?renew=true&id=";
//alert(url);
       http.open("GET", url, true);
       http.onreadystatechange = handleHttpResponse;
       enProceso = true;
       http.send(null);
    }
	
	}
}

function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
       try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (E) { xmlhttp = false; }
       }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest

function verifica(id){
 sum=3

for(i=1;i<=sum;i++){
if(i!=id){
document.getElementById(i).checked=false;
	}

	}
}

function subirimg(){

  var v = escape(document.getElementById("destino").value);
  if (v!=''){
	window.open('FormUpload.asp?destino='+v,'','width=600,height=100,scrollbars=no'); 
	}else{
	alert('seleccione destino');
	}
}


function subirimg2(){
  var v = document.getElementById("destino").value;

  if (v!=''){
	window.open('FormUpload2.asp?destino='+v,'','width=600,height=200,scrollbars=no'); 
	}else{
	document.getElementById("destino").checked=false;
	alert('seleccione destino');
	
	}
}



function limpiarSearch(){
	
	if(document.formbusqueda.txtbusqueda.value=='Search the site...'){
	document.formbusqueda.txtbusqueda.value='';}
	}

function ConfirmarPedido(){
	
	document.form1.Hacerpedido.value='true';
	document.form1.action='hacerpedido.asp';
	document.form1.submit();
	
	}


function recalcular(){

	document.form1.action='hacerpedido.asp?recalcular=true&acc=carrito';
	document.form1.submit();
	
	}


function mascarrito(id){
	
	var cant=document.getElementById("cant"+id).value ;
	if(cant>=1) 
	document.getElementById("cant"+id).value = parseInt(cant) + 1;
	
	}
	
	
function menoscarrito(id){
	 
	var cant=document.getElementById("cant"+id).value ;
	if(cant>1)
	document.getElementById("cant"+id).value = parseInt(cant) - 1;
	}

function limpiarcampo(){
	document.getElementById('campoMensaje').innerHTML = '';
	}
	
	function EditarCantCarrito(id){
		 document.getElementById("cant"+id).disabled=false;
		
		
		}

function handleHttpResponse() { 
    if (http.readyState == 4) { 
       if (http.status == 200) { 
          if (http.responseText.indexOf('invalid') == -1) {
             // Armamos un array, usando la coma para separar elementos
             results = http.responseText.split(","); 
			 

			 document.getElementById("campoMensaje").style.visibility='visible';
             document.getElementById("campoMensaje").innerHTML = results[0];
             enProceso = false;
          }
       }
    }
}

function verificaUsuario() {
    if (!enProceso && http) {
		document.getElementById("campoMensaje").innerHTML = '';
		  document.getElementById("load").style.backgroundImage='url(ajax-loader.gif)';
       var valor = escape(document.getElementById("user").value);
       var url = "consulta.asp?user="+ valor;
       http.open("GET", url, true);
       http.onreadystatechange = handleHttpResponse;
       enProceso = true;
       http.send(null);
    }
}

function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
       try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (E) { xmlhttp = false; }
       }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest

function seleccionarPromo(id){
	window.location.href='hacerpedido.asp?pedidos='+id+',';
	
	}

function validarPedido(session){


	if (document.form.pedidos.value==''){
		alert('You must select a machine or parts to add to cart ..');
		return false;
		}else{
			return true;
			}

	}


//seleccionar
function seleccionar(id,precio){

	var actual=document.form.pedidos.value;
	document.form.pedidos.value=actual+','+id;

		var objCamp1=document.form1.precio;
		var objCamp2=document.form1.Preciohidden;
		
		if(objCamp2.value==''){
			objCamp2.value=0;
			}
			

if(document.getElementById("che"+id).checked){
	
	var cantind = document.getElementById("cant"+id).value;
	var multli;
	multli=(parseFloat(precio)*parseInt(cantind));
	objCamp1.value=parseFloat(parseFloat(objCamp2.value) + parseInt(multli));
		
		var cantidad=document.getElementById("cantidad").value;
		
		if(cantind ==''){
			cantidad=1;
			}
		if(cantidad==''){
			cantidad=0;
			}
			document.getElementById("cantidad").value=parseInt(cantidad)+parseInt(cantind);
			objCamp2.value=parseFloat(objCamp1.value);
		}
		else//si deschequeo
		{
			
		var cantind = document.getElementById("cant"+id).value;
		//sumo a precio total
		var multli=parseFloat(parseFloat(precio)*parseInt(cantind));
		
		objCamp1.value=parseFloat(parseFloat(objCamp2.value) - parseFloat(multli));
		
		var cantidad=document.getElementById("cantidad").value;
			if(cantidad==''){
			cantidad=0;
			}
		
		document.getElementById("cantidad").value=parseInt(cantidad)-parseInt(cantind);
		objCamp2.value=parseFloat(objCamp1.value);
		
		
	}
	
}
	
	function mas(id,precio){
		
		if (document.getElementById("che"+id).checked==false){
			
			alert('You should select the product first');
			}else{
			//cantidad de individual
		var cant=document.getElementById("cant"+id).value ;

		document.getElementById("che"+id).checked=true;
				

			//sumo uno a cant individual
			document.getElementById("cant"+id).value = parseInt(cant) + 1;
		
		//cant general
		var cantidad=document.getElementById("cantidad").value;

		if(cantidad=='')
			cantidad=1;

		
		if(document.getElementById("che"+id).checked)
		{
			//tomo la cantidadg ral y le sumo 1
			document.getElementById("cantidad").value=parseInt(cantidad)+1;
			var actual=document.form.pedidos.value;
			
			document.form.pedidos.value=actual+','+id;
			var objCamp1=document.getElementById('precio');
			var objCamp2=document.getElementById('Preciohidden');
		
		if(objCamp2.value==''){
			objCamp2.value=0;
			}

	if(document.getElementById("che"+id).checked){
			var cantind = parseInt(document.getElementById("cant"+id).value)-1;
			objCamp1.value=parseFloat(objCamp2.value) + parseFloat(precio);
			var cantidad=document.getElementById("cantidad").value;
			objCamp2.value=objCamp1.value;
	
				}else{
		var cantind = document.getElementById("cant"+id).value;		
		//sumo a precio total
		objCamp1.value=parseFloat(objCamp2.value) - parseFloat(precio)*parseInt(cantind);
		var cantidad=document.getElementById("cantidad").value;
		objCamp2.value=parseFloat(objCamp1.value);
		}
			
			}
		}
	}
	
	
	//menos***********************************************
	function menos(id,precio){

if (document.getElementById("che"+id).checked==false){
			
			alert('Debe seleccionar el Plato');
			}else{
				
		var cant=document.getElementById("cant"+id).value ;
		//alert(cant);
		if (cant>1)
	document.getElementById("cant"+id).value = parseInt(cant) - 1;
	//fin suna cant individual
	
		var actual=document.form.pedidos.value;
		document.form.pedidos.value=actual+','+id;

		var objCamp1=document.getElementById('precio');
		var objCamp2=document.getElementById('Preciohidden');
		
		if(objCamp2.value==''){
			objCamp2.value=0;
			}
	if (cant>1){
	var cantidad=document.getElementById("cantidad").value;
		if(cantidad=='')
		{cantidad=0;}
		
		
		cant=document.getElementById("cant"+id).value ;
		objCamp2.value=objCamp1.value;
		
if(document.getElementById("che"+id).checked){
		document.getElementById("cantidad").value=parseInt(cantidad)-1;

		}
	if(document.getElementById("che"+id).checked){
		//sumo a precio total
		objCamp1.value=parseFloat(parseFloat(objCamp2.value) - parseFloat(precio));
		var cantidad=document.getElementById("cantidad").value;
				}
			}
		}
	}
	
	
	
	function alerta(){
	
alert('Debe asignar una foto, O asignar sin Foto');	
	
}

function SinFoto(id){
		window.location.href='maquina.asp?sinfoto=true&acc=editar&id='+id;
	}
	
	
function SinFotonew(){
		window.location.href='maquinanew.asp?sinfoto=true&acc=nuevo';
	}

function SinFotonewp(){
		window.location.href='maquinanewp.asp?sinfoto=true&acc=nuevo';
	}




function ModFoto(id){
window.open('FormUpload.asp?id='+id+'','','toolbar=no,directories=no,location=no,resizable=nn,status=yes,scrollbars=yes,menubar=no,width=500,height=160');
return true;
}


function newFoto(id){
window.open('FormUpload.asp?acc=nuevo&id='+id,'','toolbar=no,directories=no,location=no,resizable=nn,status=yes,scrollbars=yes,menubar=no,width=500,height=400');
return true;
}


function newFotonew(){
window.open('FormUploadnew.asp?acc=nuevo','','toolbar=no,directories=no,location=no,resizable=nn,status=yes,scrollbars=yes,menubar=no,width=500,height=400');
return true;
}

function newFotonewp(){
window.open('FormUploadnewp.asp?acc=nuevo','','toolbar=no,directories=no,location=no,resizable=nn,status=yes,scrollbars=yes,menubar=no,width=500,height=400');
return true;
}



function submitForm(id){

form=document.getElementById('form'+id);

		form.action='maquina.asp?id='+id+'&modificar=1';
		form.submit();

	}

function submitFormp(id){

form=document.getElementById('form'+id);

		form.action='maquina.asp?id='+id+'&modificar=1';
		form.submit();

	}


var pic = null
var popImg = null  // use this when referring to pop-up image
var picTitle = null
var imgCount = 0
var imgWinName = "popImg"
var imgPop = 'templates/imgpop.htm';

function openPopImg(picName, windowTitle, windowWidth, windowHeight){
  closePopImg()
  picTitle = windowTitle
  imgWinName = "popImg" + imgCount++ //unique name for each pop-up window
  popImg = window.open(picName, imgWinName,
           "toolbar=no,scrollbars=yes,resizable=yes,width=" 
           + (parseInt(windowWidth)+20)  + ",height=" 
           + (parseInt(windowHeight)+15)) 
  }
function closePopImg(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popImg != null) if(!popImg.closed) popImg.close() 
  }
function setStatus(msg){
  status = msg
  return true
  }

// for Netscape 3+ and IE 4+
var priorPic = new Array()
var noPic = 0
var foundit = false

function openPopImg(picName,  windowTitle, windowWidth, windowHeight){
 var i = 0
  if(pic == picName && winOpen()){
    popImg.focus()
    }
  else{
    foundit = false
    for(i=0; i<=noPic; i++){
      if (priorPic[i] == picName)
        foundit = true 
      }
    pic = picName
    closePopImg()
    picTitle = windowTitle
    imgWinName = "popImg" + imgCount++ //unique name for each pop-up window
    if(!foundit){
      priorPic[noPic++] = pic
      }
    popImg = openPopImgWin(imgWinName, windowWidth, windowHeight)
    }
  }
function openPopImgWin(imgWinName, windowWidth, windowHeight){
  var winFeatures = "toolbar=no,scrollbars=yes,resizable=no,width=" 
    + windowWidth + ",height=" + windowHeight
  return window.open(imgPop, imgWinName, winFeatures)
  }
function winOpen(){
  if(popImg != null){ 
    if(popImg.closed != true) return true; else return false
    }  
  else
    return false
  }

// Use this function to control placement of pop-up window
// in Netscape 4+ and Internet Explorer 4+
function openPopImgWin(imgWinName, windowWidth, windowHeight){
 var leftX = 20  // distance of window's left side from left of screen
  var topY = 20   // distance of window's top side from top of screen
  var winFeatures = "toolbar=no,scrollbars=yes,resizable=yes,width=" 
    + (parseInt(windowWidth)+18) + ",height=" + windowHeight
  if (leftX>0){
    winFeatures += ",screenX=" + leftX + ",left=" + leftX	
                + ",screenY=" + topY + ",top=" + topY
    }
  return window.open(imgPop, imgWinName, winFeatures)
  }



function GeneratePassword() {

    if (parseInt(navigator.appVersion) <= 3) {
        alert("Sorry this only works in 4.0+ browsers");
        return true;
    }

    var length=8;
    var sPassword = "";
    length = 8;//document.aForm.charLen.options[document.aForm.charLen.selectedIndex].value;

    var noPunction = true; //(document.aForm.punc.checked);
    var randomLength = false; // (document.aForm.rLen.checked);

    if (randomLength) {
        length = Math.random();

        length = parseInt(length * 100);
        length = (length % 7) + 6
    }


    for (i=0; i < length; i++) {

        numI = getRandomNum();
        if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }
        sPassword = sPassword + String.fromCharCode(numI);
    }

   document.getElementById('password').value  = sPassword;

    //return true;
}

function getRandomNum() {

    // between 0 - 1
    var rndNum = Math.random()

    // rndNum from 0 - 1000
    rndNum = parseInt(rndNum * 1000);

    // rndNum from 33 - 127
    rndNum = (rndNum % 94) + 33;
	if (rndNum >= 65 && rndNum <= 90)
	  // todo a minúsculas!
	  rndNum = rndNum + 32;
    return rndNum;
}

function checkPunc(num) {

    if ((num >=33) && (num <=47)) { return true; }
    if ((num >=58) && (num <=64)) { return true; }
    if ((num >=91) && (num <=96)) { return true; }
    if ((num >=123) && (num <=126)) { return true; }

    return false;
}




function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' No es un  e-mail Valido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' en Blanco!.\n'; }
  } if (errors) alert('Errores Ocurridos:\n'+errors);
  document.MM_returnValue = (errors == '');
}
		
	function MM_findObj(n, d) { //v4.01
			  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
			  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
			  if(!x && d.getElementById) x=d.getElementById(n); return x;
			}








function vergral(id){

	if(document.getElementById(id).style.visibility=='hidden'){
			document.getElementById(id).style.visibility='visible';
			document.getElementById(id).style.display='';
		}else{
			document.getElementById(id).style.visibility='hidden';
			document.getElementById(id).style.display='none';
			}
	}


function guardaActividad(desc){
	
document.formPasos.hiddAct.value==desc;

alert(desc);}

function limpiar(id){

alert(document.getElementById(id).value);
	document.getElementById(id).value=='';
	
	}




function pintar(id) {
	

document.getElementById(id).style.backgroundColor = "#333333";
document.getElementById('a'+id).className='descripcion-objeto';


}

function nopintar(id) {
if (document.getElementById('a'+id).className=='descripcion-objeto'){
	document.getElementById('a'+id).className='descripcion-objeto';}

document.getElementById(id).style.backgroundColor = "";
document.getElementById('a'+id).className='texto';

}


function pintarlist(id) {
	

document.getElementById(id).style.backgroundColor = "#CCD0DC";


}

function nopintarlist(id) {

document.getElementById(id).style.backgroundColor = "";

}


function validar(){

if (document.frm.txtUsername.value=='' && document.frm.txtPassword.value==''){

alert('Debe ingresar Usuario y Clave');
return false;
}else{

//document.Frm.submit();
return true;
}

}


function Page(sEntidad, iEntidad,iPage){
	
	window.open('?' + sEntidad + '='+ iEntidad +'&iPagina='+iPage, "_self");
		
		}
		
		
		

