// JavaScript Document

function ClearPlaceHolder (input) {
	if (input.value == input.defaultValue) {
		input.value = "";
}
}
function SetPlaceHolder (input) {
	if (input.value == "") {
		input.value = input.defaultValue;
}
}

function imagenZoom(nImg) {
	document.getElementById('imgZoom').src = '../Imagenes/Productos-Zoom/' + nImg;
	document.getElementById('FondoNegro').style.display = 'table';
}

function imagenZoomOut() {
	document.getElementById('FondoNegro').style.display = 'none';
}

/*Forma de contacto*/
function validateEmail(email){var splitted = email.match("^(.+)@(.+)$");if(splitted == null) return false;if(splitted[1] != null ){var regexp_user=/^\"?[\w-_\.]*\"?$/;if(splitted[1].match(regexp_user) == null) return false;}if(splitted[2] != null){var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;if(splitted[2].match(regexp_domain) == null) {var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;if(splitted[2].match(regexp_ip) == null) return false;}return true;}return false;}
function isNumberKey(evt){var charCode = (evt.which) ? evt.which : event.keyCode;if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } else { return true;}}

function CompDatosInicio(){
	var name  =  document.getElementById('name').value;
	var email =  document.getElementById('email').value;	
	var phone =  document.getElementById('phone').value;
	
	var nErrores = 0;
	var mErrores = 'The form contains the following errors: \n'; 
	
	if (name == "Name:") { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- Your name can not be empty\n";
	}
	alert('okei')
	/*
	if (validateEmail(email) == false) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- The email is invalid or is empty\n";
	}
	if (phone.length != 10) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- The phone should contain 10 digits (area code and number)\n";
	}
	if (isNaN(phone)) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- The phone can only contain numbers\n";
	}
	if (document.getElementById('state').options[0].selected == true){
	nErrores = nErrores + 1;
	mErrores = mErrores + "- The status field is mandatory\n"; 
	}*/
	
	if (nErrores == 0) { return true; } else { alert (mErrores); return false; }
	}


function CompDatos(){
	var name  =  document.getElementById('name').value;
	var email =  document.getElementById('email').value;	
	var phone =  document.getElementById('phone').value;
	
	var nErrores = 0;
	var mErrores = 'The form contains the following errors: \n'; 
	
	if (name == "") { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- Your name can not be empty\n";
	}
	if (validateEmail(email) == false) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- The email is invalid or is empty\n";
	}
	if (phone.length != 10) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- The phone should contain 10 digits (area code and number)\n";
	}
	if (isNaN(phone)) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + "- The phone can only contain numbers\n";
	}
	if (document.getElementById('state').options[0].selected == true){
	nErrores = nErrores + 1;
	mErrores = mErrores + "- The status field is mandatory\n"; 
	}
	
	if (nErrores == 0) { return true; } else { alert (mErrores); return false; }
	}
	

/*Dile a un amigo*/
function CompDatos2(){
	var yourname = document.getElementById('yourname').value;
	var youremail = document.getElementById('youremail').value;
	var friendsname = document.getElementById('friendsname').value;
	var friendsemail = document.getElementById('friendsemail').value;
	
	var nErrores = 0;var mErrores = 'El formulario contiene los sigientes errores: \n'; 
	
	if (yourname == "Name:") {
	nErrores = nErrores + 1; 
	mErrores = mErrores + " - Your name can not be empty\n" 
	}
	if (validateEmail(youremail) == false ) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + " - The email is invalid or is empty\n" 
	} 
	if (friendsname == "Your friendīs e-mail:") { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + " - El nombre de tu amigo no puede estar vacio \n" 
	}
	if (validateEmail(friendsemail) == false ) { 
	nErrores = nErrores + 1; 
	mErrores = mErrores + " - La direccion de correo de tu amigo no es valida \n" 
	} 
	
	if (nErrores == 0) { return true; } else { alert (mErrores); return false; }} 
