//Requires CQCOLibrary.js

function sendPage() {
to = prompt("Please change the value below to the address of the person you would like to send the page to.",'Enter an email address here');
if (!to) { 
	return;
}
else {
to = escape(to);
}


subject = prompt("Please enter a subject for the email message, or push Ok to accept the default.", "Interesting link from the Cancer Quality Council of Ontario");
if (!subject) {
	return;
}
else {
	subject = escape(subject);
}

myPage = window.location;
body = "Hi:\n"
       +"\n"
       +"Here is a link to the Cancer Quality Council of Ontario's\n"
       +"Cancer System Quality Index site.\n"
       +"\n"
       +"I thought you might find it interesting.\n"
       +"\n"
       +"Click on the url below, or copy and paste it into your browser's\n"
       +"location bar to view the site\n"
       +"\n"
       +myPage
body = escape(body);

foo = "mailto:"+to
                  +"?subject="+subject
                  +"&body="+body;

window.location = foo;
}

function writeSendPageLink(){
	div = document.getElementById('controller');
	ul = div.getElementsByTagName('ul');
	text = document.createTextNode('Email This Page');
	newimg = document.createElement('img');
	newimg.setAttribute('alt', 'Email');
	newimg.setAttribute('src', __CQCOInstallPath+'inc/images/email2.gif');
	newimg.style.marginRight = "4px";	
	newa = document.createElement('a');
	newa.setAttribute('href', '#');
	newa.style.color='#5876e4';
	newa.onclick = function() { sendPage(); };
	newa.appendChild(text);
	newa.id = 'pageSend';
	newli = document.createElement('li');
	newli.appendChild(newimg);
	newli.appendChild(newa);

	ul[0].appendChild(newli);
}

if(document.getElementsByTagName && document.getElementById && 
   document.createTextNode && !__CQCOMacIe5 )
{
	addLoadEvent(writeSendPageLink);
}    
