// <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 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 wr(val){return document.write(val)}
sep='~';pt='qqqq';loop='yyyy';splt='zzzz'; // defined delims to be used
rview=0
/* subscriptions : Company Profiles, Business News, Industry Reports */
/* hypothetical subscription cookie value - add from at first, last is oldest
subscriptions=sep+"links"+pt+loop+"Sub_ID1"+splt+"Subscription1"+loop+"Sub_ID2"+splt+"Subscription2"+loop+"Sub_ID3"+splt+"Subscription3"
*/

function subscribed(axn,vtype,val,title_name,sub_sub_id){
	/* axn = show or add 
	   vtype = 'links'
	   val,title_name = subid + name 
	*/
	lv=""; emptyval=sep+'links'+pt //~linksqqqq
	subscriptions=GetCookie('subscriptions');
	// Handle NULL and 
	if(subscriptions==null || subscriptions==emptyval){
		subscriptions="";
		//SetCookie('subscriptions',emptyval,null,'/')
	}
	//alert(subscriptions)
	lv_arr=subscriptions.split(sep) // split each var:value hash
	if (subscriptions != ""){
	  // THIS SECTION ONLY FOR DISPLAY PURPOSES
	  if(rview==0 && axn != 'add'){
		wr("<style>")
		wr(".Font12_sp	{font-size:12px;font-family:arial;font-weight:500;margin-bottom:2px;display:block;}")
		wr("</style>")
		wr("<span class=Font12_sp>You are currently subscribed to:</span>");rview=1
	  }
	  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}
 		
		// 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(!subscriptions.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
			if (axn == 'show' && (vtype==view_type || vtype=="all")){
////////////////////////////////////////////////////////////////////////////////
// FLAT URLs used are defined here
d="http://goliath.ecnext.com"
SubID1="/coms2/page_subscribe_compint" // Company Profiles
SubID2="/coms2/page_subscribe_research" // Business News
SubID3="/coms2/page_subscribe_industries" // Industry Reports
SubID4="/coms2/page_business_resources" // Business Development Resources: Leads / Directories

/* 
5942 // company profiles trial
8860 // business news trial
8900 // industry reports trial
*/
/*wr("<br>SHOW: "+vtype+" : "+myrow_arr[0]+" : "+myrow_arr[1]+"<p>")*/
////////////////////////////////////////////////////////////////////////////////
				if (myrow_arr[0] == 9)
				{
					wr(myrow_arr[1] +"<br>\n")
				wr("<a href='/coms2/page_subscribe_research' class=LinkBlue>Browse Business News</a><br>\n")
				wr("<a href='/coms2/page_subscribe_compint' class=LinkBlue>Browse Company Profile</a><br>\n")
				wr("<a href='/coms2/page_subscribe_industries' class=LinkBlue>Browse Industry &amp; Market Reports</a><br>\n")
				wr("<a href='/coms2/page_directories' class=LinkBlue>Browse Business Directories</a><br>\n")
				wr("<a href='/coms2/page_mgt_practices' class=LinkBlue>Browse Business Reference Tools</a><br>\n")
				}
				else
				{
					url=eval("SubID"+myrow_arr[0])
					wr("<a href='"+url+"' class=LinkBlue>"+ myrow_arr[1] +"</a><br>\n")
				}
			}
			lv=lv + loop + myrow_arr[0]+splt+myrow_arr[1]
		}
	  }
	}
	// See if last_view type didn't exist, then add it
	if (!subscriptions.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('subscriptions',lv,null,'/');SetCookie('sub_sub_id',sub_sub_id,null,'/');}
	//alert(GetCookie('subscriptions'))
}

/* AVAILABLE FUNCTION CALLS
SetCookie('subscriptions','',null,'/') // CLEAR COOKIE
SetCookie('subscriptions','~linksqqqq',null,'/') // COOKIE EXISTS, EMPTY SUBSCRIPTIONS

subscribed('add','links','1','Goliath Company Profiles (Trial)')
subscribed('add','links','2','Goliath Business News (Trial)')
subscribed('add','links','3','Goliath Industry Reports (Trial)')

subscribed('show','links')
*/

// --> 
// </script>
