// JavaScript Document
function zoomPicture(cardId) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	imgwidth = 720;
	imgheight = 515;
	sTop = (sHeight - imgheight) / 2;
	sLeft = (sWidth - imgwidth) / 2;
	
	
	window.open("showEcard.asp?cardId=" + cardId, "banner", "width=" + imgwidth + ",height=" + imgheight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function preview(cardId) {
	if(validateEcardEntry()) {
		sWidth = screen.availWidth;
		sHeight = screen.availHeight;
		
		imgwidth = 670;
		imgheight = 500;
		sTop = (sHeight - imgheight) / 2;
		sLeft = (sWidth - imgwidth) / 2;
		
		
		window.open("ecardPreview.asp?cardId=" + cardId, "banner", "width=" + imgwidth + ",height=" + imgheight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
		return;
	}
}

function sendEcard(strConfirm) {
	if(strConfirm == "same") {
		if(validateEcardEntry())
			frmElement.submit();
	}
	else {
		window.opener.document.form1.submit();
		window.close();
	}
}

function validateEcardEntry() {
		frmElement = eval("document.form1");
		toName = trimSpaces(frmElement.toName.value);
		if(toName.length <= 0) {
			alert("Kindly enter the recepient's name.");
			frmElement.toName.focus();
			return false;
		}
		
		toEmail = trimSpaces(frmElement.toEmail.value);
		if(toEmail.length <= 0) {
			alert("Kindly enter the recepient's email ID.");
			frmElement.toEmail.focus();
			return false;
		}
		else {
			if(!checkEmail(toEmail)) {
				frmElement.toEmail.focus();
				return false;
			}
		}
		
		fromName = trimSpaces(frmElement.fromName.value);
		if(fromName.length <= 0) {
			alert("Kindly enter the senders name.");
			frmElement.fromName.focus();
			return false;
		}
		
		fromEmail = trimSpaces(frmElement.fromEmail.value);
		if(fromEmail.length <= 0) {
			alert("Kindly enter the senders email ID.");
			frmElement.fromEmail.focus();
			return false;
		}
		else {
			if(!checkEmail(fromEmail)) {
				frmElement.fromEmail.focus();
				return false;
			}
		}
		
		message = trimSpaces(frmElement.message.value);
		if(message.length <= 0) {
			alert("Kindly enter the message.");
			frmElement.message.focus();
			return false;
		}
		else {
			if(message.length > 250) {
				alert("The message limit should not exceed 250 characters.");
				frmElement.message.focus();
				return false;
			}
		}
		return true;
}
