var wa = new Array('Sunday', 'Monday', 'Tuesday','Wednesday', 'Thursday', 'Friday', 'Saturday');
var ma = new Array('January', 'February', 'March','April', 'May','June', 'July', 'August', 'September','October', 'November', 'December');
var l=null,tl=null,loc=document.location.href,ahost='http://www.medicalpost.com';
function qc(url,n){
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc.replace('_off_','_on_');
//MM_swapImage('IT2_3','','/images/tabL_over.gif','IT4','','/images/tabR_over.gif',1)
if(l&&l.readyState!=0){l.abort()}l=vb();if(l){l.open("GET",url+ts(url),true);l.onreadystatechange=function(){if(l.readyState==4&&l.status==200){getEl("top_stories").innerHTML=l.responseText;}};l.send(null)}}
var qcn_obj = null;
function qcn(obj,url){
	if (!cEventsLoaded) {
		qcn_obj = obj;
		setTimeout("qcn(qcn_obj, '"+url+"');",100);
	}
	if(obj.style.fontWeight == 'bolder'){
		if(l&&l.readyState!=0){
			l.abort()
		}
		l=vb();
		if(l){
			l.open("GET",url+ts(url),true);
			l.onreadystatechange=function(){
				if(l.readyState==4&&l.status==200){
					if(l.responseText.indexOf('Content not found')==-1){
						getEl("calendar_news").innerHTML=l.responseText;
					}
				}
			};
			l.send(null);
		}
	} else {
		// construct local message
		var currM = parseInt(document.calForm.selMonth.value)
		var currY = parseInt(document.calForm.selYear.value)
		var currDate = new Date()
		currDate.setFullYear(currY)
		currDate.setMonth(currM)
		currDate.setDate(obj.innerHTML)
		var date = wa[currDate.getDay()]+' '+ma[currM]+' '+obj.innerHTML+', '+currY;
		var innerHTML = '<div class="date">'+date+'</div>';
			innerHTML += '<p>There are no events currently scheduled for this date.</p>';
			innerHTML += '<p>To submit an event for the calendar, please contact <A ';
			innerHTML += 'href="mailto:service@medicalpost.com">service@medicalpost.com</a>.';
		getEl("calendar_news").innerHTML = innerHTML;
//		alert('obj text = '+obj.innerText)
	}
}
function ts(l) {var ts='';if (document.all) {ts=l.indexOf('?')>0?'&':'?';ts+='ts='+(new Date()).valueOf();}return ts;}
function getEl(n){return (document.all)?document.all[n]:document.getElementById(n)}
function vb(){var C=null;try{C=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{C=new ActiveXObject("Microsoft.XMLHTTP")}catch(sc){C=null}}if(!C&&typeof XMLHttpRequest!="undefined"){C=new XMLHttpRequest()}return C}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validate(f){
	//var re_email=/^[a-zA-Z][\'\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/i;
	if(f.name=='Search' && f.Query.value != undefined && f.Query.value.search(/\w{2,}/)<0){
		return false;
	}
    /*
	if(f.name=='SignIn' && f.e.value != undefined  && f.e.value.search(re_email)<0){
		alert('To log in, please enter a valid email address.')
		return false;
	}
    */
	return f.submit();
}

function showMenu(menu) {
	if (MM_findObj(menu)) {
		MM_findObj(menu).style.visibility = 'visible';
		if (MM_findObj('searchcmbbox') && menu.indexOf('navMenu')>=0)
			MM_findObj('searchcmbbox').style.visibility = 'hidden';
            
		if (MM_findObj('leftnavad') && menu == 'navMenu3')
			MM_findObj('leftnavad').style.visibility = 'hidden';
	}
}

function hideMenu(menu) {
	if (MM_findObj(menu)) {
		MM_findObj(menu).style.visibility = 'hidden';
		if (MM_findObj('searchcmbbox') && menu.indexOf('navMenu')>=0)
			MM_findObj('searchcmbbox').style.visibility = 'visible';
		if (MM_findObj('leftnavad') && menu == 'navMenu3')
			MM_findObj('leftnavad').style.visibility = 'visible';
	}
}

var SelectedID = new Array();

