/* File: js/proshop.js, Ratio: 34% */

var gender=undefined;var isRoundActive=false;var isProductsLoaded=false;var isUnityVisible=false;var isUnityReady=false;var categoryXml,productsXml;var unityCommands=[];var selectedCategoryId=-1;var selectedCategoryName="";var selectedCategoryType=""
var selectedSubNavId=-1;var selectedSubNavName="";var selectedToolTipId=-1;var selectedOfbId=undefined;var selectedSort="-price";var selectedFilter="";var extraCategoryText="";var firstCategoryId=-1;var firstCategoryName="";var firstCategoryType=""
var ITEMS_PER_PAGE=9;var ITEMS_PER_PAGE_FEATURED=6;var TRUE=1;var totalPages=0;var currentPage=1;var columnsCount=3;var totalProducts=0;var lastCameraCommand="";var lastProductCommand="";var DefaultStuff=['Shoes_WhiteMale_2883','BaseballCap_BlackMale_19706','TightFlatFrontPants_KhakiMale_4363','TightPolo_PowderBlueMale_8403','EASports_Action_44398','EA_Silver_DefaultDriver_59484','EA_Silver_DefaultFairwaywood_60220','EA_Silver_Default3Iron_60271','EA_Silver_DefaultPutter_60322','EA_Silver_DefaultWedge_60373'];var FemaleCategories=['SPECIAL','PRESTIGE','CLUBS','BALLS',];var MaleOnlySpecialCategories=['MAX STATS','OUTFITS',];var MALE_SWING_AIDS="MALE_SWING_AIDS";var SHOT_PREVIEW="SHOT_PREVIEW";var PUTT_PREVIEW="PUTT_PREVIEW";function isDefaultStuff(entitlementTag){for(var i=0;i<DefaultStuff.length;i++){if(DefaultStuff[i]==entitlementTag){return true;}}
return false;}
function isFemaleCategory(tab){for(var i=0;i<FemaleCategories.length;i++){if(FemaleCategories[i]==tab){return true;}}
return false;}
function isMaleOnlySpecialCategory(tab){for(var i=0;i<MaleOnlySpecialCategories.length;i++){if(MaleOnlySpecialCategories[i]==tab){return true;}}
return false;}
function unityCallback()
{if(isUnityVisible)
{calcUnityPosition();}}
function pageReadyUser(){ShowNoUnityPage();EmbedUnity(unityRuntimePath,unityEntryPoint,unityRuntimeConfigPath,unityCallback);returningUrlParameters();$(".close_modal").click(function(){ProcessProductCommand("ResetCharacter");hideProshopUnity();});$("#unityModal").show();setupSorting();setupFiltering();setupMyGearSidePanel();getGender();if(!isMyGear)
{setupDirectedExperience({icon:'proshop',title:'Pro Shop',description:'Purchase some new gear!'});}
else
{setupDirectedExperience({icon:'proshop',title:'My Gear',description:'Manage your gear'});}}
function setupSorting(){$(".sorting select").bind("change",function(e){$(".paging").animate({opacity:0.5});selectedSort=$("option[selected]",e.currentTarget).attr("value");$(".sorting select").unbind("change");$(".sorting select option").each(function(){if($(this).attr("value")==selectedSort)
$(this).attr("selected","true");else
$(this).attr("selected","");});document.location=generateReturnUrl(null,null,null,null,null,null);setupSorting();currentPage=1;loadProducts();});}
function setupFiltering(){if(isMyGear)
selectedFilter="gear";}
function returningUrlParameters(){var returnHash=document.location.hash;if(returnHash!=undefined&&returnHash!="")
{var hashArray=document.location.hash.replace("#","").split("&");for(var i=0;i<hashArray.length;i++)
{var valueArray=hashArray[i].split("=");switch(valueArray[0].toString())
{case"c":selectedCategoryId=parseInt(valueArray[1]);break;case"sn":selectedSubNavId=parseInt(valueArray[1]);break;case"p":currentPage=parseInt(valueArray[1]);break;case"s":selectedSort=valueArray[1];break;case"f":selectedFilter=valueArray[1];break;case"ofb":selectedOfbId=valueArray[1];break;}
valueArray=undefined;}
hashArray=undefined;}}
function generateReturnUrl(categoryId,subNavId,newPage,sort,filter,ofbId){if(categoryId==undefined||categoryId==null)
categoryId=selectedCategoryId;if(subNavId==undefined||subNavId==null)
subNavId=categoryId;if(newPage==undefined||newPage==null)
newPage=currentPage;if(sort==undefined||sort==null)
sort=selectedSort;if(filter==undefined||filter==null)
filter=selectedFilter;if(ofbId==undefined||ofbId==null)
return"#c="+categoryId+"&sn="+subNavId+"&p="+newPage+"&s="+sort+"&f="+filter;else
return"#c="+categoryId+"&sn="+subNavId+"&p="+newPage+"&s="+sort+"&f="+filter+"&ofb="+ofbId;}
function getGender(){var catNum=undefined;var txtStrip=undefined;if($(".round_information").length>0){$("#proshopError").text("Items cannot be equipped during a round. Please finish your current round before attempting to equip new items");$("#proshopError").slideDown();isRoundActive=true;}
callGetWS(true,"/blaze/characters/",null,null,function(data,textStatus){gender=jQuery("sex",data).text();gender=parseInt(gender,10);if(gender===0){catNum=maleCatalog;extraCategoryText="MALE_";}else{catNum=femaleCatalog;extraCategoryText="MALE_";}
loadCategories(catNum,gender);},null,null);}
function loadCategories(catNum){callGetWS(true,"/pro_shop_service/categories/"+catNum,null,null,function(data,textStatus)
{var errorReason=$("error",data).text();if(errorReason!="")
{$("#proshopError").text("Could not retrieve pro shop information from server.  Please try again later.");$("#proshopError").slideDown();}
else
{categoryXml=data;displayCategories();}
errorReason=undefined;},null,null);}
function displayCategories(){var clubsCatId=-1;var clubsCatName="";$("categories",categoryXml).each(function()
{$(this).children().children().filter("category").each(function()
{var listLoc;var categoryType="apparel";if($(this).attr("name")==="MALE_APPAREL"||$(this).attr("name")==="FEMALE_APPAREL")
{$("#categorynav").append('<ul class="apparel tabs"></ul>');listLoc=".section_nav ul.apparel";categoryType="apparel";}
else if($(this).attr("name")==="MALE_EQUIPMENT"||$(this).attr("name")==="FEMALE_EQUIPMENT")
{$("#categorynav").append('<ul class="equipment tabs"></ul>');listLoc=".section_nav ul.equipment";categoryType="gear";}
else if($(this).attr("name")==="MALE_FEATURED_CATEGORIES"||$(this).attr("name")==="FEMALE_FEATURED_CATEGORIES")
{$("#categorynav").append('<ul class="featured tabs"></ul>');listLoc=".section_nav ul.featured";categoryType="featured";}
$('ul.equipment').insertAfter('ul.featured');$('ul.apparel').insertAfter('ul.equipment');$(this).children().filter("category").each(function()
{if($(this).attr("categoryType")!="HIDDEN"&&$(this).attr("isNotInProShop")!=TRUE)
{var newTab;var tabName=$(this).attr("name").replace(extraCategoryText,"").replace("_"," ");if(gender==1&&!isFemaleCategory(tabName))
{return;}
var categoryId=$(this).attr("categoryId");if((isMyGear&&tabName!="PRESTIGE")||!isMyGear)
{if(categoryId==selectedCategoryId)
{firstCategoryId=selectedCategoryId;firstCategoryName=tabName;firstCategoryType=categoryType;}
else if(!isMyGear&&tabName=="FEATURED"&&selectedCategoryId==-1)
{firstCategoryId=categoryId;firstCategoryName=tabName;firstCategoryType=categoryType;}
else if(!isMyGear&&tabName=="SPECIAL"&&selectedCategoryId==-1)
{firstCategoryId=categoryId;firstCategoryName=tabName;firstCategoryType=categoryType;}
else if(isMyGear&&tabName=="CLUBS"&&selectedCategoryId==-1)
{firstCategoryId=categoryId;firstCategoryName=tabName;firstCategoryType=categoryType;}
newTab='<li><a id="CategoryButton'+categoryId+'" class="'+tabName+'">'+tabName+'</a></li>';$(listLoc).append(newTab);$("#CategoryButton"+categoryId).click(function(){selectedSubNavId=-1;currentPage=1;selectedCategoryType=categoryType;selectCategory(categoryId,tabName,categoryType);selectedOfbId=undefined;});}}});listLoc=undefined;});});selectCategory(firstCategoryId,firstCategoryName,firstCategoryType);}
function selectCategory(categoryId,categoryName,catType){if(categoryName!="")
{tagInOmniture("PROSHOP"+(categoryName).toUpperCase().replace(/\s+/g,'').replace(/_/g,'').replace(/-/g,''));}
$("#categorynav li a").removeClass("selected");$("#CategoryButton"+categoryId).addClass("selected");selectedCategoryId=categoryId;selectedCategoryName=categoryName;selectedCategoryType=catType;if(selectedCategoryType=="featured")
$("#proshopFeatured").show();else
$("#proshopFeatured").hide();displaySubNav(categoryId,categoryName);}
function displaySubNav(categoryId,categoryName){var firstSubNavId=-1;$("#SubNav").empty();$("#SubNav").attr("class","proshop_subnav "+categoryName.replace(/_/g,"").replace(/ /g,"").toLowerCase());$("category",categoryXml).each(function(){if($(this).attr("categoryId")==categoryId){$(this).children().filter("category").each(function(i){if($(this).attr("categoryType")!="HIDDEN"&&$(this).attr("isNotInProShop")!=TRUE){var subNavId=$(this).attr("categoryId");var subNavName=$(this).attr("name").replace(extraCategoryText,"").replace("_"," ");if(gender==1&&isMaleOnlySpecialCategory(subNavName))
{return;}
if(subNavName!='BUNDLES'||!isMyGear){$("#SubNav").append('<li><a id="SubNavButton'+subNavId+'"><span><img src="/img/spacer.gif" /></span>'+subNavName+'</a></li>');$("#SubNavButton"+subNavId).attr("href",generateReturnUrl(null,subNavId,null,null,null));$("#SubNavButton"+subNavId).click(function(){currentPage=1;selectedOfbId=undefined;selectSubNav(subNavId);});if(firstSubNavId<0){$("#CategoryButton"+categoryId).attr("href",generateReturnUrl(categoryId,subNavId,null,null,null));firstSubNavId=subNavId;}}}});return false;}});if(selectedSubNavId==-1)
selectSubNav(firstSubNavId);else
selectSubNav(selectedSubNavId);}
function selectSubNav(categoryId){$("#subnavigation li").removeClass("selected");$("#SubNavButton"+categoryId).parent().addClass("selected");selectedSubNavId=categoryId;$("category",categoryXml).each(function(){if($(this).attr("categoryId")==categoryId){selectedSubNavName=$(this).attr("name");return false;}});loadProducts();}
function loadProducts(){$("#proShopListing").show();isProductsLoaded=false;totalProducts=0;$(".paging").animate({opacity:0.50});$("#itemListings").hide();showLoadingAnimation();var cacheMyGear=true;if(isMyGear)
cacheMyGear=false;var itemsPerPage=selectedCategoryType=="featured"?ITEMS_PER_PAGE_FEATURED:ITEMS_PER_PAGE;callGetWS(cacheMyGear,"/pro_shop_service/products/"+selectedSubNavId+"/"+currentPage+"/"+itemsPerPage+"/"+selectedSort+"/"+selectedFilter,null,null,function(data,textStatus){productsXml=data;isProductsLoaded=true;displayProducts();},null,null);}
function displayProducts(){if(isProductsLoaded&&isEntitlementsLoaded&&isEquippedLoaded)
{hideLoadingAnimation();$("#itemListings").empty();var itemsPerPage=selectedCategoryType=="featured"?ITEMS_PER_PAGE_FEATURED:ITEMS_PER_PAGE;if($("product",productsXml).length>0)
{var currentRowColumnCount=-1;if($("error",productsXml).length==0)
{totalProducts=parseInt($("products",productsXml).attr("totalCount"));totalPages=Math.ceil(totalProducts/itemsPerPage);}
else
{totalProducts=0;totalPages=0;}
$("product",productsXml).each(function(i){if(currentRowColumnCount==-1)
{$("#itemListings").append("<tr/>");currentRowColumnCount=0}
displayProduct($(this));currentRowColumnCount++;if(currentRowColumnCount>=columnsCount||i>=itemsPerPage||(itemsPerPage*(currentPage-1))+i>=totalProducts)
{currentRowColumnCount=-1;}});var lastRowColumnCount=$("#itemListings tr:last td").length;if(lastRowColumnCount<columnsCount)
{for(var i=0;i<(columnsCount-lastRowColumnCount);i++)
$("#itemListings tr:last").append("<td>");}
$("#itemListings tr:odd").addClass("zebra");}
if(totalProducts==0)
{$("#itemListings").append('<li class="no-items"><h3>There are currently no items for this category. Please select another.</h3></li>');}
displayPagination();$("#itemListings").show();$("#itemListings td:nth-child(3) div").css('border-right','none');$("#proshopLoading").fadeOut(1000);if(selectedOfbId!=undefined)
{if(unityCommands[selectedCategoryId]!=undefined){ProcessCameraCommand(unityCommands[selectedCategoryId]);}
$("#Product"+selectedOfbId).click();selectedOfbId=undefined;}}}
function displayProduct(productDataXml){var entitlementTag;var imageUrl;var name;var displayName;var useCount;var productId=$(productDataXml).attr("productId");var isOwned=false;var isEquipped=false;var isDefault=false;var isMembersOnly=false;var isOnSale=false;var ownedUsesLeft=0;var brand="ea";var brandUrl="/img/placeholder/proshop_item_logo.png";var department="apparel";var roundsColor="";var currencyType="_TB";var rack="";var isUnequippable=false;var isPreviewable=true;var isEquippable=true;var isRefillable=true;var isPerUse=false;var isBundle=false;var bundledItems=[];$("attribute",productDataXml).each(function(){var attribute=$(this);switch(attribute.attr("name")){case"entitlementTag":entitlementTag=attribute.attr("value");break;case"Thumbnail_60x60URI":imageUrl=attribute.attr("value");break;case"Product Name":displayName=attribute.attr("value");break;case"unityCommand":unityCommand=attribute.attr("value");break;case"useCount":useCount=attribute.attr("value");useCount=parseInt(useCount,10);break;case"brand":brand=attribute.attr("value");if(brand=="Other")
brand="ea";if(brand.indexOf(" ")>=0)
brand=brand.replace(/ /g,"_");brandUrl="/swappables/companylogos/"+brand.toLowerCase()+".png";break;case"department":department=attribute.attr("value");break;case"rack":rack=attribute.attr("value");break;case"membersOnly":isMembersOnly=attribute.attr("value")=="1"?true:false;break;case"isUnequippable":isUnequippable=attribute.attr("value")=="1"?true:false;break;case"isEquippable":isEquippable=attribute.attr("value")=="1"?true:false;break;case"isPreviewable":isPreviewable=attribute.attr("value")=="1"?true:false;break;case"isRefillable":isRefillable=attribute.attr("value")=="1"?true:false;break;case"onSale":isOnSale=attribute.attr("value")=="1"?true:false;break;case"isPerUse":isPerUse=attribute.attr("value")=="1"?true:false;break;case"isBundle":isBundle=attribute.attr("value")=="1"?true:false;default:break;}
attribute=undefined;});$("bundledItem",productDataXml).each(function(){var item=$(this);bundledItems.push(item.attr("entitlement"));});if(department=="Equipment"){isRefillable=!isUserSubscriber;}
var ofbId=productId;var minUsesLeft=999999999;for(var i=0;i<entitlementList.length;i++){if(entitlementList[i]!==undefined){if(entitlementList[i].entitlementTag===entitlementTag){isOwned=true;if(!isBundle){minUsesLeft=entitlementList[i].useCount;break;}}
if(isBundle){for(var j=0;j<bundledItems.length;j++){if(entitlementList[i].entitlementTag===bundledItems[j]){if(entitlementList[i].useCount<minUsesLeft){minUsesLeft=entitlementList[i].useCount;}}}}}}
if(minUsesLeft==999999999)
minUsesLeft=0;ownedUsesLeft=minUsesLeft;if(department=="Equipment"){if(isUserSubscriber){isRefillable=false;}
else{if(ownedUsesLeft==0){isRefillable=true;}
else{isRefillable=false;}}}
if(entitlementTag.indexOf("MaxStat")>=0){if(ownedUsesLeft==0){isEquippable=false;isRefillable=true;}
else{isRefillable=false;}}
if(isDefaultStuff(entitlementTag)){isOwned=true;isDefault=true;}
ofbId=encode64(ofbId).replace(/=/g,"");var pricePoint=$("pricePoints pricepoint:first",productDataXml);var price=pricePoint.attr("price");price=parseInt(price,10);currencyType=pricePoint.attr("currency");pricePoint=undefined;$("inventoryitem",equippedXml).each(function(i){if($("entitlementname",this).text()==entitlementTag){isEquipped=true;return false;}});var productStatus=calcProductStatus(entitlementTag,isOwned,isEquipped,isDefault,ownedUsesLeft);var useMessage="";if(productStatus=="available"||(entitlementTag.indexOf(SHOT_PREVIEW)>=0&&!isMyGear)||(entitlementTag.toUpperCase().indexOf(PUTT_PREVIEW)>=0&&!isMyGear))
{useMessage="<li class='price_info'>";if(currencyType=="_TB"){useMessage+=" <span class='price cash'><em>$"+abbreviateNumbers(price,false)+"</em></span>";}else{useMessage+=" <span class='price points'><em>"+abbreviateNumbers(price,false)+"</em></span>";}
if(department=="Collections")
useMessage+="";else if(department=="Apparel"&&entitlementTag.indexOf("MaxStat")<0)
useMessage+=" <span class='duration'><strong>Unlimited Rounds</strong></span>";else if(isUserSubscriber&&department=="Equipment")
useMessage+=" <span class='duration'><strong>Unlimited Rounds</strong></span>";else if(useCount<0)
useMessage+=" <span class='duration'><strong>Unlimited Rounds</strong></span>";else
{if(isPerUse)
{useMessage+=" <span class='duration'><p>Uses: </p><em>"+useCount+"</em></span>";}
else
{useMessage+=" <span class='duration'><p>Rounds: </p><em>"+useCount+"</em></span>";}}
useMessage+="</li>";}
else if(productStatus=="empty"||productStatus=="equipped"||productStatus=="owned")
{if(department=="Collections")
{useMessage="";}
else if(department=="Apparel"&&entitlementTag.indexOf("MaxStat")<0)
{useMessage="<li class='rounds_remaining blue'>";useMessage+="Unlimited Rounds";useMessage+="</li>";}
else if(isUserSubscriber&&department=="Equipment")
{useMessage="<li class='rounds_remaining blue'>";useMessage+="Unlimited Rounds";useMessage+="</li>";}
else if(isDefault)
{useMessage="<li class='rounds_remaining green'>";useMessage+="Item does not expire";useMessage+="</li>";}
else if(ownedUsesLeft==0)
{useMessage="<li class='rounds_remaining "+calcUseColor(ownedUsesLeft)+"'>";if(currencyType=="_TB")
useMessage+="<span class='price cash'><em>Refill: $"+abbreviateNumbers(price,false)+"</em></span>";else
useMessage+="<span class='price points'><em>Refill: "+abbreviateNumbers(price,false)+"</em></span>";useMessage+="</li>";}
else
{useMessage="<li class='rounds_remaining "+calcUseColor(ownedUsesLeft)+"'>";if(isPerUse)
{useMessage+=ownedUsesLeft+" Use"+(ownedUsesLeft==1?" remaining":"s Remaining");}
else
{useMessage+=ownedUsesLeft+" Round"+(ownedUsesLeft==1?" remaining":"s Remaining");}
useMessage+="</li>";}}
var tagClass="";if(isOnSale)
tagClass="on_sale";else if(isMembersOnly)
tagClass="members_tag";var newItem="<div class='proshop_item "+selectedCategoryType+" "+productStatus+"'>\
   <ul class='item_header'>\
    <li class='item_logo'><img src='"+brandUrl+"' /></li>\
    <li class='item_equipped'><span></span>Equipped</li>\
    <li class='item_owned'><span></span>Owned</li>\
   </ul>\
   <ul class='item_content'>\
    <li class='tag "+tagClass+"'></li>\
    <li class='thumbnail'><a><img src='"+imageUrl+"' /></a></li>\
    <li class='name'><h2>"+displayName+"</h2></li>\
    "+useMessage+"\
   </ul>\
  </div>";$("#itemListings tr:last").append("<td id='Product"+ofbId+"'>"+newItem+"</td>");var buttonString="";if(isPreviewable)buttonString+="<span class='preview_button UserButton UserButton_white'><a class='buttonProductPreview UserButton_text'>Preview</a></span>";if(!isOwned){if(isMembersOnly&&!isUserSubscriber){buttonString+="<span class='member_button'><a class='buttonBecomeMember'>Become a Member</a></span>";}
else{buttonString+="<span class='purchase_button'><a class='buttonProductPurchase'>Purchase</a></span>";}}
else{if(isRefillable){if(isPerUse){buttonString+="<span class='purchase_button'><a class='buttonProductPurchase'>Purchase</a></span>";}
else{buttonString+="<span class='purchase_button'><a class='buttonProductPurchase'>Refill Rounds</a></span>";}}
if(isEquippable){if(ownedUsesLeft!=0||department.toLowerCase()=="apparel"||isDefault){if(!isEquipped){buttonString+="<span class='purchase_button'><a class='buttonProductEquip'>Equip</a></span>";}}
if(isEquipped&&isUnequippable){buttonString+="<span class='purchase_button'><a class='buttonProductUnequip'>Unequip</a></span>";}}}
$("#Product"+ofbId+" .proshop_item .item_content").append("<li class='learn_more'>"+buttonString+"<li>");if($("#Product"+ofbId+" .purchase_button, #Product"+ofbId+" .member_button").length==0)
$("#Product"+ofbId+" .preview_button").css("width","100%");if($("#Product"+ofbId+" .purchase_button").length==2)
{$("#Product"+ofbId+" .purchase_button").css("width","49%");$("#Product"+ofbId+"t .purchase_button a").css("width","100%");}
else if($("#Product"+ofbId+" .preview_button").length==0)
{$("#Product"+ofbId+" .purchase_button").css("width","100%");$("#Product"+ofbId+" .purchase_button a").css("width","100%");}
var modifiersHtml=createModifierHtml(entitlementTag,productId,isOwned,isEquipped,department);$("#Product"+ofbId).unbind("mouseenter").unbind("mouseleave");$("#Product"+ofbId).mouseenter(function(){displayToolTip(displayName,ofbId+"=",productStatus,brandUrl,modifiersHtml);$("#Product"+ofbId).bind("mousemove",moveToolTip);}).mouseleave(function(){$("#gearRollOver").hide();$("#Product"+ofbId).unbind("mousemove");});if(isPreviewable){var previewButtons=$("#Product"+ofbId+" .proshop_item .item_header, #Product"+ofbId+" .proshop_item .item_content .thumbnail, #Product"+ofbId+" .proshop_item .item_content .name, #Product"+ofbId+" .proshop_item .item_content .price_info, #Product"+ofbId+" .proshop_item .item_content .rounds_remaining, #Product"+ofbId+" .buttonProductPreview");previewButtons.unbind("click");previewButtons.attr("href",generateReturnUrl(null,selectedSubNavId,null,null,null,ofbId));previewButtons.click(function(){setupProshopModal(newItem,modifiersHtml,entitlementTag,department);changeToActionModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse);show_modal("proshopModal");});}
else{if(isRefillable){var previewButtons=$("#Product"+ofbId+" .proshop_item .item_header, #Product"+ofbId+" .proshop_item .item_content .thumbnail, #Product"+ofbId+" .proshop_item .item_content .name, #Product"+ofbId+" .proshop_item .item_content .price_info, #Product"+ofbId+" .proshop_item .item_content .rounds_remaining, #Product"+ofbId+" .buttonProductPreview");previewButtons.unbind("click");previewButtons.attr("href",generateReturnUrl(null,selectedSubNavId,null,null,null,ofbId));previewButtons.click(function(){setupProshopModal(newItem,modifiersHtml,entitlementTag,department);changeToPurchaseModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse);show_modal("proshopModal");});}}
var productAHrefTag="";if(!isPreviewable)
{productAHrefTag=", #Product"+ofbId+" a";}
if(isMyGear&&(entitlementTag.indexOf(SHOT_PREVIEW)>=0||entitlementTag.toUpperCase().indexOf(PUTT_PREVIEW)>=0)){$("#Product"+ofbId+" .buttonProductPurchase"+productAHrefTag).unbind("click");$("#Product"+ofbId+" .buttonProductPurchase"+productAHrefTag).attr("href","/proShop/category/"+MALE_SWING_AIDS);}
else if(!isOwned||(isOwned&&isRefillable))
{$("#Product"+ofbId+" .buttonProductPurchase"+productAHrefTag).unbind("click");$("#Product"+ofbId+" .buttonProductPurchase"+productAHrefTag).attr("href",generateReturnUrl(null,selectedSubNavId,null,null,null,ofbId));$("#Product"+ofbId+" .buttonProductPurchase"+productAHrefTag).click(function(){setupProshopModal(newItem,modifiersHtml,entitlementTag,department);changeToPurchaseModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse);show_modal("proshopModal");});}
$("#Product"+ofbId+" .buttonBecomeMember").unbind("click");$("#Product"+ofbId+" .buttonBecomeMember").attr("href",generateReturnUrl(null,selectedSubNavId,null,null,null,ofbId));$("#Product"+ofbId+" .buttonBecomeMember").click(function(){var returnUrl=escape(document.location.toString());document.location="/users/membershipOffer?returnUrl="+escape(returnUrl);});$("#Product"+ofbId+" .buttonProductEquip").unbind("click");$("#Product"+ofbId+" .buttonProductEquip").attr("href",generateReturnUrl(null,selectedSubNavId,null,null,null,ofbId));$("#Product"+ofbId+" .buttonProductEquip").click(function(){equipItems(entitlementTag,false,department);});$("#Product"+ofbId+" .buttonProductUnequip").unbind("click");$("#Product"+ofbId+" .buttonProductUnequip").attr("href",generateReturnUrl(null,selectedSubNavId,null,null,null,ofbId));$("#Product"+ofbId+" .buttonProductUnequip").click(function(){unequipItem(entitlementTag);});$('#itemListings td').hover(function(){$(this).addClass('item_background').css('cursor','pointer');},function(){$(this).removeClass('item_background').css('cursor','default');});modifiersArray=undefined;return true;}
function calcProductStatus(entitlementTag,isOwned,isEquipped,isDefault,ownedUsesLeft){if(!isMyGear&&(entitlementTag.indexOf(SHOT_PREVIEW)>=0||entitlementTag.toUpperCase().indexOf(PUTT_PREVIEW)>=0))
return"available";if(isEquipped)
return"equipped";else if(isOwned&&ownedUsesLeft==0&&!isDefault)
return"empty";else if(isOwned||isDefault)
return"owned";else{return"available";}}
function showThisModal(){showProshopUnity();$("#UnityWrapper").css({"margin-left":"-210px"});};function showPreviewCurrentModal(){var modalContent=$("#proshopModal .content");$("#UnityWrapper").show();modalContent.empty();ProcessCommand('SetSleepMode=0');ProcessCameraCommand("SetCamera=0");ProcessProductCommand("ResetCharacter");show_modal("proshopModal");$("#proshopModal .close_modal").unbind();$("#proshopModal .close_modal").click(function(){close_modal();ProcessProductCommand("ResetCharacter");hideProshopUnity();});$("#proshopModal").css({"left":"50%","top":"50%","width":"449px","margin-left":"-225px"});setTimeout("showThisModal()",500);modalContent=undefined;}
function setupProshopModal(newItem,modifiersHtml,entitlementTag,department){$("#proshopModal .content").empty();$("#proshopModal .content").append(newItem);$("#proshopModal .content .item_content .name").after("<li class='item_stats'>"+modifiersHtml+"</li>");$("#proshopModal").css({"left":"50%","top":"50%","width":"676px","margin-left":"-350px"});tagInOmniture("PSPRV"+entitlementTag.toUpperCase().replace(/\s+/g,'').replace(/_/g,'').replace(/-/g,''));$("#proshopModal .close_modal").unbind();$("#proshopModal .close_modal").click(function(){close_modal();ProcessProductCommand("ResetCharacter");hideProshopUnity();});}
function changeToActionModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse){$("#UnityWrapper").show();$("#proshopModal .content .purchase_confirm").remove();var actionButtonsHtml="";if(isMembersOnly&&!isUserSubscriber&&productStatus!="owned")
{actionButtonsHtml+="<a class='button_action member'><span>Become a Member</span></a>";}
else if(productStatus=="equipped")
{if(useCount!=-1)
{if(isPerUse)
{actionButtonsHtml+="<a class='button_action refill'><span>Purchase more uses</span></a>";}
else
{actionButtonsHtml+="<a class='button_action refill'><span>Purchase more rounds</span></a>";}}}
else if(productStatus=="owned")
{if(useCount!=-1)
{if(isPerUse)
{actionButtonsHtml+="<a class='button_action refill'><span>Purchase more uses</span></a>";}
else
{actionButtonsHtml+="<a class='button_action refill'><span>Purchase more rounds</span></a>";}}
if(isEquippable)
{actionButtonsHtml+="<a class='button_action equip'><span>Equip</span></a>";}}
else if(productStatus=="empty")
{if(useCount!=-1)
{if(isPerUse)
{actionButtonsHtml+="<a class='button_action refill'><span>Purchase more uses</span></a>";}
else
{actionButtonsHtml+="<a class='button_action refill'><span>Purchase more rounds</span></a>";}}
if(isEquippable)
{actionButtonsHtml+="<a class='button_action equip'><span>Equip</span></a>";}}
else
{actionButtonsHtml+="<a class='button_action purchase'><span>Purchase</span></a>";}
$("#proshopModal .content .proshop_item .item_content").append("<li class='actions'>"+actionButtonsHtml+"</li>");actionButtonsHtml=undefined;$("#proshopModal .close_modal").unbind();$("#proshopModal .close_modal").click(function(){close_modal();ProcessProductCommand("ResetCharacter");hideProshopUnity();});$("#proshopModal .content .actions .refill").click(function(){$("#proshopModal .content .actions").hide();changeToPurchaseModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse);});$("#proshopModal .content .actions .equip").click(function()
{equipItems(entitlementTag,true,department);});$("#proshopModal .content .actions .purchase").click(function(){$("#proshopModal .content .actions").hide();changeToPurchaseModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse);});$("#proshopModal .content .actions .member").click(function(){var returnUrl=escape(document.location.toString());document.location="/users/membershipOffer?returnUrl="+escape(returnUrl);});$("#proshopModal .wrapper").css("background","#fff url('/img/proshop/bg_modal.jpg') top right no-repeat");ProcessCommand('SetSleepMode=0');ProcessCameraCommand("setCamera="+getCameraFromRack(rack));ProcessProductCommand('Preview='+entitlementTag);setTimeout("showProshopUnity()",500);}
function equipItems(entitlementTag,closeModal,department){if(department=="Modifiers")
{var delimiter=";";for(var i=0;i<myModifierCount;i++)
{entitlementTag=entitlementTag+delimiter+myModifiers[i];}}
var genderToEquip=gender;if(department=="Modifiers"||department=="Equipment")
{genderToEquip=-1;}
callPostWS(false,"/pro_shop_service/equipitems/"+entitlementTag+"/"+genderToEquip,null,null,null,function(data,textStatus){var errorReason=$("error",data).text();if(errorReason!="")
{if(errorReason=="INVENTORY_ERR_TOO_MANY_MODIFIERS1")
{$("#proshopError").text("Currently only 6 multipliers are allowed. Please unequip an exiting cash multiplier first.");$("#proshopError").slideDown();}
else
{$("#proshopError").text("Could not equip this item.  Please try again later.");$("#proshopError").slideDown();}}
else
{getPersonalInventory();}},null,function(data,textStatus){if(closeModal)
{close_modal();hideProshopUnity();}});}
function changeToPurchaseModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse){hideProshopUnity(false);var afterProductBalance=0;var purchasePanelHtml="";var lineItemsHtml="";if(isPreviewable)
{$("#proshopModal .content .proshop_item .item_content").append("<li class='actions'><a class='button_action preview'><span>Preview</span></a></li>");$("#proshopModal .content .actions .preview").click(function(){$("#proshopModal .content .actions").hide();changeToActionModal(productStatus,price,useCount,entitlementTag,ofbId,currencyType,isEquipped,rack,department,isMembersOnly,isPreviewable,isEquippable,isPerUse);});}
if(currencyType=="_TB")
{afterProductBalance=userMoney-price;lineItemsHtml="<dt>Item Price</dt> <dd>$"+abbreviateNumbers(price,false)+"</dd>";lineItemsHtml+="<dt>Current Balance</dt> <dd>$"+formatLargeNumbers(userMoney)+"</dd>";lineItemsHtml+="<dt class='balance'>Remaining Balance</dt> <dd class='balance'>$"+formatLargeNumbers(afterProductBalance)+"</dd>";}
else if(currencyType=="_SV")
{afterProductBalance=playerCashBalance-price;lineItemsHtml="<dt>Item Price</dt> <dd><span class='points_green'>"+abbreviateNumbers(price,false)+"</span></dd>";lineItemsHtml+="<dt>Current Balance</dt> <dd><span class='points_green'>"+formatLargeNumbers(playerCashBalance)+"</span></dd>";lineItemsHtml+="<dt class='balance'>Remaining Balance</dt> <dd class='balance'><span class='points_green'>"+formatLargeNumbers(afterProductBalance)+"</span></dd>";}
if(afterProductBalance>=0)
{purchasePanelHtml="<ul class='actions'>";purchasePanelHtml+=" <li><a class='button_action purchase purchaseAction'><span>Purchase</span></a></li>";purchasePanelHtml+=" <li><span class='UserButton UserButton_white cancel'><a class='UserButton_Text'>Cancel</a></span></li>";if(!isEquipped&&isEquippable)
purchasePanelHtml+=" <li class='equip'><input type='checkbox' id='chkEquipAfterPurchase' checked='true'/><label for='chkEquipAfterPurchase'>Equip on my golfer</label></li>";purchasePanelHtml+="</ul>";}
else
{purchasePanelHtml="<ul class='actions'>";purchasePanelHtml+=" <li class='center'><span>You don\'t have the funds to purchase this item.<br/><br/></span></li>";if(currencyType=="_SV")
purchasePanelHtml+=" <li><a class='button_action purchase addpointsAction'><span>Add Points</span></a></li>";purchasePanelHtml+=" <li><span class='UserButton UserButton_white cancel'><a class='UserButton_Text'>Cancel</a></span></li>";purchasePanelHtml+="</ul>";}
var useCountDescription="<li class='description'> <p>This item\'s boosts will last for "+useCount+" Rounds</p> </li>";if(isPerUse)
{useCountDescription="<li class='description'> <p>This item\'s boosts will last for "+useCount+" uses</p> </li>";}
if(isUserSubscriber&&entitlementTag.indexOf("MaxStat")<0&&department.toLowerCase()!="modifiers")
useCountDescription="<li class='description'> <p>Unlimited Rounds</p> </li>";else if(!isEquippable||useCount==-1)
useCountDescription="";var newHtml="<div class='purchase_confirm "+selectedCategoryType+" "+productStatus+"'>\
  <div class='panel with_header'>\
   <div class='header'>\
    <h1>Purchase Confirmation</h1>\
   </div>\
   <div class='content'>\
    <ul>\
     <li class='text'>\
      <dl>\
       "+lineItemsHtml+"\
      </dl>\
     </li>\
     "+useCountDescription+"\
     <li class='actions'>\
      <div id='panelPurchase'>\
       "+purchasePanelHtml+"\
      </div>\
      <div id='panelLoading'>\
       <a class='button_action processing'><span><img src='/img/proshop/loading.gif'> Processing</span></a>\
      </div>\
     </li>\
    </ul>\
   </div>\
  </div>\
 </div>";purchasePanelHtml=undefined;lineItemsHtml=undefined;$("#proshopModal .content").append(newHtml);setupPurchaseButton(ofbId,entitlementTag,isEquipped,department);$("#proshopModal .purchase_confirm .actions .addpointsAction").unbind();$("#proshopModal .purchase_confirm .actions .addpointsAction").click(function(){$("#proshopModal .purchase_confirm .actions .addpointsAction").unbind();document.location="/users/purchasePointsRedirect?surl="+escape(document.location);});$("#proshopModal .purchase_confirm .actions .cancel").click(function(){close_modal();});$("#proshopModal .wrapper").css("background","#fff url('/img/proshop/bg_modal.jpg') top right no-repeat");$("#proshopModal .purchase_confirm").fadeIn(500);}
