/*
Description: EFV
Author: Barnum Design
*/	


function TopNav() {
var Main_LI_Array = document.getElementById('TopNav').getElementsByTagName('li');
	for (var a=0; a<Main_LI_Array.length; a++) {
	var Main_Link_ArrayHit = Main_LI_Array[a].firstChild;
	var MainL = Main_Link_ArrayHit.href;
		if (MainL == Loc  || ( MainL.split('_')[1] == "catalog" && (Loc.split('_')[1] == "product" || Loc.split('/')[3].substring(0,13) == "OrderRetrieve"))) {
		Main_Link_ArrayHit.style.cssText = "color: #48182c";
		}
	}
}

function Sub_Set_Heights() {
var SubHeight = document.getElementById('Sub-Inner').offsetHeight;
	if (SubHeight < 544) {
	document.getElementById('Sub-Inner').style.cssText = "height:524px;";
	Set_Height();
	}
	else if (SubHeight > 544 && SubHeight <= 635) {
	document.getElementById('Sub-Inner').style.cssText = "height:635px;";
	Set_Height();
	document.getElementById('Sub-grad_bottom').src = "/Images/Sub-grad_bottom-long.jpg";
	}
	else if (SubHeight > 635) {
	Set_Height();
	document.getElementById('Sub-grad_bottom').src = "/Images/Sub-grad_bottom-long.jpg";
	}
	function Set_Height() {
	var NewHeight = document.getElementById('Sub-Inner').offsetHeight;
	document.getElementById('Layer_1').style.height = NewHeight + "px";
	document.getElementById('Layer_2').style.height = (NewHeight - 20) + "px";
	}
}

function SubBanner() {
SubBnnr = document.getElementById("SubBanner");
	switch (Loc.split('/')[3]) {
	case "":
	SubBnnr.src = "/Images/SubBanner_Home.jpg";
	break;
	case "home.htm":
	SubBnnr.src = "/Images/SubBanner_Home.jpg";
	break;
	case "Our_Team":
	SubBnnr.src = "/Images/SubBanner_Our_Team.jpg";
	break;
	case "Our_Wine":
	SubBnnr.src = "/Images/SubBanner_Our_Wine.jpg";
	break;
	case "News":
	SubBnnr.src = "/Images/SubBanner_News.jpg";
	break;
	/*
	case "Purchase":
	SubBnnr.src = "/Images/SubBanner_Purchase.jpg";
	break;
	*/
	case "Mailing_List":
	SubBnnr.src = "/Images/SubBanner_Mailing_List.jpg";
	break;
	case "Contact.htm":
	SubBnnr.src = "/Images/SubBanner_Contact.jpg";
	break;
	default:
	SubBnnr.src = "/Images/SubBanner_Purchase.jpg";
	break;
	}
}

function ShoppingCart() {
	if (document.getElementById('catCartDetails') != null && document.getElementById('catshopclear') != null) {
	var CartDetails_wrap = document.getElementById('catCartDetails');
	CartDetails_wrap.style.height = CartDetails_wrap.offsetHeight + "px";
	}
}

function ShoppingCart_clear() {
setTimeout("window.location.href = window.location.href;",2000);
}

function ShoppingCart_val() {
if (document.getElementById('catshopquote') != null && document.getElementById('catShippingDetails') != null) {
	document.getElementById('catshopquote').onclick = function() {
	var Selects_Array = document.getElementById('catShippingDetails').getElementsByTagName('select');
		for (var s=0; s<Selects_Array.length; s++) {
		var Selects_ArrayHit = Selects_Array[s];
			if (Selects_ArrayHit.selectedIndex == 0 && Selects_ArrayHit.options[Selects_ArrayHit.selectedIndex].text != "UNITED STATES") {
			alert("Please complete your shipping details.");
			return false;
 			}
		}
	}
	}
}

function LoggedIn(loggedin) {
	if (loggedin == "1") document.getElementById('LoginNav').style.display = "block"; 
}

function LeftNav(){
	if  (loggedin == "1") {
		if(Loc.split('_')[1] == "catalog" || Loc.split('_')[1] == "product"|| Loc.split('/')[3].substring(0,13) == "OrderRetrieve" || Loc.split('/')[3].substring(0,17) == "CatalogueRetrieve" || Loc.split('/')[3] == "Purchase" || Loc.split('/')[3].substring(0,7) == "Default") {
		document.getElementById('SecureZNav').style.display = "block"; 
		}
	}
}

function SoldOut() {
var LIs = document.getElementById('Catalog_Lg').getElementsByTagName('li');
	for (var x=0; x<LIs.length; x++){
		if (LIs[x].className=='instock' && LIs[x].innerHTML<=18) {
		var LIs_hit = LIs[x].parentNode.getElementsByTagName('li');
			for (var u=0; u<LIs_hit.length; u++) {
			if (LIs_hit[u].className == "quantity") LIs_hit[u].style.display = "none";
			if (LIs_hit[u].className == "send-to-cart") LIs_hit[u].style.display = "none";
			if (LIs_hit[u].className == "quantity") LIs_hit[u].style.display = "none";
			}
		}
	}
}


function windowLoadItems() {
if (document.getElementById('ShippingCountry')) document.getElementById('ShippingCountry').value = "United States";
Loc = document.location.href;
TopNav();
LeftNav();
SubBanner();
ShoppingCart();
if (document.getElementById('Catalog_Lg')!=null) SoldOut();
Sub_Set_Heights();
setupZoom()
}

window.onload = windowLoadItems;