// JavaScript Document
function subir_y(cy,c1y,dy){
	cy.style.height=dy;
	c1y.style.height=dy;
}
function v_o(cvo,on){
var fm= document.getElementById("contmcf");
var fe = document.getElementById("contzef");
//var fec = document.getElementById("contecf");
 fm.style.visibility="hidden";
  fe.style.visibility="hidden";
   //fec.style.visibility="hidden";
 if(on==1){
    cvo.style.visibility="visible";
 }
}

function verinfo(cv,dpx){
var con = document.getElementById("cont");
var conn = document.getElementById("contn");
var cone = document.getElementById("conte");
var conc = document.getElementById("contc");
conn.style.visibility="hidden";
cone.style.visibility="hidden";
conc.style.visibility="hidden";
conn.style.height=dpx;
cone.style.height=dpx;
conc.style.height=dpx;

 con.style.height=dpx;
 cv.style.height=dpx;
 cv.style.visibility="visible";
}
function ver(a,b,c){
 //cn.style.backgroundColor='DFE2DB';
 cni.style.backgroundImage='url(images/b2i.gif)';
 cnd.style.backgroundImage='url(images/b2d.gif)';
 cn.style.backgroundColor='#BBCB34';

 
 cei.style.backgroundImage='url(images/b2i.gif)';
 ced.style.backgroundImage='url(images/b2d.gif)';
 ce.style.backgroundColor='#BBCB34';
 
 cci.style.backgroundImage='url(images/b2i.gif)';
 ccd.style.backgroundImage='url(images/b2d.gif)';
 cc.style.backgroundColor='#BBCB34';
 
 a.style.backgroundImage='url(images/b1i.gif)';
 c.style.backgroundImage='url(images/b1d.gif)';
 b.style.backgroundColor='#7BB443';
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 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+' debe ingresar un e-mail valido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener numeros.\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+' no ingresado.\n'; }
  } if (errors) alert('Revise si ingreso los siguiente:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function ir(url){
window.parent.location=url;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function cambio(fcambio,idp){
var vcp="c"+idp;
var vpp="p"+idp;
fvcp= document.getElementById(vcp);
fvpp= document.getElementById(vpp);
psize="$"+fvpp.value;
csize="( "+fvcp.value+" ) Artículos Disponibles";
 fcambio.c.value=csize;
 fcambio.p.value=psize;
 fcambio.p.size=psize.length+1;
 fcambio.c.size=csize.length+1;
 fcambio.item.value=idp;
}

function validar(flogine){
 if(flogine.usuario.value==''){
 alert("Usuario no ingresado");
 }else if(flogine.clave.value==''){
 alert("Contraseña no ingresada");
 }else{
 flogine.submit();
 }
}
function validar_ec(floginec){
 if(floginec.email_log.value==''){
 alert("E-Mail no ingresado");
 }else if(floginec.pass_log.value==''){
 alert("Password no ingresado");
 }else{
 floginec.submit();
 }
}
<!--funcion para validar busqueda
function vbusca() { 
if(document.buscar.palabra.value==""){
alert("Ingrese palabra a buscar");
return false;
}else{
return true;
}
}

function cd(cc){
 c1.style.backgroundColor='';
 c2.style.backgroundColor='';
 c3.style.backgroundColor='';
 c4.style.backgroundColor='';
 c5.style.backgroundColor='';
 cc.style.backgroundColor='#D9E7C3';
}

function ocultarcapa3(form){
form.envio1[0].checked=false;
form.envio1[1].checked=false;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

////////////funciones finalizar//////////////
function ver_vpos(){
var divpos = document.getElementById("vpos2");
divpos.style.visibility="visible";
}
function dirigir(fdatos){
//var divfac = document.getElementById("vpos1");
//var divpos1 = document.getElementById("vpos3");
//var divbpago1 = document.getElementById("bpago1");
//var divbpago2 = document.getElementById("bpago2");
//var divmfp1 = document.getElementById("mfp1");
//var divmfp2 = document.getElementById("mfp2");
//var divmfp3 = document.getElementById("mfp3");
//var divmfp4 = document.getElementById("mfp4");
//var divmfp5 = document.getElementById("mfp5");
 if(document.fuso.acepto.checked==false){alert("Debe leer y aceptar las condiciones de uso");}else if(document.fuso.acepto.checked==true){ 
 /*divfac.style.visibility="hidden"; divbpago1.style.visibility="hidden"; divbpago2.style.visibility="hidden"; divmfp1.style.visibility="hidden"; divmfp2.style.visibility="hidden"; divmfp3.style.visibility="hidden"; divmfp4.style.visibility="hidden"; divmfp5.style.visibility="hidden"; divpos1.style.visibility="visible"; fdatos.target="iframevpos"; fdatos.submit();setTimeout("ver_vpos()",8000);*/
 fdatos.submit();}
}

function verfp(formfp){
document.pagar2.p_select.value=formfp;
 //if(formfp==1 || formfp==3){document.pagar2.p_select.value=formfp;}else if(formfp==2 || formfp==4){document.pagar2.p_select.value=formfp;}
}
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
/////////funciones mp/////
function valid(login){
	if((login.emailmp.value=='') || (login.emailmp.value.indexOf("@",1)==-1) || (login.emailmp.value.lastIndexOf(".")==-1)){
	alert('Ingrese un E-Mail Válido');
	}else if(login.clavemp.value==''){
	alert('Contraseña No Ingresada');
	}else{
	window.open('', 'MercadoPulgas', 'width=600, height=350, scrollbars=YES, menubar=NO, location=NO, resizable=YES, top=100, left=300')
	login.submit();
	login.clavemp.value='';
	}
}

function ver_v(){
vender1.style.visibility='visible';
vender.style.height='450px';
vender1.style.height='450px';
comprar1.style.visibility='hidden';
comprar.style.height='2px';
comprar1.style.height='2px';
}
function ver_c(){
vender1.style.visibility='hidden';
vender.style.height='2px';
vender1.style.height='2px';
comprar1.style.visibility='visible';
comprar.style.height='700px';
comprar1.style.height='700px';
}
function irmp(pag){
window.location.href='productos.php?e=18&c=' + pag;
}
function tit(t){
t.style.backgroundColor='#7BB443';
t.style.cursor='pointer';
}
function tit1(t1){
t1.style.backgroundColor='';
t1.style.cursor='default';
}
function selec(d){
d.style.backgroundColor='DFE2DB';
d.style.cursor='pointer'
}
function nselec(nd){
nd.style.backgroundColor='';
nd.style.cursor='default'
}
///f mcuenta///
function todacategoria(form){
var i;
	for(i=1;i<=30;i++){ cvs="categoria" + i; cat=document.getElementById(cvs);
		if(form.todo.checked==true){ cat.checked=true;}else{cat.checked=false;}
	}
}
function borrar(){
document.form2.Nombres.value="";
}
function validar1(flogine1){
 if(flogine1.email.value==''){alert("E-Mail no ingresado");}else if(flogine1.pass.value==''){alert("Contraseña no ingresada");}else{flogine1.submit(); }
}
function validar_r(f){
no = new Array ('profesion','fonotrabajo','n','n1','n2','dpto','ccn');
var msj="";
var nc=0;
var opcional=0;
//bucle for paso 16 para saber el total campos
	for(i=0; i<f.length; i++){
	//si el elemento definido en la array formulario esta vacio...
		if(f.elements[i].value == ""){
		  for(j=0;j<no.length;j++){
			 if(f.elements[i].name==no[j]){//campos no *
			   opcional=1;
			  }
		  }
		   if(opcional!=1){
			// cambio de color el fondo a rojo y la letra
			f.elements[i].style.backgroundColor = '#FFE6E6';
			nc=1;
		   }
		   opcional=0;
		}else{
		f.elements[i].style.backgroundColor = '';
		}
	}
 //verificar email valido
 if(f.email.value.indexOf('@')<1 && nc<1){
	 f.email.focus();
	 msj='E-Mail ingresado incorrecto';
 }////////////////fin email
 // verificar condiciones
 if(f.pv.checked==true && f.ac.checked==false && nc<1){
	 msj='Debe Aceptar las Condiciones de Uso';
 }////////////////fin email
 // verificar cedula
 /*if(f.Pais.value=='ECUADOR' && check_cedula(f)==false){
	 msj='Nº Cédula Invalido';
	 f.cedula.focus();
 }////////////////verificar cedula*/
 if(nc<1 && msj==''){
  f.submit();
 }else{
 alert("Favor ingrese todos los datos obligatorios: \n\n" + msj);
 }	
}
function validar_r1(f){
no = new Array ('profesion','fonotrabajo','n','n1','n2','dpto','ccn');
var msj="";
var nc=0;
var opcional=0;
//bucle for paso 16 para saber el total campos
	for(i=0; i<f.length; i++){
	//si el elemento definido en la array formulario esta vacio...
		if(f.elements[i].value == ""){
		  for(j=0;j<no.length;j++){
			 if(f.elements[i].name==no[j]){//campos no *
			   opcional=1;
			  }
		  }
		   if(opcional!=1){
			// cambio de color el fondo a rojo y la letra
			f.elements[i].style.backgroundColor = '#FFE6E6';
			nc=1;
		   }
		   opcional=0;
		}else{
		f.elements[i].style.backgroundColor = '';
		}
	}
 //verificar email valido
 if(f.email.value.indexOf('@')<1 && nc<1){
	 f.email.focus();
	 msj='E-Mail ingresado incorrecto';
 }////////////////fin email
 // verificar condiciones
 /*if(f.pv.checked==true && f.ac.checked==false && nc<1){
	 msj='Debe Aceptar las Condiciones de Uso';
 }////////////////fin email*/
/* if(f.Pais.value=='ECUADOR' && check_cedula(f)==false){
	 msj='Nº Cédula Invalido';
	 f.cedula.focus();
 }////////////////verificar cedula*/
 if(nc<1 && msj==''){
  f.submit();
 }else{
 alert("Favor ingrese todos los datos obligatorios: \n\n" + msj);
 }	
}
function dv(ckb){
 if(ckb.checked==true){
document.getElementById("dvv").innerHTML ='<span class="Estilo21">Ingrese los siguientes datos para vender y publicar productos en Mercado de Pulgas.<br>Ingrese la entidad bancaria, tipo de cuenta y N&ordm; de cuenta que debe estar a su nombre, donde depositaremos el dinero por la venta de sus productos.</span><br><br><table border="0" align="center" cellpadding="2" cellspacing="0" background="images/fondo1.jpg" bgcolor="#FFFFFF"><tr><td class="border"><div align="right"><strong>Banco:</strong></div></td><td class="border"><input name="banco" type="text" id="banco" size="15" maxlength="40"></td></tr><tr><td class="border"><div align="right"><strong>Tipo:</strong></div></td><td class="border"><select name="tipoc" id="tipoc"><option value="Ahorro" selected>Ahorro</option><option value="Corriente">Corriente</option></select></td></tr><tr><td><div align="right"><strong>N&ordm; Cuenta </strong></div></td><td><input name="ncuenta" type="text" id="ncuenta" size="15" maxlength="30"></td></tr></table><br><table border="0" align="center" cellpadding="0" cellspacing="0"><tr><td><a href="mp/condiciones.html" onClick="nv()" class="Estilo6" target="condicion"><u>Acepto Condiciones de uso</u> </a> <input name="ac" type="checkbox" id="ac" value="1"></td></tr></table>';
 }else{
 document.getElementById("dvv").innerHTML ='';
 }
}
function nv(){
	window.open('', 'condicion', 'scrollbars=yes,width=450,height=300,top=100,left=300')
}
function check_cedula( form )
{
  var cedula = form.cedula.value;
  array = cedula.split( "" );
  num = array.length;
  if ( num == 10 )
  {
    total = 0;
    digito = (array[9]*1);
    for( i=0; i < (num-1); i++ )
    {
      mult = 0;
      if ( ( i%2 ) != 0 )
        total = total + ( array[i] * 1 );
      else
      {
        mult = array[i] * 2;
        if ( mult > 9 )
          total = total + ( mult - 9 );
        else
          total = total + mult;
      }
    }
    decena = total / 10;
    decena = Math.floor( decena );
    decena = ( decena + 1 ) * 10;
    final = ( decena - total );
    if ( ( final == 10 && digito == 0 ) || ( final == digito ) ){
    }else
    {
      return false;
    }
  }
  else
  {
    return false;
  }
}
 
function verific(fvc){
	if(fvc.Pais.value=='ECUADOR' && check_cedula(fvc)==false && fvc.cedula.value.length>0){
	 alert('Nº Cédula Incorrecto para Ecuador');
	 fvc.cedula.value='';
	 }
}