var currentState = "hidden";

function toggleVisibility()
{
	var popup = document.getElementById("BookmarkPopup");
	if(currentState == "hidden")
	{
		popup.style.top = ((screen.availHeight - popup.clientHeight) / 3) + "px";
		popup.style.left = ((screen.availWidth - popup.clientWidth) / 2) + "px";
		currentState = "visible";
	}
	else
	{
		currentState = "hidden";
	}
	
	
	popup.style.visibility = currentState;
}


function BookmarkService(name, imageName, url)
{
	this.url = url;
	this.name = name;
	this.imageName = imageName;
	return this;
}

var bookmarkServices = new Array(
	new BookmarkService("Delicious", "delicious.png", "http://delicious.com/post?url={url}&title={title}"),
	new BookmarkService("Digg", "digg.png", "http://digg.com/submit/?phase=2&url={url}&bodytext=&tags=&title={title}"),
	new BookmarkService("Reddit", "reddit.png", "http://reddit.com/submit?url={url}&title={title}"),
	new BookmarkService("Folkd", "folkd.png", "http://www.folkd.com/page/submit.html?url={url}"),
	new BookmarkService("Faves", "faves.png", "http://faves.com/Authoring.aspx?u={url}&t={title}"),
	new BookmarkService("StumbleUpon", "stumbleupon.png", "http://www.stumbleupon.com/submit?url={url}&title={title}"),
	new BookmarkService("Google", "google.png", "http://www.google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}"),
	new BookmarkService("Yahoo", "yahoo.png", "http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u={url}&t={title}"),
	new BookmarkService("Live", "live.png", "https://skydrive.live.com/sharefavorite.aspx%2f.SharedFavorites??&mkt=en-us&url={url}&title={title}&top=1"),
	new BookmarkService("Facebook", "facebook.png", "http://www.facebook.com/sharer.php?u={url}"),
	new BookmarkService("Myspace", "myspace.png", "http://www.myspace.com/index.cfm?fuseaction=postto&t={title}&u={url}"),
	new BookmarkService("Twitter", "twitter.png", "http://twitter.com/home?status={url}")
);

var itemPerColumn = 6;

var currentURL = (location.href);
var title = (document.title);
var hostname = location.hostname; 

var content = "";

for(i = 0; i < bookmarkServices.length; i++)
{
	var url = bookmarkServices[i].url;
	url = url.replace("{url}", currentURL);
	url = url.replace("{title}", title);
	url = 'http://shipping-container-info.com/redir.php?url=' + escape(url); 
	var item = '<div class="BookmarkItem">';
	item += '<a href="' + url + '" target="_blank">';
	item += '<img src="http://' + hostname + "/images/" + bookmarkServices[i].imageName + '">';
	item += '<p>' + bookmarkServices[i].name + '</p>';
	item += '</a></div>';
	
	content += item;
}

var bookmarkServicesPopup = '<div class="bookmarkServices" id="BookmarkPopup" >';
bookmarkServicesPopup += '<div class="PopupHeader" >';
bookmarkServicesPopup += '<div class="PopupTitle" >Bookmark this page</div>';
bookmarkServicesPopup += '<div class="PopupClose" ><a href="javaScript:void(0)" onclick="toggleVisibility()" >close</a></div>';
bookmarkServicesPopup += '</div>';
bookmarkServicesPopup += content;
bookmarkServicesPopup += '</div>';

document.write(bookmarkServicesPopup);
