// <script language=javascript> 
// <!--
function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset);  if (endstr == -1) endstr = document.cookie.length;  return unescape(document.cookie.substring(offset, endstr));}
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) {var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break;} return null;}
function SetCookie (name, value) {var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");}
function wr(val){return document.write(val)}
sep='~';pt='qqqq';loop='yyyy';splt='zzzz'; // defined delims to be used
rview=0
/* Last 3 viewed : Company Profiles, Business News, Industry Reports */
/* hypothetical view list cookie value - add from at first, last is oldest
last_views=sep+"comp_ids"+pt+loop+"0000559956"+splt+"Title1"+loop+"0001146692"+splt+"Title2"+loop+"0000955652"+splt+"Title3"+
  sep+"news_ids"+pt+loop+"0199-3619675"+splt+"Title1"+loop+"0199-7358845"+splt+"Title2"+loop+"0199-7358847"+splt+"Title3"+
  sep+"mkt_rpt_ids"+pt+loop+"5500"+splt+"Title1"  +loop+"5540"+splt+"Title2"  +loop+"5510"+splt+"Title3"
*/
//last_views="~comp_idsqqqqyyyy0000559956zzzzTitle1yyyy0001146692zzzzTitle2yyyy0000955652zzzzTitle3~news_idsqqqqyyyy0199-3619675zzzzTitle1yyyy0199-7358845zzzzTitle2yyyy0199-7358847zzzzTitle3~mkt_rpt_idsqqqqyyyyTitle4zzzz5555yyyy5540zzzzTitle2yyyy5510zzzzTitle3"

function viewed_links(axn,vtype,val,title_name){
	/* axn = show or add 
	   vtype = comp_ids, news_ids, mkt_rpt_ids
	   val,title_name = id + name 
	*/
	lv=""
	last_views=GetCookie('last_views');
	if(last_views==null){last_views="";}
	//alert(last_views)
	lv_arr=last_views.split(sep) // split each var:value hash
	if (last_views != ""){
	  for (w=1; w < lv_arr.length; w++){
		view_type_arr=lv_arr[w].split(pt) // split each name w/ name:val array
		view_type=view_type_arr[0];
		vtype_val_arr=view_type_arr[1].split(loop);
		vt=sep+view_type+pt // start var for new set of name-vals
		if (lv==""){lv=vt}else{lv=lv+vt}
		//if (axn == 'show'){wr("<br>"+view_type)} // writes it out
		//else if (axn == 'add'){wr("<br>"+view_type)} // adds it
 		
		// see if we are adding a last_view
		val_arr_len=vtype_val_arr.length;
		if (axn == 'add' && vtype==view_type){
			//wr("<br>ADD:"+ pt+loop+val+splt+title_name);
			if(!last_views.match(val)){ // make sure not viewed > 1
			  lv=lv + loop+val+splt+title_name
			  if(val_arr_len > 3){val_arr_len--} //start=2 3 is max num of prev views per type
			}
		}
		// loop each view_type
		for (x=1; x < val_arr_len; x++){
			myrow_arr=vtype_val_arr[x].split(splt) // split each name:val pair
			extra=vtype // Use in case of ZoomInfo
			if (vtype.match('zoom')){vtype=vtype.replace('_zoom','')}
			if (axn == 'show' && (vtype==view_type || vtype=="all")){

			  if (rview==0){ // ONLY RUN ONCE
				wr("<style>")
				wr(".Font13B_sp	{font-size:13px;font-family:arial;font-weight:600;margin-bottom:8px;display:block;}")
				wr(".RecentLinks{width:500px;height:30px;background-color:#ececec;color:black;font-size:12px;font-family:arial;padding:4px;margin-bottom:3px;display:block;}")
				wr(".LinkBlk	{color:black;font-weight:600;}")
				wr(".img		{float:left;display:block;height:30px;vertical-align:middle;}")
				wr("</style>")
				wr("<span class=Font13B_sp>Recently Viewed Content:</span>");rview=1
			  }
	  
////////////////////////////////////////////////////////////////////////////////
// FLAT URLs used are defined here
d="http://goliath.ecnext.com"
comp_ids = d+"/coms2/merc-compint-"+myrow_arr[0]
news_ids = d+"/coms2/summary_"+myrow_arr[0]+"_ITM"
//mkt_rpt_ids = d+"/industry-reports/"+myrow_arr[0] // flat URL
mkt_rpt_ids = d+"/comsite5/bin/comsite5.pl?page=ind_mark&sicCode="+myrow_arr[0]
/*wr("<br>SHOW: "+vtype+" : "+myrow_arr[0]+" : "+myrow_arr[1]+"<p>")*/
////////////////////////////////////////////////////////////////////////////////
wr("<SPAN CLASS='RecentLinks'>\n")
//wr("\n")
wr("<SPAN class=img><img src=http://goliath.ecnext.com/goliath/images/icn_sample.gif align=left height=30 border=0 hspace=5></SPAN>\n")
wr("<a href='"+eval(view_type)+"' class='LinkBlk'>View HTML Document</a> "+myrow_arr[1]+"<br>\n")
if(extra.match('zoom')){
wr("Goliath Company Profiles with ZoomInfo<br>")
}
//wr("Document Type: "+view_type+"\n")
wr("</SPAN>\n")
				
			}
			lv=lv + loop + myrow_arr[0]+splt+myrow_arr[1]
		}
	  }
	}
	// See if last_view type didn't exist, then add it
	if (!last_views.match(vtype) && axn=='add'){
		// only add if the type of last_view does not exist
		//wr("<br>NEW ADD: "+sep+vtype+pt+loop+val+splt+title_name)
		lv=lv + sep+vtype+pt+loop+val+splt+title_name
	}
	//wr(lv+"<p>")
	if(axn=='add'){SetCookie('last_views',lv,null,'/')}
	//alert(GetCookie('last_views'))
}
/*
SetCookie('last_views','',null,'/') // CLEAR COOKIE
viewed_links('show','all')
viewed_links('show','mkt_rpt_ids')
viewed_links('add','mkt_rpt_ids','5204','Title4')
viewed_links('add','mkt_rpt_ids','5205','Title5')
viewed_links('add','mkt_rpt_ids','5306','Title6')
viewed_links('add','news_ids','0199-3619675','Title1')
viewed_links('add','news_ids','0199-7358845','Title2')
viewed_links('add','comp_ids','0000559956','Title1')
viewed_links('add','comp_ids','0000559333','Title2')
*/
// --> 
// </script>
