function Card(id, card, cardImage, pinkURL, moduleURL)
{
	this.id = id;
	this.card = card;
	this.cardImage = cardImage;
	this.front = false;
	
	this.showFront = true;
	
	this.flip = function()
	{
		this.front = !this.front;
		setTimeout("document['card_"+this.id+"'].flipping();", 30);
	}
	
	this.flipping = function()
	{
		if(this.front)
		{
			if(this.cardImage.width>0)
			{
				this.cardImage.width -= 8;
				this.card.style.left = parseInt(this.card.style.left) + 4;
				this.card.style.width = parseInt(this.card.style.width) - 8;

				setTimeout("document['card_"+this.id+"'].flipping();", 30)
			}
			else
			{
				if(this.card.innerHTML!="")
				{
					this.card.innerHTML = "";
					this.showFront = false;
				}
				
				this.card.style.left = parseInt(this.card.style.left) - 4;
				this.card.style.width = parseInt(this.card.style.width) + 8;
				
				if(parseInt(this.card.style.width)<128)
				{
					setTimeout("document['card_"+this.id+"'].flipping();", 30)
				}
				else
				{
					this.card.innerHTML = this.cardBack;
				}
			}
		}
		else
		{
			if(!this.showFront)
			{
				if(this.card.innerHTML)
				{
					this.card.innerHTML = "";
				}
			
				this.card.style.left = parseInt(this.card.style.left) + 4;
				this.card.style.width = parseInt(this.card.style.width) - 8;

				if(parseInt(this.card.style.width)<2)
				{
					this.showFront = !this.showFront;
					this.card.innerHTML = this.cardFront;
					this.cardImage = document.getElementById('img_'+this.id), 
					this.cardImage.width = 0;
				}

				setTimeout("document['card_"+this.id+"'].flipping();", 30)
			}
			else
			{
				this.cardImage.width += 8;
				this.card.style.left = parseInt(this.card.style.left) - 4;
				this.card.style.width = parseInt(this.card.style.width) + 8;

				if(this.cardImage.width<128)
				setTimeout("document['card_"+this.id+"'].flipping();", 30);
			}
		}
}

	this.cardFront = card.innerHTML;
	this.cardBack = '<table width="128" border="0" align="center" cellpadding="2" cellspacing="2"></td><tr><td class="tab"><a href="'+pinkURL+'" target="_blank" class="tab">permalink pink</a><br><a href="'+moduleURL+'" target="_blank" class="tab">permalink</a></tr></td></table>';
}

function flipCard(id, pinkURL, moduleURL)
{
	if(!document['card_'+id])
	document['card_'+id] = new Card(id, document.getElementById('mod_'+id), document.getElementById('img_'+id), pinkURL, moduleURL);

	document['card_'+id].flip();
}
