
/*********************************
* SoRP Shared Javascript Script  *
* by P Hutten Czapski - Jan 2005 *
*********************************/


/** Java script to encode email addresses **/

var user;
var domain;
var suffix;
var header;

function jemail(user, domain, suffix, header){
document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + header + '">' + user + '@' + domain + '.' + suffix + '</a>');
}


/*************************************
* Medical Director Newsletter Script *
* by Brad Grove - September 2000     *
* for Health Communication Network   *
*************************************/

var pdfWin;
var mxClicks = 2;
var current;


var newsFiles = new Array();
newsFiles['2005_Jan'] = new fileObj('05January14.pdf','Jan 2005');
newsFiles['2004_Dec'] = new fileObj('04December14.pdf','Dec 2004');
newsFiles['2004_Nov'] = new fileObj('SoRPNewsNov.pdf','Nov 2004');


var NLPath   = 'Doc/';

function fileObj(n,d) {
	this.filename = n;
	this.description = d + ' Newsletter';
	this.clickcount = 0;
}

function doConfirm(n) {
	return confirm('You have already clicked this newsletter link ' + (n-1) + ' times!\n\nYou only need to click it ONCE.\nIf you have a slow connection (modem), it may\ntake a couple of minutes before you see a response.\n\nAre you sure you want to download this file again?\n\nClick OK to download again.\nClick CANCEL to abort.');
}

function warnClose() {
	alert('You already have another newsletter window open.\n\nPlease close that window first before attempting to \ndownload this news letter.');
}
	
function getNewsLetter(){
	var ref = document.newsForm.newsSelect.options[document.newsForm.newsSelect.selectedIndex].value;
	newsFiles[ref].clickcount++;
	if ((pdfWin)&&(!pdfWin.closed)) {
		if ((current>'')&&(current != ref)) warnClose();
		pdfWin.focus();return;
	}
	var proceed = (newsFiles[ref].clickcount > mxClicks)? doConfirm(newsFiles[ref].clickcount):true;
	if (proceed) { 
		var url = NLPath + newsFiles[ref].filename;
		if ((!pdfWin)||(pdfWin.closed))	pdfWin = window.open("","pdfWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=640,height=480");
		
		with (pdfWin.document) {
			open("text/html","replace");
			writeln('<HTML>');
			writeln('<HEAD><TITLE>Downloading PDF File... Please Wait</TITLE>');
			writeln('<BODY STYLE="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; margin: 10px">');
			writeln('<H1>About to Download \'' + newsFiles[ref].description + '\'...</H1>');
			writeln('<FONT SIZE="2"><LI>Please be aware that if you have a slow connection, this may take several minutes...<BR><BR>');
			writeln('<LI>If your browser is equipped to display PDF files, you will be able to save a copy of this file by clicking the \'Save\' icon (floppy disk) in the toolbar when loaded.<BR><BR>');
			writeln('<LI>If your browser is not equipped to view PDF files you can download Adobe\'s Acrobat Reader (including browser plugin) by clicking <A HREF="http://www.adobe.com/products/acrobat/readstep.html">here</A><BR><BR>');
			writeln('<FONT COLOR="#C00000"><LI>To cancel this download, simply close this window by clicking the cross in the top right corner.<BR><BR>');
			writeln('<form><input type="button" value="Download Now" onclick="javascript:location=\''+ url+'\'" CLASS="button" onmouseover="className=\'buttonOver\'" onmouseout="className=\'button\'"></form>');
			writeln('</FONT></FONT>');
			writeln('</BODY></HTML>');
			close();
		}
	}
	current = ref;
}

function changeNewsLetter() {
	
	return true;
}
function loadNewsLetter(){
	
}

