//---------------------------------------------------------------------------------------------------------------------
//Check for platform and browser
//---------------------------------------------------------------------------------------------------------------------
b_mac = false;

if(document.getElementById) str_browser = 'nn6';
if(document.all) str_browser = 'ie';
if(document.layers) str_browser = 'nn';

if(navigator.userAgent.toLowerCase().indexOf('mac')) str_mac = true;
if(navigator.userAgent.toLowerCase().indexOf('ppc')) str_mac = true;
if(navigator.userAgent.toLowerCase().indexOf('powerpc')) SDDM_mac = true;


function drawGiftCenter()
{
//LEFT
//	document.write('<TD height="171" width="131" bgColor="#FFA90D" rowSpan="2"><IMG src="../IMAGES/CATALOG/HOMEFOOTER_0_10001.jpg" border="0" /></TD>');
//	document.write('<TD height="171" width="200" bgColor="#FFA90D" rowSpan="2"><TABLE width="100%" height="100%" cellpadding="0" cellspacing="3" border="0"><TR><TD><P class="HEADER_BLACK">3 Pack 2001</P></TD></TR><TR><TD><P class="contentBLACK">Born in Faleria, Italy in 1895, Mariano Meconi at the age of 13 immigrated from Italy to Windsor, Ontario Canada where he finished school.</P></TD></TR><TR><TD><IMG src="../IMAGES/btn_addToCart.gif" border="0" /></TD></TR><TR><TD width="1" height="100%"><IMG src="../IMAGES/spacer.gif" border="0" width="1" height="100%" /></TD></TR></TABLE></TD>');

//RIGHT TOP
//	document.write('<TD height="85" width="200" bgColor="#FFA90D" align="right"><TABLE width="100%" height="100%" cellpadding="0" cellspacing="0" border="3"><TR><TD height="85" width="135" bgColor="#ffffff"><IMG src="../IMAGES/CATALOG/HOMEFOOTER_1_10002.jpg" border="0" /></TD><TD height="85" width="100%" bgColor="#FFA90D"><TABLE width="100%" height="100%" cellpadding="0" cellspacing="3" border="1"><TR><TD><P class="HEADER_BLACK">3 Pack 2001</P></TD></TR><TR><TD><P class="contentBLACK">basket one</P></TD></TR><TR><TD><IMG src="../IMAGES/btn_addToCart.gif" border="0" /></TD></TR><TR><TD width="1" height="100%"><IMG src="../IMAGES/spacer.gif" border="0" width="1" height="100%" /></TD></TR></TABLE></TD><TD height="85" width="9" bgColor="#FFA90D" vAlign="bottom">&nbsp;</TD></TR></TABLE></TD>');
}

