//Author: Eugene Shagenov
//Modified 2/29/2008 Matt King - changed to  single column layout, link display, etc

var myUrl=document.location.href;
var startTitleIndex = myUrl.indexOf("/",8)+1;
var endTitleIndex = myUrl.indexOf("/",myUrl.indexOf("/",8)+1);
if(endTitleIndex<=0){
	var otherEndTitleIndex = myUrl.indexOf("?",myUrl.indexOf("/",8)+1);
	if (otherEndTitleIndex<=0)
	{
		endTitleIndex=myUrl.length;
	}
	else {
		endTitleIndex=otherEndTitleIndex;
	}		
}
if(endTitleIndex<=0) endTitleIndex=myUrl.length;
var myTitle=myUrl.substring(startTitleIndex,endTitleIndex).replace(/-/g,"+");
var myTitleCaps = myTitle.replace(/\+/g," ");
myTitleCaps = myTitleCaps.replace(/\w+/g, function(myTitleCaps){
        return myTitleCaps.charAt(0).toUpperCase() + myTitleCaps.substr(1).toLowerCase();
    });
var myTitleEncoded=encodeURIComponent(myTitle);

//shortcuts
var openTableRow="<tr>";
var closeTableRow="</tr>";
var openTableCell="<td>";
var closeTableCell="</td>";
var preLink = openTableRow + openTableCell;
var postLink = closeTableCell + closeTableRow;
var closeAnchor = "</a>";
var linkStyle = 'style="font-size:14px;font-family:Arial;color:#174478;"';
//var linkStyle='';

//SM Links
//Currently: Research/Reviews, Practical Articles, Patient Education, Clinical Trials, Evidence-based Articles, Practice Guidelines, CME, and All results
//To remove one, comment out it's document.writeln command
//To add a new one, add a new variable here, construct the proper html, and create a new document.writeln command with the others
//it may help to look at an existing link for help
//NOTE: Make sure to add the proper number of <tr> and </tr> tags for however you want this table to be built (2x3, 3x2, etc)

//URLs for each of the links - removed in-line style information to make it easier to style the whole section. Removed URL text so that it's easier to modify.
var researchReviewsURL,practicalArticlesURL,patientEducationURL,clinicalTrialsURL,evidenceBasedArticlesURL,practiceGuidelinesURL,cmeURL,meetingAbstractsURL,allURL;

researchReviewsURL = '<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3ASearchMedica_AllMedicine_ResReviewsF%29&c=on&p=Convera&fr=true&cid=smonc-atl" '+linkStyle+'>';

practicalArticlesURL = '<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3ASearchMedica_AllMedicine_PractArtNewsF%29&c=on&p=Convera&fr=true&cid=smonc-atl" '+linkStyle+'>';

patientEducationURL ='<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3ASearchMedica_AllMedicine_PatientEduF%29&c=on&p=Convera&fr=true&cid=smonc-atl" '+linkStyle+'>';

clinicalTrialsURL ='<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3ASearchMedica_AllMedicine_ClinTrialsF%29&c=on&p=Convera&fr=true&cid=smonc-atl" '+linkStyle+'>';

evidenceBasedArticlesURL ='<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3ASearchMedica_AllMedicine_EvidBasedArtF%29&c=on&p=Convera&fr=true&cid=smonc-atl" '+linkStyle+'>';

practiceGuidelinesURL ='<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3ASearchMedica_AllMedicine_PracticeGuideF%29&c=on&p=Convera&fr=true&cid=smonc-atl" '+linkStyle+'>';

cmeURL ='<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3ASearchMedica_AllMedicine_CMEF%29&c=on&p=Convera&fr=true&cid=smonc-atl" '+linkStyle+'>';

allURL ='<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&c=on&useraction=search&ss=defLink&fr=true&cid=smonc-atl" '+linkStyle+'>';

meetingAbstractsURL = '<a href="http://www.searchmedica.com/search.do?q='+myTitle+'&cq='+myTitle+'+%28f%3AUBM_SearchMedicaOncology_MeetingsF%29&c=on&p=ConveraNoFR&fr=true&cid=smonc-atl" '+linkStyle+'>';


//HTML Output
document.writeln('<p style="font-size:14px; font-family:Arial; color:#000000; line-height:1.4;">Find peer-reviewed literature and websites for practicing medical professionals</p>');
document.writeln('<table cellpadding="5" cellspacing="3">');

//CME results for topic
document.writeln(preLink);
document.write(cmeURL+'CME on '+myTitleCaps);
document.writeln(closeAnchor);
document.writeln(postLink);

//Evidence results for topic
document.writeln(preLink);
document.write(evidenceBasedArticlesURL+'Evidence on '+myTitleCaps);
document.writeln(closeAnchor);
document.writeln(postLink);

//Guidelines results for topic
document.writeln(preLink);
document.write(practiceGuidelinesURL+'Guidelines on '+myTitleCaps);
document.writeln(closeAnchor);
document.writeln(postLink);

//Patient Education results for topic
document.writeln(preLink);
document.write(patientEducationURL+'Patient Education on '+myTitleCaps);
document.writeln(closeAnchor);
document.writeln(postLink);

//Clinical Trials results for topic
document.writeln(preLink);
document.write(clinicalTrialsURL+'Clinical Trials on '+myTitleCaps);
document.writeln(closeAnchor);
document.writeln(postLink);

//Practical Articles results for topic
document.writeln(preLink);
document.write(practicalArticlesURL+'Practical Articles on '+myTitleCaps);
document.writeln(closeAnchor);
document.writeln(postLink);

//Research results for topic
document.writeln(preLink);
document.write(researchReviewsURL+'Research and Reviews on '+myTitleCaps);
document.writeln(closeAnchor);
document.writeln(postLink);

//Meeting Abstract results for topic
//document.writeln(preLink);
//document.write(meetingAbstractsURL+'Meeting Abstracts on '+myTitleCaps);
//document.writeln(closeAnchor);
//document.writeln(postLink);

//All results for topic
document.writeln(preLink);
document.write(allURL+'All "'+myTitleCaps+'" results');
document.write(closeAnchor);
document.writeln(postLink);

//close the table
document.writeln('</table>');

