//function to fix the IE rollover 
function fixIE6flicker(fix) {
 try {
  document.execCommand("BackgroundImageCache", false, fix);
 } catch(err) { }
}
fixIE6flicker(true);


//Global variable used to hold old CTA string
var oldSearchCTA = "";
var searchFocused = false;

//Hide the "search..." CTA string
function hideSearchCTA(ctrlName)
{
	if ((ctrlName) && (!searchFocused))
	{
		oldSearchCTA = ctrlName.value;
		ctrlName.value = "";
	}
}

//Show the CTA string "search..." if no search entered
function showSearchCTA(ctrlName)
{
	if ((ctrlName) && (ctrlName.value.length == 0))
	{
		ctrlName.value = oldSearchCTA;
		searchFocused = false;
	}
	else
		searchFocused = true;

}

function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    
    //self.xmlHttpReq.send(getquerystring());
    self.xmlHttpReq.send(get_poll_querystring());
}

function getquerystring() {
	var pid, answer, res, graph;
	pid = document.getElementById("poll_id").value;
	graph = document.getElementById("graph_type").value;
	var answers = document.getElementsByName("eisdp_poll_answer");
	for (i=0;i<answers.length; i++)
	{
		if (answers[i].checked)
			answer = answers[i].value;
	}
	res = "mode=vote&poll_id=" + pid + "&answer=" + answer + "&graph=" + graph;
	//alert(res);
    return res;
}

function get_poll_querystring() {
	var pid, answer, res, graph, poll_content;                
	pid = document.getElementById("poll_id").value;
	graph = document.getElementById("graph_type").value;
	var answers = document.getElementsByName("eisdp_poll_answer");   

                var question= document.getElementById("eisdp_poll_question").innerHTML;
                poll_content= "&poll_question="+question+"&length="+answers.length;

	for (i=0;i<answers.length; i++)
	{
                                var answer_index= "eisdp_poll_answertext"+(i+1);
                                var answer_text= document.getElementById(answer_index).innerHTML;
                                poll_content= poll_content+ "&answer"+ i +"="+ answer_text;
		if (answers[i].checked)
			answer = answers[i].value;
	}
	res = "mode=vote&poll_id=" + pid + "&answer=" + answer + "&graph=" + graph+poll_content;
                
	//alert(res); 
    return res;
}

function updatepage(str){
    var answers = document.getElementsByName("eisdp_poll_answer");
	for (i=1;i<=answers.length; i++)
	{
		var span = document.getElementById("eisdp_poll_answertext" + i);
		if (span)
			str = str.replace("eisdpa"+i,span.innerHTML);
	}
	document.getElementById("eisdp_poll_results").innerHTML = str;
}

function vote()
{
                get_poll_querystring();
	var formDiv = document.getElementById("eisdp_poll_data");
	var resDiv = document.getElementById("eisdp_poll_results");
	formDiv.style.display="none";
	resDiv.style.display="block";
	
	xmlhttpPost("/Poll");
}


//Return a tridion date string parsed to a Javascript date object
//Expected Tridion format is yyyy-mm-ddThh:mm:ss
function tridionToJSDate(dte)
{
	var result = new Date;
	
	result.setYear(dte.substring(0, 4));
	result.setMonth(Number(dte.substring(5, 7)) - 1);
	result.setDate(dte.substring(8, 10));
	result.setHours(dte.substring(11, 13));
	result.setMinutes(dte.substring(14, 16));
	result.setSeconds(dte.substring(17, 19));
	
	return result;
}

//Format the date to the company standard
function doDateFmt(dte) {

	alert('Input Date: '+ dte);
	var dteFmt = tridionToJSDate(dte);
	
	var m_names = new Array("January", "February", "March", 
	"April", "May", "June", "July", "August", "September", 
	"October", "November", "December");

	document.write(m_names[dteFmt.getMonth()] + ' ' + dteFmt.getDate() + ', ' + dteFmt.getFullYear());
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, path)
{
    var expire = new Date();
    var today = new Date();
    if (!path)
        path = "/";
		
    expire.setTime(today.getTime() + 3600000*24*365);
    document.cookie= name + "=" + escape(value) + ";expires="+expire.toGMTString()+";path="+path;
}

function setTempCookie(name, value, path)
{
    var expire = new Date();
    var today = new Date();
    if (!path)
        path = "/";
		
    expire.setTime(today.getTime() + 3600000*1);
    document.cookie= name + "=" + escape(value) + ";expires="+expire.toGMTString()+";path="+path;
}

