// Collection of various scripts for blogger hacks
// (to reduce file size)

//FreshTags v0.6 http://www.greg-hill.id.au
del_user = "thetan";
anchor = "";			// should be footy
archive = "footy_archive";
defs = "speccy";

curr_tags=defs;

FT_tags={"type": "list-cloud", "rows": "0", "prompt": "Select Tags", "cust":""};
FT_post={"type": "peek", "rows": "10", "prompt": "Please Select Post", "cust":""};
FT_arch={"type": "drop", "rows": "0", "prompt": "&nbsp;&nbsp;&nbsp;&nbsp;- Select Month -", "cust":""};

tagsDiv="FT-tags";
postDiv="FT-post";
archDiv="FT-arch";

maxposts = 100;
sort='alpha';

cloudmin=100;
cloudmax=170;
peeksize=0;

// function to manually remove non-speccy tags from delicious feed
// this is only due to a new bug in delicious 10/8/2006

tagkeeplist= ["bashing", "court", "drugs", "court", "rape", "scandals", "spoilt_rotten", "booze", "sleaze", "underworld", "traffic", "swindle", "payola"];

function droptags()
{
if (typeof(Delicious.all_tags)=='undefined'||typeof(tagkeeplist)=='undefined')
{     alert(typeof(Delicious.all_tags));
	return;
}
t=tagkeeplist;

for (var a in Delicious.all_tags)
{
	var tagmatch=false;
	for (var i=0; i<t.length; i++)
		tagmatch=tagmatch||(a==t[i]);

	if (!tagmatch)
		delete Delicious.all_tags[a];
}

curr_tags=filterTags(curr_tags);
if (!curr_tags)
	curr_tags=defs;

return;
}

function writeScript( src ) { document.write( '<script type="text/javascript" src="'+ src +'"><\/script>')  }

writeScript( "http://ghill.customer.netspace.net.au/freshtags/freshtags-v07-dev.js" );
writeScript( "http://ghill.customer.netspace.net.au/freshtags/freshads.js" );
writeScript( "http://ghill.customer.netspace.net.au/markit/markit.js" );
writeScript( "http://ghill.customer.netspace.net.au/blog-nav/blog-nav-v03.js" );
writeScript( "http://ghill.customer.netspace.net.au/backlinker/backlinker.js" );
writeScript( "http://ghill.customer.netspace.net.au/hearsay/hearsay-v01c.js" );
//writeScript( "http://ghill.customer.netspace.net.au/wisdom/wisdom-dev-v01.js" );
writeScript( "http://ghill.customer.netspace.net.au/buzzflux/buzzflux.js" );


function reFreshAds(interval) 
{
loadFreshAds(); 
setTimeout('reFreshAds('+interval+');', interval);
}

function doFreshAds(adsObj)
{
// callback for dealing with FreshAds
// assumes there's a div with id "FreshAds" somewhere.

var adHTML=listAds(adsObj);

var catanch = FreshAds.descr.substr(0,3);
var heading ='<b>Speccy Shop:</b><br/><a href="http://the-speccy.blogspot.com/2006/03/speccy-shop-surviving-footy-season.html#'+catanch+'">'+FreshAds.descr+'</a><br/><br/>';

document.getElementById('FreshAds').innerHTML = heading+adHTML;		// stuff output HTML into div
return;
}


// Blog Navigator v0.3
// http://www.greg-hill.id.au (Creative Commons)
// See http://blogfresh.blogspot.com for details

// Define archURL path 
 archURL = "http://the-speccy.blogspot.com/";

if (typeof(archURL)=='undefined')
	archURL = "http://"+document.domain+"/archive/";
PageType = "Item";


function buildArchives()
{
// Archive building code 

FreshNav=true;  // Wait on FreshTags archive to be built

if (typeof(Delicious.arch_posts)!='undefined')
{
	var p=Delicious.arch_posts;
	archives=new Array();
	for(var i=p.length-1; i>=0; i--)
		archives.push(p[i].u);
}
else
	setTimeout('doNav();', 2000);
return;
}


// Markit Blog Bookmarker
// http://www.greg-hill.id.au
// See http://blogfresh.blogspot.com

PostItemDiv="post-body";
MarkUrl="http://del.icio.us/thetan?";
tempURL="";

buttonStr='" title="Bookmark This" target="_blank" onMouseOver="doMark(this);" onMouseOut="this.href=tempURL;"><img style="border:none;" src="http://del.icio.us/static/img/delicious.small.gif"/></a>';

function list_post_tags(post_tags)
{
// included for legacy reasons only; not recommended!

	var selected, c, tags=post_tags.replace(/^.+\/thetan\//i,'').replace(/footy\W/,'').replace(/\+/ig,' ').split(' ');

	document.write('<td align="center"><small>[&nbsp;');

	for(var i=0;i<tags.length;i++)
	{

		rexp = new RegExp( tags[i], 'i' );

		selected = (curr_tags.search(rexp)>=0);
		//if (selected)
		//	document.write('<strong>');

		document.write('&nbsp;&nbsp;<span onclick="javascript: curr_tags=&quot;'+tags[i]+'&quot;;doFreshTags()">'+tags[i]+'</span>');
		if (del_user) c = Delicious.all_tags[tags[i]];
		if (c && c>0)
			document.write('('+c+')');
		
		//if (selected)
		//	document.write('</strong>');

	}
	document.write('&nbsp;&nbsp;&nbsp;]&nbsp;&nbsp;</small></td>');

	//var keep_curr_tags = curr_tags;
	//curr_tags=post_tags.replace(/ +/gi,'+');
	//document.write('<a href="'+makeURL(curr_tags)+'">&gt;&gt;</a></small></td>');
	//curr_tags = keep_curr_tags;
	
	return;
}


function show_count(count)
{

// only show the count (in braces) if it exists

if (count>0)
	document.write(' ('+count+')');
return;
}

queryStr =''	// global variable

function loadQuery()
{

function filterTags(a){ return a.replace(/\++/ig,' ');};  // clear filterTags function

var queryStr = fetchTags(location.search, ['search']) || fetchTags(unescape(document.referrer.substr(document.referrer.indexOf('?'))),['q','p','query','search', 'surname']);

var inp=document.getElementById('scan-input');

if (!queryStr)
	queryStr="Enter player or club name";
else
{
	backlinker(queryStr, 'background-check');
}

inp.value=queryStr;

return;
}

function setCollectiveWisdom()
{
// Collective Wisdom Parameters

reN=/(\w+)\s\((\w+)\)/i;				// custom name/stock code extractor
crowdRSS='http://www.crowdiq.com/opex/rss/5d4ce74a611e7832965fd3508ea04d2773004086584232444c5350483855584c4a564a435149344a.xml';								// URL of market RSS feed
crowdNode='collective-wisdom';			// ID of div to put list
scanNode='main-content';				// ID of div to scan for keywords
doHighlight=true;
doList=true;

return;
}

// BuzzFlux

Buzz = {"divid":"BuzzFlux", "limit":"15", "timer":"2000", "blogid":"1413", "period":"year", "scan":"scan-input", "queries":[]};


// AddLoadEvent
// via http://simon.incutio.com/archive/2004/05/26/addLoadEvent

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(loadQuery);