function drawTopNav(str_page, i_activeTab)
{
	if (document.images)
	{
		tabNav_0_on= new Image(81,24);
		tabNav_0_off= new Image(81,24);
		tabNav_1_on= new Image(81,24);
		tabNav_1_off= new Image(81,24);
		tabNav_2_on= new Image(81,24);
		tabNav_2_off= new Image(81,24);
		tabNav_3_on= new Image(81,24);
		tabNav_3_off= new Image(81,24);
		tabNav_4_on= new Image(81,24);
		tabNav_4_off= new Image(81,24);

		tabNav_0_on.src='../IMAGES/tabNav_HOME_0_on.gif';
		tabNav_0_off.src='../IMAGES/tabNav_HOME_0_off.gif';
		tabNav_1_on.src='../IMAGES/tabNav_HOME_1_on.gif';
		tabNav_1_off.src='../IMAGES/tabNav_HOME_1_off.gif';
		tabNav_2_on.src='../IMAGES/tabNav_HOME_2_on.gif';
		tabNav_2_off.src='../IMAGES/tabNav_HOME_2_off.gif';
		tabNav_3_on.src='../IMAGES/tabNav_HOME_3_on.gif';
		tabNav_3_off.src='../IMAGES/tabNav_HOME_3_off.gif';
		tabNav_4_on.src='../IMAGES/tabNav_HOME_4_on.gif';
		tabNav_4_off.src='../IMAGES/tabNav_HOME_4_off.gif';

		switch(str_page)
		{
			case "SPARKLING":
				document.write('<TABLE width="100%" height="24" cellpadding="0" cellspacing="0" border="0"><TR><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 0);" onmouseover="if(document.images) { this.src  = tabNav_0_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_0_on.src;}" name="tabNav_0" src="../IMAGES/tabNav_HOME_0_on.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 1);" onmouseover="if(document.images) { this.src  = tabNav_1_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_1_off.src;}" name="tabNav_1" src="../IMAGES/tabNav_HOME_1_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 2);" onmouseover="if(document.images) { this.src  = tabNav_2_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_2_off.src;}" name="tabNav_2" src="../IMAGES/tabNav_HOME_2_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 3);" onmouseover="if(document.images) { this.src  = tabNav_3_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_3_off.src;}" name="tabNav_3" src="../IMAGES/tabNav_HOME_3_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 4);" onmouseover="if(document.images) { this.src  = tabNav_4_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_4_off.src;}" name="tabNav_4" src="../IMAGES/tabNav_HOME_4_off.gif" border="0" alt="" /></TD><TD align="left" width="100%" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="100%" height="1" /></TD></TR></TABLE>');
				break;
			case "ECARDS":
				document.write('<TABLE width="100%" height="24" cellpadding="0" cellspacing="0" border="0"><TR><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 0);" onmouseover="if(document.images) { this.src  = tabNav_0_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_0_off.src;}" name="tabNav_0" src="../IMAGES/tabNav_HOME_0_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 1);" onmouseover="if(document.images) { this.src  = tabNav_1_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_1_on.src;}" name="tabNav_1" src="../IMAGES/tabNav_HOME_1_on.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 2);" onmouseover="if(document.images) { this.src  = tabNav_2_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_2_off.src;}" name="tabNav_2" src="../IMAGES/tabNav_HOME_2_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 3);" onmouseover="if(document.images) { this.src  = tabNav_3_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_3_off.src;}" name="tabNav_3" src="../IMAGES/tabNav_HOME_3_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 4);" onmouseover="if(document.images) { this.src  = tabNav_4_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_4_off.src;}" name="tabNav_4" src="../IMAGES/tabNav_HOME_4_off.gif" border="0" alt="" /></TD><TD align="left" width="100%" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="100%" height="1" /></TD></TR></TABLE>');
				break;
			case "EVENTS":
				document.write('<TABLE width="100%" height="24" cellpadding="0" cellspacing="0" border="0"><TR><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 0);" onmouseover="if(document.images) { this.src  = tabNav_0_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_0_off.src;}" name="tabNav_0" src="../IMAGES/tabNav_HOME_0_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 1);" onmouseover="if(document.images) { this.src  = tabNav_1_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_1_off.src;}" name="tabNav_1" src="../IMAGES/tabNav_HOME_1_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 2);" onmouseover="if(document.images) { this.src  = tabNav_2_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_2_on.src;}" name="tabNav_2" src="../IMAGES/tabNav_HOME_2_on.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 3);" onmouseover="if(document.images) { this.src  = tabNav_3_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_3_off.src;}" name="tabNav_3" src="../IMAGES/tabNav_HOME_3_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 4);" onmouseover="if(document.images) { this.src  = tabNav_4_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_4_off.src;}" name="tabNav_4" src="../IMAGES/tabNav_HOME_4_off.gif" border="0" alt="" /></TD><TD align="left" width="100%" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="100%" height="1" /></TD></TR></TABLE>');
				break;
			case "WWINES":
				document.write('<TABLE width="100%" height="24" cellpadding="0" cellspacing="0" border="0"><TR><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 0);" onmouseover="if(document.images) { this.src  = tabNav_0_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_0_off.src;}" name="tabNav_0" src="../IMAGES/tabNav_HOME_0_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 1);" onmouseover="if(document.images) { this.src  = tabNav_1_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_1_off.src;}" name="tabNav_1" src="../IMAGES/tabNav_HOME_1_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 2);" onmouseover="if(document.images) { this.src  = tabNav_2_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_2_off.src;}" name="tabNav_2" src="../IMAGES/tabNav_HOME_2_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 3);" onmouseover="if(document.images) { this.src  = tabNav_3_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_3_on.src;}" name="tabNav_3" src="../IMAGES/tabNav_HOME_3_on.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 4);" onmouseover="if(document.images) { this.src  = tabNav_4_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_4_off.src;}" name="tabNav_4" src="../IMAGES/tabNav_HOME_4_off.gif" border="0" alt="" /></TD><TD align="left" width="100%" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="100%" height="1" /></TD></TR></TABLE>');
				break;
			case "RWINES":
				document.write('<TABLE width="100%" height="24" cellpadding="0" cellspacing="0" border="0"><TR><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 0);" onmouseover="if(document.images) { this.src  = tabNav_0_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_0_off.src;}" name="tabNav_0" src="../IMAGES/tabNav_HOME_0_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 1);" onmouseover="if(document.images) { this.src  = tabNav_1_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_1_off.src;}" name="tabNav_1" src="../IMAGES/tabNav_HOME_1_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 2);" onmouseover="if(document.images) { this.src  = tabNav_2_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_2_off.src;}" name="tabNav_2" src="../IMAGES/tabNav_HOME_2_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 3);" onmouseover="if(document.images) { this.src  = tabNav_3_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_3_off.src;}" name="tabNav_3" src="../IMAGES/tabNav_HOME_3_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 4);" onmouseover="if(document.images) { this.src  = tabNav_4_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_4_on.src;}" name="tabNav_4" src="../IMAGES/tabNav_HOME_4_on.gif" border="0" alt="" /></TD><TD align="left" width="100%" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="100%" height="1" /></TD></TR></TABLE>');
				break;
			default:
				document.write('<TABLE width="100%" height="24" cellpadding="0" cellspacing="0" border="0"><TR><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 0);" onmouseover="if(document.images) { this.src  = tabNav_0_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_0_off.src;}" name="tabNav_0" src="../IMAGES/tabNav_HOME_0_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 1);" onmouseover="if(document.images) { this.src  = tabNav_1_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_1_off.src;}" name="tabNav_1" src="../IMAGES/tabNav_HOME_1_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 2);" onmouseover="if(document.images) { this.src  = tabNav_2_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_2_off.src;}" name="tabNav_2" src="../IMAGES/tabNav_HOME_2_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 3);" onmouseover="if(document.images) { this.src  = tabNav_3_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_3_off.src;}" name="tabNav_3" src="../IMAGES/tabNav_HOME_3_off.gif" border="0" alt="" /></TD><TD align="left" width="1" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="1" height="1" /></TD><TD align="left" vAlign="top"><IMG onMouseUp="javascript:internalTransfer(\'TOPNAV\', 4);" onmouseover="if(document.images) { this.src  = tabNav_4_on.src; }"  onmouseout="if(document.images) {this.src = tabNav_4_off.src;}" name="tabNav_4" src="../IMAGES/tabNav_HOME_4_off.gif" border="0" alt="" /></TD><TD align="left" width="100%" vAlign="top"><IMG src="../IMAGES/spacer.gif" border="0" alt="" width="100%" height="1" /></TD></TR></TABLE>');
		}
	}
}