function Delete_Cookie( name, path, domain ) {
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function refreshRememberme(){
	var test= document.getElementById("RememberMe").checked;
	if(test==false)
		Delete_Cookie('eis_remeber_me', '/', '');
	
		//deleteCookie("eis_remeber_me", "/", "");
	
	setCookie('eis_fresher', '1', '/');	
                if ( (getCookie( "onco_survey" ) ==null) && (getCookie( "eis_user_id" ) !=null)){
		//xmlHTTPRetrievePost("/survey_first.jsp", "pnav_container");
		//takeSurvey();
	}
}

function takeSurvey()
{
   //Set Cookie
   setCookie('onco_survey', '1', '/');
   // grouped question survey
   window.open ("/survey_start.jsp","survey_window","width=800,height=600,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=no,menubar=no");
   /* 
    //page-by-page survey
	window.open ("http://www.surveymethods.com/EndUser.aspx?CDE9859FC58E9A99","survey_window","width=800,height=600,scrollbars=yes,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
	*/
}

function pollFilter(){

                //temparary code to remove the search widget duplicates for the GYN/NOn-overy
               var dups=0;
	var dup_form= new Array();
	var dup_index=0;
	for(var i=0; i<document.forms.length; i++){
		var onco_form= document.forms[i];
		var form_name= onco_form.name;
		var form_content= onco_form.innerHTML;
		if((form_name.indexOf("condCtrForm")!=-1) && (form_content.indexOf('GYN (Non-Ovary)')!=-1)){
			dups++;			
		}
		
		if(dups>1){
			//dup_form[dup_index]= form_name;
			dup_form[dup_index]= onco_form;
			dup_index++;
			
		}		
	}

                 for(i=0; i<dup_form.length; i++){
 	                var df= dup_form[i];
		df.parentNode.removeChild(df);
	}
                //end the temparary code

	var xmlHttpReq = false;
    	var self = this;
	var vote_cookie, res, pid, graph;
		
    	// Mozilla/Safari
    	if (window.XMLHttpRequest) {
        	self.xmlHttpReq = new XMLHttpRequest();
    	}
    	// IE
    	else if (window.ActiveXObject) {
       	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	self.xmlHttpReq.open('POST', '/Poll', false);
    	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	if(document.getElementById("poll_id"))
		pid= document.getElementById("poll_id").value;
	else
		pid=0;
	
	vote_cookie= getCookie("voted_"+pid);
	if(vote_cookie!=null){
		var formDiv = document.getElementById("eisdp_poll_data");
		var resDiv = document.getElementById("eisdp_poll_results");

		var graphTypeCtrl = document.getElementById("graph_type"), graphType = "";
		if(graphTypeCtrl)
			graphType = "&graph_type=" + graphTypeCtrl.value;

		formDiv.style.display="none";
		resDiv.style.display="block";
		res = "mode=result&poll_id=" + pid+ graphType;
		self.xmlHttpReq.send(res);
		updatepage(self.xmlHttpReq.responseText);
    	}
}

function openPopupWindow(url)
{
	//window.open (url,"mywindow","width=450,height=768,left=275,top=0,menubar=0,toolbar=0,location=0,directories=0,resizable=0");
	//window.open (url,"mywindow","width=400,height=650,scrollbars=auto,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
	window.open (url,"mywindow","width=400,height=600,scrollbars=auto,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
}

function openTermsWindow(url)
{
	//window.open (url,"mywindow","width=450,height=768,left=275,top=0,menubar=0,toolbar=0,location=0,directories=0,resizable=0");
	//window.open (url,"mywindow","width=400,height=650,scrollbars=auto,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
	window.open (url,"mywindow","width=400,height=600,scrollbars=yes,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
}

function openRefWindow(url)
{
	//window.open (url,"mywindow","width=450,height=768,left=275,top=0,menubar=0,toolbar=0,location=0,directories=0,resizable=0");
	//window.open (url,"mywindow","width=400,height=650,scrollbars=auto,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
	//window.open (url,"mywindow","width=400,height=300,scrollbars=yes,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
                OpenWindow(url, "small");
}

function showad(url) {
	// Tracking for WebTrends should be called from here --- 
	trackClick(url);
	actionDownloadCount();
	window.open (url,"pdf_window","");
}

function testShowad(url) {
	Dialog.alert({url: "/general/ad.html?href="+url, options: {method: 'get'}}, {className: "alphacube", width:338});
}

//Retrieve the all values from URL parameters with the passed name 
function getParameters(parameterName) 
{
  var queryString = window.location.search;
  var result = null;
  
  //Check there is a query string
  if ((queryString != null) && (queryString.length > 0))
  {
    var parameters = queryString.substring(1).split('&');
    parameterName = parameterName.toLowerCase();
    result = new Array();

    //Check for matching parameter names
    for(var i = 0; i < parameters.length; i++) 
    {
      //If the parameter name matches add the value to our array
      if (parameters[i].toLowerCase().indexOf(parameterName) >= 0) 
      {
        //alert(parameters[i]);
        var parameterValue = parameters[i].indexOf('=');
        if (parameterValue >= 0)
          result.push(parameters[i].substr(parameterValue + 1));
      }
    }
  }
  
  return result;
}

//Retrieve the first value from URL parameters that has the passed name
function getParameter(parameterName) 
{
  var parms = getParameters(parameterName);
  
  if ((parms != null) && (parms.length > 0))
    return parms[0];
  else
    return null;
}

//Open a CME PDF if the user just logged in
function openCmePdf()
{
  var pdfObj = getParameter("cmepdf");
  
  if (pdfObj != null)
  {
    pdfObj = document.getElementById("cmepdf" + String(pdfObj));
	if (pdfObj != null)
      showad(String(pdfObj.href));
  }
}


function saveRefererCookie(cookieName)
{
	setCookie(cookieName,window.location.href);
}

function savePageTcmId(cookieName)
{
	var cookieValue = "";
	var eUri = document.getElementById("uri");
	if (eUri) {
		cookieValue = eUri.value;
	}
	setCookie(cookieName,cookieValue);
}


function displayArticleTitle(name)
{
	var cookie = getCookie(name);
	if(cookie!=null) 
	{
		document.write(cookie);
	}
}

function OpenWindow(url, windowSize)
{
                trackClick(url);
	if(windowSize=="small")
                       window.open (url,"mywindow","width=400,height=300,scrollbars=yes,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
                else
                        window.open (url,"window","width=770,height=500,top=50,left=125,location=1,status=1,scrollbars=1,menubar=1,toolbar=1,resizable=1");
}

//created by Hosam 
function trackClick(url){
                /* Modified By Hosam Elkhodary - Unilytics - 20070220
	   - Added functionality to attach an onclick for offsite or download. 
	*/
	l = document.createElement("A");
	l.setAttribute('href',url);
	// alert(l.hostname);
	// alert(WT.cg_n+" | "+WT.cg_s);
	if (l.hostname) {
  	if (dcsIsOnsite(l.hostname)){ // Onsite Link - Check if it is a link to a download document
    	// alert("ONsite - download");
  		var types="xls,doc,pdf,txt,csv,zip";
			var fileType=l.pathname.substring(l.pathname.lastIndexOf(".")+1,l.pathname.length);
    	if (types.indexOf(l.pathname.substring(l.pathname.lastIndexOf(".")+1,l.pathname.length))!=-1){
				WT.cg_n += ';Downloads';
				WT.cg_s += ';'+fileType;
    		var qry=l.search?l.search.substring(l.search.indexOf("?")+1,l.search.length):"";
    		if (qry.toUpperCase().indexOf("WT.SVL=")==-1){
    			WT.svl=dcsParseSvl(l.name?l.name.toString():(l.onclick?l.onclick.toString():""));
    		}
    		var path=l.pathname?((l.pathname.indexOf("/")!=0)?"/"+l.pathname:l.pathname):"/";
    		dcsMultiTrack("DCS.dcssip",l.hostname,"DCS.dcsuri",path,"DCS.dcsqry",l.search||"","WT.ti","Download:"+(path||""),"WT.dl","1");
    		DCS.dcssip=DCS.dcsuri=DCS.dcsqry=WT.ti=WT.svl=WT.dl="";
    	}
		}
  	else { // This is an offsite link
  	  // alert("Offsite");
			WT.cg_n += ';External Links';
			WT.cg_s += ';'+l.hostname;
			var qry=l.search?l.search.substring(l.search.indexOf("?")+1,l.search.length):"";
			if (qry.toUpperCase().indexOf("WT.SVL=")==-1){
				WT.svl=dcsParseSvl(l.name?l.name.toString():(l.onclick?l.onclick.toString():""));
			}
			var path=l.pathname?((l.pathname.indexOf("/")!=0)?"/"+l.pathname:l.pathname):"/";
			var trim=false; //Set to true/false to exclude/include the query parameters (see below trim?"":qry)
			dcsMultiTrack("DCS.dcssip",l.hostname,"DCS.dcsuri",path,"DCS.dcsqry",trim?"":qry,"WT.ti","Offsite:"+l.hostname+path+qry,"WT.os","1");
			DCS.dcssip=DCS.dcsuri=DCS.dcsqry=WT.ti=WT.svl=WT.os="";
		}
	}
}


function trackAudioClick(url){
                /* Modified By Hosam Elkhodary - Unilytics - 20070220
	   - Added functionality to attach an onclick for offsite or download. 
	*/
	l = document.createElement("A");
	l.setAttribute('href',url);
	// alert(l.hostname);
	// alert(WT.cg_n+" | "+WT.cg_s);
  	// alert("ONsite - download");
  	var types="mp3";
	var fileType=l.pathname.substring(l.pathname.lastIndexOf(".")+1,l.pathname.length);
    	if (types.indexOf(l.pathname.substring(l.pathname.lastIndexOf(".")+1,l.pathname.length))!=-1){
				WT.cg_n += ';Downloads';
				WT.cg_s += ';'+fileType;
    		var qry=l.search?l.search.substring(l.search.indexOf("?")+1,l.search.length):"";
    		if (qry.toUpperCase().indexOf("WT.SVL=")==-1){
    			WT.svl=dcsParseSvl(l.name?l.name.toString():(l.onclick?l.onclick.toString():""));
    		}
    		var path=l.pathname?((l.pathname.indexOf("/")!=0)?"/"+l.pathname:l.pathname):"/";
    		dcsMultiTrack("DCS.dcssip",l.hostname,"DCS.dcsuri",path,"DCS.dcsqry",l.search||"","WT.ti","Download:"+(path||""),"WT.dl","1");
    		DCS.dcssip=DCS.dcsuri=DCS.dcsqry=WT.ti=WT.svl=WT.dl="";
    	}
}

function setPageTitle()
{
	var pageTitle = "   ";
	var titleArray = document.getElementsByTagName("h2");
	for (var i=0; i<titleArray.length; i++) {
		if (titleArray[i].innerHTML != null) {
			if (titleArray[i].id == "eis_page_title") {
				pageTitle = cleanText(titleArray[i].innerHTML);
				i=titleArray.length;
			}
		}
	}
	setCookie("CallingArticleTitle",pageTitle);
}

function cleanText(text)
{
	var newText = text;
	if (text.indexOf('">')>0)
	{
		if (text.substring(text.indexOf('">')+2).indexOf('</')>0)
		{
			newText = text.substring(text.indexOf('">')+2,text.indexOf('</'));
		}
		else newText = text.substring(text.indexOf('">')+2);
	}
	return newText;
}

function WriteDivForStaticContainer(tagID,classValue,IDType) {
	var returnValue = classValue;
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			if (key == 'Group_Name' && val.length>0) {
				returnValue = 'hidden';
				i = parms.length;
			}
		}
	}

	if (IDType == 'opening') {
		returnValue = '<' + tagID + ' class="' + returnValue + '">';
	}

	if (IDType == 'closing') {
		returnValue = '</' + tagID + '>';
	}

	return returnValue;
}

function resultPage()
{
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	var returnValue = false;
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			if (key == 'result_page' && val.length>0) {
				returnValue = true;
				i = parms.length;
			}
		}
	}
	return returnValue;
}

// *** Start Tracking Most Read, Most Downloaded and Most Emailed Articles ***
function isValidClientIP()
{
	return String(WT.co_f).match(/^145\.36\..*|^63\.125\.146\..*|^63\.125\.147\..*/) == null;
}

function actionReadCount() {
	var eComments = document.getElementById("comments_form");
	if (eComments) {
		var tFound = false;
		var eTitle = null;
		var title = "";
		eTitle = document.getElementById("search_comp_feature_title");
		if (eTitle) {
			title = eTitle.innerHTML;
			if (title.length > 0) {
				tFound = true;
			}
		}

		if (!tFound) {
			eTitle = document.getElementById("eis_page_title");
			if (eTitle) {
				title = eTitle.innerHTML;
				if (title.length > 0) {
					tFound = true;
				}
			}
		}

		if (tFound) {
			var eUri = document.getElementById("uri");
			var citation = "";

			if (DCSext.CMEPage=='1') {
				ele = document.getElementById("search_author");
				if (ele) {
					citation = ele.innerHTML;
				}
			}
			else {
				var ele = document.getElementById("search_source");
				if (ele) {
					citation = ele.innerHTML + ' ';
				}
				ele = document.getElementById("search_disp_date");
				if (ele) {
					citation = citation + ele.innerHTML + ' ';
				}
				ele = document.getElementById("search_author");
				if (ele) {
					var author = ele.innerHTML;
					author = author.replace("&nbsp;", " ");
					if (author.indexOf(",")>-1) {
						citation = citation + author.substring(0,author.indexOf(",")) + ", et al";
					}
					else
						citation = citation + author;
				}
			}

			if (eUri) {
				var uri = eUri.value;
				xmlActionCount("/ActionCount", true, uri, title, "read", citation, getHasFlags(), getPublishDate());
			}
		}
	}
}

//Constants for has flags (use bitwise operators)
HF_ITEM_HAS_PDF			= 2;
HF_ITEM_HAS_VIDEO			= 4;
HF_ITEM_IS_CME			= 8;
HF_ITEM_IS_CE			= 16;

//Use bit flags to indicate what "things" the article "has"
function getHasFlags()
{
	var result = 0;
	
	if (checkHasPDF())
		result = result | HF_ITEM_HAS_PDF;
	
	if (checkHasVideo())
		result = result | HF_ITEM_HAS_VIDEO;
	
	if (checkIsCME())
		result = result | HF_ITEM_IS_CME;

	if (checkIsCE())
		result = result | HF_ITEM_IS_CE;

	return result;
}

//Check if the current page has a PDF
function checkHasPDF()
{
	var result = false;
	var links = document.links;
	var theLink;
	var i = 0;
	
	while (!result && (i < links.length))
	{
		theLink = links[i].href;
		if (typeof(theLink) != "undefined")
			result = (theLink.lastIndexOf(".pdf") == theLink.length - 4);
		
		i++;
	}
	
	return result;
}

//Check if the current page has a video
function checkHasVideo()
{
	var result = false;
	
	if (typeof(DCSext.VideoPage) != "undefined")
		result = (DCSext.VideoPage == '1');
	
	return result;
}

//Check if the current page is a CME
function checkIsCME()
{
	var result = false;
	
	if (document.getElementById('is_cme'))
		result = true;
	
	return result;
}

//Check if the current page is a CME
function checkIsCE()
{
	var result = false;
	
	if (document.getElementById('is_ce'))
		result = true;
	
	return result;
}

function getPublishDate()
{
	var result = "";
	var el = document.getElementById("search_sort_date");
	
	if (el)
	{
		result = el.innerHTML;
	
		//Date is in format YYYYMMDD with zero based month, convert to 1 based month
		var mth = Number(result.substr(4, 2)) + 1;
		if (mth < 10)
			mth = '0' + String(mth);
		else
			mth = String(mth);
		
		result = result.substr(0, 4) + mth + result.substr(6);
	}
	return result;
}

function actionDownloadCount() {
	var eComments = document.getElementById("comments_form");
	if (eComments) {
		var eUri = document.getElementById("uri");
		if (eUri) {
			var uri = eUri.value;
			xmlActionCount("/ActionCount", true, uri, "title", "download", "");
		}
	}
}

//Post an XML HTTP Request for AJAX
// This code was taken from common.css originally written by Will Price
function xmlActionCount(strURL, doAsynchronous, tcmuri, title, actionCount, citation, hasFlags, publishDate) 
{
	var xmlHttpReq = false;
	var self = this;
	
	//Check we should send the count
	if (isValidClientIP())
	{
		if (typeof(hasFlags) == "undefined")
			hasFlags = 0;
		if (typeof(publishDate) == "undefined")
			publishDate = "";
		
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
					self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
					self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, doAsynchronous);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
		//Do asynchronous request
		if (doAsynchronous)
		{
					self.xmlHttpReq.onreadystatechange = function() {
				if (self.xmlHttpReq.readyState == 4) {
					//updatePage(self.xmlHttpReq.responseText);
				}
			}
	
			//Set the current uri for setting comments when returned
			//currentTcmUri = tcmuri;
	
			//Compose and send the request string
			self.xmlHttpReq.send(setupCountQuery(tcmuri, title, actionCount, citation, hasFlags, publishDate));
	
		}
		//Return results on synchronous requests
		else
		{
					//Compose and send the request string
			self.xmlHttpReq.send(setupCountQuery(tcmuri, title, actionCount, citation, hasFlags, publishDate));
	
			return self.xmlHttpReq.responseText;
		}
	}
}

