// JavaScript Document

var URL_Parser = {
	st: null,
	qs: new Object(),
	
	init: function(){
		scripts = document.getElementsByTagName('script');
		this.st	= scripts[ scripts.length - 1 ];
		return this.pair();
	},
	
	parze: function(QPs){
	    for(var i=0; i<QPs.length; i++)
		   {
			  var kv = QPs[i].split('=');
			  if (!kv || kv.length!=2) continue;
			  var val = unescape(kv[1]);
			  this.qs[unescape(kv[0])] = val.replace(/\+/g, ' ');
		   }		
	},
	
	pair: function(){
		q_s = this.st.src.replace(/^[^\?]+\??/,'');
		// extract the QS iff it's present.
		if(q_s)
			this.parze(q_s.split(/[;&]/));
		// return the QS var; it may used as a flag.
		return q_s;	
	},
	
	burl: function(){
		uri = this.st.src.match(/^(http:\/\/[^\/]+\/)/);
		// return the base uri that is found.
		return uri[0];
	}
}

// the above class is iniated here.
//	appending the timestamp as a querystring to the image url overcomes caching.
var td_dt = new Date();
if (URL_Parser.init())
    if (URL_Parser.qs.url != null)
	document.write('<a href=http://'+URL_Parser.qs.url+'?mwp_id='+URL_Parser.qs.id+' title=""><img alt="" border="0" src="'+URL_Parser.burl()+'images/mywebpost-button2.gif?'+td_dt.getTime()+'" /></a>');
    else
	document.write('<a href="'+URL_Parser.burl()+'subscribe/welcome/'+URL_Parser.qs.id+'" title=""><img alt="" border="0" src="'+URL_Parser.burl()+'images/mywebpost-button2.gif?'+td_dt.getTime()+'" /></a>');
    