//str_NAV is a string indicating which Nav launched the page
//i_menuItem is which tab launched it
function internalTransfer(str_NAV, i_menuItem)
{
	if(str_NAV == "MAINNAV")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stjwinery.php")
				break;
			case 1:
				window.location.replace("../HTML/stjourwines.php")
				break;
			case 2:
				window.location.replace("https://shop.stjulian.com")
				break;
			case 3:
				if(!GetCookieValue('STJ', 'BILL_FNAME'))
				{
					window.location.replace("../HTML/stjwineclub.php")
				}
				else
					window.location.replace("../HTML/stjwineClub_welcome.php")

				break;
			case 4:
				window.location.replace("../HTML/stjevents.php")
				break;
			case 5:
				window.location.replace("../HTML/stjretreat.php")
				break;
			default:
		}
	}
	else if(str_NAV == "TOPNAV")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stj_wines_sparkjuices.php")
				break;
			case 1:
				window.location.replace("../HTML/stj_retreat_ecards.php")
				break;
			case 2:
				window.location.replace("../HTML/stjtour.php")
				break;
			case 3:
				window.location.replace("../HTML/stj_wines_wwines.php")
				break;
			case 4:
				window.location.replace("../HTML/stj_wines_rwines.php")
				break;
			default:
		}
	}
	else if(str_NAV == "WINERYLEFT")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stjHistory.php")
				break;
			case 1:
				window.location.replace("../HTML/stjnews.php")
				break;
			case 2:
				window.location.replace("../HTML/stjawards.php")
				break;
			case 3:
				window.location.replace("../HTML/stjhealth.php")
				break;
			case 4:
				window.location.replace("../HTML/stjdistillation.php")
				break;
			case 5:
				window.location.replace("../HTML/stjtour.php")
				break;
			case 6:
				window.location.replace("../HTML/stj_wines_blueheron.php")
				break;
			case 7:
				window.location.replace("../HTML/stj_wines_solera.php")
				break;
			case 8:
				window.location.replace("../HTML/stj_wines_simplyred.php")
				break;
			case 9:
				window.location.replace("../HTML/stj_wines_sparkjuices.php")
				break;
			case 10:
				window.location.replace("../HTML/stjbios.php")
				break;
			case 11:
				window.location.replace("../HTML/stjtastingRooms.php")
				break;
			case 12:
				window.location.replace("../HTML/stjaffiliations.php")
				break;
			case 13:
				window.location.replace("../HTML/stjwinemaking.php")
				break;
			default:
				window.location.replace("../HTML/main.php")
		}
	}
	else if(str_NAV == "WINESLEFT")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stj_wines_wwines.php")
				break;
			case 1:
				window.location.replace("../HTML/stj_wines_rwines.php")
				break;
			case 2:
				window.location.replace("../HTML/stj_wines_pwines.php")
				break;
			case 3:
				window.location.replace("../HTML/stj_wines_sparkwines.php")
				break;
			case 4:
				window.location.replace("../HTML/stj_wines_dwines.php")
				break;
			case 5:
				window.location.replace("../HTML/stj_wines_fruitbrandies.php")
				break;
			case 6:
				window.location.replace("../HTML/stj_wines_specialywines.php")
				break;
			case 7:
				window.location.replace("../HTML/stj_wines_blueheron.php")
				break;
			case 8:
				window.location.replace("../HTML/stj_wines_solera.php")
				break;
			case 9:
				window.location.replace("../HTML/stj_wines_simplyred.php")
				break;
			case 10:
				window.location.replace("../HTML/stj_wines_sparkjuices.php")
				break;
			case 11:
				window.location.replace("../HTML/stj_wines_edibles.php")
				break;
			default:
				window.location.replace("../HTML/main.php")
		}
	}
	else if(str_NAV == "CLUBLEFT")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stjwineclub.php")
				break;
			case 1:
				window.location.replace("https://www.stjulian.com/HTML/stjwineclub_reg.php")
				break;
			case 2:
				window.location.replace("../HTML/stjwineclub.php")
				break;
			case 3:
				window.location.replace("../HTML/stjwineclub_newsletter.php")
				break;
			default:
				window.location.replace("../HTML/main.php")
		}
	}
	else if(str_NAV == "EVENTSLEFT")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stjevents.php")
				break;
			case 1:
				window.location.replace("../HTML/stjevents_tastings.php")
				break;
			default:
				window.location.replace("../HTML/main.php")
		}
	}
	else if(str_NAV == "RETREATLEFT")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stjretreat.php")
				break;
			case 1:
				window.location.replace("../HTML/stjretreat_recipes.php")
				break;
			case 2:
				window.location.replace("../HTML/stjretreat_edu.php")
				break;
			case 3:
				window.location.replace("../HTML/stj_retreat_ecards.php")
				break;
			case 4:
				window.location.replace("../HTML/stjretreat_stains.php")
				break;
			default:
				window.location.replace("../HTML/main.php")
		}
	}
	else if(str_NAV == "WINECLUBREGLEFT")
	{
		switch(i_menuItem)
		{
			case 0:
				window.location.replace("../HTML/stjwineClub_welcome.php")
				break;
			case 1:
				window.location.replace("../HTML/stjwineClub_memspecials.php")
				break;
			case 2:
				window.location.replace("../HTML/stjwineClub_specialevents.php")
				break;
			default:
				window.location.replace("../HTML/main.php")
		}
	}
}