//Setup the Comment query to be sent to the server
function setupCountQuery(tcmuri, title, actionCount, citation, hasFlags, publishDate)
{
	//We will always have the action to be performed
	var result = "action=" + actionCount + "&uri=" + tcmuri + "&title=" + escape(title) + "&citation=" + 
		escape(citation) + "&has_flags=" + hasFlags + "&publish_date=" + publishDate;
	
	return result;
}
// *** End Tracking Most Read, Most Downloaded and Most Emailed Articles ***

function changeCTALinks () {
	var detailPage = document.getElementById("comments_form");
	if (detailPage) {
		for(var i=0; i<document.forms.length; i++){
			var onco_form= document.forms[i];
			var form_name= onco_form.name;
			var form_content= onco_form.innerHTML;
			if (form_name.indexOf("condCtrForm")!=-1) {
				if ((form_content.indexOf('Bladder')!=-1)) {
					//onco_form.action = '/cancer-types/bladder-cancer.html';
					onco_form.innerHTML = '<a href="/cancer-types/bladder-cancer.html"><strong>Bladder</strong></a>';
				} else if ((form_content.indexOf('Bone')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/bone-cancer.html"><strong>Bone</strong></a>';
				} else if ((form_content.indexOf('Breast')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/breast-cancer.html"><strong>Breast</strong></a>';
				} else if ((form_content.indexOf('CNS/Brain')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/cns-brain-cancer.html"><strong>CNS/Brain</strong></a>';
				} else if ((form_content.indexOf('Colon and Rectum')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/colon-and-rectum-cancer.html"><strong>Colon and Rectum</strong></a>';
				} else if ((form_content.indexOf('Endocrine System')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/endocrine-system-cancer.html"><strong>Endocrine System</strong></a>';
				} else if ((form_content.indexOf('Esophagus')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/esophagus-cancer.html"><strong>Esophagus</strong></a>';
				} else if ((form_content.indexOf('GYN (Non-Ovary)')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/gyn-non-ovary-cancer.html"><strong>GYN (Non-Ovary)</strong></a>';
				} else if ((form_content.indexOf('GYN (Ovary)')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/gyn-ovary-cancer.html"><strong>GYN (Ovary)</strong></a>';
				} else if ((form_content.indexOf('Head and Neck')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/head-and-neck-cancer.html"><strong>Head and Neck</strong></a>';
				} else if ((form_content.indexOf('HIV-Related Cancers')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/hiv-related-cancers.html"><strong>HIV-Related Cancers</strong></a>';
				} else if ((form_content.indexOf('Hodgkin')!=-1) && (form_content.indexOf('Non-')==-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/hodgkins-lymphoma.html"><strong>Hodgkin&#39;s Lymphoma</strong></a>';
				} else if ((form_content.indexOf('Kidney (Renal Cell)')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/kidney-renal-cell-cancer.html"><strong>Kidney (Renal Cell)</strong></a>';
				} else if ((form_content.indexOf('Leukemia')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/leukemia.html"><strong>Leukemia</strong></a>';
				} else if ((form_content.indexOf('Liver and Bile Duct')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/liver-and-bile-duct-cancer.html"><strong>Liver and Bile Duct</strong></a>';
				} else if ((form_content.indexOf('Lung')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/lung-cancer.html"><strong>Lung</strong></a>';
				} else if ((form_content.indexOf('Multiple Myeloma')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/multiple-myeloma.html"><strong>Multiple Myeloma</strong></a>';
				} else if ((form_content.indexOf('Myelodysplastic Syndrome')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/myelodysplastic-syndrome.html"><strong>Myelodysplastic Syndrome</strong></a>';
				} else if ((form_content.indexOf('Myeloproliferative Diseases')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/myeloproliferative-diseases.html"><strong>Myeloproliferative Diseases</strong></a>';
				} else if ((form_content.indexOf('Non-Hodgkin')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/non-hodgkins-lymphoma.html"><strong>Non-Hodgkin&#39;s Lymphoma</strong></a>';
				} else if ((form_content.indexOf('Pancreas')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/pancreas-cancer.html"><strong>Pancreas</strong></a>';
				} else if ((form_content.indexOf('Pediatric Cancers')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/pediatric-cancers.html"><strong>Pediatric Cancers</strong></a>';
				} else if ((form_content.indexOf('Prostate')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/prostate-cancer.html"><strong>Prostate</strong></a>';
				} else if ((form_content.indexOf('Rare Cancers')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/rare-cancers.html"><strong>Rare Cancers</strong></a>';
				} else if ((form_content.indexOf('Skin (Melanoma)')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/skin-melanoma-cancer.html"><strong>Skin (Melanoma)</strong></a>';
				} else if ((form_content.indexOf('Skin (Non-melanoma)')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/skin-non-melanoma-cancer.html"><strong>Skin (Non-Melanoma)</strong></a>';
				} else if ((form_content.indexOf('Soft Tissue Sarcoma')!=-1 || form_content.indexOf('Soft-Tissue Sarcoma')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/soft-tissue-sarcoma.html"><strong>Soft-Tissue Sarcoma</strong></a>';
				} else if ((form_content.indexOf('Stomach')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/stomach-cancer.html"><strong>Stomach</strong></a>';
				} else if ((form_content.indexOf('Testicle')!=-1)) {
					onco_form.innerHTML = '<a href="/cancer-types/testicle-cancer.html"><strong>Testicle</strong></a>';
				}
			} 
		}
	}
}

//Generate client side computer date
function getCalendarDate()
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   
   var days= new Array(7);
   days[0]= "Sunday";
   days[1]= "Monday";
   days[2]= "Tuesday";
   days[3]= "Wednesday";
   days[4]= "Thursday";
   days[5]= "Friday";
   days[6]= "Saturday";
   
   var now         = new Date();
   var daynumber= now.getDay();
   var day= days[daynumber];
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = day + ", "+ monthname +
                    ' ' +
                    monthday +
                    ', ' +
                    year;
   return dateString;
} // function getCalendarDate()

//generate Client side clock time
function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   = "0" + hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour +
                    ':' +
                    minute +
                    ':' +
                    second +
                    " " +
                    ap;
   return timeString;
} // function getClockTime()

//random header image rotator
function imageRotator(){
      var p = 2;
      var whichImage = Math.round(Math.random()*(p-1));
      var headerImage= document.getElementById("logo_image");
       headerImage.className = "logo"+whichImage ; 
} //function imageRotator()

//print years of option
function print_yr_option(start, end){
      document.write("<select><option>select a value</option>");
      for(var index=start; index<=end; index++){
                 document.write("<option value='"+index+"'>"+index+"</option>");
      }
      document.write("</select>");
} //function print_yr_option()

function textCounter(field,cntfield,maxlimit) {
     if (field.value.length > maxlimit) // if too long...trim it!
                field.value = field.value.substring(0, maxlimit);
      // otherwise, update 'characters left' counter
     else
                cntfield.value = maxlimit - field.value.length;
}

function changeOncologyProfessionCss(){
	updateCtrlsClass('0', 'hidden'); 

	updateCtrlsClass('Specialty_0_container', 'hidden');
    document.reg.Speciality_0.selectedIndex=0;
	
	updateCtrlsClass('Specialty_1_container', 'hidden');
                document.reg.Speciality_1.selectedIndex=0;
               
	updateCtrlsClass('Specialty_2_container', 'hidden');
                document.reg.Speciality_2.selectedIndex=0;
	
	updateCtrlsClass('practice_years_container', 'hidden'); 
                document.reg.Practice_Years.selectedIndex=0;
	
	updateCtrlsClass('physician_count_container', 'hidden'); 
                document.reg.Physician_count.selectedIndex=0;

	updateCtrlsClass('cancer_type_container', 'hidden');
                document.reg.Cancer_type.selectedIndex=0;

	//for the physician
	if(document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Physician'){
		updateCtrlsClass('Specialty_1_container', '');
		updateCtrlsClass('practice_years_container', ''); 
		updateCtrlsClass('physician_count_container', ''); 
	}else if(document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Fellow/Resident' ||
			document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Nurse' ||
			document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Nurse Practitioner' ||
			document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Pharmacist' ||
			document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Physician Assistant' ||
			document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Other Health Professional'){
		updateCtrlsClass('Specialty_1_container', '');
	}		
	else if(document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Faculty/Educator' || document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Student')
		updateCtrlsClass('Specialty_2_container', '');
	else if(document.reg.Profession.selectedIndex!=0){
		updateCtrlsClass('Specialty_0_container', '');
		document.reg.Speciality_0.selectedIndex=1;
	}
			

	updateCtrlsClass(document.reg.Profession.options[document.reg.Profession.selectedIndex].value, '');
}//show or hidden profession fields by change profession div css between hidden and show

function changeSpecialtyCss(){
     if(document.reg.Profession.options[document.reg.Profession.selectedIndex].value=='Physician'){
           if(document.reg.Speciality_1.options[document.reg.Speciality_1.selectedIndex].value=='Oncology, Hematology/Oncology' ||
		document.reg.Speciality_1.options[document.reg.Speciality_1.selectedIndex].value=='Oncology, Medical' ||
		document.reg.Speciality_1.options[document.reg.Speciality_1.selectedIndex].value=='Oncology, Other' ||
		document.reg.Speciality_1.options[document.reg.Speciality_1.selectedIndex].value=='Oncology, Radiation' ||
		document.reg.Speciality_1.options[document.reg.Speciality_1.selectedIndex].value=='Surgery, Surgical Oncology'){
		updateCtrlsClass('cancer_type_container', '');
		 document.reg.Cancer_type.selectedIndex=0;
           }else{
		updateCtrlsClass('cancer_type_container', 'hidden');
		document.reg.Cancer_type.selectedIndex=0;
          }
     }
}

function changeCountryCss(){
	if(document.reg.Country.options[document.reg.Country.selectedIndex].value=='United States'){
		updateCtrlsClass('State_container', '');
	}
	else{
		updateCtrlsClass('State_container', 'hidden');
		document.reg.State.selectedIndex=0;
	}
}

//unccheck subscription box if other country instead us is being selected
function uncheckSub(){
                var country= document.reg.Country.options[document.reg.Country.selectedIndex].value
                if(country == 'United States'){
                        for(var j=1; j<=4; j++){
                                box = eval("document.reg.Sub" + j);
                                box.checked = true;
                        }
                 }else{
                        for(var j=1; j<=4; j++){
                                box = eval("document.reg.Sub" + j);
                                box.checked = false;
                        }
                }
}  

function uncheckNewsletter(){
                for(var j=1; j<=20; j++){
                                box = eval("document.reg.Sub" + j);
		if(box)
		        box.checked = false;
                }
}

function uncheckOptoutBox(){
	document.reg.Optout.checked= false;
}


//function will truncate a textarea, set maxlength
function ismaxlength(obj)
{
	var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : 0
	var len = obj.value.length

	if (obj.getAttribute && len > mlength)
		obj.value=obj.value.substring(0, mlength)

	return Math.max(mlength - len, 0);
}                      

//This function updates the element with the passed ID
//  with the number of characters allowed to enter left
function maxLengthDisplay(obj, updID)
{
	var el = document.getElementById(updID);
	var val = String(ismaxlength(obj));

	if (el)
		el.innerHTML = val;
}            

//display hidden drop down menu
function display_pulldown(el) {
	//use radio button's value to identify which select menu to display
	var selectMenu;
	var selectContainers = document.getElementById(el.form.id).getElementsByTagName('div');
			
	//hide all select menu containers
	for (var i=0; i<selectContainers.length; i++) {
		if(cssjs('check',selectContainers[i],'showBlock')) {
			cssjs('swap',selectContainers[i],'showBlock','hidden');
		}
		else {
			cssjs('add',selectContainers[i],'hidden');
		}
	}

	var obj = document.getElementById(el.value + '_select');

	cssjs('swap',obj,'hidden','showBlock');
			
	// put focus on appropriate select menu;
	selectMenu = obj.getElementsByTagName('select');
	if (selectMenu.length >= 0) {
		selectMenu[0].focus();
	}
}      

function cssjs(a,o,c1,c2) {
	switch (a){
		case 'swap':
		o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
		break;

		case 'add':
		if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;

		case 'remove':
		var rep=o.className.match(' '+c1)?' '+c1:c1;
		o.className=o.className.replace(rep,'');
		break;

		case 'check':
		return new RegExp('\\b'+c1+'\\b').test(o.className)
		break;
	}
}

//show or hidden profession fields by change patient handout div css between hidden and show
function changeHandoutCss(displayDiv, hiddenDiv, hiddenOption){
                document.handout.HandoutConditions.selectedIndex=0;
                document.handout.HandoutTreatments.selectedIndex=0;
                updateCtrlsClass(displayDiv, '');
                updateCtrlsClass(hiddenDiv, 'hidden');          
}

function addJournal(el) {
	var srcParent = el.parentNode.previousSibling;
	var src;
	var srcClone;
	if (srcParent.nodeName.indexOf('#text') >= 0) {
		srcParent = srcParent.previousSibling;
		}
	src = srcParent.getElementsByTagName('div');
	srcClone = src[0].cloneNode(true);
	srcClone.getElementsByTagName('input')[0].value='';
	document.getElementById(srcParent.id).appendChild(srcClone);
	}

function removeJournal (el) {
	var divContainer = el.parentNode;
	var divAncestor = divContainer.parentNode;
	var coll = divAncestor.getElementsByTagName('div');
	if (coll.length > 1) {
		var deletedNode = divAncestor.removeChild(divContainer);
		}
	}

//Attempt to capture the article title from the div with "eis_page_title" ID
function getArticleTitle () 
{
	var elTitle = document.getElementById("eis_page_title");

	//Capture article title if possible, otherwise use page title
	if (elTitle)
		return cleanText(elTitle.innerHTML);
	else
		return document.title;
}

function clearGroup(el) {
	var parent = el.parentNode;
	var selector = 'field';
	var inputFields;
	while (String(parent.className) != 'field') {
		parent = parent.parentNode;
		}
	inputFields = parent.getElementsByTagName('input');
	for (var i=0; i<inputFields.length; i++) {
		if (inputFields[i].type == 'text') {
			inputFields[i].value = '';
			}
		if (inputFields[i].type == 'checkbox') {
			inputFields[i].checked = '';
			}
		}
	}

function displayDateRange(selectObj,containerEl) {
	var showDateRange = 'specific';
	var container = document.getElementById('date_range_group');
	if (String(selectObj.options[selectObj.selectedIndex].value) == showDateRange) {
		cssjs('add',container,'showBlock');
		}
	else {
		if(cssjs('check',container,'showBlock')) {
			cssjs('remove',container,'showBlock');
			}
		}
	}


//=========================================
// JavaScript Document
// BY: Michale Cai
// CREATED: October 13, 2006
// ABSTRACT: Contains javascript functions used with the "seven feature items" forms in EIS Platform

//Name of  component/date we want to retrieve information for
var dateRetrieve = "";
var weekClass= "";

//Update the week div class
function updateDayTabClass(dayCode)
{
               var days= new Array(7);
               days[0]= "sunday";
               days[1]= "monday";
               days[2]= "tuesday";
               days[3]= "wednesday";
               days[4]= "thursday";
               days[5]= "friday";
               days[6]= "saturday";
 
               var this_date= new Date();                                       
               var ctrl= document.getElementById("week");
                if(ctrl!=null)
	        ctrl.className = "current_day"+dayCode;
                this_date.setDate(this_date.getDate()- dayCode);

               var request_month= this_date.getMonth()+1;
               var request_year= this_date.getFullYear();
               var request_day= this_date.getDate();
               var request_day_number= this_date.getDay();

               if(request_day<10)
	        request_day= "0"+request_day;
               if(request_month<10)
                        request_month= "0"+request_month;
               dateRetrieve= request_day+"/"+request_month+"/"+request_year;

               //alert("dateRetrieve is "+ dateRetrieve);	   
                
	//update the div featureDate content
	var featureDate = document.getElementById("featureDate");
	var featureDate_content= getFeatureDate(request_day_number, request_day, request_month, request_year);
                //temporarily disable this dynamic function for show dynamic date in the feature seven items home page, may be used in the future
	//featureDate.innerHTML = "<span>"+featureDate_content+"</span>";
			   
	//Ajax request
	xmlHTTPRetrievePost("/FeatureSeven", "featuresweek");  
}

function RefreshServerDateTime()
{
	//Ajax request
	xmlHTTPRetrievePost("/ServerDateTime", "date");  
}

function updateDayTabClassWithServerTime(dayCode)
{
               dateRetrieve= dayCode;
	//Ajax request
	xmlHTTPRetrievePost("/FeatureSeven", "feature");  
}

//Show the featured items for the selected day
//Show the featured items for the selected day
function changeItems(dayCode)
{
     //code for web trends
     trackHomeFeature(dayCode);

     //client side time 
     //updateDayTabClass(dayCode); 

    //server side time
    updateDayTabClassWithServerTime(dayCode);
}

//function for Web trends track Feature Seven
function trackHomeFeature(dayCode){
      if (dayCode!=0) {
            dcsuri_ORIG = DCS.dcsuri;
            ti_ORIG=WT.ti;
            var dayDelta = "_Previous_Day(-"+dayCode+")"; 
            var fileName = DCS.dcsuri.substring(DCS.dcsuri.lastIndexOf("/")+1);
            fileName = fileName.replace(/\./,dayDelta+"\.");
            var pathNoFile = DCS.dcsuri.substring(0,DCS.dcsuri.lastIndexOf("/")+1);
            var datedURI = pathNoFile+fileName;
            dcsMultiTrack("DCS.dcssip",DCS.dcssip,"DCS.dcsuri",datedURI,"DCS.dcsqry",DCS.dcsqry,"WT.ti",WT.ti+dayDelta,"WT.ajax","1");
            WTajax="";
            DCS.dcsuri=dcsuri_ORIG;
            WT.ti=ti_ORIG;
     }
}

//when page landed, generate the class for the div week
function refreshItems()
{
             var dayCode="0";

              //For Client time, disable it
              //updateDayTabClass(dayCode);  
 
             // For server time
             updateDayTabClassWithServerTime(dayCode);
}

//Post an XML HTTP Request for AJAX
function xmlHTTPRetrievePost(strURL, divName) 
{
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            populateItems(self.xmlHttpReq.responseText, divName);
        }
    }
	
    //Compose and send the request string
    self.xmlHttpReq.send("forDate=" + dateRetrieve);
}

//Update the page according to results returned from the AJAX request
// This code was taken from common.css originally written by Will Price
function populateItems(strResult, divName)
{
    //var ctrl = document.getElementById("featuresweek");
    var ctrl = document.getElementById(divName);

    //alert("populate");    
    if (ctrl) 
          ctrl.innerHTML = strResult;         		
}


//Does load testing script fire client-side JS?
function doJSLoadTest() 
{
    var xmlHttpReq = false;
    var self = this;
    var strURL = "/Comment";

    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            populateItems(self.xmlHttpReq.responseText);
        }
    }
	
	//Compose and send the request string
    self.xmlHttpReq.send("commentAction=post&uri=tcm:13-435-64&comment=load_test_JS_fired" );
}

//Generate client side computer date
function getFeatureDate(request_day_number, request_day, request_month, request_year)
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   
   var days= new Array(7);
   days[0]= "Sunday";
   days[1]= "Monday";
   days[2]= "Tuesday";
   days[3]= "Wednesday";
   days[4]= "Thursday";
   days[5]= "Friday";
   days[6]= "Saturday";      

   var day= days[request_day_number];
   var monthname   = months[request_month-1];
   var dateString = day + ", "+ monthname +
                    ' ' +
                    request_day +
                    ', ' +
                    request_year;
   return dateString;
} // function getFeatureDate()

//This function print out the month name for Feature Seven Items
//Param Daycode passing from template page
function printMonth(dayCode){
      var months = new Array(13);
      months[0]  = "Jan";
     months[1]  = "Feb";
     months[2]  = "Mar";
     months[3]  = "Apr";
     months[4]  = "May";
     months[5]  = "Jun";
     months[6]  = "Jul";
     months[7]  = "Aug";
     months[8]  = "Sep";
     months[9]  = "Oct";
     months[10] = "Nov";
     months[11] = "Dec";

      var this_date= new Date();   
      this_date.setDate(this_date.getDate()- dayCode);
      var request_month= months[this_date.getMonth()];
      document.write(request_month);
}

//This function print out name of day for Feature Seven Items
function printDay(dayCode){
    var this_date= new Date();   
      this_date.setDate(this_date.getDate()- dayCode);
      var request_day= this_date.getDate();
      document.write(request_day);
} //fucntion printDay

function doClear(elementId)
{
	var el = document.getElementById(elementId);
	if ((el)  && (!focused))
	{
		focused = true;
		el.value = '';
	}
}

//*************Following code is for Gold standard Web Service Application

//Ajax Call for Web Service
function getSearchResult(strURL) 
{
    var searchString= document.getElementById("gsSearch").value;
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            populateContent(self.xmlHttpReq.responseText, "goldStandard_results");
        }
    }
	
    //Compose and send the request string
    self.xmlHttpReq.send("gsSearch=" + searchString);
 }

//Ajax Call for Web Service for getMonograph web service result
function getMonographWebService(strURL, divId, intCpnum) 
{
   //alert("I am here");    
    updateCtrlsClass('webservice', 'hidden');    
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            populateContent(self.xmlHttpReq.responseText, divId);
        }
    }

    //Compose and send the request string
    self.xmlHttpReq.send("intCpnum="+intCpnum);    
}

function populateContent(strResult, divId)
{
    var ctrl = document.getElementById(divId);
    //alert("populate");    
    if (ctrl) 
          ctrl.innerHTML = strResult;    
    updateCtrlsClass(divId, "");  		
}

function checkEnter(e){
        //literal character code will be stored in this variable
       var characterCode;
       if(e && e.which){ //if which property of event object is supported (NN4)
              e = e
              characterCode = e.which //character code is contained in NN4's which property
       }
       else{
              e = event
              characterCode = e.keyCode //character code is contained in IE's keyCode property
       }
        
       if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
               // Web Service Call
               getSearchResult('/GoldStandard');
               return true;
       }
}

var current_photo=0;
function getNextDrugPhoto(photo_length){
       if(current_photo<(photo_length-1)){

           var photo_pre= "photo"+ current_photo;
           var des_pre= "des"+ current_photo;
           updateCtrlsClass(photo_pre, "hidden");
           updateCtrlsClass(des_pre, "hidden");

           current_photo= current_photo+1;
           var photo_current= "photo"+ current_photo;
           var des_current= "des"+current_photo;
           updateCtrlsClass(photo_current, "");
           updateCtrlsClass(des_current, "");
           
       }else{
           current_photo= photo_length-1;
       }            
}

function getPreDrugPhoto(photo_length){
       if(current_photo>0){

           var photo_pre= "photo"+ current_photo;
           var des_pre= "des"+ current_photo;
           updateCtrlsClass(photo_pre, "hidden");
           updateCtrlsClass(des_pre, "hidden");

           current_photo= current_photo-1;
           var photo_current= "photo"+ current_photo;
           var des_current= "des"+current_photo;
           updateCtrlsClass(photo_current, "");
           updateCtrlsClass(des_current, "");
           
       }else{
           current_photo= 0;
       }            
}

//********************preview 7 Feature Items Javascript function**********************************
var preview_current=0;
function previewUpdateDayTabClass(dayCode)
{
               var days= new Array(7);
               days[0]= "sunday";
               days[1]= "monday";
               days[2]= "tuesday";
               days[3]= "wednesday";
               days[4]= "thursday";
               days[5]= "friday";
               days[6]= "saturday";
 
               var this_date= new Date(); 
               //alert("preview current is "+	preview_current);	   
			   this_date.setDate(this_date.getDate()+ preview_current);
               var ctrl= document.getElementById("week");
               if(ctrl!=null)
					ctrl.className = "current_day"+dayCode;
                this_date.setDate(this_date.getDate()- dayCode);

               var request_month= this_date.getMonth()+1;
               var request_year= this_date.getFullYear();
               var request_day= this_date.getDate();
               var request_day_number= this_date.getDay();

               if(request_day<10)
	        request_day= "0"+request_day;
               if(request_month<10)
                        request_month= "0"+request_month;
               dateRetrieve= request_day+"/"+request_month+"/"+request_year;

               //alert("dateRetrieve is "+ dateRetrieve);	   
                
	//update the div featureDate content
	var featureDate = document.getElementById("featureDate");
	var featureDate_content= getFeatureDate(request_day_number, request_day, request_month, request_year);
                //temporarily disable this dynamic function for show dynamic date in the feature seven items home page, may be used in the future
	//featureDate.innerHTML = "<span>"+featureDate_content+"</span>";
			   
	//Ajax request
	//xmlHTTPRetrievePost("/FeatureSeven");  
                xmlHTTPRetrievePost("/FeatureSeven", "featuresweek");  
}


//Show the featured items for the selected day
function previewChangeItems(dayCode)
{
                //client time
	previewUpdateDayTabClass(dayCode);	
}

function previewPrintMonth(dayCode){
      var months = new Array(13);
      months[0]  = "Jan";
     months[1]  = "Feb";
     months[2]  = "Mar";
     months[3]  = "Apr";
     months[4]  = "May";
     months[5]  = "Jun";
     months[6]  = "Jul";
     months[7]  = "Aug";
     months[8]  = "Sep";
     months[9]  = "Oct";
     months[10] = "Nov";
     months[11] = "Dec";
      var this_date= new Date(); 
	  this_date.setDate(this_date.getDate()+ preview_current);
      this_date.setDate(this_date.getDate()- dayCode);
      var request_month= months[this_date.getMonth()];
	  var preview_month = document.getElementById("month"+dayCode);
	  preview_month.innerHTML = "<span>"+request_month+"</span>";
      //document.write(request_month);
}

function previewPrintDay(dayCode){
    var this_date= new Date();  
     this_date.setDate(this_date.getDate()+ preview_current);	
      this_date.setDate(this_date.getDate()- dayCode);
      var request_day= this_date.getDate();
      var preview_day = document.getElementById("date"+dayCode);
      preview_day.innerHTML = request_day;
      //document.write(request_day);
}

function previewRefreshItems()
{
             //var dayCode="0";
              //previewUpdateDayTabClass(dayCode);      
			previewPrintMonth("0"); 
			previewPrintMonth("1"); 
			previewPrintMonth("2");
			previewPrintMonth("3");  
			previewPrintMonth("4"); 
			previewPrintMonth("5");
			previewPrintMonth("6");

            previewPrintDay("0");
			previewPrintDay("1");
			previewPrintDay("2");
			previewPrintDay("3");
			previewPrintDay("4");
			previewPrintDay("5");
			previewPrintDay("6");
}

//*******************end functions for preview 7 Feature Items javascript function***********************************

//code from Matt
function getStyle(obj, style){
	if(!document.getElementById) return;

	var obj = document.getElementById(obj);
	var value = obj.style[style];

	if(!value)
		if(document.defaultView)
			value = document.defaultView.
			getComputedStyle(obj, "").getPropertyValue(style);

		else if(obj.currentStyle)
			value = obj.currentStyle[style];

	return value;
}

/*CME Heading Toggle*/
function toggler(el) {
	var obj = $(el).up();
	var subsection = obj.next();

	if (obj && subsection && obj.hasClassName('minus')) {
		obj.removeClassName('minus');
		subsection.addClassName('hidden');
	}
	else {
		obj.addClassName('minus');
		subsection.removeClassName('hidden');
	}
	return false;
}

//toggle results
function toggleGs(dir) {
	var direction = dir;
	var gs_carousel = $('carousel');

	var gs_photo = $('carousel_photo');
	var gs_description = $('carousel_des');
	var gs_page = $('page_amt');

	var gs_photo_coll = gs_photo.getElementsByTagName("DIV");
	var gs_description_coll = gs_description.getElementsByTagName("DIV");
	var gs_page_coll = gs_page.getElementsByTagName("DIV");
	
	var current = -1;

	var nav_back = $('carousel_nav_back');
	var nav_fwd = $('carousel_nav_fwd');
	var nav_delim = $('carousel_nav_delim');

	//hide current visible elements, copy it's position in the array
	for (var i=0; i<gs_photo_coll.length; i++) {
		var photo_el = $(gs_photo_coll[i].id);
		var description_el = $(gs_description_coll[i].id);
		var page_el = $(gs_page_coll[i].id);
		if (getStyle(photo_el.id,'display').indexOf('block') > -1) {
			photo_el.style.display = 'none';
			description_el.style.display = 'none';
			page_el.style.display = 'none';
			current = i;
		}

	}
	
	// display next group of elements
	if (current > -1) {
		if (direction.indexOf('forward') > -1&& current < (gs_photo_coll.length-1)) {
			current+=1;
		}
		if (direction.indexOf('back') > -1 && current) {
			current-=1;
		}

		var photo_el = $(gs_photo_coll[current].id);
		var description_el = $(gs_description_coll[current].id);
		var page_el = $(gs_page_coll[current].id);
		photo_el.style.display = 'block';
		description_el.style.display = 'block';
		page_el.style.display = 'block';
		nav_back.style.visibility = 'visible';
		nav_delim.style.visibility = 'visible';
		nav_fwd.style.visibility = 'visible';

		if ((current > 0) && (current < gs_photo_coll.length-1)) {
			nav_back.style.visibility = 'visible';
			nav_delim.style.visibility = 'visible';
			nav_fwd.style.visibility = 'visible';
		}

		else if (current == 0) {
			nav_back.style.visibility = 'hidden';
			nav_delim.style.visibility = 'hidden';
		}

		else if (current == gs_photo_coll.length-1) {
			nav_fwd.style.visibility = 'hidden';
			nav_delim.style.visibility = 'hidden';
		}


	}

}

function panelOpen() {
	if(cssjs('check',document.getElementById('ipanel'),'ipanel_closed')) {
		cssjs('swap',document.getElementById('ipanel'),'ipanel_closed','ipanel_open');
		cssjs('swap',document.getElementById('ipanel_content'),'ipanel_content_narrow','ipanel_content_wide');
	}
}
	
function panelClose() {
	if(cssjs('check',document.getElementById('ipanel'),'ipanel_open')) {
		cssjs('swap',document.getElementById('ipanel'),'ipanel_open','ipanel_closed');
		cssjs('swap',document.getElementById('ipanel_content'),'ipanel_content_wide','ipanel_content_narrow');
	}
}

//displays main feature content section and sets tab states
function setMainfeature(el) {
	var amt = $$('#mainfeature .content');
	var lnkAmt = $$('#mainfeature_tabs a');
	var section;
	for (var i=0;i<lnkAmt.length;i++) {
		if (el == lnkAmt[i]) {
			section = i;
		}
	}

	for (var j=0;j<lnkAmt.length;j++) {
		if (j != section) {
			if (amt[j].hasClassName('showBlock')) {
				amt[j].removeClassName('showBlock');
				amt[j].addClassName('hidden');
			}
			if (lnkAmt[j].hasClassName('active')) {
				lnkAmt[j].removeClassName('active');
			}
		}
		else {
			amt[j].removeClassName('hidden');
			amt[j].addClassName('showBlock');
			lnkAmt[j].addClassName('active');
		}
	}
}


function resendReg(form){
	//document.ref_ref.reg_ref_url.value= window.location.pathname;
	var resendURL = getParameter('from');
	if (resendURL == null)
		resendURL = window.location.pathname;
	setTempCookie("reg_ref_url", resendURL);
	//alert("I am here");
	return true;
}

function setCurrentTab(tabnum) {
	document.getElementById('popular0'+tabnum).className='active'+tabnum;
	document.getElementById('pop'+tabnum).className='popular_content showBlock';
	for (var x = 1; x <= 3; x++)
   {
	   if(x!=tabnum)
	   {
		   document.getElementById('pop'+x).className='popular_content hidden';
	   }
   }
	
   if(tabnum==3){
	document.getElementById('popular02').className='separated2';
	document.getElementById('popular01').className='inactive1';
   }
   if(tabnum==2){
	document.getElementById('popular03').className='inactive3';
	document.getElementById('popular01').className='inactive1';
	}
   if(tabnum==1){
	document.getElementById('popular03').className='separated3';
	document.getElementById('popular02').className='inactive2';
	}
}

function showNav() {
	$('gnav').toggleClassName('cancertypes');
}
function showTab(obj) {
	selectedClass = $(obj).up(0).className.substring(0,$(obj).up(0).className.indexOf(' '));
	navList = $(obj).up(1).childElements();
	displayGroup = $(obj).up(2).childElements();
	for (i=1;i<displayGroup.length;i++){
		if(displayGroup[i].className.match(selectedClass)) {
			navList[i-1].addClassName('active');
			navList[i-1].removeClassName('inactive');
			displayGroup[i].addClassName('showBlock');
			displayGroup[i].removeClassName('h');
		}
		else {
			navList[i-1].addClassName('inactive');
			navList[i-1].removeClassName('active');
			displayGroup[i].addClassName('h');
			displayGroup[i].removeClassName('showBlock');
			}
	}
	
}

//end code from Matt

/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;
//end of SWFObject

// Remove Abstract Header where not needed
$j(document).ready(function() {
	var possibleAbstracts = $j(".largecolumn_container").children("p, .abstractcontent");

	var filledPCount = 0;

	possibleAbstracts.each(function() {
		if(!$j(this).hasClass("content")) {
			if($j(this).html() != '') {
				filledPCount++;
			}
		}
	});
	if(filledPCount == 0) {
		$j("h4.abstractheader").hide();
	}
});

// Expert Articles
$j(document).ready(function() {
	
	var minArticles = 5;
	var maxArticles = 20;
	var minHeight = 0;
	var maxHeight = 0;
                var container = $j('.expertProfileRecentPosts');
	var articles = $j('.expertProfilePost');
	var articlesContainer = $j('.expertProfilePostContainer');
	var readMore = $j('.readMoreExpertPosts');
	var readMoreContainer = $j('.readMoreExpertPostsContainer');
	
	// Remove Excess Articles
	if ($j(articles).length > maxArticles)
	{
		$j(articles).slice(maxArticles, $j(articles).length).each( function(i) 
			{
				
				$j(this).remove();
			}  
		);
		var articles = $j('.expertProfilePost');
	}
	
	if ($j(articles).length > minArticles)
	{
		// Get Closed Height
		$j('.expertProfilePost').slice(0,minArticles).each( function(i) 
			{
				minHeight += $j(this).outerHeight();
			}  
		);

		// Get Opened Height
		$j('.expertProfilePost').each( function(i) 
			{
				maxHeight += $j(this).outerHeight();
			}  
		);

		// Set Container Height
		$j(articlesContainer).height(minHeight);
		
		$j(readMore).click(function () {
			if($j(articlesContainer).hasClass("expanded")){
				$j(articlesContainer).stop();
				customCollapse($j(articlesContainer), minHeight, 'slow');
				$j(readMore).text("Read More");
			}
			else 
			{
				$j(articlesContainer).stop();
				customExpand($j(articlesContainer), maxHeight, 'slow');
				$j(readMore).text("Read Less");
			}
			$j(articlesContainer).toggleClass("expanded");
		});
	}
	else
	{
		$j(readMoreContainer).hide();
	}

               // Turn on container
               if (!$j(articles).length > 0)
               {
                    $j(container).hide();
               }
	
});

function customExpand(item, itemHeight, speed){
	$j(item).animate({height: itemHeight}, speed);
}

function customCollapse(item, itemHeight, speed){
	$j(item).animate({height: itemHeight}, speed);
}