function setupPurchaseButton(ofbId,entitlementTag,isEquipped,department){$("#proshopModal .purchase_confirm .actions .purchaseAction").unbind();$("#proshopModal .purchase_confirm .actions .purchaseAction").click(function(){$("#proshopModal .close_modal").unbind();$("#proshopModal .purchase_confirm .actions .purchaseAction").unbind();$("#proshopModal .purchase_confirm .actions .purchaseAction").addClass("disabled");$("#panelPurchase").hide();$("#panelLoading").show();callPostWS(false,"/pro_shop_service/buynow/"+ofbId+"/1",WSRequestTimeout,"",null,function(data,textStatus){$("#proshopModal .purchase_confirm .actions .purchaseAction").removeClass("disabled");if($("status",data).text()==='CLOSED'){if(!isEquipped&&$("#chkEquipAfterPurchase").attr("checked")==true&&department!="Collections"){equipItems(entitlementTag,false,department);}
getEntitlements();loadPlayerCardCash();$("#proshopModal .purchase_confirm .header h1").text("Purchased Successfully");$("#proshopModal .purchase_confirm .content").html("<h2 class='confirmation'>Thank you for your purchase!</h2><h3 class='confirmation'>You may close this window at any time to return to the Pro Shop.</h3><div class='purchase_close'><span class='UserButton UserButton_white'><a class='UserButton_text'>Close This Window</a></span></div>");if(department=="Collections")
{callPostWS(false,"/messaging_service/sendtrophymessagetomyfriends/"+entitlementTag,WSRequestTimeout,"",null,null,null);}
$("#proshopModal .close_modal").unbind();$("#proshopModal .close_modal").click(function(){close_modal();});$(".purchase_close a").click(function(){close_modal();});}
else{$("#proshopModal .purchase_confirm .header h1").text("Item Was Not Purchased");$("#proshopModal .purchase_confirm .content").html("<h2 class='confirmation'>You could not purchase this item at this time!</h2>");if($("failure",data).attr("cause")=="INSUFFICIENT_BALANCE")
$("#proshopModal .purchase_confirm .content").append("<h3 class='confirmation text_red'>You have insufficient funds to purchase this item.</h3>");if($("failure",data).attr("cause")=="INVALID_VALUE"&&$("failure",data).attr("field")=="billingAccount.accountId")
$("#proshopModal .purchase_confirm .content").append("<h3 class='confirmation text_red'>You do not have a valid billing account setup.</h3>");if($("failure",data).attr("cause")=="CURRENCY_MISMATCH"&&$("failure",data).attr("field")=="billingAccount.currency")
$("#proshopModal .purchase_confirm .content").append("<h3 class='confirmation text_red'>You do not have a valid billing account setup.</h3>");$("#proshopModal .purchase_confirm .content").append("<h3 class='confirmation'>You may close this window at any time to return to the Pro Shop.</h3>");$("#panelLoading").hide();$("#panelPurchase").show();setupPurchaseButton(ofbId,entitlementTag,isEquipped,department);$("#proshopModal .close_modal").unbind();$("#proshopModal .close_modal").click(function(){ProcessProductCommand("ResetCharacter");close_modal();});}},function(){setupPurchaseButton(ofbId,entitlementTag,isEquipped,department);$("#proshopModal .purchase_confirm .actions .purchaseAction").removeClass("disabled");$("#proshopModal .close_modal").unbind();$("#proshopModal .close_modal").click(function(){close_modal();ProcessProductCommand("ResetCharacter");hideProshopUnity();});},null);});}
function displayToolTip(productName,ofbId,productStatus,brandUrl,modifiersHtml){if(selectedToolTipId!=ofbId)
{selectedToolTipId=ofbId;$("#gearRollOver").remove();var newHtml='<div id="gearRollOver" class="item_rollover gear">\
    <div class="inner">\
     <ul class="item_header '+productStatus+'">\
      <li class="item_logo"> <img src="'+brandUrl+'" /></li>\
      <li class="item_equipped"><span></span>Equipped</li>\
      <li class="item_owned"><span></span>Owned</li>\
     </ul>\
     <div class="item_name">\
      <h1>'+productName+'</h1>\
     </div>\
     <div class="content">\
      '+modifiersHtml+'\
     </div>\
     <div class="bottom"></div>\
    </div>\
   </div>';$("body").append(newHtml);}
$("#gearRollOver:not(:animated)").fadeIn(500);}
function moveToolTip(e){var clientWidth=document.body.clientWidth;var toolTipWidth=$('#gearRollOver').width();if((e.pageX+toolTipWidth+15)>clientWidth){$("#gearRollOver").css({"top":(e.pageY+15)+"px","left":(e.pageX-245)+"px"});}else{$("#gearRollOver").css({"top":(e.pageY+15)+"px","left":(e.pageX+15)+"px"});}}
function createModifierHtml(entitlementTag,productId,isOwned,isEquipped,department){var modifiersArray=getProductModifiersComparison(productId);var isModifiersForProduct=false;var newHtml='<table class="stats_gear" cellpadding="0" cellspacing="0" border="0">';if(entitlementTag.toLowerCase()=="two_playercombo_bundle")
{newHtml+="<tr class='item_boosts_description'>";newHtml+=" <td>";newHtml+="  Taylor Made &reg;R9&trade;Series<br>";newHtml+="  40x Birdies Cash Multiplier<br>";newHtml+="  40x Eagles Cash Multiplier<br>";newHtml+="  10x Long Drive XP Multiplier<br>";newHtml+="  10x Final Score XP Multiplier<br>";newHtml+=" </td>";newHtml+="</tr>";newHtml+="</table>";return newHtml;}
else if(entitlementTag.toLowerCase()=="two_procombo_bundle")
{newHtml+="<tr class='item_boosts_description'>";newHtml+=" <td>";newHtml+="  EA SPORTS&trade; Classic Bundle<br>";newHtml+="  75x Birdies Cash Multiplier<br>";newHtml+="  75x Eagles Cash Multiplier<br>";newHtml+="  25x GIRs XP Multiplier<br>";newHtml+="  25x Final Score XP Multiplier<br>";newHtml+="  20x Shot Previews - 20 Uses<br>";newHtml+=" </td>";newHtml+="</tr>";newHtml+="</table>";return newHtml;}
else if(entitlementTag.toLowerCase()=="two_tourprocombo_bundle")
{newHtml+="<tr class='item_boosts_description'>";newHtml+=" <td>";newHtml+="  75x Birdies Cash Multiplier<br>";newHtml+="  75x Eagles Cash Multiplier<br>";newHtml+="  75x Long Drive Cash Multiplier<br>";newHtml+="  25x GIRs XP Multiplier<br>";newHtml+="  25x Long Putt XP Multiplier<br>";newHtml+="  25x Final Score XP Multiplier<br>";newHtml+="  100x Shot Previews - 100 Uses<br>";newHtml+=" </td>";newHtml+="</tr>";newHtml+="</table>";return newHtml;}
if(modifiersArray[0]==undefined&&(entitlementTag.indexOf(SHOT_PREVIEW)<0||entitlementTag.toUpperCase().indexOf(PUTT_PREVIEW)<0)){return"";}
if(department.toLowerCase()=="apparel"||department.toLowerCase()=="modifiers")
{if(entitlementTag.indexOf("SHOT_PREVIEW")>=0){var modifierDesc="";var valueString="";var boostDescription="";modifierDesc="Swing Trainer";valueString="Max Stats";boostDescription=" <td colspan='2'>Shot Previews are available once per hole</td>";newHtml+="<tr class='item_boosts_description'>";newHtml+=boostDescription;newHtml+="</tr>";}
else{var newModifierName=modifiersArray[0].modifierName;var newModifierValue=parseInt(modifiersArray[0].newItemValue);if((newModifierValue==0||newModifierValue==""||isNaN(newModifierValue)||newModifierName=="No Bonuses")&&entitlementTag.indexOf("MaxStat")<0){newHtml+="<tr><td><h3 class='no_bonus'>No Bonuses</h3></td></tr>";}
else{var modifierDesc="";var valueString="";var boostDescription="";if(entitlementTag.indexOf("MaxStat")>=0){modifierDesc="Swing Trainer";valueString="Max Stats";boostDescription=" <td colspan='2'>Important: Swing Trainer updates are paused during use of Max Stats items. However, other equipment will continue to provide their normal boost.</td>";}
else{modifierDesc=getModifierDescription(newModifierName);valueString=(newModifierValue>=0?"+"+Math.floor(newModifierValue):Math.floor(newModifierValue))+"x "+getValueType(newModifierName);boostDescription=" <td colspan='2'>When using this item with boosts you will earn "+valueString+" for "+modifierDesc+"</td>";}
newHtml+="<tr class='item_boosts_heading'><td>Boost To:</td><td>Boost Multiplier</td></tr>";newHtml+="<tr class='item_boosts_content'>";newHtml+=" <td><h3>"+modifierDesc+"</h3></td>";newHtml+=" <td><h3>"+valueString+"</h3></td>";newHtml+="</tr>";newHtml+="<tr class='item_boosts_description'>";newHtml+=boostDescription;newHtml+="</tr>";}}
isModifiersForProduct=true;}
else
{newHtml+="<tr class='heading'><td colspan='4'><h5>Equipped</h5><span class='arrow'></span></td></tr>"
for(var i=0;i<modifiersArray.length;i++)
{var arrowDirection="<span class='arrow_direction none'></span>";var modifierName=modifiersArray[i].modifierName;var oldValue=modifiersArray[i].equippedItemValue;var newValue=modifiersArray[i].newItemValue;var useCount=modifiersArray[i].equippedItemUseCount;if(useCount==0)
oldValue=0;if(parseInt(newValue)>parseInt(oldValue))
arrowDirection="<span class='arrow_direction up'></span>"
else if(parseInt(newValue)<parseInt(oldValue))
arrowDirection="<span class='arrow_direction down'></span>";if(newValue>0)
newValue="+"+newValue;if(oldValue>0)
oldValue="+"+oldValue;var newValueString=newValue>=0?"+"+Math.floor(newValue):Math.floor(newValue);var oldValueString=oldValue>=0?"+"+Math.floor(oldValue):Math.floor(oldValue);newHtml+="<tr class='"+modifierName.toLowerCase().replace(/ /g,"")+"'>";newHtml+=" <td class='name'><h3>"+getModifierDescription(modifierName)+"</h3></td>";if(modifierName.toUpperCase()=="PREVIEW LIMIT")
{if(useCount==0)
newHtml+=" <td class='old_value red'>"+oldValueString+"</td>";else
newHtml+=" <td class='old_value'>"+oldValueString+"</td>";}
else
{if(useCount==0)
newHtml+=" <td class='old_value red'>"+oldValueString+"0%</td>";else
newHtml+=" <td class='old_value'>"+oldValueString+"0%</td>";}
newHtml+=" <td class='arrow_value'>"+arrowDirection+"</td>";if(modifierName.toUpperCase()=="PREVIEW LIMIT")
{newHtml+=" <td class='new_value'>"+newValueString+"</td>";}
else
{newHtml+=" <td class='new_value'>"+newValueString+"0%</td>";}
newHtml+="</tr>";isModifiersForProduct=true;}}
if(!isModifiersForProduct)
{newHtml+="<tr>";newHtml+=" <td><h3 class='no_bonus'>No Bonuses</h3></td>";newHtml+="</tr>";}
newHtml+="<table>";return newHtml;}
function getRackName(rackIndex){switch(rackIndex)
{case"1":return"ARM_HAND";case"2":return"BEARD";case"3":return"BROW";case"4":return"HAIR";case"5":return"HEAD";case"6":return"LEG_FOOT";case"7":return"GLASSES";case"8":return"GLOVE";case"9":return"HAT";case"10":return"PANTS";case"11":return"SHIRT";case"12":return"SHOES";case"13":return"SOCKS";case"14":return"SUIT";case"15":return"WATCH";case"16":return"BALL";case"17":return"DRIVER";case"18":return"GRIP";case"19":return"FAIRWAY_WOODS";case"20":return"HYBRIDS";case"21":return"IRONS";case"22":return"PUTTER";case"23":return"SHAFT";case"24":return"WEDGES";default:return"UNKNOWN";}}
function getCameraFromRack(rackName){switch(rackName.toUpperCase())
{case"ARM HAND":return 3;case"BEARD":return 1;case"BROW":return 1;case"HAIR":return 1;case"HEAD":return 1;case"LEG FOOT":return 2;case"GLASSES":return 1;case"GLOVE":return 0;case"HAT":return 1;case"PANTS":return 2;case"SHIRT":return 3;case"SHOES":return 2;case"SOCKS":return 2;case"SUIT":return 0;case"WATCH":return 0;case"BALL":return 5;case"DRIVER":return 6;case"GRIP":return 0;case"FAIRWAY WOODS":return 6;case"HYBRIDS":return 6;case"IRONS":return 6;case"PUTTER":return 6;case"SHAFT":return 0;case"WEDGES":return 6;default:return 1;}}
function getProductModifiersComparison(productId){var modifiersArray=new Array();var currentRack="";var data=productsXml;$("product",data).each(function(i){if($(this).attr("productId")==productId)
{$("attribute",this).each(function(j){var attributeName=$(this).attr("name");if(attributeName=="rack")
currentRack=$(this).attr("value");if(attributeName.indexOf("customModifier1")>=0||attributeName.indexOf("customModifier2")>=0||attributeName.indexOf("customModifier3")>=0||attributeName.indexOf("customModifier4")>=0||attributeName.indexOf("customModifier5")>=0||attributeName.indexOf("customModifier6")>=0||attributeName.indexOf("customModifier7")>=0||attributeName.indexOf("customModifier8")>=0)
{var modifierNum=parseInt(attributeName.replace("customModifier","").replace("Type","").replace("Value",""))-1;if(modifiersArray[modifierNum]==undefined)
modifiersArray[modifierNum]=new Object();if(attributeName.indexOf("Type")>=0)
modifiersArray[modifierNum].modifierName=$(this).attr("value");else if(attributeName.indexOf("Value")>=0)
modifiersArray[modifierNum].newItemValue=parseInt($(this).attr("value"));modifiersArray[modifierNum].equippedItemValue=undefined;modifiersArray[modifierNum].equippedItemUseCount=undefined;}});return false;}});$("inventoryitem",equippedXml).each(function(){var rack="";if($("productinfo producttype",this).length>1)
rack=$("getpersonalinventory inventoryitems inventoryitem productinfo producttype",this).text();else
rack=$("productinfo producttype",this).text();if(getRackName(rack).replace(/_/g," ").toLowerCase()==currentRack.toLowerCase())
{var modifierList="";var equippedEntitlement="";var useCount=-1;if($("productinfo producttype",this).length>1)
{modifierList=$("getpersonalinventory inventoryitems inventoryitem productinfo equipmentmodifierlist gamemodifier",this);equippedEntitlement=$("getpersonalinventory inventoryitems inventoryitem productinfo entitlementname",this).text();}
else
{modifierList=$("equipmentmodifierlist gamemodifier",this);equippedEntitlement=$("productinfo entitlementname",this).text();}
for(var i=0;i<entitlementList.length;i++)
{if(entitlementList[i]!=undefined&&entitlementList[i].entitlementTag!=undefined&&entitlementList[i].entitlementTag==equippedEntitlement&&entitlementList[i].useCount!=undefined)
{useCount=parseInt(entitlementList[i].useCount);break;}}
modifierList.each(function(){if($("type",this).text()!="0")
{for(var i=0;i<modifiersArray.length;i++)
{if(getModiferTypeEnum($("type",this).text())==modifiersArray[i].modifierName.toUpperCase())
{modifiersArray[i].equippedItemValue=parseInt($("strvalue",this).text());modifiersArray[i].equippedItemUseCount=useCount;break;}}}});return false;}});return modifiersArray;}
function showLoadingAnimation(){var loadingHtml="<tr><td><div class='loading-items'>Loading Pro Shop Items</div></td></tr>";$("#itemListings").html(loadingHtml).fadeIn(500);$(".loading-items").css({"width":"200px","height":"30px","position":"absolute","top":"130px","left":"250px","background":"url('/img/proshop/loading.gif') no-repeat","text-indent":"30px","font-weight":"bold"});}
function hideLoadingAnimation(){$('.no-items').hide();}
function displayPagination(){if(totalProducts!=0)
{$(".paging .page_buttons .text").text(currentPage+" of "+totalPages);$(".paging .page_buttons .text").show();$(".paging .page_buttons .page_prev").unbind();$(".paging .page_buttons .page_prev").show();if(currentPage>1)
{$(".paging .page_buttons .page_prev").removeClass("disabled");$(".paging .page_buttons .page_prev").attr("href",generateReturnUrl(selectedCategoryId,selectedSubNavId,currentPage-1,null,null));$(".paging .page_buttons .page_prev").click(function(){$(".paging .page_buttons .page_prev").unbind();$(".paging").animate({opacity:0.5});currentPage--;loadProducts();});}
else
{$(".paging .page_buttons .page_prev").addClass("disabled");}
$(".paging .page_buttons .page_next").unbind();$(".paging .page_buttons .page_next").show();if(currentPage<totalPages)
{$(".paging .page_buttons .page_next").removeClass("disabled");$(".paging .page_buttons .page_next").attr("href",generateReturnUrl(selectedCategoryId,selectedSubNavId,currentPage+1,null,null));$(".paging .page_buttons .page_next").click(function(){$(".paging .page_buttons .page_next").unbind();$(".paging").animate({opacity:0.5});currentPage++;loadProducts();});}
else
{$(".paging .page_buttons .page_next").addClass("disabled");}}
else
{$(".paging .page_buttons .text").hide();$(".paging .page_buttons .page_prev").hide();$(".paging .page_buttons .page_next").hide();}
$(".paging").animate({opacity:1},function(){$(".paging").show();});}
function calcUnityPosition(){$("#UnityWrapper").css({"width":449+"px","height":409+"px","left":"50%","top":"50%","margin-left":"-"+108+"px","margin-top":"-"+190+"px"});}
function showProshopUnity(){calcUnityPosition();isUnityVisible=true;}
function hideProshopUnity(sleepThread){if(sleepThread==undefined)
sleepThread=true;isUnityVisible=false;$("#UnityWrapper").css("left",-9999);if(sleepThread)
ProcessCommand('SetSleepMode=1');}
function UnityLog(str){return false;}
function GameInitialized()
{var authTokenStr=getCookie("CEM-login");loadPersonaCookie();GetUnity().SendMessage("GameController","MessageSetAuthToken",authTokenStr!=null?authTokenStr:'0');GetUnity().SendMessage("GameController","MessageSetPersona",personaId!=undefined?personaId:'0');GetUnity().SendMessage("GameController","MessageSetMode",'normal');}
function ProcessCameraCommand(command){lastCameraCommand=command;ProcessCommand(command);}
function ProcessProductCommand(command){lastProductCommand=command;ProcessCommand(command);}
function ProcessCommand(command){if(!command)return false;try
{var tmp='';if(command.match(/SetCamera=\d/)){tmp=command.split('=')[1];if(tmp!=='0'){strCameraAngle=tmp;}}
if(window.console){if(window.console.log){console.log('Sending Unity Command: '+command)}}
GetUnity().SendMessage("GameController","MessageProcessCharacterViewerCommand",command);}
catch(err)
{}
return true;}
function UpdateCharacterEquipmentDetails(){}
function characterPartsAttached(){}
function characterViewerReady(){ProcessCommand("SetViewerMode=1");ProcessCommand('SetGender='+gender);if(lastCameraCommand!="")
ProcessCommand(lastCameraCommand);if(lastProductCommand!="")
ProcessCommand(lastProductCommand);if(!isUnityVisible)
ProcessCommand('SetSleepMode=1');}
function refreshPageData(){getPersonalInventory();}
function GameWebDocumentReadyTest()
{if(isWebDocumentReady)
{GetUnity().SendMessage("GameController","MessageWebDocumentReady","");}}
function getValueType(modifierName)
{if(modifierName.substring(0,2).toUpperCase()=="XP")
{return"XP";}
else
{return"money";}}
var isWebDocumentReady=false;$(document).ready(function()
{isWebDocumentReady=true;});