function drawMainNav(str_page, i_activeTab)
{
	if (document.images)
	{
		mainNav_0_on= new Image(102, 30);
		mainNav_1_on= new Image(106, 30);
		mainNav_2_on= new Image(114, 30);
		mainNav_3_on= new Image(214, 30);
		mainNav_4_on= new Image(98, 30);
		mainNav_5_on= new Image(111, 30);

		mainNav_0_off= new Image(102, 30);
		mainNav_1_off= new Image(106, 30);
		mainNav_2_off= new Image(114, 30);
		mainNav_3_off= new Image(214, 30);
		mainNav_4_off= new Image(98, 30);
		mainNav_5_off= new Image(111, 30);

		mainNav_0_on.src='../IMAGES/mainNav_' + str_page + '_0_on.gif';
		mainNav_1_on.src='../IMAGES/mainNav_' + str_page + '_1_on.gif';
		mainNav_2_on.src='../IMAGES/mainNav_' + str_page + '_2_on.gif';
		mainNav_3_on.src='../IMAGES/mainNav_' + str_page + '_3_on.gif';
		mainNav_4_on.src='../IMAGES/mainNav_' + str_page + '_4_on.gif';
		mainNav_5_on.src='../IMAGES/mainNav_' + str_page + '_5_on.gif';

		mainNav_0_off.src='../IMAGES/mainNav_' + str_page + '_0_off.gif';
		mainNav_1_off.src='../IMAGES/mainNav_' + str_page + '_1_off.gif';
		mainNav_2_off.src='../IMAGES/mainNav_' + str_page + '_2_off.gif';
		mainNav_3_off.src='../IMAGES/mainNav_' + str_page + '_3_off.gif';
		mainNav_4_off.src='../IMAGES/mainNav_' + str_page + '_4_off.gif';
		mainNav_5_off.src='../IMAGES/mainNav_' + str_page + '_5_off.gif';

		document.write('<TABLE width="100%" border="0" cellPadding="0" cellSpacing="0"><TR><TD><IMG onMouseUp="javascript:internalTransfer(\'MAINNAV\', 0);" onmouseover="if(document.images) { this.src  = mainNav_0_on.src; }"  onmouseout="if(document.images) {this.src = mainNav_0_off.src;}" name="mainNav_0" src="../IMAGES/mainNav_' + str_page + '_0_off.gif" alt="" /></TD><TD><IMG src="../IMAGES/mainNav_spacer.gif" width="1" /></TD><TD><IMG onMouseUp="javascript:internalTransfer(\'MAINNAV\', 1);" onmouseover="if(document.images) { this.src  = mainNav_1_on.src; }"  onmouseout="if(document.images) {this.src = mainNav_1_off.src;}" name="mainNav_1" src="../IMAGES/mainNav_' + str_page + '_1_off.gif" alt="" /></TD><TD><IMG src="../IMAGES/mainNav_spacer.gif" width="1" /></TD><TD><IMG onMouseUp="javascript:internalTransfer(\'MAINNAV\', 2);" onmouseover="if(document.images) { this.src  = mainNav_2_on.src; }"  onmouseout="if(document.images) {this.src = mainNav_2_off.src;}" name="mainNav_2" src="../IMAGES/mainNav_' + str_page + '_2_off.gif" alt="" /></TD><TD><IMG src="../IMAGES/mainNav_spacer.gif" width="1" /></TD><TD><IMG onMouseUp="javascript:internalTransfer(\'MAINNAV\', 3);" onmouseover="if(document.images) { this.src  = mainNav_3_on.src; }"  onmouseout="if(document.images) {this.src = mainNav_3_off.src;}" name="mainNav_3" src="../IMAGES/mainNav_' + str_page + '_3_off.gif" alt="" /></TD><TD><IMG src="../IMAGES/mainNav_spacer.gif" width="1" /></TD><TD><IMG onMouseUp="javascript:internalTransfer(\'MAINNAV\', 4);" onmouseover="if(document.images) { this.src  = mainNav_4_on.src; }"  onmouseout="if(document.images) {this.src = mainNav_4_off.src;}" name="mainNav_4" src="../IMAGES/mainNav_' + str_page + '_4_off.gif" alt="" /></TD><TD><IMG src="../IMAGES/mainNav_spacer.gif" width="1" /></TD><TD><IMG onMouseUp="javascript:internalTransfer(\'MAINNAV\', 5);" onmouseover="if(document.images) { this.src  = mainNav_5_on.src; }"  onmouseout="if(document.images) {this.src = mainNav_5_off.src;}" name="mainNav_5" src="../IMAGES/mainNav_' + str_page + '_5_off.gif" alt="" /></TD><TD width="100%" height="30"><IMG src="../IMAGES/spacer.gif" alt="" width="100%" height="1"/></TD></TR></TABLE>');

	}
}

function GetCookie(sCookieName){
	sCookieName += "="
	var i = 0
	while (i < document.cookie.length) {
		var j = i + sCookieName.length
		if (document.cookie.substring(i, j) == sCookieName){
			var lEndPos = document.cookie.indexOf (";", j)
			if (lEndPos == -1){
				lEndPos = document.cookie.length
			}
			return unescape(document.cookie.substring(j, lEndPos))
		}

		i = document.cookie.indexOf(" ", i) + 1
		if (i == 0){
			break
		}
	}
	return ""
}

