function validar( frm ){
	missinginfo = "";
	for ( i = 0; i < frm.elements.length; i++ ){
		if ( !validar_campo( frm.elements[i] ) )
		missinginfo += "\n     -  "+strMayuscula(frm.elements[i].name);
	}
	if (missinginfo != "") {
		missinginfo ="_____________________________\n" +
		"Te ha faltado introducir los siguientes datos:\n" +
		missinginfo + "\n_____________________________" +
		"\n�Por favor pulsa enter, rellena los datos y prueba de nuevo!";
		alert(missinginfo);
		return false;
	}
}
function validar_campo( campo ){
	if ( isnull( campo.name ) ){
		return true;
	}else{
		if ( campo.type == "hidden"){
			return true;
		}else {
			if ( campo.type == "checkbox" ){
				if ( campo.checked == false ) return false;
				else return true;
			}else {
				if ( campo.name == "email" ) return isValidEmailAddress( campo.value );
				if ( campo.value == "" ) return false;
				else return true;
			}
		}
	}
}
function isnull( name ){
	if ( name.substring(0,4) == "null" ) return true;
	else return false;
}
function strMayuscula( name ) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = name.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0) {
		for (index = 0; index < strLen; index++) {
			if (index == 0) {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1)) {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	return tmpStr;
}
function isValidEmailAddress(s) {

	var atPosition = s.indexOf("@");

	if(atPosition == -1)
	return false;

	if(atPosition < s.lastIndexOf("@"))
	return false; // more than one

	var dotPosition = s.lastIndexOf(".");

	if(dotPosition < atPosition || dotPosition == (atPosition + 1))
	return false;

	return true;

}

function opendiv(id){

	if ( document.getElementById(id).style.display == "block" ){

		document.getElementById(id).style.display = "none";

	}else{

		if( document.getElementById(id).style.display == "none" ){

			document.getElementById(id).style.display = "block";

		}

	}

}

function isValidLink( url ){
	
	alert('no paso');
	
	if ( (url.substring(0,6) == 'http://') || (url.substring(0,2) == 'www') )
		return true;
	else
		return false;
	
}