function toggleEmail() {

	var pop_email 			= document.getElementById('pop_email');
	var pop_email_confirm 	= document.getElementById('pop_email_confirm');
	var ad_box 				= document.getElementById('placement_box_1');
	
	pop_email_confirm.style.display="none";

	if (pop_email.style.display == "block") {
		pop_email.style.display = "none";
		ad_box.style.display="block";
		
	} else {
		pop_email.style.display = "block";
		if (ad_box) {
			ad_box.style.display="none";
		}
		//clearTimeout(pop_timeout);
		pop_timeout = setTimeout("hide_pop('pop_email')", 15000 );
	}
}

		
		
			
function sendEmail(url, ref) {
	var sender = document.getElementById("sender").value;
	var recipients = document.getElementById("recipients").value;
	var message = document.getElementById("message").value;
	var emailMessage = document.getElementById("emailMessage");
	var pop_email = document.getElementById("pop_email");
	var pop_email_confirm = document.getElementById("pop_email_confirm");
	var emailConfirm = document.getElementById("emailConfirm");

	if (sender.length > 0 && recipients.length > 0) {
		var xmlhttp;
		if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();}
		else if (window.ActiveXObject) {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
		xmlhttp.open("GET",url+"/sendEmail/?sender="+sender+"&recipients="+recipients+"&pers_mess="+message+"&refurl="+ref,true);
		xmlhttp.send(null);
		
		var recipientsSplit = recipients.split(",");
		var recipientsNew = '';
		
		for ( i = 0; i < recipientsSplit.length; i++) {
			recipientsNew = recipientsNew + recipientsSplit[i]+'<br />';
		}

		emailConfirm.innerHTML = recipientsNew;
		pop_email.style.display="none";
		pop_email_confirm.style.display="block";
		document.getElementById("sender").value = "";
		document.getElementById("message").value = "";
		document.getElementById("recipients").value = "";
		setTimeout ( "hide_pop('pop_email_confirm')", 10000 );
	}
	else {
		emailMessage.innerHTML = "You must fill out your e-mail and the recipient\'s email";
	}
}

