changeLink = 'go.php?link=traders';
expTime = 12*60*60*1000;   // 12 hours

function getDocCookie(name) {
	var labelLen = name.length,
	    cookieData = document.cookie,
	    cLen = cookieData.length,
	    i = 0,
	    j,
	    cEnd;
	while (i < cLen) {
		j = i + labelLen;
		if (cookieData.substring(i, j) == name) {
			cEnd = cookieData.indexOf(";",j)
			if (cEnd == -1) {
				cEnd = cookieData.length
			}
			return unescape(cookieData.substring(j + 1, cEnd))
		}
		i++
	}
	return "";
}

function setDocCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}


$(document).ready( function() {
	$(document).bind('click', function(ev) {
		var el = ev.target;
		
		if (el.tagName.toLowerCase() == 'img' && $(el).parents('.change-container').length > 0 && !(jQuery.browser.mozilla && ev.which != 1)) {
			if (!getDocCookie('firstclick')) {
				var currDate = new Date(),
					cTimeout;
    			currDate.setTime(currDate.getTime() + expTime);
    			setDocCookie('firstclick', '1', currDate, '/', '', 0);
				cTimeout = setTimeout("$('.change-container a:not(.no-change)').attr('href', changeLink);", 1000);
			}	
		}

	});
		 
});