/*		2011-03-21 	Metaways - Thomas Voßfeldt		*/
/*
#################################################

		This script requires Prototype!
		
		This script manages 
		
		a.) the social links in the share rollover
		in the hdrLinks area
		b.) The generation of floodlight tags used
		for tracking by DoubleClick

		updates:
		2011-04-12 	Added DoubleClick floodlight tags
					Added function smailafriend()
					Author: Thomas Voßfeldt
		2011-04-14  Added functions sregister() 
					and samazon() to provide
					floodlight tags onClick
					for register button and Amazon link
					Author: Thomas Voßfeldt
		2011-04-18	Added alternative functions with image tags for
					tracking, as the load of iframe is
					interrupted when page changes after click.
		
#################################################
*/


// Generate DoubleClick´s Random ID
// This one is structurally and functionally different from the rest of the script, kind of an Init procedure
function dcRandomize() {

	var axel = Math.random() + "";
	var a = axel * 10000000000000;
}
// ##############################################

// The following part consists of several functions with all more or less the same structure

//SOCIAL LINKS
function sfacebook() {

	// Generate floodlight tag ID
	dcRandomize();
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<iframe src="http://fls.doubleclick.net/activityi;src=2878926;type=kenco-ns;cat=kenco428;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'} );

	// Open Facebook in new window
	var u = 'http://www.kenco.co.uk/';
	var t = 'Have you seen the brand new Kenco website? There\'s lots of great new stuff. I think you\'ll like it. Take a look at www.kenco.co.uk';

	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer');
}


function stwitter() {

	// Generate floodlight tag ID
	dcRandomize();
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<iframe src="http://fls.doubleclick.net/activityi;src=2878926;type=kenco-ns;cat=kenco305;ord=1;num=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'} );

	// Open Twitter in new window
	var u = 'http://www.kenco.co.uk/';
	var t = 'Have you seen the brand new Kenco website? There\'s lots of great new stuff. I think you\'ll like it. Take a look at www.kenco.co.uk';

	window.open('http://twitter.com/home?status='+encodeURIComponent(t)+'+'+encodeURIComponent(u),'twitter');
}


function smailafriend() {

	// Generate floodlight tag ID
	dcRandomize();
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<iframe src="http://fls.doubleclick.net/activityi;src=2878926;type=kenco-ns;cat=kenco938;ord=1;num=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>' });
	// That´s all we have to do here, no forwarding - the Mail-a-friend layer is opened from within CMSLite  */
}

// Special links client wants to be tracked
function sregister() {

	// tracks clicks on registration link on Macmillan Page (cRef 658)
	
	// Generate floodlight tag ID
	dcRandomize();	
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<iframe src="http://fls.doubleclick.net/activityi;src=2878926;type=kenco-ns;cat=kenco450;ord=1;num=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'} );

	// Forward to disclaimer page
	window.location.href = "http://www.kenco.co.uk/kenco3/page?siteid=kenco3-prd&locale=uken1&TemplateId=Disclaimer&cache=off&url=http%3A//coffeeregister.macmillan.org.uk/2010/kenco/register.asp";
}

function samazon() {

	// tracks clicks on Amazon link on Where to buy Page (cRef 704)
	
	// Generate floodlight tag ID
	dcRandomize();	
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<iframe src="http://fls.doubleclick.net/activityi;src=2878926;type=kenco-ns;cat=kenco317;ord=1;num=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'} );

	// Forward to disclaimer page
	window.location.href = "http://www.kenco.co.uk/kenco3/page?siteid=kenco3-prd&locale=uken1&TemplateId=Disclaimer&cache=off&url=http%3A//www.amazon.co.uk/s/ref%3Dnb_sb_noss%3Furl%3Dsearch-alias%253Daps%26field-keywords%3Dkenco+%26x%3D0%26y%3D0%23/ref%3Dnb_sb_ss_i_0_12%3Furl%3Dsearch-alias%253Daps%26field-keywords%3Dkenco+coffee%26sprefix%3Dkenco+coffee%26rh%3Di%253Aaps%252Ck%253Akenco+coffee";
}

// When iframe will not load, try to use an image instead
function imgRegister() {

	// tracks clicks on registration link on Macmillan Page (cRef 658)
	
	// Generate floodlight tag ID
	dcRandomize();	
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<img src="http://ad.doubleclick.net/activity;src=2878926;type=kenco-ns;cat=kenco450;ord=1;num=' + a + '?" width="1" height="1" alt=""/>'} );

	// Forward to disclaimer page
	window.location.href = "http://www.kenco.co.uk/kenco3/page?siteid=kenco3-prd&locale=uken1&TemplateId=Disclaimer&cache=off&url=http%3A//coffeeregister.macmillan.org.uk/2010/kenco/register.asp";
}


function imgAmazon() {

	// tracks clicks on Amazon link on Where to buy Page (cRef 704)
	
	// Generate floodlight tag ID
	dcRandomize();	
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<img src="http://ad.doubleclick.net/activity;src=2878926;type=kenco-ns;cat=kenco317;ord=1;num=' + a + '?" width="1" height="1" alt=""/>'} );

	// Forward to disclaimer page
	window.location.href = "http://www.kenco.co.uk/kenco3/page?siteid=kenco3-prd&locale=uken1&TemplateId=Disclaimer&cache=off&url=http%3A//www.amazon.co.uk/s/ref%3Dnb_sb_noss%3Furl%3Dsearch-alias%253Daps%26field-keywords%3Dkenco+%26x%3D0%26y%3D0%23/ref%3Dnb_sb_ss_i_0_12%3Furl%3Dsearch-alias%253Daps%26field-keywords%3Dkenco+coffee%26sprefix%3Dkenco+coffee%26rh%3Di%253Aaps%252Ck%253Akenco+coffee";
}


function imgFindoutmore() {

	// tracks clicks on Find out more button on Where to buy Page (cRef 704)
	
	// Generate floodlight tag ID
	dcRandomize();	
	str = $('ftrText');
	// Write floodligfht tag into iFrame
	str.insert( {top:'<img src="http://ad.doubleclick.net/activity;src=2878926;type=kenco-ns;cat=kenco522;ord=1;num=' + a + '?" width="1" height="1" alt=""/>'} );

	// Forward to disclaimer page
	window.location.href = "http://www.kencocoffeecompany.co.uk/kencocoffeecompany2/page?PagecRef=1";
}













