﻿function addbookmark(name, url){
if ( navigator.appName != 'Microsoft Internet Explorer'){ 
window.sidebar.addPanel(name, url);
    }else{ 
window.external.AddFavorite(url, name); 
    } 
} 

//Funcion de popup
function popUp(winHeight,winWidth){
var winOpen = window.open('','winOpen','height=' + winHeight + ',width=' + winWidth + ',scrollbars=1,resizable=1,menubar=0'); return false;
}

//Boxes
function disable_box(box){
	if(box.id="box1" && box.value=='Republica Dominicana'){
			document.getElementById('box2').disabled=false
		}else{
			document.getElementById('box2').disabled=true
		}
						}

//Form Validations Basic

function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("nombre", "apellido", "direccion", "pais", "provincia", "telefono", "plan", "tipo_dominio", "email", "dominio", "ns1", "ns2", "asunto", "mensaje", "compania");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Nombre", "Apellido", "Dirección", "Pais", "Provincia", "Telefono", "Plan Hosting", "Acción de Dominio", "Email", "Dominio", "Servidor DNS 1", "Servidor DNS 2", "Asunto", "Mensaje", "Compania");
	// dialog message
	var alertMsg = "Por favor introduzca la Siguiente Informacion:\n\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == "" || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
				
				case "password":
				if (obj.value == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}

}
	
	
	///Form Validation Complex
function validarNombre(formobj){	
if (formobj.nombre.value.length < 2) {
    alert("Escriba por lo menos 2 letras en el campo \"Nombre\".");
    formobj.nombre.focus();
    return (false);
  }
 var checkOK = "ABCDEFGHIJKLMNÑ?OPQRSTUVWXYZ ?????" + "abcdefghijklmn?opqrstuvwxyz ñáéíóú?????";
 var checkStr = formobj.nombre.value;
  var allValid = true;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  if (!allValid) {
    alert("Escriba solo letras en el campo \"Nombre\".");
    formobj.nombre.focus();
    return (false);
  }
  
 }


///Form Validation Complex
function validarEmail(formobj){
//y esta es la parte de la validacion de el email
    if ((formobj.email.value.indexOf ('@', 0) == -1)||(formobj.email.value.length < 5)) {
    alert("Escriba una direccion de correo valida en el campo \"Direccion de correo@.com\".");
  formobj.email.focus();
    return (false);
  }
  
}