function getNameAndImages(menuPrefix, imagePrefix, id, state){
	var ln,cn,rn;
	var lm,cm,rm;
	var side;
	var stateL, stateR;
	
	if (id==1) {
		ln = menuPrefix+'0_'+id;
		side = 'L';
		stateL = state;
	} else {
		ln = menuPrefix+(id-1)+'_'+id;
		side = 'R';
		stateR = state;
		
		if (SelectedID[menuPrefix] == (id-1)) {
			stateL = 'on';
		} else {
			stateL = 'off';
		}
	}
	var imageLeft = imagePrefix+side+(stateR?'':'1')+'_'+stateL+(stateR?'_n_'+stateR:'')+'.gif';
	
	cn = menuPrefix+id;
	var imageCenter = imagePrefix+'_bg_'+state+'.gif';
		

	side='R';
	if (rm = MM_findObj( menuPrefix+id+'_'+(id+1) )) {
		rn = menuPrefix+id+'_'+(id+1);
		stateL = state;
		if (SelectedID[menuPrefix] == (id+1)) {
			stateR = 'on';
		} else {
			stateR = 'off';
		}
	} else {
		rn = menuPrefix+(id)+'_0';
		stateL = state;
		stateR = 0;
	}
	var imageRight = imagePrefix+side+'_'+stateL+(stateR?'_n_'+stateR:'')+'.gif';
	
	var ret = new Array();
	ret[0]=ln;ret[1]=imageLeft;ret[2]=cn;ret[3]=imageCenter;ret[4]=rn;ret[5]=imageRight;

	//alert(ret[0]+ret[1]+ret[2]+ret[3]+ret[4]+ret[5]);

	return ret;
}

function navOver(menuPrefix, imagePrefix, id) {
	var i;
	var menu = getNameAndImages(menuPrefix, imagePrefix, id, 'over');
	
	for (i=0;i<(menu.length-1);i+=2) {
		var obj = MM_findObj(menu[i]+'');
		if (obj) {
			obj.style.backgroundImage = 'url('+menu[i+1]+')';
		}
	}
	//if (MM_findObj(menuPrefix+"Menu"+id)) {
		//showMenu(MM_findObj(menuPrefix+"Menu"+id));
		showMenu(menuPrefix+"Menu"+id);
	//}
}

function navOut(menuPrefix, imagePrefix, id) {
	var i;
	var state;
	if (SelectedID[menuPrefix] == id) {
		state = 'on';
	} else {
		state = 'off';
	}
	
	var menu = getNameAndImages(menuPrefix, imagePrefix, id, state);
	
	for (i=0;i<(menu.length-1);i+=2) {
		var obj = MM_findObj(menu[i]+'');
		if (obj) {
			obj.style.backgroundImage = 'url('+menu[i+1]+')';
		}
	}
	
	//if (MM_findObj(menuPrefix+"Menu"+id)) {
		//hideMenu(MM_findObj(menuPrefix+"Menu"+id));
		hideMenu(menuPrefix+"Menu"+id);
	//}
}

function navClick(menuPrefix, imagePrefix, id) {
	var i;
	var oldSelectedID = SelectedID[menuPrefix];

	// Update selected ID
	SelectedID[menuPrefix]=id;

	var oldmenu = getNameAndImages(menuPrefix, imagePrefix, oldSelectedID, 'off');
	var menu = getNameAndImages(menuPrefix, imagePrefix, id, 'on');
	
	// Undo the selected ID
	for (i=0;i<(oldmenu.length-1);i+=2) {
		var obj = MM_findObj(oldmenu[i]+'');
		if (obj) {
			obj.style.backgroundImage = 'url('+oldmenu[i+1]+')';
		}
	}	
	

	for (i=0;i<(menu.length-1);i+=2) {
		var obj = MM_findObj(menu[i]+'');
		if (obj) {
			obj.style.backgroundImage = 'url('+menu[i+1]+')';
		}
	}
	
}

