var dUrlAnimal="/widgets/critter_carpool/actions/claim_ajax.php";var animalBonusUrl="/widgets/critter_carpool/actions/bonus_ajax.php";var currentShow=[];var animalSlotUrl=[];var animalSlotName=[];var animalSlotPoints=[];var animalSlotPhoto=[];var animalSlotId=[];var animalUrl;var animalItem;var animalItemPoints;var animalPhoto;var animalId;var currentItem;var response;function popScreen(popWin,boxId){if(currentShow[boxId]==popWin){document.getElementById(popWin).style.display='none';currentShow[boxId]="";}
else{if(document.getElementById('bagId_'+boxId)!=null)
document.getElementById('bagId_'+boxId).style.display='none';document.getElementById(popWin).style.display="block";currentShow[boxId]=popWin;}
if(document.getElementById('overlay'+boxId)!=null)
document.getElementById('overlay'+boxId).style.display='none';}
function closeAll(boxId){document.getElementById('claimPop'+boxId).style.display='none';document.getElementById('myBag_'+boxId).style.display='none';}
function animalResetValue(availableSlot){animalUrl=dUrlAnimal+animalSlotUrl[availableSlot];animalItem=animalSlotName[availableSlot];animalItemPoints=animalSlotPoints[availableSlot];animalPhoto=animalSlotPhoto[availableSlot];animalId=animalSlotId[availableSlot];currentItem=availableSlot;}
function animalHandleClose(popBox){document.getElementById(popBox).style.display='none';}
function spin(boxId){document.getElementById('spin1'+boxId).src=IMAGE_HOST+"/images/widget/critter_carpool/bonus/animate1.gif"
document.getElementById('spin2'+boxId).src=IMAGE_HOST+"/images/widget/critter_carpool/bonus/animate2.gif"
document.getElementById('spin3'+boxId).src=IMAGE_HOST+"/images/widget/critter_carpool/bonus/animate3.gif"}
function animalHandleBonusClick(boxId,animalsCaptured){ajax_getPage(animalBonusUrl,function(data){animalHandleBonusSuccess(data,boxId,animalsCaptured);});}
function animalHandleBonusSuccess(data,boxId,animalsCaptured){var bonusPopContent='';var bonusDescription='';var bonusSummary='';var spin1=IMAGE_HOST+"/images/widget/critter_carpool/bonus/banana.gif";var spin2=IMAGE_HOST+"/images/widget/critter_carpool/bonus/peanut_shells.gif";var spin3=IMAGE_HOST+"/images/widget/critter_carpool/bonus/steak.gif";response=data.split(":");var bonusCode=response[0];var bonusPositive=response[1];var bonusPromote=response[2];var bonusRank=response[3];var bonusLevel=response[4];var bonusSetComplete=response[5];var bonusPoints=response[6];var bonusAnimalId=response[7];var bonusAnimalName=response[8];var bonusAnimalPoint=response[9];var bonusRemaining=response[10];var bonusPointsLeft=response[11];spin(boxId);if(bonusCode==-1){spin1=IMAGE_HOST+"/images/widget/critter_carpool/bonus/fishbones.gif";spin2=spin1;spin3=spin1;bonusDescription='Darn! Not only did you not win anything, but while you were playing with the slot machine, '+bonusAnimalName+' wandered away and needs to be track down again!';bonusSummary='Animals left to find for this carpool trip: '+bonusRemaining;}
else if(bonusCode==1){spin1=IMAGE_HOST+"/images/widget/critter_carpool/bonus/peanuts.gif";spin2=spin1;spin3=spin1;bonusDescription='You have added '+bonusPoints+' bonus points';bonusSummary='Animals left to find for this carpool trip: '+numRemaining;}
else if(bonusCode==2){if(bonusSetComplete==0){spin1=IMAGE_HOST+"/images/widget/critter_carpool/bonus/fish.gif";bonusSummary='Animals left to find for this carpool trip: '+bonusRemaining;}
else{spin1=IMAGE_HOST+"/images/widget/critter_carpool/bonus/steak.gif";bonusSummary='Not only that, but you completed your assignment and received '+bonusPoints+' bonus points. Click \"Keep Looking\" to see your next assignment!';}
spin2=spin1;spin3=spin1;bonusDescription='Jake helped you find '+bonusAnimalName+', and you got '+bonusAnimalPoint+' points!';document.getElementById('animalAvatar'+boxId).src=IMAGE_HOST+"/images/widget/critter_carpool/mediumIcons/"+bonusAnimalId+".gif"
updateBasket(boxId,bonusAnimalId,animalsCaptured);}
else if(bonusCode==3){spin1=IMAGE_HOST+"/images/widget/critter_carpool/bonus/banana.gif";spin2=spin1;spin3=spin1;bonusDescription='<div style="float:left;margin-right:5px;margin-bottom:10px;"><img src="'+IMAGE_HOST+'/images/widget/critter_carpool/bonus/raffle_ticket.gif" align="left" /></div>You\'ve won a raffle ticket for the Critter Carpool Gift Card Giveaway!';bonusSummary='<a href="http://www.cafemom.com/group/106160/forums/read/9725339/">Click here to learn more.</a>';}
else if(bonusCode==4){spin1=IMAGE_HOST+"/images/widget/critter_carpool/bonus/peanut_shells.gif";spin2=spin1;spin3=spin1;bonusDescription='<div style="float:left;margin-right:5px;margin-bottom:10px;"><img src="'+IMAGE_HOST+'/images/widget/critter_carpool/bonus/energy_pack.gif" align="left" /></div>You\'ve won a Latte Land Energy Pack! It\'s been added into your <a href="/games/latte_land/inventory.php#llTop">Inventory</a>.';bonusSummary='';}
else{bonusDescription='Sorry, you didn\'t win anything from Jake the Jackal\'s Casino. Better luck next time!';bonusSummary='Only '+numRemaining+' animals left to complete your current assignment!';}
if(bonusPromote==1){bonusSummary+='<br /><br />Congrats - you have been promoted to level '+bonusRank+'!';}
if(bonusPointsLeft>0){bonusSummary+="<br /><br />Only "+bonusPointsLeft+" points to the next level!";}
document.getElementById('spin1'+boxId).src=spin1;document.getElementById('spin2'+boxId).src=spin2;document.getElementById('spin3'+boxId).src=spin3;bonusPopContent='<p class="bonusDescription">'+bonusDescription+'</p>';bonusPopContent+='<p class="summary">'+bonusSummary+'</p>';document.getElementById('bonusMsg_'+boxId).innerHTML=bonusPopContent;spinLayer='bonusPop'+boxId;resultLayer='bonusAnimalPop'+boxId;setTimeout("document.getElementById(spinLayer).style.display = 'none'",2000);setTimeout("document.getElementById(resultLayer).style.display = 'block'",2000);}
function updateBasket(boxId,animalId,animalsCaptured){var myBagContent=document.getElementById("animalList_"+boxId);var animals=myBagContent.getElementsByTagName('img');for(i=0;i<animals.length;i++){caughtAnimalId=animals[i].src;if(caughtAnimalId.indexOf(animalId)>=0){animals[i].src=IMAGE_HOST+"/images/widget/critter_carpool/smallIcons/"+animalId+".gif";}}
document.getElementById('currentAnimalCaptured_'+boxId).innerHTML=animalsCaptured+1;}
function animalHandleClick(item,boxId,availableSlot,animalsCaptured){animalResetValue(availableSlot);ajax_getPage(animalUrl,function(data){animalHandleSuccess(data,boxId,animalsCaptured);});}
function animalHandleSuccess(data,boxId,animalsCaptured){response=data.split(":");var animalCode=response[0];var animalStatus=response[1];var animalSetComplete=response[2];var animalPromoted=response[3];var animalEndRank=response[4];var animalEndLevel=response[5];var animalBonusPoints=response[6];var animalRemaining=response[7];var animalPointsLeft=response[8];var popMessage;document.getElementById('claimPop'+boxId).className='clearfix transparentOverlay missed';document.getElementById('animalAvatar'+boxId).src=animalPhoto;if(animalCode==1){if(animalSetComplete==1){popMessage="<strong>Great job!</strong> You completed your assignment and received "+animalBonusPoints+" bonus points! If you'd like, you can leave a Chatterbox message for <strong>"+screenName+"</strong> to thank her for her help. Click \"Keep Looking\" to see your new assignment!";}
else{popMessage="<p>Success! You've tracked down <span class='animal'>"+animalItem+"</span> for "+animalItemPoints+" points. If you'd like, you can leave a Chatterbox message for <strong>"+screenName+"</strong> to thank her for her help.</p>";popMessage+='<p class="summary">Animals left to find for this carpool trip: '+animalRemaining+'</p>';document.getElementById('claimPop'+boxId).className='clearfix transparentOverlay caught';}
updateBasket(boxId,animalId,animalsCaptured);}
else if(animalCode==0){popMessage="Sorry, an error occurred. Please try again.";}
else if(animalCode==-1){popMessage="Sorry! You must be a member to play the game. <br><br><a href='/widgets/splash.php?widget_id=190'>Click here</a> to join CafeMom add the widget to your page.";}
else if(animalCode==-2){popMessage="Sorry! You must have this widget to play the game. <br><br><a href='/widgets/splash.php?widget_id=190'>Click here</a> to add the widget to your page.";}
else if(animalCode==-3){popMessage="Sorry, you can't find any animals right now. Jake the Jackal is waiting for you to complete the Bonus Round! Return to your homepage to play!";}
else if(animalCode==-4){popMessage="Sorry, <strong>"+screenName+"</strong> no longer has this widget.";}
else if(animalCode==-5){popMessage="Sorry, another player claimed this gift before you! Try claiming a different gift on this player's page or click the 'Keep Looking' button to find new gifts. ";}
else if(animalCode==-6){popMessage="Sorry! <strong>"+screenName+"</strong> already helped you find an animal in the past 24 hours. You'll need to look somewhere else. Click \"Keep Looking\" below to continue!";}
else if(animalCode==-7){popMessage="Sorry! "+animalItem+" isn't one of the animals you're trying to find right now.";}
else if(animalCode==-8){popMessage="Sorry! You've already found "+animalItem+", who will be ready to go as soon as you track down the other animals.";}
else{popMessage="Sorry, an error occurred. Please try again.";}
if(animalPromoted==1){popMessage+="<p>Congrats, you\'re now at level "+animalEndRank+"!</p>";}
else{if(animalPointsLeft>0){popMessage+="<p>Only "+animalPointsLeft+" points to the next level!</p>";}}
if(animalSetComplete==1){document.getElementById('completeMsg_'+boxId).innerHTML=popMessage;document.getElementById('setCompletePop'+boxId).style.display='block';}
else{document.getElementById('msg_'+boxId).innerHTML=popMessage;document.getElementById('claimPop'+boxId).style.display='block';}}
