
/* 

Find all links
		"link":     "http://www.amsterdammarijuanaseeds.com/marijuana-seeds.php?affilid=411661375612",

If they match what we think
	Make sure the href is what we want
	Add the on-click handler
	Add a mouse-over
	Add a mouse-out
	Make sure the target is _blank
*/	


var affiliateData = new Array (

	{
		"patterns": ["http://www.amsterdammarijuanaseeds.com"],
		"link":     "http://www.google.fi",
		"display":  "http://www.amsterdammarijuanaseeds.com",
		"tracker":  "ams"
	}
);


function fixAff () {

	var doc = document.body.getElementsByTagName("a");
	
	for (var x = 0; x < doc.length; x++) {
		affLink = doc[x];

		// Get the href		
		var href = affLink.href;
		
		// Cycle through our patterns
		for (var i = 0; i < affiliateData.length; i++) {
			affiliate = affiliateData[i];
			
			var foundMatch;
			var patterns = affiliate.patterns;
			for (var j = 0; j < patterns.length; j++) {
				var pattern = patterns[j];
				if ( href.indexOf( pattern ) > 0 ) { foundMatch = 1 }

			}

			if ( foundMatch ) {
				affLink.setAttribute("onclick", "parent.location.href='" + affiliate.link+ "'; return event.returnValue=false");
			}
		}
	}

}