function navPageDetect() {
	if (loc.indexOf('/news/') != -1)
		navClick('nav','/images/tab',2);
	else if (loc.indexOf('/opinions/') != -1)
		navClick('nav','/images/tab',3);
	else if (loc.indexOf('/medicine/') != -1)
		navClick('nav','/images/tab',4);
	else if (loc.indexOf('/life/') != -1)
		navClick('nav','/images/tab',5);
	else if (loc.indexOf('patientcare') != -1)
		navClick('nav','/images/tab',6);
/*	else if (loc.indexOf('/bulletin/') != -1)
		navClick('nav','/images/tab',7);*/
	else if (loc.indexOf('/contact/') != -1)
		navClick('R','/images/right_tab',1);
	else if (loc.indexOf('/classifieds/') != -1)
		navClick('R','/images/right_tab',2);
/*	else if (loc.indexOf('/help/') != -1)
		navClick('R','/images/right_tab',3);*/
	else 
		navClick('nav',ahost+'/images/tab',1);
}

function printPopup(){
	var l='/shared/print.jsp'+loc.split("article.jsp")[1]
	window.open(l, "print", 'width=600,height=680,resizable=1,location=0,top=0,left=0,scrollbar=0,scrollbars=yes');
}

function emailPopup(){
	var l='/shared/email.jsp?loc='+escape(loc)+'&content='+document.location.search.split("content=")[1]
	window.open(l, "Email", 'width=468,height=560,resizable=0,location=0,top=0,left=0,scrollbar=0,scrollbars=no, address=no, menu=no');
}
function showDate() {
	var d=new Date(),m=ma[d.getMonth()],w=wa[d.getDay()],dy=d.getDate(),hr=d.getHours(),mnt=d.getMinutes()
	if(dy<10)dy='0'+dy
	if(hr<10)hr='0'+hr
	if(mnt<10)mnt='0'+mnt
	document.write(w+' '+m+' '+dy+', '+' '+d.getFullYear()+' | '+hr+':'+mnt);
}
function show_msg(s) {
	if(s=='template') s='Template letters, forms, worksheets, guides and talking points. Use these templates to manage your communication and relationships with clients and prospects quickly and easily.  Each template can be downloaded as a Word document so that you can customize it for use in your practice.'
	else if(s=='morningstar') s='A comprehensive set of tools that let you research, compare and analyze investment funds.'
	else if(s=='client_education') s='Do you want to help your clients learn more about investing?  From brochures to interactive online tools, the Canadian Securities Administrators, the Ontario Securities Commission and the Investor Education Fund have a number of tools to help educate your clients about the securities industry, investor protection and other investing basics.'
	else if(s=='tax_form') s='Medicalpost.com has dug into the CRA site to retrieve and label the downloadable forms for individual federal and provincial income taxes - including the professional and business income forms for those who have to declare self-employment earnings. Also included are links to other information such as tax guides and worksheets.'
	else if(s=='industry_links') s='Looking for the web sites of various industry resources? Medicalpost.com has gathered the site links to numerous financial services industry organizations in one convenient location. We\'ve got links to professional and industry associations, regulators and educational institutions. '
	else if(s=='default') s= 'From template letters to tax forms, Medicalpost.com has the tools you need to help you manage your business easily and efficiently. Simply click one of the icons above to start using these valuable tools in your practice today.'
	getEl("tools_desc").innerHTML=s
}
/*
function hp_top_stories() {
	var show_tab=Math.random()
	var show_file='INVESTMENTS_INSURANCE'
	var tab_id='tab_insurance'
	if(show_tab<0.3){show_tab=2;show_file='INVESTMENTS';tab_id='tab_investment'
	}else if(show_tab>0.4){show_tab=1;show_file='PRACTICE';tab_id='tab_practice'
	}else{show_tab=3}
	navClick('IT','/images/tab',show_tab)
	qc('/content/HOMEPAGE/TOP/3/'+show_file+'_ARCHIVE.jsp',tab_id)
}*/
function hp_top_stories()
{
	var show_tab=Math.random()
	var show_file='LIFE'
	var tab_id='tab_life'
	if(show_tab<0.3){show_tab=2;show_file='MEDICINE';tab_id='tab_medicine'
	}else if(show_tab>0.4){show_tab=1;show_file='OPINIONS';tab_id='tab_opinions'
	}else{show_tab=3}
	navClick('IT','/images/tab',show_tab)
	//qc('/content/'+show_file+'/TOP/5/'+show_file+'_ARCHIVE_TOP_3.jsp',tab_id)
	if(show_file == 'LIFE')
	{
		qc('/content/'+show_file+'/TOP/10/'+show_file+'_ARCHIVE_TOP_3.jsp',tab_id)
	}
	else
	{
		qc('/content/'+show_file+'/TOP/5/'+show_file+'_ARCHIVE_TOP_3.jsp',tab_id)
	}
}
function maxDays(mm, yyyy){	var mDay;
	if((mm == 3) || (mm == 5) || (mm == 8) || (mm == 10)) mDay = 30;
	else { mDay = 31;
		if(mm == 1) {
			if (yyyy/4 - parseInt(yyyy/4) != 0) mDay = 28;
	   		else mDay = 29;
		}
	}
return mDay;
}
function maxDays(mm, yyyy){
var mDay;
	if((mm == 3) || (mm == 5) || (mm == 8) || (mm == 10)){
		mDay = 30;
  	}
  	else{
  		mDay = 31
  		if(mm == 1){
   			if (yyyy/4 - parseInt(yyyy/4) != 0){
   				mDay = 28
   			}
		   	else{
   				mDay = 29
  			}
		}
  }
return mDay;
}

