salmon.namespace.addNamespace("boots.common");

if(typeof boots.common.siteConfig != "object"){
	boots.common.siteConfig = {
		imageDirectoryURL: ""
	}
}

boots.common.cookie = {
	Collection: null,
	init: function() {
		this.Collection = {};
		var cookies = document.cookie.split(";");
		var cookie;
		for( var i = cookies.length-1; i >= 0 ;i--) {
			cookie = cookies[i].split("=");
			var cookieName = cookie[0].replace(/ /g,"");
			if (cookie.length >= 2) {
				this.Collection[cookieName] = cookie[1];
			}
		}
		this.init = function(){	};
	},
	setCookie: function(name,value,days) {
		this.init();
		var expires = "";
		if (days) {
			var date = new Date();
			date.setDate(date.getDate() + days);
			expires = "expires=" + date.toGMTString();
		}
		var cookie = name + "=" + value + ";" + expires + ";path=/";
		document.cookie = cookie;
		this.Collection[name] = value;
	},
	getCookie: function(name) {
		this.init();
		return this.Collection[name];
	},
	removeCookie: function(name) {
		this.init();
		this.setCookie(name,"",-1);
		delete this.Collection[name];
	}
}


boots.common.print = {
	/*
		@param object literal with the following properties
			1. href
			2. className
			3. image
			4. alt
		@return printButton as DOM Node
	*/
	createPrintButton: function() {
		var buttonDetails = {
			href: "#print",
			className: "printButton",
			image: "btn_print.gif",
			alt: "Print this page"
		};
		
		/* allow the passing in of an object literal */
		if (typeof arguments[0] == "object") {
			buttonDetails.href = arguments[0].href || buttonDetails.href;
			buttonDetails.className = arguments[0].className || buttonDetails.className;
			buttonDetails.image = arguments[0].image || buttonDetails.image;
			buttonDetails.alt = arguments[0].alt || buttonDetails.alt;
		}
	
		var activator = document.createElement("a");
		activator.href = buttonDetails.href;
		activator.className = buttonDetails.className;
		$(activator).bind("click", boots.common.print.activate);	
		var img = document.createElement("img");
		img.src = boots.common.siteConfig.imageDirectoryURL + buttonDetails.image;
		img.alt = buttonDetails.alt;
		activator.appendChild(img);
		return activator;
	},
	activate: function() {
		window.print();
		return false;
	}	
}

$(document).ready(function(){
	// error if no methods listed, so if no methods, don't show the doc.ready
	salmon.popupwindow.init();
	
	//remove as nick request
	//$("a[href='#']").click(function(){
		//alert("DEV: this link not done.");
		//return false;
	//});
	
});