
if(typeof(Adk)=="undefined"||!Adk){Adk={};}
Adk.ScaleResize=function(image,maxWidth,maxHeight)
{image=$(image);var resize=function()
{if(maxHeight>=maxWidth)
{var ratio=image.width()/image.height();var maxRatio=maxWidth/maxHeight;if(ratio>=maxRatio)
{image.width(ratio*maxHeight);image.height(maxHeight);}
else
{image.height(image.height()/image.width()*maxWidth);image.width(maxWidth);}}
else
{var ratio=image.height()/image.width();var maxRatio=maxHeight/maxWidth;if(ratio<=maxRatio)
{image.height(ratio*maxWidth);image.width(maxWidth);}
else
{image.width(image.width()/image.height()*maxHeight);image.height(maxHeight);}}};if(image.width()>0&&image.height()>0)
{resize();}
else
{image.load(resize);}};Adk.Report=function(adId,publisherId,applicationId)
{this.adId=adId;this.publisherId=publisherId;this.applicationId=applicationId;this.element=null;this.content=null;this.ad=null;this.other=null;this.otherContent=null;this.init();};Adk.Report.prototype={init:function()
{var self=this;if(Adk.Report.instance==null)
{this.ad=$('#dvDisplayAd');$('body').append("<a class='report' href='javascript:void(0);'></a>");this.element=$('.report');this.element.css('left',this.ad.width()-self.element.outerWidth()+'px');this.element.hover(function(){self.element.addClass('report-hover');},function(){self.element.removeClass('report-hover');});this.element.click(function(){self.report();});}},report:function()
{var self=this;if(this.content==null)
{$('body').append("<div class='report-form'><a class='report-undo' href='javascript:void(0);'>Undo</a><p>Please tell us why you don't like this ad.</p></div>");this.content=$('.report-form');this.content.append("<a class='report-do' href='javascript:void(0);'><input type='radio' name='report-reason' value='Uninteresting' />Uninteresting</a>");this.content.append("<a class='report-do' href='javascript:void(0);'><input type='radio' name='report-reason' value='Misleading' />Misleading</a>");this.content.append("<a class='report-do' href='javascript:void(0);'><input type='radio' name='report-reason' value='Offensive' />Offensive</a>");this.content.append("<a class='report-do' href='javascript:void(0);'><input type='radio' name='report-reason' value='Repetitive' />Repetitive</a>");this.content.append("<a class='report-doOther' href='javascript:void(0);'><input type='radio' name='report-reason' value='Other' />Other</a>");this.content.append("<div class='report-other'><textarea></textarea><button>Okay<button></div>");this.other=$('.report-doOther',this.content);this.otherContent=$('.report-other',this.content);if($(window).height()>150)
{$('.report-do').addClass('report-doTall');$('.report-doOther').addClass('report-doTall');}
this.other.click(function(){self.showOther();});$('button',this.otherContent).click(function(){self.submitReport(self.other);});$('.report-do',this.content).click(function(){self.hideOther();self.submitReport(this);});$('.report-undo',this.content).click(function(){self.cancel();});this.hideOther();}
this.element.hide();this.ad.hide();this.content.show();},showOther:function()
{this.otherContent.show();$('textarea',this.otherContent).focus();},hideOther:function()
{$('textarea',this.otherContent).val('');this.otherContent.hide();},cancel:function()
{this.content.hide();this.ad.show();this.element.show();},submitReport:function(element)
{$.ajax({url:'http://advertiser.cubics.com/reportAd.aspx?',dataType:'jsonp',jsonp:'callback',data:{adId:this.adId,publisherId:this.publisherId,applicationId:this.applicationId,reason:$('input',element).val(),other:$('textarea',this.otherContent).val()}});this.content.html('Thanks for your feedback. Over time, this information helps us deliver more relevant ads to you.');this.content.addClass('report-done');}};Adk.Report.instance=null;