var cStarted = false;
var cLastDiv = null;
var cLastDivClass = null;
var cEventDay = new Array();
var cEventsLoaded = false;
function changeBg(id){
	//alert('ID: '+id+', Old ID: '+cLastDiv);
	if (id == cLastDiv) return;	// Selecting the same one

	// Revert old one
	if (cLastDiv) {
		MM_findObj(cLastDiv).className = cLastDivClass;
	}
	
	// Record last
	cLastDiv = id;
	cLastDivClass = MM_findObj(id).className;

	// Make change
	MM_findObj(id).className = "cselected";
}
function selectDay(day, month, year){
	for(var i=0;i<=41;i++) {
		date = MM_findObj('spd'+i).innerHTML;
		if (  date == day && (!( ((i<7)&&(date>20)) || ((i>27)&&(date<20)) ))  ) {
			if (i == cLastDiv) return;	// Selecting the same one

			//alert('Day '+day+' = ID'+i);
			// Revert old one
			if (cLastDiv) {
				MM_findObj(cLastDiv).className = cLastDivClass;
			}
			
			// Record last
			cLastDiv = 'spd'+i;
			cLastDivClass = MM_findObj('spd'+i).className;
		
			// Make change
			MM_findObj('spd'+i).className = "cselected";
			
			qcn(MM_findObj('spd'+i),"/homepage/dailynews.jsp?date="+year+doubleDigits(month)+doubleDigits(day));
			return;
		}
	}
	//alert('ID: '+id+', Old ID: '+cLastDiv);

}
function changeCal(){
var now = new Date
var dd = now.getDate()
var mm = now.getMonth()
var dow = now.getDay()
var yyyy = now.getFullYear()
var currM = parseInt(document.calForm.selMonth.value)
var prevM
	if (currM!=0){
		prevM = currM - 1
	}
	else{
		prevM = 11
	}
var currY = parseInt(document.calForm.selYear.value)
var mmyyyy = new Date()
mmyyyy.setFullYear(currY)
mmyyyy.setMonth(currM)
mmyyyy.setDate(1)
var day1 = mmyyyy.getDay()
	if (day1 == 0){
		day1 = 7
	}
var arrN = new Array(41)
var aa
	for (ii=0;ii<day1;ii++){
		arrN[ii] = maxDays((prevM),currY) - day1 + ii + 1
	}
	aa = 1
	for (ii=day1;ii<=day1+maxDays(currM,currY)-1;ii++){
		arrN[ii] = aa
		aa += 1
	}
	aa = 1
	for (ii=day1+maxDays(currM,currY);ii<=41;ii++){
		arrN[ii] = aa
		aa += 1
	}
	/*
	for (ii=0;ii<=41;ii++){
		MM_findObj("sp"+ii).style.backgroundColor = "#FFFFFF"
	}*/
var dCount = 0
	cLastDiv=null;
	cLastDivClass=null;

	for (ii=0;ii<=41;ii++){
		if ( ((ii<7)&&(arrN[ii]>20)) || ((ii>27)&&(arrN[ii]<20)) ){
			var year;
			var month;
			if ((ii<7)&&(arrN[ii]>20)) {	// Previous Month
				if (currM==0) {	// If January, then previous year
					year = currY - 1;
					month = 12;
				} else {
					year = currY;
					month = currM;
				}
			} else if ((ii>27)&&(arrN[ii]<20)) {	// Next Month
				if (currM==11) {	// If December, then previous year
					year = currY + 1;
					month = 1;
				} else {
					year = currY;
					month = currM + 2;
				}
			} else {
				year = currY;
				month = currM + 1;
			}
			
			var isMonthNow = false;
			if ( (mm==(month-1))&&(yyyy==year) ) {
				isMonthNow = true;
			}
			MM_findObj("sp"+ii).innerHTML = "<a id='spd"+ii+"' onClick='outsideCalendarClick("+arrN[ii]+","+month+","+year+","+isMonthNow+");'>"+arrN[ii]+"</a>"
			MM_findObj("spd"+ii).className = "c3"
		}
		else{
			var year = currY;
			var month = currM+1;
			MM_findObj("sp"+ii).innerHTML = "<a id='spd"+ii+"' onClick='changeBg(\"spd"+ii+"\");qcn(this,\"/homepage/dailynews.jsp?date="+year+doubleDigits(month)+doubleDigits(arrN[ii])+"\");'>"+arrN[ii]+"</a>"
			MM_findObj("spd"+ii).style.fontWeight = 'normal';
			//MM_findObj("sp"+ii).style.backgroundColor=""
			if ((arrN[ii]==dd)&&(mm==currM)&&(yyyy==currY)){
				MM_findObj("spd"+ii).className = "ctoday"
				//MM_findObj("sp"+ii).style.backgroundColor="#90EE90"
			}else if ((dCount==0)||(dCount==6)){
				MM_findObj("spd"+ii).className = "c2"
			}else{
				MM_findObj("spd"+ii).className = "c1"
			}
			
			if ( (arrN[ii]==dd)&&(mm==currM)&&(yyyy==currY) ) {
				if (!cStarted) {
					changeBg("spd"+ii);
				}
			}
		}
		dCount += 1
		if (dCount>6){
			dCount=0
		}
	}

	cEventsLoaded = false;
	if(tl&&tl.readyState!=0){tl.abort()}
	tl=vb();
	if(tl){
		currM = (currM+1)+'';		// Convert to string
		var urlmonth = ((currM<10)?'0':'')+currM;
		tl.open("GET","/homepage/getEvents.jsp?date="+currY+urlmonth,true);
		tl.onreadystatechange=function(){
			if(tl.readyState==4&&tl.status==200){
				var events=','+tl.responseText.replace(/\W/,'');
				for (ii=0;ii<=41;ii++){
					// Within month
					if (!( ((ii<7)&&(arrN[ii]>20)) || ((ii>27)&&(arrN[ii]<20)) )){
						if (events.indexOf(','+arrN[ii]+',')>-1) {
							MM_findObj("spd"+ii).style.fontWeight = 'bolder';
						}
					}
				}
				cEventsLoaded = true;
			}
		};
		tl.send(null);
	}
	cStarted = true;
}
function outsideCalendarClick(day, month, year, isMonthNow) {
	document.calForm.selMonth.selectedIndex=(month-1);
	document.calForm.selYear.value=year;
	changeCal();
	if (isMonthNow) {
		//cLastDiv=null;
		cLastDivClass="c1";
	}
	selectDay(day, month, year);
}
function writeCalendar(){
var now = new Date
var dd = now.getDate()
var mm = now.getMonth()
var dow = now.getDay()
var yyyy = now.getFullYear()
var arrM = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var arrY = new Array()
	for (ii=0;ii<=4;ii++){
		arrY[ii] = yyyy - 2 + ii
	}
var arrD = new Array("S","M","T","W","T","F","S")

var text = ""
text = "<form name=calForm>"
text += "<table border=0 cellspacing=\"1\" cellpadding=\"0\">"
text += "<tr><td>"
text += "<table width=100% border=0 cellspacing=\"1\" cellpadding=\"0\"><tr>"
text += "<td align=left>"
text += "<select name=selMonth style=\"border:1px solid #ccddff;\" onChange='changeCal()'>"
	for (ii=0;ii<=11;ii++){
		if (ii==mm){
			text += "<option value= " + ii + " Selected>" + arrM[ii] + "</option>"
		}
		else{
			text += "<option value= " + ii + ">" + arrM[ii] + "</option>"
		}
	}
text += "</select>"
text += "</td>"
text += "<td align=right>"
text += "<select name=selYear style=\"border:1px solid #ccddff;\" onChange='changeCal()'>"
	for (ii=0;ii<=4;ii++){
		if (ii==2){
			text += "<option value= " + arrY[ii] + " Selected>" + arrY[ii] + "</option>"
		}
		else{
			text += "<option value= " + arrY[ii] + ">" + arrY[ii] + "</option>"
		}
	}
text += "</select>"
text += "</td>"
text += "</tr></table>"
text += "</td></tr>"
text += "<tr><td>"
text += "<table border=0 cellspacing=\"1\" cellpadding=\"0\" style=\"border: 1px solid #000000;\">"
text += "<tr>"
	for (ii=0;ii<=6;ii++){
		text += "<td align=center><span class=label>" + arrD[ii] + "</span></td>"
	}
text += "</tr>"
aa = 0
	for (kk=0;kk<=5;kk++){
		text += "<tr>"
		for (ii=0;ii<=6;ii++){
			text += "<td align=center><span id='sp" + aa + "'>1</span></td>"
			aa += 1
		}
		text += "</tr>"
	}
text += "</table>";
text += "</td></tr>";
text += "</table>";
text += "</form>";
document.write(text);
changeCal();
}

