function ajax(){
	var ajx;
	try{
		ajx = new XMLHttpRequest();
	} catch (e){
		try{
			ajx = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajx = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Your browser doesn't support the features of our site, please consider upgrading!");
				return false;
			}
		}
	}
	return ajx;
}
function EAF_send(){

	document.getElementById('EAF_sendbutton').disabled=true;
	
	var ck=0;
	var emailto = document.getElementById('EAF_emailto').value;
	var yemail = document.getElementById('EAF_yemail').value;
	var emailurl = document.getElementById('EAF_emailurl').value;
	var emailbody = document.getElementById('EAF_emailbody').value;
	
	var emailCHK=emailto.split('@');
	if(emailCHK.length < 2){
		ck++;
	}else{
		emailCHK=emailCHK[1].split('.');
		if(emailCHK.length < 2){
			ck++;
		}
	}
	
	var yemailCHK=yemail.split('@');
	if(yemailCHK.length < 2){
		ck++;
	}else{
		yemailCHK=yemailCHK[1].split('.');
		if(yemailCHK.length < 2){
			ck++;
		}
	}

	if(ck > 0){
		document.getElementById('EAF_status_div').innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;<b>please be sure to use a valid email address!</b>';
		document.getElementById('EAF_sendbutton').disabled=false;
	}else{
		var ajaxRequest = ajax();
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 1){
				var displayStat = document.getElementById('EAF_status_div');
				displayStat.innerHTML = '<br/><br/><b>sending ...</b><br/><br/>';
			}
			if(ajaxRequest.readyState == 4 || ajaxRequest.readyState == "complete"){
				var display = document.getElementById('EAF_content_div');
				display.innerHTML = ajaxRequest.responseText;
				window.setTimeout("EAF_remove()",2000);
			}
		}
		var getVars = "?pass=EAFform&email="+emailto+"&yemail="+yemail+"&url="+emailurl+"&body="+emailbody;
		ajaxRequest.open('GET', '/common/code/email_a_friend/EAF_email.php' + getVars, true);
		ajaxRequest.send(null);
	}
}
function EAF_remove(){
	var d1 = document.getElementById('EAF_background_div');
	var d2 = document.getElementById('EAF_wrap_div');
	document.body.removeChild(d1);
	document.body.removeChild(d2);
	document.body.style.overflow="auto";
	document.getElementsByTagName("html")[0].style.overflow="auto";
}
function EAF_open(){
	var back = document.createElement('div');
	var wrap = document.createElement('div');
	var content = document.createElement('div');
	document.body.style.overflow="hidden";
	document.getElementsByTagName("html")[0].style.overflow="hidden";
	
	back.setAttribute('id', 'EAF_background_div');
	back.style.position = "absolute";
	back.style.top = "0px";
	back.style.left = "0px";
	back.style.width = "100%";
	back.style.height = "100%";
	back.style.background = "#555555";
	try{back.style.filters.alpha.opacity=75;}catch(err){}
	try{back.style.filter="alpha(opacity=75)";}catch(err){}
	try{back.style.MozOpacity=0.75;}catch(err){}
	back.style.zIndex=1;
	document.body.appendChild(back);
	
	wrap.setAttribute('id', 'EAF_wrap_div');
	wrap.style.position = "absolute";
	wrap.style.top = "0px";
	wrap.style.left = "0px";
	wrap.style.width = "100%";
	wrap.style.zIndex=2;
	document.body.appendChild(wrap);
	
	content.setAttribute('id', 'EAF_content_div');
	content.style.width = "560px";
	content.style.marginTop = "80px";
	content.style.marginLeft = "auto";
	content.style.marginRight = "auto";
	content.style.textAlign = "left";
	content.style.color = "#613318";
	content.style.fontFamily = "arial, helvetica, sans-serif";
	content.style.fontSize = "13px";
	content.style.padding = "60px 20px 20px 20px";
	content.style.background = "#febe37";
	content.style.backgroundImage = "url('/common/images/EAF-background.gif')";
	content.style.border = "3px solid #ffffff";
	content.style.zIndex=2;

	content.innerHTML = "<br/><br/>Email this page to a friend?<br/><br/>\n";
	content.innerHTML += "<b>"+document.location+"</b><br/><br/>\n";
	content.innerHTML += "Your Friend's Email Address:<br/>\n";
	content.innerHTML += "<input type=\"text\" id=\"EAF_emailto\" size=\"35\" class=\"input\" /><br/><br/>\n";
	content.innerHTML += "Your Email Address:<br/>\n";
	content.innerHTML += "<input type=\"text\" id=\"EAF_yemail\" size=\"35\" class=\"input\" />";
	content.innerHTML += "<input type=\"hidden\" id=\"EAF_emailurl\" value=\""+document.location+"\" /><br/><br/>\n";
	content.innerHTML += "Your Message:<br/>";
	content.innerHTML += "<textarea id=\"EAF_emailbody\" cols=\"34\" class=\"input\"></textarea><br/><br/>\n";
	content.innerHTML += "<input type=\"button\" id=\"EAF_sendbutton\" onclick=\"EAF_send();\" value=\"   send   \" class=\"input pointer\" /> ";
	content.innerHTML += "<input type=\"button\" onclick=\"EAF_remove();\" value=\"   cancel   \" class=\"input pointer\" />";
	content.innerHTML += "<span id=\"EAF_status_div\"></span>";
	
	wrap.appendChild(content);
	scroll(0,0);
}
