// JavaScript Document


var sDataView = null;
var fDataView = null;
var fGridView = null;
var currentCaseId;
var header_height = 35;
var toolbar_height = 40;
var isMember = true;
	 
var communitesJSON = null;	 
	 
	 
     function handleActivate(tab){
	 	var a = tabs.getActiveTab();
	 	if(tab.id == 'tab_communities'){
			//alert('do');
	 		tab.load({url: 'communities.cfm?height=' + tabs.getInnerHeight(), scripts:true});
			tab.removeListener('activate',handleActivate);
		}else if(a.id == 'tab_profile') {
			tab.load({url: 'myrsna/index.cfm', text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);
//			tab.addListener('activate',updateBookmarks);


		}else if(a.id == 'tab_cod') {
			tab.load({url: 'COD.cfm', text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);

		}else if(a.id == 'tab_video') {
			tab.load({url: 'videos.cfm', text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);

		}else if(a.id == 'tab_search') {
			tab.load({url: 'search.cfm', text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			//tab.removeListener('activate',handleActivate);

		}else if(a.id == 'tab_survey') {
			tab.load({url: 'survey.cfm', text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);
		}
		else if(a.id == 'tab_help') {
			tab.load({url: 'help.cfm', text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);
		}	
		else if(a.id == 'tab_awards') {
			tab.load({url: 'awards.cfm', text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);
		}	
		else if(a.id == 'tab_dss') {
		
			tab.load({url: 'dssContent.cfm?height=' + tabs.getInnerHeight() + '&width=' + tabs.getInnerWidth(), text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);
		}	
		
				else if(a.id == 'tab_sunday') {
			tab.load({url: 'presentation.cfm', params:{pm_id:4101,showdiscussion:false,showabstract:false,tabtitle:false}, text: 'Loading...', scripts:true});
			//remove the listner so we dont load again
			tab.removeListener('activate',handleActivate);
		}	
		

		
    }	
	
	
	
function loadCommunityContent(community){
	communitypanel.load({url:'searchResults.cfm', scripts:true, params:{community:community}});	
}

function loadCODHistory(pm_id){
	//CODDisplayPanel.load({url:'CODDisplayPanel.cfm?pm_id=' + pm_id + '&ps_id=' + ps_id, scripts:true});
	CODDisplayPanel.load({url:'presentation.cfm',scripts:true,text:'Loading',params:{pm_id:pm_id,bookmarkview:true,displayheight:CODDisplayPanel.getInnerHeight()-5} });
}

function PassCODHistoryPMID(pm_id) {
	CODDiagnosisPanel.load({url:'CODDiagnosis.cfm?pm_id=' + pm_id, scripts:true});
	//alert('Passed ID '  + pm_id);
}

function helpHighlight(id){
	var oldtarget = 'caseSelected_' + currentCaseId;
	try{document.getElementById(oldtarget).className = 'lakeside_help_normal';}catch(e){}
	var newtarget = 'caseSelected_' + id;
	document.getElementById(newtarget).className = 'lakeside_help_selected';
	currentCaseId = id;
}


function loadHelpPages(id) {
	helppanel.load({url: 'help_main.cfm?id=' + id, scripts:true});
}

function PassCODDiscussionPMID(pm_id) {
	CODDiagnosisPanel.load({url: 'CODDiscussionPanel.cfm?pm_id=' + pm_id, scripts:true});
}
function reloadCODHistoryList(pm_id) {
	CODHistoryList.load({url: 'CODHistory.cfm?pm_id=' + pm_id, scripts:true});
}
function reloadDiagnosisPanel(pm_id) {
	CODDiagnosisPanel.load({url:'CODDiagnosis.cfm?pm_id=' + pm_id, scripts:true});
	//document.getElementById(target).innerHTML='test';
}

function caseHighlight(pm_id){
	var oldtarget = 'caseSelected_' + currentCaseId;
	try{document.getElementById(oldtarget).className = 'lakeside_case_normal';}catch(e){}
	var newtarget = 'caseSelected_' + pm_id;
	document.getElementById(newtarget).className = 'lakeside_case_selected';
	currentCaseId = pm_id;
}

function showPresentation(params){
	var url = 'presentation.cfm';
	tabs.setActiveTab('tab_presentation');
	tabs.getItem('tab_presentation').load({url:url, scripts:true, params:params});
	//tabs.load({url: 'presentation.cfm?height=' + tabs.getInnerHeight(), scripts:true});
}

function ValidateCODSearch(theform, pm_id){
	if(theform.diagnosis.value.length <= 2){
		alert('Please enter your diagnosis');
		return false;
	}
 var status = AjaxRequest.submit(
    theform
    ,{
      'onSuccess':function(req){ 
	  //	alert('advance');
		document.getElementById('results').innerHTML = req.responseText;
		reloadDiagnosisPanel(pm_id); reloadCODHistoryList(pm_id);	
		//alert('Success: ' + pm_id);
		}
    }
  );
  return status;
}


function validateSurveyForm(theform)
{
	var Q1A = false;
	var Q1B = false;
	var Q1C = false;
	for (var i=0; i<theform.sc.length; i++) {
		if (theform.sc[i].checked )
			Q1A = true;
		if (theform.ev[i].checked)
			Q1B = true;
		if (theform.gl[i].checked)
			Q1C = true;
	}
	
	var Q3 = false;
	var Q4 = false;
	if (theform.overall[0].checked || theform.overall[1].checked) 
		Q3 = true;
	if (theform.content[0].checked || theform.content[1].checked)
		Q4 = true;
	
	if(!Q1A) {
		alert('Please select an answer for the "Scientific content" topic of question 1.');
	}else if (!Q1B) {
		alert('Please select an answer for the "Educational value" topic of question 1.');
	}else if (!Q1C) {
		alert('Please select an answer for the "General learning environment" topic of question 1.');
	}else if (!Q3) {
		alert('Please select an answer for question 3.');
	}else if (!Q4) {
		alert('Please select an answer for question 4.');
	}else{
//		alert("Thank you for taking the survey! \n You may edit survey responses through Friday.");
		alert("Thank you for taking the survey!");
		
		 var status = AjaxRequest.submit(
			theform
			,{
			  'onSuccess':function(req){ 
				document.getElementById('dps_survey_div').innerHTML = req.responseText;
				}
			}
		  );
	}
}

function resizePresentationView(target,h,w){
	
	//pad th width by 10
	w = w -10;
	
	newH = (h - toolbar_height).toFixed(2);

	
	
	newW = (newH * 1.33).toFixed(2);
	
	if(newW > w){newW = w; newH = (newW * .75);}
	//alert('w: ' + w + ' newW: ' + newW);
	
	
	newX = ((w-newW)/2).toFixed(2);
	
	//alert('newX: ' + newX.toFixed(2));
	document.getElementById(target).style.left = newX + 'px';
	document.getElementById(target).style.width = newW + 'px';
	document.getElementById(target).style.height = newH + 'px';
	
// resize the background	
	//document.getElementById(target + 'BG').style.left = newX + 'px';
	document.getElementById(target + 'BG').style.width = newW + 'px';
	document.getElementById(target+ 'BG').style.height = newH + 'px';
	
// resize the ppt	
	//document.getElementById(target + 'PPT').style.left = newX + 'px';
	document.getElementById(target + 'PPT').style.width = newW + 'px';
	document.getElementById(target+ 'PPT').style.height = newH + 'px';	
	
	
// resize the layers	
	//document.getElementById(target + 'LAYERS').style.left = newX + 'px';
	document.getElementById(target + 'LAYERS').style.width = newW + 'px';
	document.getElementById(target+ 'LAYERS').style.height = newH + 'px';		
	
	
	//resize the tools
	
	document.getElementById(target+ 'TOOLS').style.left = newX + 'px';
	document.getElementById(target+ 'TOOLS').style.width = newW + 'px';
	document.getElementById(target+ 'TOOLS').style.height = toolbar_height + 'px';
	document.getElementById(target+ 'TOOLS').style.display='';

	
	
	 width_delta = (newW / 800).toFixed(2);
	 height_delta = (newH /600).toFixed(2);

	//showSlide(ps_id)
	//getResizeBuild(pm_id,ps_id,newW,newH,width_delta,height_delta,'N',target);
	
	
}

function doAdvanceSlide(form,delta,ps_id){
	
		//try catch for the popups
		try{
		//alert(sortfield);
		
		//alert(delta);
		
		
		if(form.delta.value != undefined){
			form.delta.value = delta;
		}
		
		var test = document.getElementById(form.loadtarget.value);

		if(form.loadtarget.value.length > 0){
			document.getElementById(form.loadtarget.value).innerHTML='<img src="/images/indicator.gif" />';
		}
		
		if(ps_id != undefined){
			form.ps_id.value = ps_id;	
		} else {
			form.ps_id.value = '';
		}
		
		
		form.dheight.value = document.getElementById(form.basetarget.value).style.height.split('px')[0];
		form.dwidth.value = document.getElementById(form.basetarget.value).style.width.split('px')[0];


		if(form.onsubmit())
		 {//this check triggers the validations
			form.submit();
		 }		
		} catch(e) {}	
}
function ValidateAdvanceSlide(theform){

var resultTarget = theform.loadtarget.value;
 var status = AjaxRequest.submit(
    theform
    ,{
      'onSuccess':function(req){ 
	  	//alert('advance');
		try{
		document.getElementById(resultTarget).innerHTML = req.responseText;
		executeJavascript(resultTarget);
		}catch(e){}
			
		}
    }
  );
}


function drawSlide(basetarget, bg_id, bg_url, bg_frame, ppt_id, ppt_url,ppt_autoplay,slidetype,haslayers){

var slideBG = basetarget + 'BG';
var slidePPT = basetarget + 'PPT';

if(bg_id > 0){
	//alert(bg_url);
		drawFlashBG(slideBG,bg_url,bg_frame, bg_id);
	} else {
		document.getElementById(slideBG).innerHTML = '';
	}
	if(ppt_id > 0){
		drawFlashPPT(slidePPT,ppt_url, ppt_id,ppt_autoplay,'PPT SLIDE',slidetype);
	} else {
		document.getElementById(slidePPT).innerHTML = '';
	}
}
function bookmark_presentation(pm_id){

	var presIndex = searchStore.findBy(	    
				    				function(record,id){
									if(record.data.pm_id == pm_id){return true;}
								}
							);
	if(presIndex >= 0 ){
		var title = searchStore.getAt(presIndex).data.pm_title;
		title = title.substr(3,title.length-7);
		bookmark_popup('PRESENTATION','My Bookmarks',title,'','','','',pm_id);
	}
}


function bookmark_video(mm_key){
	var videoIndex = videostore.findBy(	    
				    				function(record,id){
									if(record.data.mm_key == mm_key){return true;}
								}
							);

	if(videoIndex >= 0){
		var title = videostore.getAt(videoIndex).data.ps_title;
//		title = title.substr(3,title.length-7);
		bookmark_popup('DPSVIDEO','My Bookmarks',title,'','','',mm_key,'');
	}
}
	
	
	
var oldWidth;
var oldHeight;
	
	function handleViewportResize(viewport, adjWidth, adjHeight, rawWidth, rawHeight){
	//alert(Ext.get('tabs'));

	diffWidth = adjWidth - oldWidth;
	diffHeight = adjHeight - oldHeight;
	deltaWidth = adjWidth/oldWidth;
	deltaHeight = adjHeight/oldHeight;
	
	var commListExists = (Ext.getCmp('comContainer') != undefined && communityContainer.findById('west-panel') != null ? true : false);
//	var commListExists = true;
	

	if(Ext.get('dpstabs') != undefined){
	
	//dpsHomePanel.syncSize();
	
	//alert(dpsHomePanel.getSize().width);
	
	//alert(dpsHomePanel.getSize().width + ' h: ' + dpsHomePanel.getSize().height);
	//dpsTabs.setSize(dpsHomePanel.getSize().width,dpsHomePanel.getSize().height);
	//dpsTabsHeight = dpsViewport.getSize().height - dpsHeaderPanel.getSize().height;
	//tabs.doLayout();
	
	//tabs.getActiveTab().doLayout();
	//tabs.setSize(dpsHomePanel.getSize().width,dpsHomePanel.getSize().height);

		nTPw = tabs.getSize().width * deltaWidth;
		nTPh = tabs.getSize().height* deltaHeight;
		
		tabs.setSize(nTPw,nTPh);

		//tabs.syncSize();
		tabs.doLayout();
		
	if(tabs.getActiveTab().id == 'tab_communities'){
		communityContainer.setHeight(tabs.getInnerHeight() -1);
		searchPanel.setHeight(tabs.getInnerHeight() - 1);
		psearchDataView.setWidth(searchPanel.getInnerWidth() -20);
		searchPanel.doLayout();
		communitypanel.doLayout();
		if(commListExists){
			commList.doLayout();
		}
		
		communityContainer.doLayout();
	
	}else if(tabs.getActiveTab().id == 'tab_presentation'){
		var pres_container = Ext.getCmp('presentationContainer'+tabs.getActiveTab().randomdiv);
		if(Ext.isGecko){
			pres_container.setSize(tabs.getInnerWidth()-5,tabs.getInnerHeight()-25);
		}else if(Ext.isIE){
			pres_container.setSize(tabs.getInnerWidth()-5,tabs.getInnerHeight()-5);
		}else{
			pres_container.setSize(tabs.getInnerWidth()-5,tabs.getInnerHeight()-25);

			var randomdiv = tabs.getActiveTab().randomdiv;
			var presdisplay = Ext.getCmp('PresentationDataDisplayPanel'+randomdiv);			
			
			if(presdisplay != undefined){
				presdisplay.setSize(presdisplay.getInnerWidth()-5,presdisplay.getInnerHeight()-5);
//				presdisplay.doLayout();
			}
			
		}
		
	}else if(tabs.getActiveTab().id == 'tab_communitiesold'){
		//alert(tabs.getActiveTab().id + ' ' + adjWidth + ' ' + oldWidth + ' ' + diffWidth );
		//alert(communityContainer.getSize().width)
		
		//alert('diffWidth: ' + diffWidth + ' diffHeight: ' + diffHeight + ' deltaWidth: ' + deltaWidth + '  deltaHeight: ' + deltaHeight);
		
		nCCw = tabs.getInnerWidth();
		//nCCh = communityContainer.getSize().height * deltaHeight;		
		nCCh = tabs.getInnerHeight() - 1;
		
		nCPw = communitypanel.getInnerWidth() * deltaWidth;
		nCPh = communitypanel.getInnerHeight() * deltaHeight - 1;
		
		//communityContainer.setHeight(tabs.getInnerHeight() -1);
		communityContainer.setSize(nCCw,nCCh);
		communitypanel.setSize(nCPw,nCPh);
		
		if(commListExists){
			nCLw = commList.getInnerWidth() * deltaWidth;
			nCLh = commList.getInnerHeight() * deltaHeight - 1;
			commList.setSize(nCLw,nCLh);
		}
		
		//communityContainer.doLayout();
		//communitypanel.doLayout();
		//commList.doLayout();
		
		
		//communitypanel.doLayout();
		
		//ccW = communityContainer.getSize().width + diffWidth;
		//ccH = communityContainer.getSize().height + diffHeight;
		//communityContainer.setSize(ccW,ccH);
		//
		
		communitypanel.doLayout();
		if(commListExists){
			commList.doLayout();
		}
		communityContainer.doLayout();
		
	}
	
	
	
	
	//dpsTabs.getActiveTab().load({url:dpsTabs.getActiveTab().contenturl, scripts:true});
 
	
	}
	
	oldWidth = adjWidth;
	oldHeight = adjHeight;
	
}

function popHighlights(pm_id){
	
	
			//alert(Ext.get('pop' + pm_id).getLeft());
			loadwin = true;
			winleft = Ext.get('pop' + pm_id).getLeft() + 20;
	
			if(Ext.WindowMgr.get('launchPopWin') != null){
				
				if(Ext.WindowMgr.get('launchPopWin').pm_id != pm_id){
				
						Ext.WindowMgr.get('launchPopWin').destroy();
						
				} else {
					loadwin = false;	
					
				}
			}	
	
		if(loadwin){
		launchPopWin = new Ext.Window(
			{
				id:'launchPopWin',
				title:'Highlights',
				width:800,
				height:600,
				autoScroll:true,
				modal:false,
				closable: true
				,x:winleft
				,autoLoad:{url:'presentation.cfm',scripts:true,params:{pm_id:pm_id,highlightsview:true,slidefilter:'HIGHLIGHTS'}}
				,pm_id:pm_id
			}
		).show();
		}
	
}


/*		
-------------------------------------------------------------
TEMPLATE
------------------------------------------------------------
*/	

	var pstpl_body = get_pstpl_body();
	pstpl = new Ext.XTemplate(pstpl_body);	
				
	commTPL = new Ext.XTemplate(
	'<tpl for=".">',
	'<table class="x-combo-list-item" width="250px" align="center">',
	'<tr>',
	'<td width="10" class="solid_{atm_code}" align="center" >&nbsp;</td><td class="tools" width="240">{atm_description}</td></tr></table></tpl>');
	
function get_pstpl_body(type){
	

	if(type == undefined || type == ''){type = 'default';}
	
	var bookmark_function, rating_div, rating_text
	
	if(type == 'my_annotated'){
		if(isMember){
			bookmark_function = 'myAP_bookmark_presentation';
		} else {
			bookmark_function = 'nonMemberBookmark';
		}
		rating_div = 'myAP_rating';
	}else if(type == 'my_key'){
		if(isMember){	
			bookmark_function = 'myKP_bookmark_presentation';
		} else {
			bookmark_function = 'nonMemberBookmark';
		}
		rating_div = 'myKP_rating';
	}else if(type == 'my_notes'){
		if(isMember){	
			bookmark_function = 'myNP_bookmark_presentation';
		} else {
			bookmark_function = 'nonMemberBookmark';
		}
		rating_div = 'myNP_rating';
	}else if(type == 'my_ratings'){
		if(isMember){
			bookmark_function = 'myRatings_bookmark_presentation';
		} else {
			bookmark_function = 'nonMemberBookmark';
		}
		rating_div = 'myRatings_rating';
	}else{
		if(isMember){
			bookmark_function = 'bookmark_presentation';
		} else {
			bookmark_function = 'nonMemberBookmark';
		}
		rating_div = 'search_rating';
	}
	
	if(type == 'mm_key'){
		rating_text = '<img src="/images/star<tpl if="cr_rating &lt; 1">_0</tpl>.png">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 2">_0</tpl>.png">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 3">_0</tpl>.png">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 4">_0</tpl>.png">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 5">_0</tpl>.png">';
	}else{
		rating_text = '<img src="/images/star<tpl if="cr_rating &lt; 1">_0</tpl>.png" onclick="Javascript:myPresentationRating({id:\'{pm_id}\',rate:1,type:\'PRESENTATION\'})">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 2">_0</tpl>.png" onclick="Javascript:myPresentationRating({id:\'{pm_id}\',rate:2,type:\'PRESENTATION\'})">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 3">_0</tpl>.png" onclick="Javascript:myPresentationRating({id:\'{pm_id}\',rate:3,type:\'PRESENTATION\'})">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 4">_0</tpl>.png" onclick="Javascript:myPresentationRating({id:\'{pm_id}\',rate:4,type:\'PRESENTATION\'})">'
		+'<img src="/images/star<tpl if="cr_rating &lt; 5">_0</tpl>.png" onclick="Javascript:myPresentationRating({id:\'{pm_id}\',rate:5,type:\'PRESENTATION\'})">';
	}
	
	var pstpl_body = '<tpl for=".">'
				+'<div style="cursor:pointer" id="DV{pm_id}" class="{[xindex % 2 === 0 ? "dps_row1" : "dps_row2"]}">'
				+'<table width="98%"><tr><td valign="top" width="15" class="lakeside_small_tag" align="left">{rownumber}</td>'
				+'<td valign="top">'
				+'<table width="100%"><tr><td align="left">'
				+'<table><tr>'
				+'<td  style="width:20px" class="solid_{pm_community}">'
				+'{[values.pm_community.substring(4,6)]}'
				+'</td><td class="lakeside_large_tag" width="150">{em_public_id}</td>'
				+'<td align="left" width="125">[<tpl if="am_id == 4">Education Exhibit</tpl><tpl if="am_id == 3">Scientific Poster</tpl><tpl if="am_id == 2">Scientific Sessions</tpl><tpl if="am_id == 12">Refresher Course</tpl>]</td>'
				+'<td align="left"><tpl if="pm_web == \'Y\'"><img src="/images/world_go.png" ext:qtip="This presentation will be available online."></tpl>'
				+'<tpl if="pm_web != \'Y\'"><img src="/images/rsna2008.png" ext:qtip="This presentation only available at RSNA."></tpl></td>'
				+'</tr></table>'
				+'</td></tr>'
				+'<tr><td colspan="2">'
				+'<table width="100%"><tr><td width="25px">'
				+'<a onmouseover="Javascript:popHighlights({pm_id});" id="pop{pm_id}"><img src="/images/transmit_blue.png" /></a>'
				+'</td><td  >'
				+'<a href="Javascript:showPresentation(' + String.fromCharCode(123) + 'pm_id:{pm_id}' + String.fromCharCode(125) + ');" class="lakeside_title">{pm_title}</a>'
				+'</td></tr></table>'
				+'</td></tr>'
				+'<tr><td colspan="2">'
				+'<table width="100%">'
					  +'<tr>'
						+' <td style="width:25px">&nbsp;</td>'
						 +'<td style="width:50px" class="lakeside_small_tag" valign="top" align="left">Authors: </td>'
						 +'<td class="lakeside_authors" align="left" valign="top">{pm_authors}</td>'
					 +' </tr>'
				   +'</table>'
				+'</td></tr>'
				+'<tr><td colspan="2">'
				+'<table>'
					  +'<tr>'
						+' <td style="width:25px">&nbsp;</td>'
						 +'<td style="width:65px" class="lakeside_small_tag" valign="top" align="left">Bookmark: </td>'
						 +'<td style="width:30px" align="left"><a href="#" onClick="'+bookmark_function+'({pm_id});"><img src="/images/book_add.png"></a></td>'
						 +'<td style="width:65px" class="lakeside_small_tag" valign="top" align="left">My Rating: </td>'
						 +'<td align="left" style="width:100px" valign="top">'
							+'<div id="'+rating_div+'_{pm_id}" style="width:100px">'
								+rating_text
							+'</div>'
						 +'</td>'
						 +'<td width="16" valign="top"><img src="../images/user_edit.png"></td>'
						 +'<td class="lakeside_small_tag" valign="top" align="left">Notes:</td>'
						 +'<td align="left" class="lakeside_small_notes" valign="top">{notes} slide(s).</td>'
						 +'<td width="16" valign="top"><img src="../images/map_edit.png"></td>'
						 +'<td class="lakeside_small_tag" valign="top" align="left">Annotations:</td>'
						 +'<td align="left" class="lakeside_small_notes" valign="top">{annotations} slide(s). </td>'
					 +' </tr>'
				   +'</table>'
				+'</td></tr>'
				+'<tr><td colspan="2">'
				+'<tpl if="c != 0"><img src="/images/cum.gif"  ext:qtip="Cum Laude"></tpl>'
				+'<tpl if="e != 0"><img src="/images/excellence.gif" ext:qtip="Excellence in Design"></tpl>'
				+'<tpl if="m != 0"><img src="/images/magna.gif" ext:qtip="Magna Cum Laude"></tpl>'
				+'<tpl if="moawd != 0"><img src="/images/MI.gif" ext:qtip="Molecular Imaging Travel Award"></tpl>'
				+'<tpl if="refund != 0"><img src="/images/re.gif" ext:qtip="Research and Education Foundation Support"></tpl>'
				+'<tpl if="resawd != 0"><img src="/images/res_ppr.gif" ext:qtip="Trainee Research Prize - Resident"></tpl>'
				+'<tpl if="x != 0"><img src="/images/cert.gif" ext:qtip="Certificate of Merit"></tpl>'
				+'<tpl if="rg != 0"><img src="/images/rg.gif" ext:qtip="Selected for RadioGraphics"></tpl>'
				+'</td></tr>'
				+'</table>'
				+'</td></tr></table>'
				+'</div>'
			+'</tpl>';
	
	return pstpl_body;
}
			
function myRating(params){
	Ext.Ajax.request({
		url: 'updateVideoNote.cfm',
		success: function(response , request)
			{
				for(var i=1; i<=5;i++){
					sDiv=Ext.get('rate_' + i + '_' + params.id);
					if(i<=params.rate){
						sDiv.dom.innerHTML = '<img src="/images/star.png" onclick="Javascript:myRating({id:' + String.fromCharCode(39) + params.id + String.fromCharCode(39) + ',rate:' + i+',type:' + String.fromCharCode(39) + params.type + String.fromCharCode(39) + '})">';
					}else {
						sDiv.dom.innerHTML = '<img src="/images/star_0.png" onclick="Javascript:myRating({id:' + String.fromCharCode(39) + params.id + String.fromCharCode(39) + ',rate:' + i+',type:' + String.fromCharCode(39) + params.type + String.fromCharCode(39) + '})">';
					}// end if	
				}
			},
		failure: function(){handleActionFailure('Sorry, we were unable rate the '+ params.type.toLowerCase() +'.');},
	
		params: {type:params.type,q:params.id,rating:params.rate,ACTION:'RATING' }
	});			
}

function myPresentationRating(params){
	Ext.Ajax.request({
		url: 'updateVideoNote.cfm',
		success: function(response , request)
			{
				var rating_html = '';
				for(var i=1; i<=5;i++){
					if(i<=params.rate){
						rating_html = rating_html + '<img src="/images/star.png" onclick="Javascript:myPresentationRating({id:' + String.fromCharCode(39) + params.id + String.fromCharCode(39) + ',rate:' + i+',type:' + String.fromCharCode(39) + params.type + String.fromCharCode(39) + '})">';
					}else {
						rating_html = rating_html + '<img src="/images/star_0.png" onclick="Javascript:myPresentationRating({id:' + String.fromCharCode(39) + params.id + String.fromCharCode(39) + ',rate:' + i+',type:' + String.fromCharCode(39) + params.type + String.fromCharCode(39) + '})">';
					}// end if	
				}
				var pres_tab_rating = document.getElementById('search_rating_'+params.id);
				var myNP_tab_rating = document.getElementById('myNP_rating_'+params.id);
				var myAP_tab_rating = document.getElementById('myAP_rating_'+params.id);
				var myKP_tab_rating = document.getElementById('myKP_rating_'+params.id);
				var myRatings_tab_rating = document.getElementById('myRatings_rating_'+params.id);
				if(pres_tab_rating != null){pres_tab_rating.innerHTML = rating_html;}
				if(myNP_tab_rating != null){myNP_tab_rating.innerHTML = rating_html;}
				if(myAP_tab_rating != null){myAP_tab_rating.innerHTML = rating_html;}
				if(myKP_tab_rating != null){myKP_tab_rating.innerHTML = rating_html;}
				if(myRatings_tab_rating != null){myRatings_tab_rating.innerHTML = rating_html;}
			},
		failure: function(){handleActionFailure('Sorry, we were unable rate the '+ params.type.toLowerCase() +'.');},
	
		params: {type:params.type,q:params.id,rating:params.rate,ACTION:'RATING' }
	});			
}
		
		


function myKeyMedia(params){
			
			//alert(params.type);
			
			
			
				Ext.Ajax.request({
					url: 'updateSlideNotes.cfm',
					success: function(response , request)
						{
					
						sDiv=Ext.get('keymedia_' + params.id);
							
								if(params.method == 'ADD'){
									
									sDiv.dom.innerHTML = '<img src="/images/key_delete.png" /> <a href="Javascript:myKeyMedia({id:' + String.fromCharCode(39) + params.id + String.fromCharCode(39) +',type:' + String.fromCharCode(39) + params.type + String.fromCharCode(39) + ',method:' + String.fromCharCode(39) + 'REMOVE' + String.fromCharCode(39) + '})">Remove as a "Key Slide".</a>';
									
								} else {
								sDiv.dom.innerHTML = '<img src="/images/key_add.png" /> <a href="Javascript:myKeyMedia({id:' + String.fromCharCode(39) + params.id + String.fromCharCode(39) +',type:' + String.fromCharCode(39) + params.type + String.fromCharCode(39) + ',method:' + String.fromCharCode(39) + 'ADD' + String.fromCharCode(39) + '})">Mark as a "Key Slide".</a>';	
									
								}
							
						} ,
					failure: function(){alert('failed');},
				
					params: {type:params.type,q:params.id,ACTION:'KEY',keymethod:params.method }
				});			
			
			

			
		
		
		}

	
	
function SlideFilter(filter_type,randomdiv,pm_id){
	var filter_text,filter_icon
	if(filter_type == undefined || filter_type == ''){filter_type = 'ALL';}
	
	if(filter_type == 'HIGHLIGHTS'){
		filter_text = 'Highlighted Slides';
		filter_icon = 'slide-HIGHLIGHTON';
	}else if(filter_type == 'NOTES'){
		filter_text = 'My Noted Slides';
		filter_icon = 'slide-NOTE';
	}else if(filter_type == 'ANNOTATIONS'){
		filter_text = 'My Annotated Slides';
		filter_icon = 'presentation-SLIDEANNOTATIONS';
	}else if(filter_type == 'KEYSLIDE'){
		filter_text = 'My Key Slides';
		filter_icon = 'slide-KEY';
	}else if(filter_type == 'RATINGS'){
		filter_text = 'My Rated Slides';
		filter_icon = 'slide-HIGHLIGHTOFF';		
	}else{
		filter_text = 'ALL Slides';
		filter_icon = 'presentation-SLIDES'
	}

//	clearSearch#randomdiv#();
//	slidestore#randomdiv#.load({params:{pm_id:#pm_id#,ACTION:filter_type}});
//	bSlideFilter#randomdiv#.setText(filter_text);
//	bSlideFilter#randomdiv#.setIconClass(filter_icon);		

	try{
	eval('clearSearch'+randomdiv+'();');
	} catch (e) {}
	eval('slidestore'+randomdiv+'.load({params:{pm_id:'+pm_id+',ACTION:filter_type}});');
	eval('bSlideFilter'+randomdiv+'.setText(filter_text)');
	eval('bSlideFilter'+randomdiv+'.setIconClass(filter_icon);');
	
	
	
}