function $(id)
{
	return document.getElementById(id);
} // $

function is_empty(str)
{
	return ( str==null || str==0 || str=="" || str.length<1 );
} // is_empty

function is_numeric(str)
{
	regularExp = new RegExp("^[0-9-.]*$");
	return regularExp.test(str);
} // is_numeric

function is_email(str)
{
	return ( ( str.indexOf("@")>0 ) && ( str.indexOf(".")>0 ) );
} // is_email

// fuction to clear fields in login
function textClear(fieldText) {
	if (fieldText.value == fieldText.defaultValue) {
		fieldText.value = ""
	}
}
// fuction to write default text in login if fields are empty
function defaultText(fieldText) {
	if (fieldText.value == "") {
		fieldText.value = fieldText.defaultValue
	}
}

// fuction to use target blank in xhtml strict
function transformExternalAnchors()
{
	var i,a,f;
	if ( document.getElementsByTagName )
	{

		a = document.getElementsByTagName("a");
		i = 0;

		// for using in normal href tag, you you have to add: rel="external"
		// example: <a href="http://website.com" rel="external">Web Site</a>
		for(i=0;i<a.length;i++)
		{
			if ( a[i].getAttribute('href') && ( a[i].getAttribute("rel")=="external" ) )
			{
				a[i].target = "_blank";
			}
		} // for

		f = document.getElementsByTagName("form");
		i = 0;

		// for using in forms, you have to add in the form tag: title="external"
		// example: 		<form action=# id="frmId" title="external"></form>
		for(i=0;i<f.length;i++)
		{
			if ( f[i].getAttribute('action') && ( f[i].getAttribute("title")=="external" ) )
			{
				f[i].target = "_blank";
			}
		} // for
	} // if
} // transformExternalAnchors


//funtion value Form
function contentVerificationEsp(){

	var finalMessage = "";
	var error = false;


	var client_name = $('client_name').value;
	var client_company = $('client_company').value;
	var client_phone = $('client_phone').value;
	var client_fax = $('client_fax').value;
	var client_postal = $('client_postal').value;
	var client_email = $('client_email').value;
	var client_address = $('client_address').value;
	var client_country = $('client_country').value;
	var client_message = $('client_message').value;
	var auth_code = $('auth_code').value;


	if ( is_empty(client_name) )
	{
		finalMessage += "* Por favor comprobar el campo nombre.\n";
		error = true;
	}
	if ( is_empty(client_company))
	{
		finalMessage += "* Por favor comprobar el campo compa\u00f1ia.\n";
		error = true;
	}
	if ( is_empty(client_phone) || !is_numeric(client_phone))
	{
		finalMessage += "* Por favor comprobar el campo tel\u00e9fono.\n";
		error = true;
	}
   if (is_empty(client_fax) || !is_numeric(client_fax) )
	{
		finalMessage += "* Por favor comprobar el campo fax.\n";
		error = true;
	}
	if (is_empty(client_postal))
	{
		finalMessage += "* Por favor comprobar el campo apartado postal.\n";
		error = true;
	}
	if (is_empty(client_email) || !is_email(client_email))
	{
		finalMessage += "* Por favor comprobar el campo correo electr\u00f3nico.\n";
		error = true;
	}
	if (is_empty(client_address))
	{
		finalMessage += "* Por favor comprobar el campo direcci\u00f3n.\n";
		error = true;
	}
	if (is_empty(client_country))
	{
		finalMessage += "* Por favor comprobar el campo pa\u00eds.\n";
		error = true;
	}
	if ( is_empty(auth_code) )
	{
		finalMessage += "* Por favor comprobar el campo autenticaci\u00f3n.\n";
		error = true;
	}
	if ( error == false )
	{
		return true;
	}
	else
	{
		alert("Problemas enviando la informaci\u00f3n, por favor tome en cuenta los siguientes error(es):\n\n"+finalMessage);
		return false;
	}

}// contentVerification


//funtion value Form
function contentVerificationEng(){

	var finalMessage = "";
	var error = false;


	var client_name = $('client_name').value;
	var client_company = $('client_company').value;
	var client_phone = $('client_phone').value;
	var client_fax = $('client_fax').value;
	var client_postal = $('client_postal').value;
	var client_email = $('client_email').value;
	var client_address = $('client_address').value;
	var client_country = $('client_country').value;
	var client_message = $('client_message').value;
	var auth_code = $('auth_code').value;


	if ( is_empty(client_name) )
	{
		finalMessage += "* Please check name.\n";
		error = true;
	}
	if ( is_empty(client_company))
	{
		finalMessage += "* Please check company.\n";
		error = true;
	}
	if ( is_empty(client_phone) || !is_numeric(client_phone))
	{
		finalMessage += "* Please check phone.\n";
		error = true;
	}
   if (is_empty(client_fax) || !is_numeric(client_fax) )
	{
		finalMessage += "* Please check fax.\n";
		error = true;
	}
	if (is_empty(client_postal))
	{
		finalMessage += "* Please check code postal.\n";
		error = true;
	}
	if (is_empty(client_email) || !is_email(client_email))
	{
		finalMessage += "* Please check email\n";
		error = true;
	}
	if (is_empty(client_address))
	{
		finalMessage += "* Please check address.\n";
		error = true;
	}
	if (is_empty(client_country))
	{
		finalMessage += "* Please check country.\n";
		error = true;
	}
	if ( is_empty(auth_code) )
	{
		finalMessage += "* Please check code.\n";
		error = true;
	}
	if ( error == false )
	{
		return true;
	}
	else
	{
		alert("It seems there''s a problem sending the information, please take a look to the following error(s):\n\n"+finalMessage);
		return false;
	}

}// contentVerification

window.onload = transformExternalAnchors;
