function viewSampleEmail(strPagePath,from, toName, email,selectedSkuId) {
	showModal(strPagePath+"?from=" + from + "&toName=" + toName + "&email=" + email + "&selectedSkuId=" + selectedSkuId,'600','900');
}
function giftNoteFocus(e,m) {
	if (e.value == m) {
		e.value='';
	}
}
function giftNoteBlur(e,m) {
	if (e.value.length == 0) {
		e.value=m.toString();
	} else if (e.name=='gw_input_notify_recipient') {
		if (validateEmailAddress(e.value)==false) {
			alert("The email address you provided (" + e.value + ") does not appear to be formatted properly");
			e.select();
		}
	}
}

function validateEmailAddress(incoming) {
	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
		// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
		// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
		// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
		// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));
		//old regex did not allow subdomains and dots in names
		//var email_regex = /^[\w\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+(\.[\w\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~])*\@(((\w+[\w\d\-]*[\w\d]\.)+(\w+[\w\d\-]*[\w\d]))|((\d{1,3}\.){3}\d{1,3}))$/;
	var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/ 
		// index of -1 means "not found"
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) &&
		(email_regex.test(emailstring)) ) {
		return true;
	} else {
		return false;
	}
}

function checkGiftcardBal() {
	var objForm = document.getElementById('frmGiftcardBalance');
	objForm.submit();
}

function viewSampleVirtualCardEmail(strPagePath,from, toName, email,noteMessage,selectedSkuId) {
	alert(strPagePath+"?from=" + from + "&toName=" + toName + "&email=" + email + "&noteMessage=" + noteMessage + "&selectedSkuId=" + selectedSkuId);
	showModal(strPagePath+"?from=" + from + "&toName=" + toName + "&email=" + email + "&noteMessage=" + noteMessage + "&selectedSkuId=" + selectedSkuId,'600','900');
}



	function blurGCInput(e) {
		if (e.value=='') {
			if (e.name=='ADD_CART_ITEM_ARRAY<>gw_to_1') {
				e.value = 'Recipient\'s Email';
			} else if (e.name=='txtRecipientEmail2') {
				e.value = 'Confirm Recipient\'s Email';
			} else if (e.name=='ADD_CART_ITEM_ARRAY<>gw_toName_1') {
				e.value = 'Recipient\'s Name';
			} else if (e.name=='ADD_CART_ITEM_ARRAY<>gw_from_1') {
				e.value = 'Your Name';
			}
		}
	}

	function focusGCInput(e) {
		if ((e.name=='ADD_CART_ITEM_ARRAY<>gw_to_1') && (e.value == 'Recipient\'s Email')) {
			e.value = '';
		} else if ((e.name=='txtRecipientEmail2') && (e.value == 'Confirm Recipient\'s Email')) {
			e.value = '';
		} else if ((e.name=='ADD_CART_ITEM_ARRAY<>gw_from_1') && (e.value == 'Your Name')) {
			e.value = '';
		} else if ((e.name=='ADD_CART_ITEM_ARRAY<>gw_toName_1') && (e.value == 'Recipient\'s Name')) {
			e.value = '';
		}
	}

	function cleanMessage(e) {

	//e.value = e.value.replace(/[^a-zA-Z 0-9.!$]+/g,'');


	}


    function getNoteValues() {
    	var element1 = document.getElementById('txtSenderEmail');
    	var element2 = document.getElementById('txtRecipientEmail');
    	var element3 = document.getElementById('txtToName');
    	var element4 = document.getElementById('gw_message_1');
    	if ($(sizeDropDown)) {
		var selectedSkuId = $(sizeDropDown).value;
	}
    	viewSampleVirtualCardEmail('<%=previewEmailTemplate%>',element1.value,element2.value,element3.value,element4.value,selectedSkuId);
    }

    function cleanBadInput() {
    	var fromField = document.getElementById('txtSenderEmail');
    	var toField = document.getElementById('txtRecipientEmail');
    	var toNameField = document.getElementById('txtToName');
    	var messageField = document.getElementById('gw_message_1');
    	var recipientField = document.getElementById('gw_input_notify_recipient');

    	if (fromField.value == 'Your Name'){
    		fromField.value = '';
    	}
    	if (toField.value == 'Recipient\'s Email'){
    		toField.value = '';
    	}
    	if (toNameField.value == 'Recipient\'s Name'){
    		toNameField.value = '';
    	}
    	if (messageField.value == 'Message:'){
    		messageField.value = '';
    	}
    	if (recipientField.value == 'Recipient email:'){
    		recipientField.value = '';
    	}
    }