function writePageNumber(num){
	var subNum=loc.substring(loc.indexOf('page='));
	if(num>1){
		document.write('<p align="center" class="page">PAGE:');
		for(var i=1;i<=num;i++){
			if((("page="+i)==subNum) || loc.indexOf('page=')==-1 && i==1){
				document.write('&nbsp;&nbsp;<span class="pageOn">'+i+'</span>');
			}else{
				document.write('&nbsp; <a href="'+loc.replace(/&page=\d+/,'')+'&page='+i+'">'+i+'</a>');
			}
		}
		document.write('</p>');
	}
}
/*
function checkSelected(num){
	if(num < 0) {num=3} 
	var found=0,i=0,sf=getEl('searchcmbbox');qry=document.location.search
	for(i;i<sf.options.length;i++){
		if(qry.indexOf(sf.options[i].value)>0){sf.selectedIndex=i;found=1}
	}
	if(found==0){sf.selectedIndex=num}
}
*/
function getCookie(n){
	var c,i=0,eq=n+'=',ca=document.cookie.split(';');
	for(i;i<ca.length;i++){
		c = ca[i];
		while(c.charAt(0)==' ') c=c.substring(1,c.length);
		if (c.indexOf(eq)==0) return c.substring(eq.length,c.length);
	}
	return '';
}

