

function UpsellPopUp(id)
{
	var url = strURLjs + "/popups/upsellpopup.asp?VID=" + vidjs + "&id=" + id;
	var width = 450;
	var height = 450;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}
function deliveryPopUp()
{
	var url = strURLjs + "/popups/deliverypolicy.asp?VID=" + vidjs;
	var width = 500;
	var height = 380;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}

function newPopUp(point, pid, color)
{
	var url = strURLjs + "/popups/newpopup.asp?point="+point+"&pid=" + pid+"&c="+color;
	var width = 400;
	var height = 500;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}
function PopUpLink(pid)
{
	var url = strURLjs + "/popups/PopupLink.asp?Popupid="+pid+"&ID=0";
	var width = 500;
	var height = 500;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes, resize=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}


function luxuryPopUp(pricepoint,pid)
{
	if (pricepoint == 2) {
		var url = strURLjs + "/popups/deluxe_popup.asp?pid=" + pid;
	} else {
		var url = strURLjs + "/popups/premium_popup.asp?pid=" + pid;
	}

	var width = 410;
	var height = 570;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes, resizable=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}

function deluxePopUp(pid)
{
	var url = strURLjs + "/popups/deluxe_popup.asp?pid=" + pid;
	var width = 400;
	var height = 500;
	var winleft = 0;//(screen.width - width) / 2;
	var wintop = 0;//(screen.height - height) / 2;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=no, resize=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}

function premiumPopUp(pid)
{
	var url = strURLjs + "/popups/premium_popup.asp?pid=" + pid;
	var width = 400;
	var height = 500;
	var winleft = 0;//(screen.width - width) / 2;
	var wintop = 0;//(screen.height - height) / 2;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=no';
	var win = window.open(url, 'win', winprops);
	//return false;
}

function privacyPopUp()
{
	var url = strURLjs + "/popups/privacypolicypopup.asp?VID=" + vidjs;
	var width = 450;
	var height = 500;
	var winleft = 0;//(screen.width - width) / 2;
	var wintop = 0;//(screen.height - height) / 2;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}

function safeShoppingPopUp()
{
	var url = strURLjs + "/popups/safeshoppingpopup.asp?VID=" + vidjs;
	var width = 400;
	var height = 300;
	var winleft = 0;//(screen.width - width) / 2;
	var wintop = 0;//(screen.height - height) / 2;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',resizable=yes, scrollbars=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}
function TellaFriendPopUp(id)
{
	var url = "/popups/TellAFriend.asp?VID=" + vidjs + "&ID="+id;
	var width = 600;
	var height = 450;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}
function LargerImagePopUp(id)
{
	var url = "/popups/LargerImage.asp?vtid=" + vtidjs + "&VID=" + vidjs + "&ID="+id+"&point=" + pricepointsjs;
	var width = 500;//600;
	var height = 550;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes, resizable=yes';
	var win = window.open(url, 'win', winprops);
	//return false;
}

function KeepsakeLargerImagePopup(pid)
{
	var url = "/popups/KeepsakeLargerImage.asp?pid="+pid+"&point=" + pricepointsjs;
	var width = 500;//600;
	var height = 550;
	var winleft = 0;
	var wintop = 0;
	var winprops = 'height='+height+',width='+width+',top='+wintop+',left='+winleft+',scrollbars=yes, resizable=yes';
	var win = window.open(url, 'win', winprops);

}
function checkBox(upsellid,position, rownum)
{
	var temp = false;
	chkName = "upsell_" + upsellid

	if (typeof (document.product.upsell_total) == 'object') {
	    var upsell_total_exists = true;
	} else {
	    var upsell_total_exists = false;
    }

	if (position == 1) {
	    if (eval("document.product." + chkName + "_1.checked") == true) {
	        if (upsell_total_exists) {
	            if (eval("document.product." + chkName + "_2.checked") == true) {
	                document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_2_value.value")));
	            } else if (eval("document.product." + chkName + "_3.checked") == true) {
	                document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_3_value.value")));
    	        }
	            document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) + parseFloat(eval("document.product." + chkName + "_1_value.value")));
	        }
	        eval("document.product." + chkName + "_2.checked = false");
	        eval("document.product." + chkName + "_3.checked = false");
	        temp = true;
	    } else if (upsell_total_exists) {
	        document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_1_value.value")));
    	}
	}
	if (position == 2) {
	    if (eval("document.product." + chkName + "_2.checked") == true) {
	        if (upsell_total_exists) {
	            if (eval("document.product." + chkName + "_1.checked") == true) {
	                document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_1_value.value")));
	            } else if (eval("document.product." + chkName + "_3.checked") == true) {
	                document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_3_value.value")));
	            }
	            document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) + parseFloat(eval("document.product." + chkName + "_2_value.value")));
	        }
	        eval("document.product." + chkName + "_1.checked = false");
	        eval("document.product." + chkName + "_3.checked = false");
	        temp = true;
	    } else if (upsell_total_exists) {
	        document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_2_value.value")));
    	}
	}
	if (position == 3) {
	    if (eval("document.product." + chkName + "_3.checked") == true) {
	        if (upsell_total_exists) {
	            if (eval("document.product." + chkName + "_2.checked") == true) {
	                document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_2_value.value")));
	            } else if (eval("document.product." + chkName + "_1.checked") == true) {
	                document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_1_value.value")));
	            }
	            document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) + parseFloat(eval("document.product." + chkName + "_3_value.value")));
	        }
	        eval("document.product." + chkName + "_1.checked = false");
	        eval("document.product." + chkName + "_2.checked = false");
	        temp = true;
	    } else if (upsell_total_exists) {
	        document.product.upsell_total.value = round2(parseFloat(document.product.upsell_total.value) - parseFloat(eval("document.product." + chkName + "_3_value.value")));
    	}
    }

	var frmValue;

	if (temp == true) {
		document.product.UpsellCTR.value = 1;
		frmValue = eval("document.product.upsell_" + rownum);
		frmValue.value = 1;
	} else {
		frmValue = eval("document.product.upsell_" + rownum);
		frmValue.value = 0;
	}
}

