/**
 * JavaScript Document
 * v1.0
 * Plantilla de validaciones para rmusical 
 * @author Jonathan Palomares <jon.paloamres@gmail.com> 
 */
function valSearch(url) {
	var _search_ = trim(document.getElementById('txtSearch').value);
	if (_search_ == "") {
		elementValue('txtSearch',"");
		focusElement('txtSearch');
		mensages(" Favor de escribir el producto que desea buscar ");
		return false;
	} else {
		formAction('formSearch',url);
		return true;
	}/* Termina if (_search_ == "") */
}/* Termina function valSearch(url) */
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}/* Termina function trim(stringToTrim) */
function verDiv(id_div,ielem) {
	divResultado = document.getElementById(id_div);
	divResultado.className = "divVer";
	updobj = divResultado;	
	document.getElementById(id_div).style.left = Left(ielem);
	document.getElementById(id_div).style.top = Top(ielem)+35;
}/* Termina function verDiv(id_div,ielem) */
function ocuDiv(id_div,ielem) {
	divResultado = document.getElementById(id_div);
	divResultado.className="divOculto";
}/* Termina function ocuDiv(id_div,ielem) */
function cmbServs() {
	var divResultado = document.getElementById('divServ');	
	ajax=objetoAjax();
	ajax.open("POST", "servicios.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText;
		}/* Termina if (ajax.readyState==4) */
	}/* Termina ajax.onreadystatechange=function() */
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("type="+document.getElementById('cmbServ').value);			
}/* Termina function cmbServs() */
function valContacto() {
	var d = document;
	var msg = " Favor de verificar los siguientes campos \n";
	if(d.getElementById('txtNombre').value == ""){
		msg += " * Escriba su nombre \n";
		elementValue('txtSearch',"");
		focusElement('txtSearch');
	}/* Termina if(d.getElementById('txtNombre').value == "") */
	if(d.getElementById('txtApe').value == ""){
		msg += " * Escriba sus apelldios \n";
		elementValue('txtSearch',"");
		focusElement('txtSearch');
	}/* Termina if(d.getElementById('txtApe').value == "") */
	if(d.getElementById('txtMail').value == ""){
		msg += " * Escriba su mail \n";
		elementValue('txtSearch',"");
		focusElement('txtSearch');
	}else{
		if(!valEmail(d.getElementById('txtMail').value)){
			msg += " * El formato de su mail no es corrrecto \n";
			focusElement('txtSearch');
		}/* Termina if(!valEmail(d.getElementById('txtMail').value)) */
	}/* Termina if(d.getElementById('txtMail').value == "") */
	if (d.getElementById('cmbServ').value == "") {
		msg += " * Seleccione un servicio \n";
		elementValue('txtSearch',"");
		focusElement('txtSearch');
	}else{
		switch (d.getElementById('cmbServ').value){
			case "1":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "2":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "3":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "4":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "5":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "6":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "7":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "10":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "11":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
			case "12":
				if(d.getElementById('txaComentarios').value == ""){
					msg += " * Escriba en breve comentario \n";
					elementValue('txaComentarios',"");
					focusElement('txaComentarios');
				}/* Termina if(d.getElementById('txaComentarios').value == "")*/
			break;
		}/* Termina switch (d.getElementById('cmbServ').value) */
	}/* Termina if (d.getElementById('cmbServ').value == "") */
	if(msg != " Favor de verificar los siguientes campos \n") {
		mensages(msg);
		return false;
	}else{
		formAction('formContacto','envia_contacto.php'); 
		return true;
	}/* Termina if(msg != " Favor de verificar los siguientes campos \n") */
}/* Termina function valContacto() */