function setCookie(n,v,days){
  var ex='',xd=new Date();
  days=isNaN(days)?0:days;
  days=(days==0)?999:days;
  xd.setTime(xd.getTime()+days*24*60*60*1000);
  ex='; expires='+xd.toGMTString();
	document.cookie=n+'='+v+ex+'; path=/';
}
/*
function loginCheck(url){
	var ca=unescape(getCookie('ext')).split('|')
	if(ca[1] != undefined && ca[1].length>1){
		document.write('<td width="288">&nbsp;&nbsp;&nbsp;&nbsp;Welcome '+ca[1]+', you are logged in. </td>')
		document.write('<td width="55"><a href="http://members.medicalpost.com/umsSignOut.jsp?p=100002"><img src="'+ahost+'/images/BTN_logout.gif" border="0"></a></td>')
		document.write('<td width="89"><a href="http://members.medicalpost.com/advisor_ca/profile.jsp"><img src="'+ahost+'/images/BTN_updateProfile.gif" border="0"></a></td>')
	} else {
		if(loc.indexOf('http://members.medicalpost.com/advisor_ca/')>-1){
			document.write('<td width="432" align="right"><a href="http://members.medicalpost.com/advisor_ca/profile.jsp"><img src="'+ahost+'/images/BTN_updateProfile.gif" border="0"></a></td>')
		} else {
			document.write('<td width="40"> <div align="right">login:&nbsp;</div></td>')
			document.write('<td width="120"> <form name="SignIn" method="post" action="http://members.medicalpost.com/umsSignIn.jsp" onsubmit="validate(this)"><input name="e" type="text" value="email address" size="16" onfocus="if(this.value == \'email address\')this.value=\'\'"> ')
			document.write('	<input type="hidden" name="t" value="http://www.medicalpost.com">')
			document.write('	<input type="hidden" name="p" value="100002">')
			document.write('	<input type="hidden" name="x" value="2,6,8,300102,300103,20,21,22,300105">')
			document.write('</td>')
			document.write('<td width="120"> <input type="password" name="w" value="Password" size="16" onfocus="if(this.value == \'Password\')this.value=\'\'">')
			document.write('</td></form>')
			document.write('<td width="76"><img src="'+ahost+'/images/go.gif" width="22" height="23" border="0" onclick="validate(document.SignIn)"></a></td>')
			document.write('<td width="76"><a href="http://members.medicalpost.com/advisor_ca/signup.jsp"><img src="'+ahost+'/images/BTN_register.gif" border="0"></a></td>')
		}
	}
}
*/
/** popup window in the home page */
function openpopup(popBig,popSmall){
	if (loc.indexOf(ahost) == 0){
		var popurl=loc.substr(0,ahost.length);
		var feaures='scrollbars=,resizable=,fullscreen=';
		if (popBig && !getCookie('popupbig') && !getCookie('ppb')){
			setCookie('popupbig','yes',7)
			document.cookie='ppb=y;';
			winpops=window.open(popurl+"/content/SHARED/BIG_POP_UP_CONTENT.jsp","MedicalPost_Ad_Popup",feaures+'yes');
		} else if (popSmall && !getCookie('popupsmall') && !getCookie('ppb')){
			feaures='width=600,height=400,resizable=yes,menubar=no,location=no,toolbar=no,status=no,scrollbars=yes';
			setCookie('popupsmall','yes',7);
			winpops=window.open(popurl+'/content/SHARED/SMALL_POP_UP_CONTENT.jsp','MedicalPost_Ad_Popup',feaures);
		}
	}
}

