DpChatImage = {
	
	chatStatus: -1,
	
	init: function(type) {		
		type = type || 'small';
		
		var url = DpLoc.serverUrl;
		
		document.write('<a href="#" id="dpchatimage_link" onclick="DpChatImage.popWin(); return false;"><img src="' + url + 'locator/chat_image.php?type=' + type + '" alt="" border="" id="dpchatimage_img" /></a>');
	},

	here: function() { this.init(); },
	
	popWin: function() {
		
		var url = DpLoc.serverUrl + 'chat.php?tid=';
		
		// Append a track id if we have it
		if (DpLoc.trackId) {
			url += DpLoc.trackId;
		} else {
			url += '0';
		}
		
		// If chat status is unknown or on, then show the popup to the form
		if (this.chatStatus == -1 || this.chatStatus == 1) {
			url += '&do=form';
			window.open(url, 'popchat', 'width=750,height=520,toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=no');
			
		// We know chat is unavailable, bring to the chat page
		} else {
			url += '&unavailable=newticket';
			window.open(url, 'popchat');
		}
	},
	
	chatOn: function() { DpChatImage.chatStatus = 1; },
	chatOff: function() { DpChatImage.chatStatus = 0; }
};

