function comprar(tel){

//	alert(tel.length);
	if (tel.length<8){
		alert("Por favor, ingrese el numero de celular");
		return false;
	} else {
		return true;
	}
}
function presente(tel,tel2){
//alert(tel.length);
	if (tel.length<10 || tel2.length <10 ){
		alert("Por favor, ingrese el codigo de area");
		return false;
	}
	else {
		return true;
	}
}

function isNum(caractere) {
	//alert(caractere);
 	//var strNum = "0123456789"
	//if (strNum.indexOf(caractere) == -1) {
	
	if(caractere>=48 && caractere<=57){
		return true;
	}
	else {
		return false;
	}
}
 
function validaNum(campo, evt) {
 	var BACKSPACE = 8;
	var key;
	var tecla;


evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
	if (charCode  < 31 ) {
		return true;
	}
	//alert(isNum(charCode));
	return (isNum(charCode ));
};

function stringSplit ( string, delimiter ) {
    if ( string == null || string == "" ) {
        return null;
    } else if ( string.split != null ) {
        return string.split ( delimiter );
    } else {
        var ar = new Array();
        var i = 0;
        var start = 0;
        while( start >= 0 && start < string.length ) {
             var end = string.indexOf ( delimiter, start ) ;
             if( end >= 0 ) {
                 ar[i++] = string.substring ( start, end );
                 start = end+1;
             } else {
                 ar[i++] = string.substring ( start, string.length );
                 start = -1;
             }
        }
        return ar;
    }
}

/******************************************************************************************************/
var menu1 = new Array();
var menu2 = new Array();
/******************************************************************************************************/
function createMenus () {

    for ( var i=0; i < marca_modelo.length; i++ ) {
        menu1[i] = stringSplit ( marca_modelo[i], '*' );
        menu2[i] = stringSplit ( menu1[i][1], '|' );
    }

    var marcas = document.sugestao.contato_fabricante;
    var modelos = document.sugestao.contato_modelo;

    marcas.length = menu1.length;
    modelos.length = menu2[0].length;
    for ( var i=0; i < menu1.length; i++ ) {
         marcas.options[i].value  = val_fab[i];
         marcas.options[i].text   = menu1[i][0];
    }
    document.sugestao.contato_fabricante.selected = 0;
    for (var x=0; x < menu2[0].length; x++) {
         modelos.options[x].text = menu2[0][x];
         modelos.options[x].value = val_mod[x];
    }
    document.sugestao.contato_modelo.selected = 0;
}

/******************************************************************************************************/

function updateMenus ( what ) {
    var sel = what.selectedIndex;
    
    if ( sel >= 0 && sel < menu1.length )
        var temp = menu2[sel];
    else
        var temp = new Array ();

    what.form.contato_modelo.length = temp.length;

    for ( var i = 0; i < temp.length; i++ ) {
        st = sel + '-' + i;
        what.form.contato_modelo.options[i].text  = temp[i];
        what.form.contato_modelo.options[i].value = val_mod[st];
    }
    what.form.contato_modelo.selected=0;
}
