	// creating link
	function PureLib_createUrl () {
		var referrer = escape (document.referrer);
		// www page displaying the banner
		var webpage = escape (location.href);
		var url = '&r=' + referrer + '&w=' + webpage;	
		return url;
	}

	// add parametrs to the banner link
	function PureLib_appendToUrl (id) {
		var link = document.getElementById ('casinoLink' + id);
		
		if (link.href.indexOf ('?') == -1) {
			url = '?';
		}
		else {
			url = '&';
		}
		
		link.href += url + createUrl ();
	}
	
	function PureLib_redirect (url) {
		if (url.indexOf ('?') == -1) {
			link = '?';
		}
		else {
			link = '&';
		}
		window.location = url + link + createUrl ();
	}
	
	function PureLib_displayFlash (link, filepath, width, height) {
	
		if (link.indexOf('?') == -1) {
			link = link + '?';
		}
		else {
			link = link + '&';
		}
	
		link = escape (link + PureLib_createUrl ());
		
		var uniqueId = Math.round(Math.random() * 1000);
		var protocol = 'http' + (window.location.href.indexOf("https") == 0 ? 's' : '');
		
		document.write ('<object width="'+width+'" height="'+height+'"' + 
			'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
			'codebase="'+protocol+'://fpdownload.macromedia.com/pub/'+
			'shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="pureFlashObject' + uniqueId + '">'+
			'<param name="movie" value="'+filepath+'" />' +
			'<param name="menu" value="false" />' +
			'<param name="quality" value="high" />' +
			'<param name="bgcolor" value="#000000" />' +
			'<param name="wmode" value="transparent"> ' +
			'<param name="allowScriptAccess" value="always"> ' +
			'<param name="flashvars" value="landingPage='+link+'" />' +
			'<embed src="'+filepath+'" width="'+width+'" height="'+height+'"' +
				'menu="false" quality="high" bgcolor="#000000" wmode="transparent" allowscriptaccess="always" ' +
			  	'flashvars="landingPage='+link+'" ' +
			  	'type="application/x-shockwave-flash" pluginspage= ' +
			  	'id="pureFlashObject' + uniqueId + '"' +
			  	'"'+protocol+'://www.macromedia.com/go/getflashplayer" name="flashLink"/>' +
			'</object>');
			
	}
	
	// peel global object
	var pagepeel = new Object();
	pagepeel.useFixedPosition = 0;

	// inserts peel banner into page
	function PureLib_peel (targetURL, smallSwf, bigSwf, smallImg, bigImg) {
		if (pagepeel.useFixedPosition) {
			pagepeel.position = 'fixed; top:0; right:0';
		}
		else {
			pagepeel.position = 'absolute';
		}
		
		// change protocol to https if curent page is also https
		if (window.location.href.indexOf("https") == 0) {
			smallSwf 	= smallSwf.replace ('http://', 'https://');
			bigSwf 		= bigSwf.replace ('http://', 'https://');
			bigImg		= bigImg.replace ('http://', 'https://');
			smallImg 	= smallImg.replace ('http://', 'https://');
		}
		
		pagepeel.ad_url = escape(targetURL); // Link Address when ad is clicked on
		// preloading for smooth image swapping
		preloadedBigImg = new Image(500,500); 
		preloadedBigImg.src = bigImg; 

	
		pagepeel.small_path = smallSwf; // Path where you placed the small.swf
		//pagepeel.small_image = escape(smallIMG); // Small Image before hover (.jpg, .gif, .png, .swf) - 75X75
		pagepeel.small_image = smallImg; // Small Image before hover (.jpg, .gif, .png, .swf) - 75X75
		pagepeel.small_width = '100';
		pagepeel.small_height = '100';
		pagepeel.small_params = 'ico=' + pagepeel.small_image;
	
		pagepeel.big_path = bigSwf; // Path where you placed the big.swf
		//pagepeel.big_image = escape(bigIMG); // Large Image after hover (.jpg, .gif, .png, .swf) - 500X500
		pagepeel.big_image = bigImg; // Large Image after hover (.jpg, .gif, .png, .swf) - 500X500
		pagepeel.big_width = 650;
		pagepeel.big_height = 650;
		pagepeel.big_params = 'big=' + pagepeel.big_image + '&ad_url=' + pagepeel.ad_url;
	
		pagepeel.putObjects();
		
	}

	// helper for peel banner
	function sizeup987(){
		document.getElementById('PagePeelBig').style.top = '0px';
		document.getElementById('PagePeelSmall').style.top = '-1000px';
	}

	// helper for peel banner
	function sizedown987(){
		document.getElementById("PagePeelSmall").style.top = "0px";
		document.getElementById("PagePeelBig").style.top = "-1000px";
	}

	// method for peel banner object
	pagepeel.putObjects = function () {
		if (tmp = document.getElementById ('peelPreview')) {
			tmp.innerHTML = '';
		}
			
		// <PagePeelSmall>
		var peelStr= '<div id="PagePeelSmall" style="position:'+pagepeel.position+';width:'+ pagepeel.small_width +'px;height:'+ pagepeel.small_height +'px;z-index:9999;right:0px;top:0px;">'+
		// object
		'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
		' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"'+
		' id="PagePeelSmallObject" width="'+pagepeel.small_width+'" height="'+pagepeel.small_height+'">'+
		// object params
		' <param name="allowScriptAccess" value="always"/> '+
		' <param name="movie" value="'+ pagepeel.small_path +'?'+ pagepeel.small_params +'"/>'+
		' <param name="wmode" value="transparent" />'+
		' <param name="quality" value="high" /> '+
		' <param name="FlashVars" value="'+pagepeel.small_params+'"/>'+
		// embed
		'<embed src="'+ pagepeel.small_path + '?' + pagepeel.small_params +'" name="PagePeelSmallObject" wmode="transparent" quality="high" width="'+ pagepeel.small_width +'" height="'+ pagepeel.small_height +'" flashvars="'+ pagepeel.small_params +'" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>'+
		'</object></div>'+
		'</script>'+
		// </PagePeelSmall>
		// <PagePeelBig>
		'<div id="PagePeelBig" style="position:'+pagepeel.position+';width:'+ pagepeel.big_width +'px;height:'+ pagepeel.big_height +'px;z-index:9999;right:0px;top:0px;">'+
		// object
		'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
		' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"'+
		 ' id="PagePeelBigObject" width="'+ pagepeel.big_width +'" height="'+ pagepeel.big_height +'">'+
		// object params
		' <param name="allowScriptAccess" value="always"/> '+
		' <param name="movie" value="'+ pagepeel.big_path +'?'+ pagepeel.big_params +'"/>'+
		' <param name="wmode" value="transparent"/>'+
		' <param name="quality" value="high" /> '+
		' <param name="FlashVars" value="'+ pagepeel.big_params +'"/>'+
		// embed
		'<embed src="'+ pagepeel.big_path + '?' + pagepeel.big_params +'" id="PagePeelBigEmbed" name="PagePeelBigObject" wmode="transparent" quality="high" width="'+ pagepeel.big_width +'" height="'+ pagepeel.big_height +'" flashvars="'+ pagepeel.big_params +'" swliveconnect="true" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>'+
		'</object></div>';
		// </PagePeelBig>
		
		setTimeout('document.getElementById("PagePeelBig").style.top = "-1000px";',1000);
		var peelDiv;
		
		if (document.getElementById ('peelPreview')) {
			peelDiv = document.getElementById ('peelPreview');
		}
		else {
			peelDiv = document.createElement ('div');
			peelDiv.id = "peelPreview";
		}
		
		peelDiv.innerHTML = peelStr;
		
		if (pagepeel.peelPlace) {
			var peelPlace = document.getElementById (pagepeel.peelPlace);
			peelPlace.appendChild (peelDiv);
		}
		else {
			document.body.appendChild (peelDiv);
		}
	}
	
	if (typeof (createUrl) 		== 'undefined') { var createUrl = function () {return PureLib_createUrl ();};}
	if (typeof (appendToUrl) 		== 'undefined') { var appendToUrl = function (id) {return PureLib_appendToUrl (id);};}
	if (typeof (displayFlash) 		== 'undefined') { var displayFlash = function (a1, a2, a3, a4) {return PureLib_displayFlash (a1, a2, a3, a4);};}