function GetParamValue(sKey, oWin) {
	if (oWin == null){
		oWin = window
	}
	sKey += "="
	var iPos1 = oWin.document.URL.indexOf(sKey)
	if (iPos1 < 0){
		return ""
	}
	var iPos2 = oWin.document.URL.indexOf("&", iPos1)
	return unescape( iPos2 >= iPos1  ? 
	oWin.document.URL.substring(iPos1 + sKey.length, iPos2) :
	oWin.document.URL.substring(iPos1 + sKey.length))
}

function spawnWindow(URL,Name,features)  { 
//	window.open('html', 'name', 'width=770, height=500, scrollbars=yes, toolbar=no, location=no, menubar=no, status=no, resizable=yes, copyhistory=no');
	window.open(URL,Name,features);
}

function GetCookieValue(sCookieName, sKey){
	var sCookie = GetCookie(sCookieName)
	var lStartPos = sCookie.indexOf(sKey + "=")
	var sValue
	if (lStartPos < 0 ){
		return ""
	}
	else{
		lStartPos += sKey.length + 1
	}
	var lEndPos = sCookie.indexOf("&", lStartPos)
	if (lEndPos < 0 ){
		lEndPos = sCookie.length
	}
	sValue = unescape(sCookie.substring(lStartPos, lEndPos))
	return sValue.replace(/\+/gi, ' ')
}

function getCartQuantity()
{
	var aCookies
	var sCookie
	var sValue
	var lTotalNum
	
	lTotalNum = 0
	aCookies = document.cookie.split(";")
	
	for (i in aCookies) {
		//loop through the cookies
		//grep out the cookie name
		sCookie = aCookies[i].substring(0, aCookies[i].indexOf("="))
		sCookie = sCookie.replace(" ", "")
		sValue = GetCookieValue(sCookie, "QUANTITY")
		if (parseInt(sValue)){
			lTotalNum += parseInt(sValue)
		}
	}
	
	if (lTotalNum == 1){
		document.write("<P class='content'>" + lTotalNum + " item in your shopping bag.</P>")
	}
	else {
		document.write("<P class='content'>" + lTotalNum + " item in your shopping bag.</P>")
	}
}



var bAllowEcardSubmit = true

function checkEcardFields(){
	if (bAllowEcardSubmit){

		if (document.frmEcard.SOURCENAME.value == ""){
			alert("Please enter your name")
			document.frmEcard.SOURCENAME.focus()
			return false
		}
		else if (document.frmEcard.SOURCEEMAIL.value == ""){
			alert("Please enter your email address")
			document.frmEcard.SOURCEEMAIL.focus()
			return false
		}
		else if (document.frmEcard.TARGETNAME.value == ""){
			alert("Please enter the recipient's name")
			document.frmEcard.TARGETNAME.focus()
			return false
		}
		else if (document.frmEcard.TARGETEMAIL.value == ""){
			alert("Please enter the recpient's email address")
			document.frmEcard.TARGETEMAIL.focus()
			return false
		}
		else if (document.frmEcard.MESSAGE.value == ""){
			alert("Please enter a message")
			document.frmEcard.MESSAGE.focus()
			return false
		}
		bAllowEcardSubmit = false
		return true
	}

	else{
		return false
	}
}

function checkEcardChoice()
{
	var ecard_choice = false;
	for (i = 0; i<document.forms['frmEcard'].ECARD.length; i++)
	{
		if (document.forms['frmEcard'].ECARD[i].checked)
		ecard_choice = document.forms['frmEcard'].ECARD[i].value
	}
	return ecard_choice; 
}

