﻿// JavaScript Document
// funcion de autotexto de formularios simple.
// diseño y desarrollo por MAGO Creativos. Diego H Quintero  (c) 2009
//-------------------------------------------------------------------

function set(myName,myWord)
{
	if(myWord == null)
	{
		myWord = "";
	}
	
	myForm = document.getElementById(myName).value;
	
	if(myForm == myWord || myForm == "please, write your email" || myForm == "Please, write your email" || myForm == "Please, write your name" || myForm == "Please, write a comment" || myForm == 'comment:')
	{
		if(myName == 'c_comment')
		{
			document.getElementById(myName).className = "text";
		}
		document.getElementById(myName).value = "";
	} else if(myForm == "")
	{
		if(myName == 'c_comment')
		{
			document.getElementById(myName).className = "title";
		}
		document.getElementById(myName).value = myWord;
	}
}
function testMail(myName)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById(myName).value)){
		return true;
	}
	document.getElementById(myName).value = "please, write your email";
	return false;
}

function ResetContact()
{
	document.getElementById('contact').reset()
	document.getElementById('c_comment').className = "title";
}
function SubmitContact()
{
	error = 0;
	if (document.getElementById('c_name').value.length < 4)
	{
		document.getElementById('c_name').value = "Please, write your name";
		error++;
	}
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('c_mail').value)))
	{
		document.getElementById('c_mail').value = "Please, write your email";
		error++;
	}
	if (document.getElementById('c_comment').value.length < 10 || document.getElementById('c_comment').value == 'comment')
	{
		document.getElementById('c_comment').className = "text";
		document.getElementById('c_comment').value = "Please, write a comment";
		error++;
	}
	if(error == 0)
	{
		document.getElementById('contact').submit();
	}
}
function myURL()
{
	document.getElementById('c_url').value = window.location.href;
}

function showQ(capa)
{
	if(document.getElementById(capa).style.display == "")
	{
		document.getElementById(capa).style.display = "none";
	} 
	else if(document.getElementById(capa).style.display == "none")
	{
		document.getElementById(capa).style.display = "";
	}
}