// JavaScript Document
function nbc (obj, color) {
obj.style.backgroundColor = color;
}

function d(css, obj) {
//does not set cookie !
document.getElementById(obj).style.display = css;
}

function chkCookie () {
this.cookIt = new CookieHandler();
this.cookedValue = (this.cookIt.getCookie("css") == "block")?"block":"none";
this.miniCart = document.getElementById("miniCart");
this.showCart = document.getElementById("showCart");
this.setDisplay = setDisplay;
this.showHide = showHide;
this.setDisplay();
this.showCart.style.visibility = "visible";
}

function showHide() {
// Swaps CSS display.
this.cookedValue = (this.cookIt.getCookie("css") == "block")?"none":"block";
this.setDisplay();
this.cookIt.setCookie("css", this.cookedValue, 60*60*24*7); // 7 days ?
}

function setDisplay() {
this.miniCart.style.display = this.cookedValue;	
	if (!(this.cookedValue == "none")) {
	this.miniCart.style.borderTop = '1px dashed #aaaaaa';
	} else {
	this.miniCart.style.borderTop = 'none';
	}
}

function StartChk () {
intCook = setInterval("canChkCookie()", 50);
}
 
function canChkCookie () {
	// Ensure subject div is loaded.
	if (document.getElementById("miniCart") == null) return 0;
	if (document.getElementById("showCart") == null) return 0;
clearInterval(intCook);
cc = new chkCookie (); 
} 
 
 
/**
*
*  Javascript cookies
*  http://www.webtoolkit.info/
*
**/
 
function CookieHandler() {
 
	this.setCookie = function (name, value, seconds) {
 
		if (typeof(seconds) != 'undefined') {
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else {
			var expires = "";
		}
 
		document.cookie = name+"="+value+expires+"; path=/";
	}
 
	this.getCookie = function (name) {
 
		name = name + "=";
		var carray = document.cookie.split(';');
 
		for(var i=0;i < carray.length;i++) {
			var c = carray[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
 
		return null;
	}
 
	this.deleteCookie = function (name) {
		this.setCookie(name, "", -1);
	}
 
}
