if(typeof(window.JQ)=="undefined"){var JQ=jQuery.noConflict()}function swfAjaxRequest(a,d,b,c){this.url=a||"";this.method=d||"POST";this.data=b||{};this.callback=c||function(){alert("No callback provided")};this.req={url:this.url,meth:this.method,data:this.data,onready:function(e){c(e)}};this.sendRequest=function(){f4a.open(this.req)}}function embedFileUploader(a){var b=new Date();var c=new SWFObject("/nikeos/global/modules/profile_image_upload/v1/swf/uploader22.swf","uploader","140","14","9.0.47","#aaaaaa");c.addParam("wmode","transparent");c.addParam("allowScriptAccess","always");c.write(a);moveOverLink(JQ("#"+a),JQ("#profile_caption a:visible"))}function moveOverLink(a,b){var d=b.offset({border:true,padding:true}).left;var c=b.offset({border:true,padding:true}).top;if(jQuery.browser.msie&&(jQuery.browser.version<7)){c=c-15}a.css({top:c+"px",left:d+"px",width:"140px",height:"14px",position:"absolute"})}var uploadUtils={browse:function(){var c=new Array();var b={description:"Images (*.jpg, *.jpeg, *.png)",extension:"*.jpg;*.jpeg;*.png"};c.push(b);var a={filters:c};EventBridge.dispatchEvent({type:"onFileBrowse",data:a})},upload:function(){if(JQ("#image_file_name").val()!=""){var b=UPM.UPLOAD_URL+"&locale="+UPM.locale;var a="Filedata";EventBridge.dispatchEvent({type:"onFileUpload",data:{uploadPath:b,fieldName:a}});JQ.blockUI();if(typeof(window.tracking!="undefined")){tracking.deleteProp("prop19");tracking.click({pageName:track_site+">profile>my_profile>upload_photo"})}}else{console.warn("No File Entered")}}};var uploadListener={onUploadFileSelect:function(c){var b=c.data.name;var a=c.data.size;if(a>200000){alert(_("fileTooBig"));JQ("#image_file_name").val("")}else{JQ("#image_file_name").val(b);uploadUtils.upload()}},onUploadCompleteData:function(b){var a=b.data.response;var c=JQ.xml2json(a);if(c.status=="success"){profileImage.handleScaledImage(c)}else{console.warn("uploadListener.onUploadCompleteData upload failure...")}},onUploadProgress:function(a){console.log("onUploadProgress");setTimeout(function(){console.log(a.data.bytesLoaded+" of "+a.data.bytesTotal+" loaded...")},100)},onUploadIoError:function(a){alert(_("problemUploadingImage"));JQ.unblockUI()}};var objectUtils={printObject:function(b){var a="";for(i in b){a+="<strong>"+i+"</strong> -- "+b[i]+"<br />"}return a},serialize:function(a){var b="";var c="";for(i in a){b+=c+i+"="+a[i];c="&"}return b}};var profileImage={image_width:140,image_height:85,image_left_offset:44,image_top_offset:90,draggable_width:null,draggable_height:null,draggable_left_offset:null,draggable_top_offset:null,frame_width:null,frame_height:null,frame_left_offset:null,frame_top_offset:null,horizontal_play:null,vertical_play:null,tempURL:null,finalURL:null,file_extension:null,init:function(){var a=this;JQ("#uploader_swf_content").hover(function(){JQ("#default_image").css({width:"136px",height:"81px",border:"2px solid #f60",cursor:"pointer"})},function(){JQ("#default_image").css({width:"140px",height:"85px",border:"none"})});JQ("#uploader_swf_content").click(function(){uploadUtils.browse()});JQ("#save_link").click(function(){a.postToCropURL(a.getPostData())});JQ("#delete_link").click(function(){a.deleteImage()});embedFileUploader("uploader_swf_content")},handleScaledImage:function(b){var a=this;a.draggable_width=parseInt(b.imgwidth);a.draggable_height=parseInt(b.imgheight);a.horizontal_play=(a.draggable_width-a.image_width);a.vertical_play=(a.draggable_height-a.image_height);a.frame_width=a.draggable_width+a.horizontal_play;a.frame_height=a.draggable_height+a.vertical_play;a.frame_left_offset=a.image_left_offset-a.horizontal_play;a.frame_top_offset=a.image_top_offset-a.vertical_play;a.draggable_left_offset=Math.round(a.horizontal_play/2);a.draggable_top_offset=Math.round(a.vertical_play/2);a.tempURL=UPM.TEMP_IMAGE_FOLDER_URL+b.response;a.file_extension="jpg";JQ.unblockUI();JQ("#uploader_swf_content").css({zIndex:-1});a.makeDraggable()},makeDraggable:function(){var a=this;JQ("#default_image, #new_image").hide();var b=JQ("#save_link").html();JQ("#draggable_frame").css({width:a.frame_width+"px",height:a.frame_height+"px",left:a.frame_left_offset+"px",top:a.frame_top_offset+"px"});JQ("#draggable").css({backgroundImage:"url("+a.tempURL+")",width:a.draggable_width+"px",height:a.draggable_height+"px",left:a.draggable_left_offset+"px",top:a.draggable_top_offset+"px"}).show().draggable({zIndex:1000,opacity:0.8,containment:"parent",start:function(){JQ(this).css({cursor:"url(/nikeos/site/profile/global/images/cursors/grab.gif), move"})},stop:function(){JQ(this).css({cursor:"pointer"})}}).hover(function(){JQ("#save_link").css({color:"#f60"}).html(_("clickToDrag"))},function(){JQ("#save_link").css({color:"#C4C1BE"}).html(b)});JQ("#save_link").show();JQ("#delete_link, #upload_link").hide()},getPostData:function(){var b=this;var f=parseInt(JQ("#draggable_frame").css("left").split("px")[0]);var e=parseInt(JQ("#draggable_frame").css("top").split("px")[0]);var d=parseInt(JQ("#draggable").css("left").split("px")[0]);var c=parseInt(JQ("#draggable").css("top").split("px")[0]);var a=b.image_left_offset-f-d;var g=b.image_top_offset-e-c;return{email:UPM.prof.email,description:"profile_image",name:"profile_image",site:"nikeprototype",locale:UPM.locale,filename:b.tempURL.split("/")[b.tempURL.split("/").length-1],xcoord:a,ycoord:g}},postToCropURL:function(d,f){var a=this;console.log(d);var b=UPM.CROP_URL;var c=objectUtils.serialize(d);b+="&"+c;var e=new swfAjaxRequest(b,"GET",{},function(h){var g=JQ.xml2json(h);if(g.status=="success"){a.croppedImageURL=g.response;JQ("#new_image").css("background-image","url("+UPM.TEMP_IMAGE_FOLDER_URL+"/vc/profile/"+a.croppedImageURL+"_LRG."+a.file_extension+")").show();JQ("#draggable").hide();JQ("#delete_link").show();JQ("#save_link, #upload_link").hide();JQ("#uploader_swf_content").css({zIndex:-1});NIKEOS.ME.addToCookie({profileImage:a.croppedImageURL});setNavProfile({profileImage:UPM.TEMP_IMAGE_FOLDER_URL+"/vc/profile/"+a.croppedImageURL});if(typeof(window.tracking!="undefined")){tracking.deleteProp("prop19");tracking.click({pageName:track_site+">profile>my_profile>upload_photo>success"})}ss.syncProfile(ss.DPSID);if(typeof(window.nikeplus)!="undefined"){nikeplus.plus.syncProfileSettings(function(j){});nikeplus.user.reload()}}else{console.warn("crop failed")}JQ.unblockUI()});JQ.blockUI();e.sendRequest()},deleteImage:function(){var b=UPM.DELETE_URL;if(confirm(_("areYouSure"))){var a=new swfAjaxRequest(b,"GET",{},function(d){var c=JQ.xml2json(d);if(c.status=="success"){self.newImageURL=null;JQ("#upload_link").show();JQ("#delete_link, #save_link").hide();JQ("#draggable, #new_image").hide();JQ("#default_image").show();JQ("#uploader_swf_content").css({zIndex:9999});NIKEOS.ME.removeFromCookie(["profileImage"]);setNavProfile({profileImage:UPM.TEMP_IMAGE_FOLDER_URL+"/nikeos/site/profile_v1.0b/global/images/profile_image/default_image"});if(typeof(window.tracking!="undefined")){tracking.deleteProp("prop19");tracking.click({pageName:track_site+">profile>my_profile>upload_photo>delete"})}ss.syncProfile(ss.DPSID);if(typeof(window.nikeplus)!="undefined"){nikeplus.plus.syncProfileSettings(function(e){});nikeplus.user.reload()}}else{console.warn("didn't delete image")}JQ.unblockUI()});JQ.blockUI();a.sendRequest()}},getProfileImage:function(){if(UPM.prof!=null){if(!NIKEOS.ME.getCookie().profileImage){var b=UPM.GET_PROFILE_IMAGE_URL;var a=new swfAjaxRequest(b,"GET",{},function(d){var c=JQ.xml2json(d);if(c.status=="success"){if(c.response=="none"){JQ("#uploader_swf_content").css({zIndex:9999})}else{profileImage.croppedImageURL=c.response;NIKEOS.ME.addToCookie({profileImage:c.response});JQ("#default_image").hide();JQ("#new_image").css("background-image","url("+UPM.TEMP_IMAGE_FOLDER_URL+UPM.PROFILE_IMAGE_BASE_URL+profileImage.croppedImageURL+"_LRG.jpg)").show();JQ("#delete_link").show();JQ("#save_link, #upload_link").hide()}}else{console.error("getprofileimage error...")}});a.sendRequest()}else{profileImage.croppedImageURL=NIKEOS.ME.getCookie().profileImage;JQ("#default_image").hide();JQ("#new_image").css("background-image","url("+UPM.TEMP_IMAGE_FOLDER_URL+UPM.PROFILE_IMAGE_BASE_URL+profileImage.croppedImageURL+"_LRG.jpg)").show();JQ("#delete_link").show();JQ("#save_link, #upload_link").hide()}}}};function getDimensions(a){return{height:a.height(),width:a.width()}};