function selectCard(id)
{
    var a = { i: id, t: "selectcard" };
    var params = $H(a);
	
	var myAjax = new Ajax.Request("/data.php", 
								   { asynchronous: true,
                                     parameters: params.toQueryString(), 
								     onComplete:  function(originalRequest){ $('ecardimage').innerHTML = originalRequest.responseText; $('eid').value = id; }
								   }
								  );
}

function getCards()
{
	var a      = {t: "imagelist", i0: $F('i0'), i1: $F('i1') };
	var params = $H(a);
	
	var myAjax = new Ajax.Request("/data.php",
								   { asychronous: true, parameters: params.toQueryString(),
								     onComplete: function(originalRequest){ $('imagelist').innerHTML = originalRequest.responseText; }
								   }
								  );
}

function getFirstId()
{
	var a      = {t: "firstid" };
	var params = $H(a);
	
	var  myAjax = new Ajax.Request("/data.php",
								   { asychronous: true, parameters: params.toQueryString(),
								     onComplete: function(originalRequest){ $('eid').value = originalRequest.responseText; }
								   }
								  );	
}


function confirmReset()
{	
	return confirm("Are you sure you want to reset the E-Card?");
}

function checkForm()
{
	var errorTxt = new String();
	var success = new Boolean(true);
	
	var sn = new String($F('sendername'));
	var se = new String($F('senderemail'));
	var re = new String($F('recepientemail'));	
	var cn = new String($F('message'));

	if (sn.length == 0 || se.length == 0 || re.length == 0 || cn.length == 0)
	{
		errorTxt += "- Please fill out all fields\n";
		success = false;
	}
	
	if (errorTxt.length > 0) alert(errorTxt);
	return success;
}

window.onload = function()
{
	getFirstId();
	getCards();
	selectCard($F('eid'));
}

