function switchAppear(text, number) {
	oldId = blockId;	
	if(sIFR.callbacks.length > 0) {
		sIFR.callbacks["h2"][0].replaceText(text);
	} else {
		document.getElementById("detailTitle").innerHTML = text;
	}
	populateSizes(number);
	blockId = number;
	document.getElementById('product_id').value = number;
	new Effect.Fade('mainImage' + oldId, {from: 1, to: 0, duration: 0.5});
	setTimeout("makeAppear()", 550);
}
function makeAppear() {
	new Effect.Appear('mainImage' + blockId, {from: 0, to: 1, duration: 0.5});
}
function populateSizes(id) {
	var select = document.getElementById('product_size');
	var price = document.getElementById('product_price');
	select.options.length = 0;
	var availableCount = 0;
	price.innerHTML = productSizePrices[id];
	for (i=0;i<productSizeIdx[id].length;i++) {
		select.options[i] = new Option(productSizeNames[id][i], productSizeIdx[id][i]);
		if (productSizeSoldOut[id][i]) {
			select.options[i].disabled = "disabled";
		}
		else if (availableCount == 0) {
			select.options[i].selected = "selected";
			availableCount++;
		}
	}
}

function ecardEnvelopeOpen() {
	document.getElementById('cardBack').className = '';
	document.getElementById('cardBack').style.display = 'none';	
	new Effect.Fade('envelopeFront', {from: 1, to: 0, duration: 0.5});
	setTimeout("appearCardFront()", 550);
	sIFR.callbacks["h2"][0].replaceText('By clicking the photo you see who sent you this e-card');	
}
function ecardCardFront() {
	new Effect.Fade('cardBack', {from: 1, to: 0, duration: 0.5});
	setTimeout("appearCardFront()", 550);
	sIFR.callbacks["h2"][0].replaceText('Just click the photo to see the message again');			
}
function ecardCardBack() {
	new Effect.Fade('cardFront', {from: 1, to: 0, duration: 0.5});
	setTimeout("appearCardBack()", 550);
	sIFR.callbacks["h2"][0].replaceText('The photo is visible by clicking the message');		
}
function appearCardFront() {
	new Effect.Appear('cardFront', {from: 0, to: 1, duration: 0.5});
}
function appearCardBack() {
	new Effect.Appear('cardBack', {from: 0, to: 1, duration: 0.5});
}