// Función de contacto
function getContact() {
	var domain = "&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;";
	//var name = "&#115;&#101;&#114;&#114;&#097;&#110;&#111;&#046;&#118;&#097;&#108;&#108;&#101;";	
	var name = "&#115;&#101;&#114;&#114;&#097;&#110;&#111;&#046;&#118;&#097;&#108;&#108;";	
	var separator = "&#064;";		
	var em = name + '&#' + (99+2) + ';' + separator + domain;	
	return em;
}

function isBrowser(){
	var minDimension = 50;
	if((screen.availWidth > minDimension) && (screen.availHeight > minDimension)) {
		return true;
	} else {
		return false;	
	}
}

function includeContact(imageCode, contactFile){	
	if(!this.isBrowser()){
		return;
	}	
	var fullLink = "<a href='./" + contactFile + ".htm' rel='nofollow' target='_blank'>" + imageCode + "</a>"
	document.write(fullLink);	
}

function doContact(theLanguage) {
	if(!this.isBrowser()){
		return;
	}
	
	var theMessage;
	if(theLanguage == "en"){
		theMessage = "Please, send me a contact e-mail to the following address:";	
	} else {
		theMessage = "Por favor, p&oacute;ngase en contacto conmigo a trav&eacute;s de la siguiente direcci&oacute;n de correo:";
	}
	
	var command="&#109;&#97;&#105;&#108;&#084;&#111;&#58;";	
	var details="";//"&#63;&#115;&#117;&#98;&#106;&#101;&#99;&#116;&#61;&#76;&#111;&#103;&#111;&#115;";
	// location.href = command + this.getContact() + details; 
	
	var contactString = command + this.getContact() + details;
	
	var newElementId = "theClicker";
	var formId = "contactForm";
	
	//document.write("<a id='" + newElementId + "' href='" + contactString + "'>contact</a>");
	document.write("<html><head>");
	document.write("<link href='css/style.css' rel='stylesheet' type='text/css' />");
	document.write("<title>Contact Enrique Serrano for professional identity design</title>");
	document.write("</head><body bgcolor='#393A40'>");
	document.write("<div><p style='color:#FFFFFF'>" + theMessage + "</p></div>");
	document.write("<div style='bgcolor:#393A40;'><img style='bgcolor:#393A40;color:#393A40;' src='./img/addr.gif' alt='contact me for your logo design' width='147' height='13' /></div>");
	document.write("<div>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/></div>");
	document.write("<div style='display:none;' id='" + newElementId + "'>" + contactString + "</div>");
	document.write("<form action='#' id='" + formId + "'> </form>");
	document.write("</body></html>");
	document.close();			

	// TODO la clave es llevar a una página destinada SÓLOo al envío del e-mail en una ventana nueva

	
	//document.forms[formId].action = document.getElementById(newElementId);
	document.forms[formId].action = document.getElementById(newElementId).firstChild.nodeValue;
	document.forms[formId].submit();

	
	/*var eminfo = command + this.getContact() + details;
document.forms[0].action = eminfo;
document.forms[0].submit();*/
/*alert(document.getElementById('placeholder'));

var newFormNode = document.createElement('form1');
var actionAttribute = document.createAttribute('action');
actionAttribute.value = command + this.getContact() + details;
newFormNode.setAttributeNode(actionAttribute);
document.forms.firstChild.appendChild(newFormNode);
newFormNode.submit();*/
}
