/* -----------------------------------
			tarot_image_class.js
			class def for
				vn_image (image of card, etc.)
			used by vn_piece (in vn_experience_classes.js)
            
            new - IMAGE_BASE_PATH global variable
	----------------------------------- */ 

if( IMAGE_BASE_PATH == "" ){
  var IMAGE_SRC = "/";
  //document.write("base path: / <BR>");
}else{
  var IMAGE_SRC = IMAGE_BASE_PATH;
  //document.write("base path: "+IMAGE_SRC+" <BR>");
}
    
////////////////////////////////////////////////////////////////////
// vn_image -- used by vn_piece -- would vary tween dif projects  //
////////////////////////////////////////////////////////////////////

// The term "images" here refers to the .gif images that appear under each piece (e.g. "Ace of Swords"),
// as opposed to "faces" which are the actual cards, for example.

//
// "clears" pieces imgs by changing images back to "ghost" or "blank" images
//
function image_clear() {
	// set equal to "ghost" images
	this.piece_path = "blank.gif";
	this.name_path = "blank.gif";

	this.piece_img.src = IMAGE_SRC + "images/decks/" + this.piece_path;
	this.name_img.src = IMAGE_SRC + "images/" + this.name_path;
}

//
// should have setPath ftn to set path of image based on number picked
//
function image_setPath( refNum ) 
{
	if (refNum >= 0) {
		this.piece_path = refNum + ".jpg"; // for easy deck updating, etc.
		this.name_path = refNum + ".gif";
		this.set_face();
	} else {
		// set equal to "ghost" images
		this.clear();
	}
}

//
// should have setFace ftn to set different faces of choice, i.e. deck
//
function image_setFace( newFace ) {
	if (newFace) {
		this.deck = newFace;
		this.deckfolder = jsDeckFolders[this.deck];
	}
    if( this.piece_path == "blank.gif" ){
        // pull up default blank image
        this.piece_img.src = IMAGE_SRC + "images/decks/blank.gif";
        this.name_img.src = IMAGE_SRC + "images/blank.gif";
    }else{
    	this.piece_img.src = IMAGE_SRC + "images/decks/" + this.deckfolder + "/table_card/" + this.piece_path;
    	this.name_img.src = IMAGE_SRC + "images/decks/" + this.deckfolder + "/names/" + this.name_path;
    }
}


//---------------------------------------------
// constructor for vn_image object (i.e. card image)
//---------------------------------------------
function vn_image( num, idDeck, imageObj, nameObj )
{
	// properties
	this.deck = idDeck;
	// note: jsDeckFolders array comes from PHP Deck.class
	this.deckfolder = jsDeckFolders[this.deck];
	this.name_path = "blank.gif";
	this.name_img = new Image();
	this.piece_path = "blank.gif";
	this.piece_img = new Image();

	// methods
	this.set_face = image_setFace;
	this.set_path = image_setPath; // for setting the paths based on piece ref number
	this.clear = image_clear; // for "clearing" piece selections

	// if num has been passed, set up the image params
	if (num >= 0) this.set_path(num);
}
