//  @import com.hedgehoglab.application.view.BaseView;
//	@import com.hedgehoglab.solomon.helper.QTipViewHelper;
//	@import com.hedgehoglab.solomon.helper.DealsHelper;
	
function ContactDealsView(scope){
	BaseView.call(this,scope);
	
	QTipViewHelper.call(this,scope);
	DealsHelper.call(this,scope);
	
    var _this = this;
    this.setElement=function(element){
        scope.element=element;
    };

    this.render = function(model,length){
        _this.render_template_with_view('contacts/ContactsDeals',{deals:model},{},function(f){
			f = $(f);
      		$(scope.element).html("").append(f);

			// Render the qtip template for this user
			
			$.each($('dd',f),function(i,n){
				var index=$(n).attr('id');
				var array=$(n).attr('rel');
				
				// console.log(model[array].data[index],array,index);
				deal = model[array].data[index];
				// console.log(deal);
				// deal = deals[id];
				// alert(deal);
				_this.render_template_with_view('deal_involved_qtip',{deal:deal},_this,function(qtip_markup){
					// console.log(qtip_markup);
					// console.log(_this.qtip_that_mofo,n,qtip_markup);
					_this.qtip_that_mofo($(n),deal.name,qtip_markup);
				});
			});
			
  		});
    };
}