var JQ=jQuery.noConflict();JQ(document).ready(function(){TAFItem.startFunction();if(JQ("#TAFShowPopup").length>0){TAFItem.TAFRender()}});var TAFItem={sizeValue:"",colorValue:"",childAsinValue:"",tafWindow:"",winHeight:303,winWidth:585,startFunction:function(){var parentThis=this;JQ("#tellAFriendButton").click(function(){parentThis.TAFRender();return false});var TAFFrame=JQ("<iframe></iframe>");TAFFrame.attr({name:"TAFFrame",className:"TAFFrame",id:"TAFFrame",frameborder:0,position:"absolute"});TAFFrame.hide();var RTAFC=JQ("<div></div>");RTAFC.attr({id:"RTAF",className:"RTAF"});RTAFC.hide();var wrapperParent=JQ("#wrapper").parent();wrapperParent.append(TAFFrame);wrapperParent.append(RTAFC);this.TAFMoveWindow();this.attachEvents();if(JQ("#signinChildAsin").size()>0){this.showTAFPopUp();this.dialogEvents()}},dialogEvents:function(){var parentThis=this;JQ("#TAFContent").find("#cancelButton").click(function(){parentThis.closeTAFPopUp()});JQ("#TAFContent").find("#confirmButton").click(function(){parentThis.tafSubscribe();JQ("#TAFContent").find("#closeButtonDiv").click(function(){parentThis.closeTAFPopUp()});JQ("#TAFContent").find("#closeButtonDiv2").click(function(){parentThis.closeTAFPopUp()})})},hoverIn:function(domElem){JQ(domElem).find("img").attr("src",TAFHover)},hoverOut:function(domElem){JQ(domElem).find("img").attr("src",TAFOutButton)},attachEvents:function(){var parentThis=this;JQ("#TAFButton").click(function(){parentThis.showTAFPopUp();parentThis.dialogEvents()});JQ("#TAFBodyButton").hover(function(){parentThis.hoverIn(this)},function(){parentThis.hoverOut(this)})},changeChildAsinValue:function(){var detailDataObject=detailData;var asin=detailDataObject.sizeColorMap[this.sizeValue+"_"+this.colorValue];this.setTAFChildAsin(asin)},tafSubscribe:function(){var parentThis=this;var asin=JQ("#asin").attr("value");JQ.get("/ajax/?page=detail&layoutDomain=Starter&pagelet=inca-tell-a-friend-pagelet&ASIN="+asin+"&TAFAction=display&layoutId=3",function(data){parentThis.tafWindow=data;parentThis.TAFBuildPage(parentThis.tafWindow);parentThis.TAFShowMain()})},setTAFChildAsin:function(childAsinValue){this.childAsinValue=childAsinValue},showErrorPopUp:function(){JQ("#RContentChild").find("#dialogTable").css("display","none");JQ("#RContentChild").find("#errorContent").css("display","block")},showTYouPopUp:function(){JQ("#RContentChild").find("#dialogTable").css("display","none");JQ("#RContentChild").find("#thankyouContent").css("display","block")},createFrameAndDiv:function(parentElement){var TAFFrame=JQ("<iframe></iframe>");TAFFrame.attr("id","TAFFrame");TAFFrame.css("height",this.getWindowHeight());TAFFrame.hide();var RTAFC=JQ("<div></div>");RTAFC.attr("id","RTAF");RTAFC.hide();var wrapperParent;if(parentElement!=null){wrapperParent=JQ(parentElement).parent()}else{wrapperParent=JQ("#wrapper").parent()}TAFFrame.css("height",document.body.clientHeight);wrapperParent.append(TAFFrame);wrapperParent.append(RTAFC);this.tafWindow=JQ("#RTAF");this.tafFrame=JQ("#TAFFrame");this.tafButton=JQ("#tellAFriendButton");this.tafWindow.css("opacity",0);this.tafFrame.css("opacity",0)},displayTAF:function(){if(this.sizeValue==""||this.colorValue==""){return false}this.changeChildAsinValue();this.populateDialog();var detailDataObject=detailData;if(this.childAsinValue!=null){var TAFStatus=false;var availabilityStatus=false;var dataObjectAsin=detailDataObject.asinData[this.childAsinValue];if(dataObjectAsin.IsEmailMeWhenAvailable!=undefined&&dataObjectAsin.IsEmailMeWhenAvailable=="true"){TAFStatus=true}if(dataObjectAsin.IsAsinAvailable!=undefined&&dataObjectAsin.IsAsinAvailable=="false"){availabilityStatus=true}if(TAFStatus&&availabilityStatus){JQ("#submitButton").css("display","none");JQ("#TAF").css("display","block");JQ("#childAsin").val(this.childAsinValue)}else{JQ("#submitButton").css("display","block");JQ("#TAF").css("display","none")}}else{JQ("#submitButton").css("display","block");JQ("#TAF").css("display","none")}},TAFMoveWindow:function(){var winW=0;var winH=0;if(window.innerWidth){winW=window.innerWidth;winH=window.innerHeight}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){winW=document.documentElement.clientWidth;winH=document.documentElement.clientHeight}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){winW=document.body.clientWidth;winH=document.body.clientHeight}}}var pageHeight=(document.body.scrollHeight>document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;JQ("#RTAF").css({top:(winH-this.winHeight)/2+"px",left:(winW-this.winWidth)/2+"px"});if(JQ.browser.msie){JQ("#TAFFrame").css({top:(winH-this.winHeight)/2+"px",left:(winW-this.winWidth)/2+"px",width:winW+"px",height:pageHeight+"px"});JQ("#TAFFrame").hide();JQ("#RTAF").hide()}JQ("#TAFFrame").css("opacity",0);JQ("#RTAF").css("opacity",0)},TAFSendEmail:function(){parentThis=this;if(JQ("#TAFTo").attr("value")&&JQ("#TAFTo").attr("value")!=""){var asin=JQ("#asin").attr("value");var tafSendEmailUrl="/ajax/?page=detail&layoutDomain=Starter&pagelet=inca-tell-a-friend-pagelet&ASIN="+asin+"&TAFAction=send&layoutId=2&TAFTo="+JQ("#TAFTo").attr("value");if(JQ("#TAFCCMe").attr("checked")==true){tafSendEmailUrl+="&TAFCCMe=true"}JQ.get(tafSendEmailUrl,function(data){if(data.indexOf("error")>0){JQ.get("/ajax/?page=detail&layoutDomain=Starter&pagelet=inca-tell-a-friend-pagelet&ASIN="+asin+"&TAFAction=display&layoutId=3&emailSendingError=true",function(data){JQ("#TAFContent").empty();JQ("#TAFContent").append(data);JQ("#closeTAFPopupButton").click(function(){parentThis.closeTAFPopUp()});JQ("#tafSendEmailButton").click(function(){parentThis.TAFSendEmail()})})}else{JQ("#TAFContent").empty();JQ("#TAFContent").append(data);JQ("#closeTAFPopupButton").click(function(){parentThis.closeTAFPopUp()})}})}else{var asin=JQ("#asin").attr("value");JQ.get("/ajax/?page=detail&layoutDomain=Starter&pagelet=inca-tell-a-friend-pagelet&ASIN="+asin+"&TAFAction=display&layoutId=3&emailSendingError=true",function(data){JQ("#TAFContent").empty();JQ("#TAFContent").append(data);JQ("#closeTAFPopupButton").click(function(){parentThis.closeTAFPopUp()});JQ("#tafSendEmailButton").click(function(){parentThis.TAFSendEmail()})})}},TAFCreateContent:function(nodeName){var newDOMElem=JQ('<div id="RContentChild"></div>');newDOMElem.css("display","block");newDOMElem.html(nodeName);var RTAFContent=JQ("#TAFContent").append(newDOMElem);var parentThis=this;JQ("#tafSendEmailButton").click(function(){parentThis.TAFSendEmail()});JQ("#closeTAFPopupButton").click(function(){parentThis.closeTAFPopUp()});return RTAFContent},TAFBuildPage:function(nodeName){JQ("#TAFContent").empty();var RTAFMain=JQ("<div></div>").append(this.TAFCreateContent(nodeName));JQ("#RTAF").append(RTAFMain)},TAFShowPage:function(){JQ("#RTAF").css("display","");JQ("#TAFContent").css("display","block");JQ("#tafThankYou").css("display","none")},TAFShowMain:function(){var parentThis=this;JQ("#wrapper").fadeTo("slow",0.3,function(){JQ("#TAFFrame").fadeTo("slow",1);JQ("#RTAF").fadeTo("slow",1);parentThis.TAFShowPage()})},TAFHideMain:function(){if(JQ.browser.mozilla){JQ("#wrapper").fadeTo("slow",1)}else{if(JQ.browser.msie){JQ("#TAFFrame").fadeTo("slow",0);JQ("#wrapper").fadeTo("slow",1)}}},closeTAFPopUp:function(){JQ("#TAFFrame").hide();JQ("#RTAF").hide();JQ("#RTAF").css("opacity",0);this.TAFHideMain()},TAFRender:function(){var parentThis=this;parentThis.showTAFPopUp();parentThis.tafSubscribe()},showTAFPopUp:function(){var parentThis=this;JQ("#TAFFrame").css("display","")},getWindowHeight:function(){var winH=window.innerHeight;if(winH<document.body.clientHeight){winH=document.body.clientHeight}if(winH<document.documentElement.clientHeight){winH=document.documentElement.clientHeight}return winH}};
