// nothing in this file is used but we're keeping it just in case that changes.

// global vars, ugly I know
var api = 0;
// currentCard number is a global
var currentCardNum = 0;
// card type, set by rendering
var currentCardType = "";
var suitCards;
var suitStr;


$(document).ready(function(){
	
	// preload our large images
	/*for(j = 0; j < 4; ++j){
		suit = "";
		if(j == 0)
			suit = "c";
		if(j == 1)
			suit = "s";
		if(j == 2){
			suit = "h";
		}
		if(j == 3){
			suit = "d";
		}
		
		for(i = 1; i < 14; ++i){
			$.preloadImages("decks/hm_large/" + suit + "/" + i + "/" + i + suit + ".gif");
		}
	}*/
	
	// set the scroller up
	/*api = $("#triggers").scrollable({size: 1}).navigator({api:true});

	api.onSeek(function() { 
	    // here, the 'this' variable points to the API 
	    index = this.getIndex();

		if(currentCardType == "gallery")
			$("div#gallery_title").html(suitCards[currentCardNum].gallery_titles[0][index + 1]);

		sourceStr = 'decks/hm_large/' + suitStr + '/' + (currentCardNum + 1) + '/assets/' + (index + 1) + '.jpg';
		//console.log(sourceStr);
		$("img#gallery_popup").attr("src", sourceStr );
	});



	$(".enlarge").click(function(){
		//console.log("LOAD OVERLAY PLEASE WITH: " + $("img#gallery_popup").attr("src"));
		showOverlay();
	});

	$(".close").click(function(){
		//$("div#page-lightbox").hide();
		$("div#overlay").hide();
	});*/

});

// similar to gallery's version of this card but not 100%
function renderCard(cardNumber, suit){
		cardNumber = cardNumber - 1;
		suitStr = suit;
		// load our data from the json in card_data.js

		if(suitStr == "h")
			suitCards = cards.h;
		if(suitStr == "d")
			suitCards = cards.d;						
		if(suitStr == "c")
			suitCards = cards.c;						
		if(suitStr == "s")
			suitCards = cards.s;
	
	$("div#text").hide();
	$("div#text").css("font-family", "Tahoma, Geneva, sans-serif");
	$("div#gallery_title").html("");
	currentCardNum = cardNumber;
	$("div.super_card").hide();
	$("div.super_card img#thecard").attr("src", 'decks/hm_large/' + suitStr + '/' + (cardNumber + 1) + '/' + (cardNumber + 1) + suitStr + '.gif');
	
	dataIndex = cardNumber - 1;
	if(dataIndex < 0){
		dataIndex = 0;
	}
				
	$("div.gallery_title").html(suitCards[cardNumber].title);
	// handle GALLERY type cards
	if(suitCards[cardNumber].type == "gallery"){
		currentCardType = "gallery";
		$("div.items img").each(function(i){
			imgStr = 'decks/hm_large/' + suitStr + '/' + (cardNumber + 1) + '/assets/' + (i + 1) + '.jpg';
			thumbImgStr = 'decks/hm_large/' + suitStr + '/' + (cardNumber + 1) + '/assets/' + (i + 1) + 't.jpg';
			$(this).attr("src", thumbImgStr);
			if(i == 0){
				//console.log("SETTING POP TO " + imgStr);
				//console.log("TITLE: " + suitCards[cardNumber].gallery_titles[0][4]);
				$("div#gallery_title").html(suitCards[cardNumber].gallery_titles[0][0]);
				$("img#gallery_popup").attr("src", imgStr );
			}
		});

		$("div.scrollable").show();
		$("div.navi").show();
		$("div.enlarge").show();
	} else {
		$("div.scrollable").hide();
		$("div.navi").hide();
		$("div.enlarge").hide();
	}
	// handle HTML type cards
	if(suitCards[cardNumber].type == "html"){
		currentCardType = "html";
		//console.log("TYPE IS HTML");
		//console.log("FETCHING: " + 'decks/hm_large/' + suitStr + '/' + (cardNumber + 1) + '/assets/' + suitCards[cardNumber].file);
		$("div#text").load('decks/hm_large/' + suitStr + '/' + (cardNumber + 1) + '/assets/' + suitCards[cardNumber].file);
		$("div#text").show();
	}
	
	if(suitCards[cardNumber].type == "link"){
		currentCardType = "link";
		//console.log("WE ARE A LINK");
		$("div.super_card").wrap("<a id='super_card_link' href='" + suitCards[cardNumber].url + "' />");
	} else {
		$("#super_card_link").replaceWith($("div.super_card"));
	}
	
	$("div.super_card").append($("div.super_card_content"));
	$("div.super_card_content").show();
	$("div.super_card").css("z-index", "10000");
	$("div.super_card").fadeIn(500);
	
}

function showOverlay(){
	//$("div#page-lightbox").show();
	index = api.getIndex();
	sourceStr = 'decks/hm_large/' + suitStr + '/' + (currentCardNum + 1) + '/assets/' + (index + 1) + '.jpg';
	//console.log(sourceStr);
	$("img#gallery_popup").attr("src", sourceStr );
	$("#overlay").show();	
}

