jQuery(document).ready( function() {
	jQuery("#banners_container .graybox div span a").click( function() {
		openOverlay(this);
		return false;
	});
	jQuery(".closewindow").click( function() {
		closeOverlay();
		return false;
	});
	jQuery(".copycode").click( function() {
		textToCopy = jQuery("#bannerinfo_text").html();
		copyToClipboard(textToCopy);
		return false;
	});
openOverlay = function(e) {
		if(jQuery(e).parents("div").children(".bannercode").children("h2").length > 0) {jQuery("#bannerinfo_text").children(".code").html("<h2>"+jQuery(e).parents("div").children(".bannercode").children("h2").html()+"</h2>"); }
		else { jQuery("#bannerinfo_text").children(".code").html(" "); }
		jQuery("#bannerinfo_text").children(".code").append("<pre>"+jQuery(e).parents("div").children(".bannercode").children(".code").html().replace(/</g, "&lt;")+"</pre>");
	jQuery.blockUI({
		message: jQuery("#bannerinfo_text"),
		css: {
			border: 'none',
			cursor: 'arrow'
		}
	});
	jQuery("#bannerinfo_text .yellowbutton2").width(jQuery("#bannerinfo_text .yellowbutton2").width());
	jQuery("#bannerinfo_text .yellowbutton2").css('float', 'none');
	jQuery.blockUI.center();
}
closeOverlay = function() {
	jQuery.unblockUI();
}


function copyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
	else
	{
		// You have to sign the code to enable this or allow the action in about:config by changing
		user_pref("signed.applets.codebase_principal_support", true);
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

		var clip = Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		// create a transferable
		var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		// specify the data we wish to handle. Plaintext in this case.
		trans.addDataFlavor('text/unicode');

		// To get the data from the transferable we need two new objects
		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=meintext;

		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]);

		var clipid=Components.interfaces.nsIClipboard;

		if (!clip) return false;

		clip.setData(trans,null,clipid.kGlobalClipboard);	   
	}
}

});
