
// - ///////////////////////////////////////////////////////////////////////
// - PHONEDOG TIPS MODULE
// - ///////////////////////////////////////////////////////////////////////
// - Finds all tips based on a specified class name and creates prototips
//fields
pdTipsModule.prototype._transport;
pdTipsModule.prototype._user;
pdTipsModule.prototype._channelId = 'site.tips';

function pdTipsModule() {}

pdTipsModule.prototype.initialize = function(transport, user){
  	//this function is called back during module registration
	this._transport = transport;
	this._user = user;
	
	//attach events
	this.attachEvents();
}

pdTipsModule.prototype.attachEvents = function(){
	$$('.tip-dynamic').each(function(tip){
		var me = this; //set reference to current class to pass within Starbox constructor
		var callBack = this.getTipContent.bind(this);
		var tipId = tip.identify();
		var tipContentId = tipId.split('_')[1];
		var tipTitle = tip.readAttribute('title');
		var tipTrackPath = tip.readAttribute('path');
		
		new Tip(tipId, {
			title : tipTitle,
			ajax: {url: '/ajax.aspx?x=8XHrl0xJZEU%3d',options: {parameters:{id:tipContentId},onComplete: function(transport) {
				if(typeof pageTracker != 'undefined'){
					pageTracker._trackPageview(tipTrackPath);
				}
			}}},
			showOn: 'click',
			hideOn: { element: 'closeButton', event: 'click' },
			width: 400,
			stem: 'topLeft',
			style: 'darkgrey',
			offset: { x: 6, y: 3 }
		});
	});

	$$('.tip-static-hover').each(function(tip){
		var tipTitle = tip.readAttribute('tiptitle');
		var tipContent = tip.readAttribute('tipcontent');

		new Tip(tip, tipContent, {
			title : tipTitle,
			width: 300,
			stem: 'topLeft',
			style: 'darkgrey',
			offset: { x: 6, y: 3 }
		});
	});	
}

pdTipsModule.prototype.getTipContent = function(){
	this._transport.transmitRequest('site.shared', 'gettip', request, this.tipContentRetrieved.bind(this));		
}

pdTipsModule.prototype.tipContentRetrieved = function(objResponse){
	return objResponse.text;
}


