// Bell Micro Canada

/*The function below shows and hide the banner for the home page*/

var homepage;

function showBanner (){
	if (homepage == "show"){
		document.getElementById("homepageDiv").style.display = "block";
	}
	else {
		return;
	}
}


/* function used for the search */

function findString(value){
	document.partDescSearch.sp_q.value = value;
}

function whichSite(){
	var whichSearch = document.partDescSearch.searchSelect;
    var thisSearch = whichSearch.options[whichSearch.selectedIndex].value;
	
	if(thisSearch == "ecommerce"){
		document.partDescSearch.action = "https://shop.bellmicroproducts.ca/exec/partDescSearch.tsb";
		document.partDescSearch.method = "post";
		}
		
	if(thisSearch == "corporate"){
		document.partDescSearch.action = "/search.asp";
		document.partDescSearch.method = "get";
		}
}

function checkEnter(e,formName){ //e is event object passed from function invocation
var characterCode // literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e;
characterCode = e.which; //character code is contained in NN4's which property
}
else{
e = event;
characterCode = e.keyCode; //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
var currentForm = eval("document."+ formName);
currentForm.submit(); //submit the form
return false;
}
else{
return true;
}

}

/*The function below controls the global, the e-commerce menu*/

var clientLogin = 0;
var cartItems = 0;
var cartValue = "0.00";

function checkLogin(){
	if(clientLogin){
		document.getElementById("eCommerce").style.display ="";
		document.getElementById("firstLog").innerHTML="log out";
		document.getElementById("firstLog").className = "login";
		document.getElementById("secondLog").innerHTML= cartItems + " items - $ " + cartValue;
		document.getElementById("secondLog").className = "cart";
	}
	else if (!clientLogin){
		document.getElementById("eCommerce").style.display = "none";
		document.getElementById("firstLog").innerHTML="register";
		document.getElementById("firstLog").className = "register";
		document.getElementById("secondLog").innerHTML="log in";
		document.getElementById("secondLog").className = "login";
	}
}

//to reset search box

function resetSearch() {
	document.partDescSearch.searchSelect.value = "ecommerce";
}

function resetForm() {
	document.onload = resetSearch();
}

//to open/close country selector
function hidediv() {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('hideShow').style.visibility = 'hidden';
	}
	else {
		if (document.layers) { // Netscape 4
			document.hideShow.visibility = 'hidden';
		}
		else { // IE 4
			document.all.hideShow.style.visibility = 'hidden';
		}
	}
}

function showdiv() {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('hideShow').style.visibility = 'visible';
	}
	else {
		if (document.layers) { // Netscape 4
			document.hideShow.visibility = 'visible';
		}
		else { // IE 4
			document.all.hideShow.style.visibility = 'visible';
		}
	}
}