// Dynamic Article Font Size (dafs)
var dafs_collected = new Array();
var dafs_collection = new Array();
var dafs_cFontSize = new Array();
var dafs_startCollect = false;
//var dafs_level = 0;
var dafs_index = new Array();
//var debug_code_buffer = '';
function dafs_collectArray(array_name, startobj) {
	if (!startobj || startobj == undefined) return;	// Error handling
	if (startobj.className == 'regularcontentTitle') dafs_startCollect = true;
	// Match
	if (dafs_startCollect
		&& startobj.nodeName.indexOf('#text')>-1) {
		if (!dafs_exist(array_name,startobj.parentNode)) {	// Make sure only one exist
			dafs_collection[array_name].push(startobj.parentNode);
		}
	}
	// Skip/Ignore the following nodes
	// - Skip images <img>
	// - Skip line fedds <br>
	// - Skip horizontal rulers <hr>
	// - Skip scripts <script>
	// - Skip selection boxes <select>
	///debug_code_buffer += startobj.nodeName+'/t';
	if (startobj.nodeName.toLowerCase() == 'img'
		|| startobj.nodeName.toLowerCase() == 'br'
		|| startobj.nodeName.toLowerCase() == 'hr'
		|| startobj.nodeName.toLowerCase() == 'script'
		|| startobj.nodeName.toLowerCase() == 'select') {
		return;
	}
	
	// Loop through children
	//dafs_level++;
	if (startobj.childNodes.length>0) {
		for (var i=0;i<startobj.childNodes.length;i++) {
			//alert (dafs_level+') '+startobj.nodeName+'['+(i+1)+'/'+startobj.childNodes.length+'] - '+startobj.childNodes[i].nodeName+":\n"+startobj.childNodes[i].innerHTML);
			dafs_collectArray(array_name, startobj.childNodes[i]);
		}
	}
	//dafs_level--;
	//alert ('Closed '+startobj.nodeName+', level now '+dafs_level);
}
function dafs_exist(name, obj) {
	// Loop backwards, most likely the last element of the array is the one that returns true.
	for (var i=dafs_collection[name].length;i>=0;i--) {	
		if (dafs_collection[name][i] == obj) {
			return true;
		}
	}
	return false;
}
function dafs_getSize(obj) {
	if (obj.className == 'author') {
		return 10;
	} else if(obj.className == 'regularcontentTitle') {
		return 12;
	} else if(obj.className == 'date') {
		return 10;
	} else if(obj.nodeName.toLowerCase() == 'p') {
		return 11;
	} else if(obj.nodeName.toLowerCase() == 'a') {
		return 11;
	} else {
		return 11;
	}
}
function changeArticleFontSize(sizeChange, name) {
	if (!dafs_collected[name]) {
		var startobj = MM_findObj(name);
		if (!startobj) return;
		if (!dafs_collection[name]) dafs_collection[name] = new Array();
		dafs_collectArray(name, startobj);
		
		//Record the size of each element
		if (!dafs_cFontSize[name]) dafs_cFontSize[name] = new Array();
		for (i=0;i<dafs_collection[name].length;i++) {
			dafs_cFontSize[name][i] = dafs_getSize(dafs_collection[name][i]);
		}
		dafs_collected[name] = true;
	}
	
	//Change size of font
	for (i=0;i<dafs_collection[name].length;i++) {
		dafs_collection[name][i].style.fontSize = dafs_cFontSize[name][i] + sizeChange + 'px';
	}
	setCookie('ArticleTextSize',sizeChange,365);
}
var fontsizechange = 0;
function increaseFontSize(name) {
	fontsizechange += 2;
	changeArticleFontSize(fontsizechange, name);
}
function decreaseFontSize(name) {
	fontsizechange -= 2;
	changeArticleFontSize(fontsizechange, name);
}
function normalFontSize(name) {
	fontsizechange = 0;
	changeArticleFontSize(fontsizechange, name);
}
function doubleDigits(d) {
	return d > 9 ? d : '0'+d
}


