// JavaScript Document



function disp_confirm(action, id)
{
	var cf = confirm("Remove this item?");
	 if(cf == true) 
	{
		location = "admin.php?action="+ action + "&id=" + id;				
	}

}

function disp_lconfirm(action, id, label)
{
	var cf = confirm(label);
	 if(cf == true) 
	{
		location = "admin.php?action="+ action + "&id=" + id;				
	}

}



function disp_categ_confirm(id)
{
	var cf = confirm("Remove this item?");
	 if(cf == true) 
	{
		location = "admin.php?action=del_categ&id=" + id;				
	}

}


function on_change_order(selop)
{
	//alert(selop);
		location = "admin.php?action=sortby&selop=" + selop;

}

function performx(linkpage)
{
	window.name="Add Category";
   
	wPerform = window.open(linkpage, 'perform' , 'top=0,left=0,width=800,height=300,scrollbars=1');
	wPerform.focus();
	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+' debe de contener una direccion de email valida.\n';
      }  else if(test.indexOf('isPassword') !=-1)
	  {      if(val != MM_findObj(args[i+1]).value) errors += '- las claves no son iguales.\n';	  		
		  } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe de contener un numero.\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+' debe de contener un numero entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
   if (errors) alert('Los siguientes errores ocurrieron:\n'+errors);
  document.MM_returnValue = (errors == '');
}

    function isNumber(numero){
        i=0;
        while(i<numero.length){
            if(numero[i]==1 || numero[i]==2 || numero[i]==3 || numero[i]==4 || numero[i]==5 ||
                numero[i]==6 || numero[i]==7 || numero[i]==8 || numero[i]==9 || numero[i]==0)
                i++;
            else return false;
        }
        return true;
    }

    function validafecha(fecha){
        if(fecha.length!=10 || fecha.charAt(2)!="-" || fecha.charAt(5)!="-"){
            return false;
        }
        MMDDYYYY=fecha.split("-");
        mes=MMDDYYYY[0];
        dia=MMDDYYYY[1];
        anio=MMDDYYYY[2];
        if(isNumber(anio)==false || isNumber(dia)==false || isNumber(mes)==false || mes>12==true){
            return false;
        }
        return true;
    }