function deck(){var a=this;var b;this.fan=function(){b=window.setInterval(a.reveal,5)};this.reveal=function(){if(a.fan_count==a.all_cards){window.clearInterval(b);document.getElementById("rshuffle").style.visibility="hidden";if(a.set_aside_cards>0){a.reveal_set_asides()}}else{var c=document.createElement("img");c.src=a.deck_path+"ghost.jpg";c.onclick=a.cardevent;c.className="fan_card";if(a.pick_number>0){c.className+="_"+a.pick_number}if(typeof product_id!="undefined"){if(a.fan_count>a.all_cards-a.set_aside_cards-1){c.style.visibility="hidden"}}else{c.style.position="absolute"}c.style.left=a.ghost_position+"px";c.id=a.fan_count;c.onmouseover=raise_card;$("#fan_container").append(c);a.ghost_position=a.ghost_position+a.fan_spacing;a.fan_count++}};this.empty_fan=function(){my_fan_container=document.getElementById("fan_container");for(var b=0;b<a.all_cards;b++){my_image_to_remove=document.getElementById(b);my_fan_container.removeChild(my_image_to_remove)}a.ghost_position=a.ghost_position-a.fan_spacing*a.active_cards;a.fan_count=0;a.fan_spacing=34};this.pick_number=0;this.fan_count=0;this.fan_spacing=7;this.skip_motion=false;if(typeof product_id!="undefined"){this.fan_spacing=4}if(typeof IMAGES_URL=="undefined"){IMAGES_URL="http://gfx.tarot.com/"}this.all_cards=0;this.cards_set=false;this.set_aside_cards=0;this.active_cards=0;this.mix_deck_count=14;this.mc=0;this.cards=new Array;this.picked_cards_access=new Array;this.deck_path=ReadingData["Reading"]["DeckPath"];this.position_count=ReadingData["Reading"]["Position_Count"];this.nocardspicked=0;this.ghost_position=0;this.ghost_position0=0;this.mixdeck_interval=0;this.card_names_by_id=new Array;this.pick_complete=false;this.cardevent=function(a){mydeck.pick_card(this.id);my_card=this.id;document.getElementById(my_card).onmouseover="";if(mydeck.position_count==mydeck.nocardspicked){document.getElementById("step1").style.display="none";if(typeof product_id!="undefined"){$("#fan_cover").show();document.getElementById("fan_cover").style.filter="Alpha(opacity=0)";$("#fan_cover").animate({opacity:100,duration:10},10,function(){mydeck.remove_deck(my_card);var a="spread";if(this.pick_number>0){a="spread_"+this.pick_number}})}else{document.getElementById("step2").style.display="none";document.getElementById("step3").style.display="block"}}};this.revealed=0}document.write('<script type="text/javascript" src="/js/jquery/plugins/animate/easing.js"></script>');document.write('<script type="text/javascript" src="/js/jquery/plugins/animate/fxqueues.js"></script>');deck.prototype.pickSpecificCard=function(a){var b=0;while(b<this.cards.length){if(this.cards[b].get_id()==a){mydeck.pick_card(b);break}b=b+1}};deck.prototype.makeDeck=function(){var a=new Array;this.all_cards=deck_data["deck"]["card_name"].length;this.active_cards=deck_data["deck"]["card_name"].length;for(var b=0;b<this.all_cards;b++){a.push(deck_data["deck"]["card_name"][b]["#text"])}this.cards=new Array;for(var c=0;c<a.length;c++){var d=new card(c,a[c],"upright");this.cards[this.cards.length]=d}};deck.prototype.process_set_asides=function(){if(typeof set_asides!="undefined"){for(var a=0;a<set_asides.length;a++){this.setCardAside(set_asides[a],a+1)}}if(typeof exclusions!="undefined"){for(var a=0;a<exclusions.length;a++){this.excludeCard(exclusions[a])}if(document.getElementById("fan_container")){this.fan_spacing=Math.floor((parseInt($("#fan_container").css("width").split("px")[0])-75)/this.all_cards);var b=$("#fan_container").css("width").length;if(b==0){this.fan_spacing=Math.floor(276/this.all_cards)}}}};deck.prototype.reveal_set_asides=function(){this.skip_motion=true;for(var a=0;a<this.set_aside_cards;a++){array_position=this.all_cards-(a+1);mydeck.pick_card(array_position)}if(typeof selectedDeckID!="undefined"){mydeck.change_deck(selectedDeckID)}this.skip_motion=false};deck.prototype.excludeCard=function(a){var b=0;while(b<this.active_cards){if(this.cards[b].get_id()==a){this.cards.splice(b,1);this.active_cards--;this.all_cards--;break}b=b+1}};deck.prototype.setCardAside=function(a,b){var c=0;while(c<this.active_cards){if(this.cards[c].get_id()==a){var d=this.active_cards-1;if(c!=d){temp=this.cards[c];this.cards.splice(c,1);this.cards[d]=temp}this.set_aside_cards++;this.active_cards--;break}c=c+1}};deck.prototype.reveal_mixdeck=function(){for(this.mc=0;this.mc<this.mix_deck_count;this.mc++){var a=mydeck.mc%2;if(a==0){a+=2}var b="rshuffle"+a;var c=document.createElement("IMG");c.src=mydeck.deck_path+"ghost.jpg";c.id="mix"+mydeck.mc;c.onclick="javascript:steps_display()";c.style.position="absolute";c.style.left=mydeck.ghost_position0+"px";c.className="mix_card"+a;c.style.border="1px solid white";mydeck.ghost_position0+=0;document.getElementById(b).appendChild(c)}document.getElementById("rshuffle").style.visibility="visible"};deck.prototype.add_adjacent_cards=function(a,b){var c=document.createElement("IMG");c.src=this.cards[1].get_ghost_image_src(a);c.className="adjacent_cards";c.id="adjacent_card"+b;document.getElementById("rshuffle").appendChild(c)};deck.prototype.change_deck=function(a){selectedDeckID=a;deck_url="/tarot/deckConfig.php?deck_id="+a;deck_xml=new ParseXML(deck_url);deck_data=deck_xml.parse();var b=deck_data["deck"]["card_name"].length;if(!this.cards_set){this.all_cards=b}var c=deck_data["deck"]["deck_folder"];this.deck_path=c;this.deck_path_name=deck_data["deck"]["deck_path_name"];this.card_names_by_id=new Array;for(var d=0;d<b;d++){this.card_names_by_id.push(deck_data["deck"]["card_name"][d]["#text"])}for(var e=0;e<this.cards.length;e++){var f=this.cards[e].get_id();var g=deck_data["deck"]["card_name"][f]["#text"];this.cards[e].set_name(g);this.cards[e].set_image_folder(c)}if(typeof product_id!="undefined"&&this.pick_complete!=true){var h=this.cards[1].get_ghost_image_src();for(var i=0;i<this.mix_deck_count;i++){if(document.getElementById("mix"+i)){document.getElementById("mix"+i).src=h}}if(document.getElementById("adjacent_card1")){document.getElementById("adjacent_card1").src=this.cards[1].get_ghost_image_src("adjacent1");document.getElementById("adjacent_card2").src=this.cards[1].get_ghost_image_src("adjacent2")}}if(this.pick_complete==true){change_picked_cards_deck(a)}};deck.prototype.upright_shuffle=function(a){var b,c,d;var e;for(b=0;b<a;b++)for(c=0;c<this.active_cards;c++){d=Math.floor(Math.random()*this.active_cards);e=this.cards[c];this.cards[c]=this.cards[d];this.cards[d]=e}};deck.prototype.rotate_shuffle=function(a){var b,c,d;var e;var f=new Array("upright","right","reversed","left");for(b=0;b<a;b++)for(c=0;c<this.cards.length;c++){d=Math.floor(Math.random()*this.cards.length);e=this.cards[c];this.cards[c]=this.cards[d];this.cards[d]=e;this.cards[d].rotation=f[Math.floor(Math.random()*f.length)]}};deck.prototype.prune_cards=function(){var a,b;var c=this.position_count;for(a=0;a<c;a++){b=a+1;keep_card_position_num=this.picked_cards_access[document["main"]["card_"+b+"_tarot"].value];temp=this.cards[a];this.cards.splice(a,1,this.cards[keep_card_position_num]);this.cards.splice(keep_card_position_num,1,temp);this.picked_cards_access[document["main"]["card_"+b+"_tarot"].value]=a;this.picked_cards_access[this.cards[keep_card_position_num].get_id()]=keep_card_position_num}this.cards.splice(c,this.all_cards-c);this.empty_fan();this.cards_set=true;this.all_cards=c;this.active_cards=c;this.set_aside_cards=0;set_asides.splice(0,set_asides.length)};deck.prototype.picked_cards_shuffle=function(){var a,b;for(a=0;a<this.position_count;a++){b=a+1;my_card_container=document.getElementById("position"+b);my_image_to_remove=document.getElementById("position"+b+"_img");my_card_container.removeChild(my_image_to_remove)}document.getElementById("step1").style.display="block";document.getElementById("step2").style.display="none";document.getElementById("step3").style.display="none";document.getElementById("rshuffle").style.visibility="visible";document.getElementById("flashcontent").style.visibility="visible";document.getElementById("flashcontent").style.display="block";if(document.getElementById("your_concerns")){document.getElementById("your_concerns").style.background="transparent url(http://gfx.tarot.com/images/product/en_us/"+product_id+"/backgrounds/shuffle.jpg) no-repeat"}document.getElementById("deck_change_select1").style.display="none";var c="http://gfx.tarot.com/flash/tarot/"+product_id+"/shuffle02.swf";var d=new SWFObject(c,"flash_shuffle2","100%","100%","7.0","#FFFFFF",true);d.addVariable("cardimg","http://gfx.tarot.com/images/decks/"+selectedDeckID+"/ghost.jpg");d.addVariable("nCards",8);d.addParam("allowScriptAccess","always");d.write("flashcontent")};deck.prototype.showcard=function(a){return this.cards[a].get_name()+"["+this.cards[a].get_image_path()+"]"};deck.prototype.removeCards=function(a){return this.cards[a].get_name()+"["+this.cards[a].get_image_path()+"]"};deck.prototype.reassign_spread_id=function(){if(this.pick_number>0){document.getElementById("spread").id="spread_"+this.pick_number;var a,b;for(a=0;a<this.position_count;a++){b=a+1;document.getElementById("position"+b).id="position"+b+"_"+this.pick_number}fan_spread_offsets[0]=-15;fan_spread_offsets[1]=-30;document.getElementById("step2").style.top="150px";document.getElementById("step2").style.left="20px"}};deck.prototype.put_pick_into_form=function(a,b){if(document["hidden_form"]){document["hidden_form"]["TF_card"+a].value=this.cards[b].get_id()}else{document["main"]["card_"+a+"_tarot"].value=this.cards[b].get_id()}this.picked_cards_access[this.cards[b].get_id()]=b;var c;switch(this.cards[b].rotation){case"upright":c="u";break;case"right":c="r";break;case"reversed":c="d";break;case"left":c="l";break}if(document["hidden_form"]){document["hidden_form"]["TF_rotations"].value=document["hidden_form"]["TF_rotations"].value+c}else{if(document["main"]["card_"+a+"_rotation"]){document["main"]["card_"+a+"_rotation"].value=document["main"]["card_"+a+"_rotation"].value+c}}};deck.prototype.pick_card=function(a){function v(a,b,c){next_card=a+1;if(typeof autoFlipCards!="undefined"&&autoFlipCards){flip_over(a)}if(next_card>this.position_count){next_card="reveal"}if(typeof disableScrolls=="undefined"||!disableScrolls){$("#scroll_container").animate({opacity:0},150,function(){if(document.getElementById("scroll_container_text_"+a)){$("#scroll_container_text_"+a).css({display:"none"})}if(typeof disableScrollBg=="undefined"||!disableScrollBg){document.getElementById("scroll_container").style.backgroundImage='url("'+IMAGES_URL+"images/product/en_us/"+product_id+"/scrolls/"+next_card+'.jpg")';$("#scroll_container").animate({opacity:1},{speed:"slow",queue:"pick2",scope:"p10"});$("#scroll_container_text_"+next_card).css({display:"block"})}else{document.getElementById("scroll_decoration").className="png_sprite scroll_decoration_"+next_card;$("#scroll_container_text_"+next_card).css({display:"block"})}if(a!=this.position_count){$("#fan_cover").hide()}if(document.getElementById("scroll_container_text_"+next_card)){$("#scroll_container").animate({opacity:1},{speed:"slow",queue:"pick2",scope:"p10"})}else{$("#complete_btn_container").show;if(typeof postPickSpreadMove!="undefined"&&postPickSpreadMove){$("#spread").animate({top:postPickSpreadMove[1],left:postPickSpreadMove[0]},{speed:"slow",queue:"pick2",scope:"p10"})}}if(document.getElementById("position"+a+"_title")){$("#position"+a+"_title").removeClass("card_highlighted");$("#position"+a+"_cell").removeClass("cell_highlighted");if(document.getElementById("position"+next_card+"_title")){$("#position"+next_card+"_title").addClass("card_highlighted");$("#position"+next_card+"_cell").addClass("cell_highlighted")}}})}else{if(a!=this.position_count){$("#fan_cover").hide()}if(typeof document.getElementById("scroll_container_text_"+next_card)=="undefined"){$("#complete_btn_container").show}}}var b=this;var a=a;if(this.nocardspicked==this.position_count){alert("You have already picked all the cards you need")}else{this.nocardspicked++;var c=this.nocardspicked;var d="position"+c;if(this.pick_number>0){d=d+"_"+this.pick_number}if(typeof product_id!="undefined"&&!this.skip_motion){$("#"+d).hide();var e=$("#"+d).css("top");var f=$("#"+d).css("left");var g=$("#0").css("height");g=parseInt(g.split("px")[0]);var h=$("#0").css("width");var i=parseInt($("#step2").css("left").split("px")[0]);var j=parseInt($("#step2").css("top").split("px")[0])+9;if(typeof fan_spread_offsets=="object"){i+=fan_spread_offsets[0];j+=fan_spread_offsets[1]}var k="spread";if(this.pick_number>0){k="spread_"+this.pick_number}var l=parseInt($("#"+k).css("top").split("px")[0]);var m=$("#"+k).css("left");if(m.match("auto")){m=0}else{m=parseInt(m.split("px")[0])}if(h.match("auto")){h=Math.floor(g*.7)}else{h=parseInt(h.split("px")[0]);if(h>g){h=Math.floor(g*.7)}}var n=parseInt(e.split("px")[0])-j+l;var o=parseInt(f.split("px")[0])-i+m;var p=a*this.fan_spacing-15;var q=1.5;var r=Math.floor(g*q);var s=Math.floor(h*q);document.getElementById("fan_cover").style.display="block";$("#fan_cover").show();document.getElementById(a).onclick=null;$("#"+a).animate({width:s,height:r,left:p,top:"-=24px"},{speed:"slow",easing:"easeOutExpo",queue:"pick",postDelay:100,scope:"p1"});$("#"+a).animate({width:h,height:g},{speed:900,easing:"easeOutExpo",queue:"pick",postDelay:10,scope:"p3"});$("#"+a).animate({left:o},{easing:"easeOutCubic",queue:"pick",postDelay:10,scope:"p4",duration:600});$("#"+a).animate({top:n},{easing:"easeOutCubic",queue:"pick",postDelay:10,scope:"p4",duration:1e3,complete:t});var t=function(){if(typeof card_slot_angles!="undefined"||typeof card_slot_angles[d]!="undefined"&&card_slot_angles[d]!==0){$("#"+a).addClass("card-rotate-"+card_slot_angles[d])}};var u=function(){$("#"+d).show();b.cards[a].appendtodiv(d);$("#spread #"+d).addClass("active");$("#spread #"+d+"_img").show();$("#spread #"+d+"_img").css("visibility","visible");$("#"+a).hide();v(c,d,a)};$("#"+a).animate({opacity:50},{speed:"fast",preDelay:0,queue:"pick",scope:"p5",complete:u},100)}else{this.cards[a].appendtodiv(d);$("#spread #"+d).addClass("active");document.getElementById(a).style.visibility="hidden";if(typeof product_id!="undefined"){document.getElementById("fan_cover").style.display="none"}}if(document.getElementById(d)){if(typeof card_slot_angles=="undefined"||typeof card_slot_angles[d]=="undefined"){document.getElementById(d).style.display="block";document.getElementById(d).style.visibility="visible"}}this.put_pick_into_form(c,a);if(c==this.position_count){this.pick_complete=true;if(typeof product_id!="undefined"){if(product_id==68e3&&this.pick_number<1){this.pick_number++;document.getElementById("scroll_container").style.filter="Alpha(opacity=100)";$("#fan_container > .fan_card[@id!="+a+"]").animate({left:"+=770",top:"-=230"},3500,"easeOutBack");$("#scroll_container").animate({opacity:100},3500,function(){mydeck.prune_cards();mydeck.picked_cards_shuffle();mydeck.reassign_spread_id()});this.pick_complete=false;this.nocardspicked=0}else if(product_id==68e3&&this.pick_number>0){flip_all_hidden();document.getElementById("flashcontent2").style.display="block";run_flash_continue()}}}}deck.prototype.remove_deck=function(a){$("#fan_container .fan_card[@id!="+a+"]").each(function(){$(this).animate({left:"+=670px",top:"-=250px",opacity:0},2500,function(){$("#step2").hide();$("#step3").show()})})}}