///////////////////////////////////////SHOWZONE/////////////////////////////////
var ZONE_EDIT_URL = "http://rciesncma/iw/webdesk/edit";
var MEDICALPOST_VPATH = "?vpath=/default/main/media/publishing/medicalpost_com/dev/WORKAREA/common/iw-web";
var ZONE_VPATH = MEDICALPOST_VPATH.substring(1, MEDICALPOST_VPATH.length);
var SHOWZONE_HREF = ZONE_EDIT_URL + MEDICALPOST_VPATH;
/*	example invokations:
 printShowzoneBegin("/content/SECTION/SUBSECTION/SECTION_SUBSECTION_MAIN.jsp", "SECTION_SUBSECTION_MAIN", "Article")
 printShowzoneBegin("/content/SECTION/SUBSECTION/SECTION_SUBSECTION_MAIN.jsp")
 printShowzoneBegin("/content/SECTION/SUBSECTION/SECTION_SUBSECTION_MAIN.jsp", "", "Article")

	Print out the beginning part of the showzone content to the document. Can be invoked with:
1. At the least the ContentPath in which case the function, appends this to the SHOWZONE_HREF, and ContentPath is used
	as the DisplayPath.
2. The ContentPath, the DisplayPath and the ZoneType, in which case ContentPath is appended to
	the SHOWZONE_HREF, while DisplayPath is used as the display link and the ZoneType is used to
	print out an explanatory message about what type of zone is being published to.
3. The ContentPath, a blank DisplayPath and a ZonePath, this will work the same as 2, except the blank DisplayPath
	will be replaced with ContentPath, i.e. ContentPath will be used as the DisplayPath.
*/
function printShowzoneBegin()
{
	if(arguments.length == 0)
		return;
	else
	{
		var contentPath = arguments[0];
		var zoneLabel = (arguments.length >= 2)?((arguments[1]=="")?contentPath:arguments[1]):contentPath;
		var dcrType = (arguments.length == 3)?arguments[2]:"";
		document.write();
		document.write('<table border="1"><tr><td bgcolor="yellow" class="showzonefont"><a href="'+SHOWZONE_HREF+contentPath+'">'+zoneLabel+'</a>');
		if(dcrType != "")
		{
			document.write('<div class="showzonefont">::::: DCR type is <font color="#FF0000">'+dcrType+'</font></div>');
		}
		document.write('</td></tr><tr><td>');
	}
}
function printShowzoneEnd()
{
		document.write('</td></tr></table>');
}
function getShowzoneHref()
{
	if(arguments.length != 0)
		return SHOWZONE_HREF + arguments[0];
	else
		return SHOWZONE_HREF;
}
function getZoneEditPath()
{
	return ZONE_EDIT_URL;
}
function getZoneVpath()
{
	return ZONE_VPATH;
}