function popPreviewECARD()
{
	var popPreveiw = window.open('about:blank', 'ECARD', 'width=500,height=345,scrollbars=0,resizable=0');
	var sFlashMovie;
	var flashWidth;
	var flashHeight;
	var sourceName = document.forms['frmEcard'].SOURCENAME.value;
	var sourceEmail = document.forms['frmEcard'].SOURCEEMAIL.value;
	var targetName = document.forms['frmEcard'].TARGETNAME.value;
	var targetEmail = document.forms['frmEcard'].TARGETEMAIL.value;
	var message = document.forms['frmEcard'].MESSAGE.value;
	var iCardChoice = checkEcardChoice();

	switch(iCardChoice)
	{
		case '0':
			sFlashMovie = 'LTG.swf';
			break;
		case '1':
			sFlashMovie = 'Congrats.swf';
			break;
		case '2':
			sFlashMovie = 'ThankYou.swf';
			break;
	}
		
	flashWidth = 237;
	flashHeight = 339;


		
	var str_text = "<html><head><title>St. Julians Winery</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"><link rel=\"StyleSheet\" href=\"../_ScriptLibrary/stj.css\" type=\"text/css\" /><script language=\"JavaScript\" src=\"../_ScriptLibrary/utils.js\"></script></head>"
	str_text = str_text + "<table width=\"100%\" height=\"100%\" cellPadding=\"0\" cellSpacing=\"0\" border=\"0\"><tr><td width=\"237\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + flashWidth + "\" height=\"" + flashHeight + "\"><param name=\"movie\" value=\"../FLASH/" + sFlashMovie + "\"><param name=\"quality\" value=\"high\"><embed src=\"../FLASH/" + sFlashMovie + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + flashWidth + "\" height=\"" + flashHeight + "\"></embed></object></td><td><td>&nbsp;</td><td> <table width=\"100%\" height=\"100%\" cellPadding=\"0\" cellSpacing=\"0\" border=\"0\" bgColor=\"#2A3553\"><tr><td bgColor=\"#ffffff\" height=\"65\">&nbsp;</td></tr><tr><td><p class=\"contentWHITE\">Message from: " + sourceName + "</p></td></tr><tr><td><p class=\"contentWHITE\">hello, " + targetName + "</p></td></tr><tr><td  height=\"100%\" vAlign=\"top\"><p class=\"contentWHITE\">" + message + "</p></td></tr><tr><td bgColor=\"#ffffff\" height=\"10\"></td></tr></table>  </td></tr></table>"

//	str_text = str_text + "</td><td width=\"5\"></td><td>"
//	str_text = str_text + "<table width=\"100%\" height=\"100%\" cellPadding=\"0\" cellSpacing=\"0\" border=\"0\" bgColor=\"#2A3553\"><tr><td bgColor=\"#ffffff\" height=\"65\">&nbsp;</td></tr><tr><td><p class=\"contentWHITE\">Message from: " + sourceName + "</p></td></tr><tr><td><p class=\"contentWHITE\">hello, " + targetName + "</p></td></tr><tr><td  height=\"100%\" vAlign=\"top\"><p class=\"contentWHITE\">" + message + "</p></td></tr><tr><td bgColor=\"#ffffff\" height=\"10\"></td></tr></table>"
//	str_text = str_text + "</td><td width=\"8\"></td></tr></body></html>"
	popPreveiw.document.open();
	popPreveiw.document.write(str_text);
	popPreveiw.document.close();



//<body marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" topmargin=\"0\">
}

var bAllowLogin = true;

function symbolCheck(value)
{
  if (value.match(/[^a-zA-Z0-9]/))
    return 1;
  else
    return 0;
}