function round2(num) {
    return Math.round(num * 100) / 100
}

function validateForm() 
{
	//if (TrimAll(document.product.teleflorakeepsake.value) == 'True') {
			var zip = TrimAll(document.product.zip.value);
			var ziplength = zip.length;
			
			if (zip == '') {
				alert('Please enter Zip.');
				document.product.zip.focus();
				return false;
			}
			
			if (zip.length != 10 && zip.length != 9 && zip.length != 5 && zip.length != 7 && zip.length != 6){
				alert('Zip Length should be at least 5 digits. Please check your zip value.');
				document.product.zip.focus();
				return false;
			}
			
			if (zip.indexOf("'")>=0) {
				alert ('This does not appear to be good Zip.');
				document.product.zip.focus();
				return false;
			}
			
			var goodZip = true;
			if ((zip.length == 5) ||(zip.length == 9)) {
				for (var i = 0; i < ziplength; i++){
					var theChar = zip.substring(i, i+1)
					if (theChar < "0"  || theChar > "9") {
						goodZip = false;
					}
				}
			}
			
			if (zip.length == 6){
				var ZipCode1 = zip.substring(0, 3);
				var ZipCode2 = zip.substring(3, 6);
				ZipCode = (ZipCode1 + " " + ZipCode2);
				document.product.zip.value = ZipCode
						return true;
				}
			
			if (zip.length == 10){
				for (var i = 0; i < 5; i++){
					var theChar9 = zip.substring(i, i+1)
					if (theChar9 < "0"  || theChar9 > "9") {
						alert ('This does not appear to be good Zip.');
						document.product.zip.focus();
						return false;
					}
				}

				for (var i = 5; i < 6; i++){
					var theChar10 = zip.substring(i, i+1)
					if (theChar10 != "-" ) {
						alert ('This does not appear to be good Zip.');
						document.product.zip.focus();
						return false;
					}
				}
				for (var i = 6; i < 10; i++){
				 	var theChar11 = zip.substring(i, i+1)
						if (theChar9 < "0"  || theChar9 > "9") {
							alert ('This does not appear to be good Zip.');
							document.product.zip.focus();
							return false;
						}
				}
			}

			if (goodZip == false){
				alert('Please check your Zip Code.');
				document.product.zip.focus();
				return false;
			}
	//}

	var upsellnum = document.product.UpsellCTR.value;
	if (upsellnum > 0) {
		var ctr = document.product.totalupsells.value;
		var UpsellCTR = 0;
		for (i = 1; i <= ctr; i++) {
			if (eval("document.product.upsell_" + i + ".value") == "1") {

				UpsellCTR++;
			}
		}

		if (UpsellCTR > 3) {
			alert('At this time, you can only select up to 3 extras');
			return false;
		}
	}
	return true;
}
