var ProjectClipboard = {

	items: new Array(),
	viewPage: 0,

	addItem: function(id) {
		if (this.items.length>=15) {
			alert('W Twojej teczce znajduje się już 15 projektów. \nAby móc dodać ten projekt, musisz usun±ć który¶ z projektów już dodanych do teczki.');
			return false;
		}

		if (inArray(id,this.items)) {
			alert('Ten projekt znajduje się już w Twojej teczce');
			return false;
		}

		this.items.push(id);
		setCookie('clipboard',this.items.join('|'));
		ProjectClipboard.getContent();
	},

	deleteItem: function(id) {
		this.items=arrayUnset(this.items,inArray(id,this.items));
		setCookie('clipboard',this.items.join('|'));
		ProjectClipboard.draw();
	},

	getContent: function() {
		$('pFClipContainer').src="atrium.php?p=clip_content&view="+this.viewPage+"&"+Math.random();
	},

	init: function(showHeader,showAddButton,id) {
		showHeader=showHeader || false;
		showAddButton=showAddButton || false;

		clip = getCookie('clipboard');
		if (clip!=null) {
			this.items=clip.split('|');
		}

		if (showHeader) {
			document.write('<img src="layout/teczka2.gif" style="margin-bottom: 6px">');
		}
		document.write('<iframe src="" id="pFClipContainer" frameborder="0" scrolling="auto" style="border: none; margin: 0; padding: 0; width: 100%; height: 239px"></iframe>');
		if (showAddButton!=false) {
			if (inArray(id,this.items)===false) {
				document.write('<table border="0" cellspacing="0" cellpadding="0" onclick="ProjectClipboard.addItem('+id+')" class="hand" style="margin-top: 10px;"><tr><td><img src="layout/clip_1.gif"></td><td style="background-image: url(layout/clip_b.gif); background-repeat: repeat-x; font-size: 10px; color: #B51B1B">dodaj '+showAddButton+' do teczki</td><td><img src="layout/clip_2.gif"></td></tr></table>');
			} else {
				document.write('<div style="text-align: center; font-size: 10px;">'+showAddButton+' jest już w Twojej teczce</div>');
			}
		}
		if (this.items.toString()!='') {
			document.write('<div style="text-align: center; margin: 6px;"><a href="atrium.php?p=u" class="org" style="font-size: 10px;">porównaj projekty z teczki</a></div>');
		}
		this.getContent();
	}
}