function symbolCheckEMAIL(value)
{
  if (value.match(/[\\\/:*?" <>|]/))
    return 1;
  else
    return 0;
}

function checkLoginFields(){
	if (bAllowLogin){
		if (document.frmLogin.USERNAME.value == ""){
			alert("Please enter your username")
			document.frmLogin.USERNAME.focus()
			return false
		}
		else if (document.frmLogin.PASSWORD.value == ""){
			alert("Please enter your password")
			document.frmLogin.PASSWORD.focus()
			return false
		}
		bAllowLogin = false
		return true
	}
	else{
		return false
	}
}

function writeLPACookie()
{
	document.cookie="STJbMONTH=" + top.document.forms[0].month.selectedIndex + "; expires=Tuesday, 01-Apr-2020 08:00:00 GMT; path=/";
	document.cookie="STJbDAY=" + top.document.forms[0].day.selectedIndex + "; expires=Tuesday, 01-Apr-2020 08:00:00 GMT; path=/";
	document.cookie="STJbYEAR=" + top.document.forms[0].year.value + "; expires=Tuesday, 01-Apr-2020 08:00:00 GMT; path=/";
}










//Age Verify
function run()
{
  with (window.document.frmRegister)
  {
    dd = parseInt(day.selectedIndex) + 1;
    mm = parseInt(month.selectedIndex) + 1;
    yy = year.value;
    if (yy.length != 4 || isNaN(yy))
    {
      alert("Please enter a 4-digit year.");
      window.document.frmRegister.year.select();
      window.document.frmRegister.year.focus();
      return;
    }
  }
  days = new Date();
  gdate = days.getDate();
  gmonth = days.getMonth();
  gyear = days.getYear();
  if (gyear < 2000) gyear += 1900;
    age = gyear - yy;
  if ((mm == (gmonth + 1)) && (dd <= parseInt(gdate)))
  {
    age = age; 
  } 
  else
  {
    if (mm <= (gmonth))
    {
      age = age;
    }
    else
    {
      age = age - 1; 
     }
  }
  if (age == 0)
    age = age;
  if (age > 20)
  {
    window.location.replace("https://www.stjulian.com/html/stjwineclub_reg.php");
  }
  else
  {
    window.location.replace("http://www.yahoo.com")
  }
  if (mm <= (gmonth + 1))
    age = age - 1;
if ((mm == (gmonth + 1)) && (dd > parseInt(gdate))) 
age = age + 1;
var m;
var n;
var p;
if (mm == 12) n = 31 - dd;
if (mm == 11) n = 61 - dd;
if (mm == 10) n = 92 - dd;
if (mm == 9) n = 122 - dd;
if (mm == 8) n = 153 - dd;
if (mm == 7) n = 184 - dd;
if (mm == 6) n = 214 - dd;
if (mm == 5) n = 245 - dd;
if (mm == 4) n = 275 - dd;
if (mm == 3) n = 306 - dd;
if (mm == 2) { n = 334 - dd; if (leapyear(yy)) n++; }
if (mm == 1) { n = 365 - dd; if (leapyear(yy)) n++; }
if (gmonth == 1) m = 31;
if (gmonth == 2) {
m = 59;
if (leapyear(gyear)) m++;
}
if (gmonth == 3)  { m = 90;  if (leapyear(gyear)) m++; }
if (gmonth == 4)  { m = 120; if (leapyear(gyear)) m++; }
if (gmonth == 5)  { m = 151; if (leapyear(gyear)) m++; }
if (gmonth == 6)  { m = 181; if (leapyear(gyear)) m++; }
if (gmonth == 7)  { m = 212; if (leapyear(gyear)) m++; }
if (gmonth == 8)  { m = 243; if (leapyear(gyear)) m++; }
if (gmonth == 9)  { m = 273; if (leapyear(gyear)) m++; }
if (gmonth == 10) { m = 304; if (leapyear(gyear)) m++; }
if (gmonth == 11) { m = 334; if (leapyear(gyear)) m++; }
if (gmonth == 12) { m = 365; if (leapyear(gyear)) m++; }
months = age * 12;
months += 12 - parseInt(mm);
months += gmonth;
totdays = (parseInt(age) * 365);
totdays += age / 4;
totdays = parseInt(totdays) + gdate + m + n;
if (gmonth == 1) p = 31 + gdate;
if (gmonth == 2) {
p = 59 + gdate;
if (leapyear(gyear)) m = m+1;
}
if (gmonth == 3)  { p = 90 + gdate;  if (leapyear(gyear)) p++; }
if (gmonth == 4)  { p = 120 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 5)  { p = 151 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 6)  { p = 181 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 7)  { p = 212 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 8)  { p = 243 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 9)  { p = 273 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 10) { p = 304 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 11) { p = 334 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 12) { p = 365 + gdate; if (leapyear(gyear)) p++; }
weeks = (age * 365) + n + p;
weeks = weeks / 7;
etcdays = parseFloat(weeks) - parseInt(weeks);
etcdays = Math.round(etcdays * 7);
weeks = parseInt(weeks);
etcdays += parseInt(age / 4);
if (etcdays > 7)
weeks += parseInt(etcdays / 7);

var time = new Date();
ghour = time.getHours();
gmin = time.getMinutes();
gsec = time.getSeconds(); 
hour = ((age * 365) + n + p) * 24;
hour += (parseInt(age / 4) * 24);

var min = (hour * 60) + gmin;

sec = (min * 60) + gsec;

mm = mm - 1;
var r;
if (mm == 0) r = 0;
if (mm == 1) r = 31;
if (mm == 2) { r = 59; if (leapyear(gyear)) m++; }
if (mm == 3)  { r = 90;  if (leapyear(gyear)) r++; }
if (mm == 4)  { r = 120; if (leapyear(gyear)) r++; }
if (mm == 5)  { r = 151; if (leapyear(gyear)) r++; }
if (mm == 6)  { r = 181; if (leapyear(gyear)) r++; }
if (mm == 7)  { r = 212; if (leapyear(gyear)) r++; }
if (mm == 8)  { r = 243; if (leapyear(gyear)) r++; }
if (mm == 9)  { r = 273; if (leapyear(gyear)) r++; }
if (mm == 10) { r = 304; if (leapyear(gyear)) r++; }
if (mm == 11) { r = 334; if (leapyear(gyear)) r++; }
mm = mm + 1;
r = parseInt(r) + parseInt(dd);

if ((mm >= (gmonth + 1)) && (dd > gdate)) {
bday = r - m - gdate;
}
else {
if ((leapyear(gyear)) && ((mm > 2) && (dd < 29))) {
a = 366;
} else {
a = 365;
}
bday = a + (r - m - gdate);
}
nhour = 24 - parseInt(ghour);
nmin = 60 - parseInt(gmin);
nsec = 60 - parseInt(gsec);
while (bday > 366) bday -= 365;
if (((bday == 366) && (leapyear(gyear)) || ((bday == 365) && (!leapyear(gyear))))) {

} else {

+ bday + " days " + nhour + " hrs " + nmin + " mins " + nsec + " secs";
   }
}

function leapyear(a)
{
  if (((a%4 == 0) && (a%100 != 0)) || (a%400 == 0))
    return true;
  else
    return false;
}




//Begin CCard
function isCreditCard(st) {
  /*  ================================================================
      FUNCTION:  isCreditCard(st)
   
      INPUT:     st - a string representing a credit card number
  
      RETURNS:  true, if the credit card number passes the Luhn Mod-10
  		    test.
  	      false, otherwise
      ================================================================ */

    // Encoding only works on cards with less than 19 digits
    if (st.length > 19)
      return (false);
  
    sum = 0; mul = 1; l = st.length;
    for (i = 0; i < l; i++) {
      digit = st.substring(l-i-1,l-i);
      tproduct = parseInt(digit ,10)*mul;
      if (tproduct >= 10)
        sum += (tproduct % 10) + 1;
      else
        sum += tproduct;
      if (mul == 1)
        mul++;
      else
        mul--;
    }
    if ((sum % 10) == 0)
      return (true);
    else
      return (false);
  
  } // END FUNCTION isCreditCard()
  

   
    /*  ================================================================
        FUNCTION:  isVisa()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid VISA number.
    		    
    	      false, otherwise
    
        Sample number: 4111 1111 1111 1111 (16 digits)
        ================================================================ */
    
    function isVisa(cc)
    {
      if (((cc.length == 16) || (cc.length == 13)) &&
          (cc.substring(0,1) == 4))
        return isCreditCard(cc);
      return false;
    }  // END FUNCTION isVisa()
    
    
    
    
    /*  ================================================================
        FUNCTION:  isMasterCard()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid MasterCard
    		    number.
    		    
    	      false, otherwise
    
        Sample number: 5500 0000 0000 0004 (16 digits)
        ================================================================ */
    
    function isMasterCard(cc)
    {
      firstdig = cc.substring(0,1);
      seconddig = cc.substring(1,2);
      if ((cc.length == 16) && (firstdig == 5) &&
          ((seconddig >= 1) && (seconddig <= 5)))
        return isCreditCard(cc);
      return false;
    
    } // END FUNCTION isMasterCard()
    
    
    /*  ================================================================
        FUNCTION:  isAmericanExpress()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid American
    		    Express number.
    		    
    	      false, otherwise
    
        Sample number: 340000000000009 (15 digits)
        ================================================================ */
    
    function isAmericanExpress(cc)
    {
      firstdig = cc.substring(0,1);
      seconddig = cc.substring(1,2);
      if ((cc.length == 15) && (firstdig == 3) &&
          ((seconddig == 4) || (seconddig == 7)))
        return isCreditCard(cc);
      return false;
    
    } // END FUNCTION isAmericanExpress()
    
    
    
    
    /*  ================================================================
        FUNCTION:  isDinersClub()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid Diner's
    		    Club number.
    		    
    	      false, otherwise
    
        Sample number: 30000000000004 (14 digits)
        ================================================================ */
    
    function isDinersClub(cc)
    {
      firstdig = cc.substring(0,1);
      seconddig = cc.substring(1,2);
      if ((cc.length == 14) && (firstdig == 3) &&
          ((seconddig == 0) || (seconddig == 6) || (seconddig == 8)))
        return isCreditCard(cc);
      return false;
    }
    
    
    
    /*  ================================================================
        FUNCTION:  isCarteBlanche()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid Carte
    		    Blanche number.
    		    
    	      false, otherwise
        ================================================================ */
    
    function isCarteBlanche(cc)
    {
      return isDinersClub(cc);
    }
    
    
    
    
    /*  ================================================================
        FUNCTION:  isDiscover()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid Discover
    		    card number.
    		    
    	      false, otherwise
    
        Sample number: 6011000000000004 (16 digits)
        ================================================================ */
    
    function isDiscover(cc)
    {
      first4digs = cc.substring(0,4);
      if ((cc.length == 16) && (first4digs == "6011"))
        return isCreditCard(cc);
      return false;
    
    } // END FUNCTION isDiscover()
    
    
    
    
    
    /*  ================================================================
        FUNCTION:  isEnRoute()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid enRoute
    		    card number.
    		    
    	      false, otherwise
    
        Sample number: 201400000000009 (15 digits)
        ================================================================ */
    
    function isEnRoute(cc)
    {
      first4digs = cc.substring(0,4);
      if ((cc.length == 15) &&
          ((first4digs == "2014") ||
           (first4digs == "2149")))
        return isCreditCard(cc);
      return false;
    }
    
    
    
    /*  ================================================================
        FUNCTION:  isJCB()
     
        INPUT:     cc - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is a valid JCB
    		    card number.
    		    
    	      false, otherwise
        ================================================================ */
    
    function isJCB(cc)
    {
      first4digs = cc.substring(0,4);
      if ((cc.length == 16) &&
          ((first4digs == "3088") ||
           (first4digs == "3096") ||
           (first4digs == "3112") ||
           (first4digs == "3158") ||
           (first4digs == "3337") ||
           (first4digs == "3528")))
        return isCreditCard(cc);
      return false;
    
    } // END FUNCTION isJCB()
    
    
    
        
    /*  ================================================================
        FUNCTION:  isCardMatch()
     
        INPUT:    cardType - a string representing the credit card type
    	      cardNumber - a string representing a credit card number
    
        RETURNS:  true, if the credit card number is valid for the particular
    	      credit card type given in "cardType".
    		    
    	      false, otherwise
        ================================================================ */
    
    function isCardMatch (cardType, cardNumber)
    {
    	cardType = cardType.toUpperCase();
    	var doesMatch = true;
    
    	if ((cardType == "VISA") && (!isVisa(cardNumber)))
    		doesMatch = false;
    	if ((cardType == "MASTERCARD") && (!isMasterCard(cardNumber)))
    		doesMatch = false;
    	if ((cardType == "AMEX") && (!isAmericanExpress(cardNumber)))
    		doesMatch = false;
    	if ((cardType == "DISCOVER") && (!isDiscover(cardNumber)))
    		doesMatch = false;
    	if ((cardType == "JCB") && (!isJCB(cardNumber)))
    		doesMatch = false;
    	if ((cardType == "DINERS") && (!isDinersClub(cardNumber)))
    		doesMatch = false;
    	if ((cardType == "CARTEBLANCHE") && (!isCarteBlanche(cardNumber)))
    		doesMatch = false;
    	if ((cardType == "ENROUTE") && (!isEnRoute(cardNumber)))
    		doesMatch = false;
    	return doesMatch;
    
    }  // END FUNCTION CardMatch()
   
    
    function localCardValidation() {
      var szCardType = window.document.frmPayment.CCTYPE.options[window.document.frmPayment.CCTYPE.selectedIndex].value
      var bValidCard = isCardMatch(szCardType, getNumeric(document.frmPayment.CCNUM.value))
      return   bValidCard
    }
   
     function getNumeric(ccNum) {
        var ccNum2 =""
       
        for ( var i=0;i<ccNum.length;i++) {
          var singChar = ccNum.substring(i,i+1)
          if ( singChar != " " && singChar != "-" )
             ccNum2 += singChar
        }
       // alert("b" + ccNum2 + "e")
        return ccNum2

      }
  
  
//End CCard

