function showTab(strTab) {
	if (document.getElementById) {
		var arrTabs = document.getElementById("Tabs").getElementsByTagName("div");
		var strTabDivName = strPage.replace("btn_","tab_") + "_" + strTab;
		if (document.getElementById("Text")) {
			var arrText = document.getElementById("Text").getElementsByTagName("div");
			var strTxtDivName = strPage.replace("btn_","txt_") + "_" + strTab;
		}
	
		for (var i=0; i < arrTabs.length; i++) {
			arrTabs[i].style.display = (arrTabs[i].id == strTabDivName) ? "block" : "none";
			if (arrText)
				arrText[i].style.display = (arrText[i].id == strTxtDivName) ? "block" : "none";				
		}
	}
}

function showItems(strParent){
	if (document.getElementById) {
		var arrItems = document.getElementById(strParent).getElementsByTagName("div");
	
		for (var i=0; i < arrItems.length; i++) {
			if (strParent.substring(0,1)*1 == arrItems[i].id.substring(0,1)*1 - 1) {
				arrItems[i].style.display = (arrItems[i].style.display == "none") ? "block" : "none";
			}
		}
	}
}

function getLocation() {
	var strLocation = document.location.href;

	strLocation = strLocation.substring(strLocation.lastIndexOf("/")+1,strLocation.length);
	if (strLocation.indexOf("?") >= 0) {
		strLocation = strLocation.substring(0,strLocation.indexOf("?"));
	}

	return strLocation;
}

function getArg(strArg) {
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split('&');
	for (var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos + 1);
		args[argname] = unescape(value);
	}
	if (args[strArg])
		value = args[strArg];
	else
		value = "";

	return value;
}

function getCookie(strName) {
	var strCookies = (document.cookie) ? document.cookie : "";
	var strValue = "";
    
	intIndex = strCookies.indexOf(strName);
	if (intIndex != -1) {
		intValue_start = strCookies.indexOf("=", intIndex) + 1;
		intValue_end = strCookies.indexOf(";", intIndex);
		if (intValue_end == -1) {
			intValue_end = strCookies.length;
		}
		strValue = strCookies.substring(intValue_start, intValue_end);
	}

	return strValue;
}

function ok() {
	var browser = navigator.appName;
	var version = parseInt(navigator.appVersion);
	var NSok = ((browser == "Netscape") && (version >= 3));
	var IEok = ((browser == "Microsoft Internet Explorer") && (version >=4 ));

	if ((NSok) || (IEok))
		return true;
	else return false;
}

function selectButton(strButton,strSection) {
	if (strButton != getCookie("strPage")) {
		if (!strButton) strButton = "null";

		document.cookie="strPage=" + strButton;
		if (top.ib_topbar) top.ib_topbar.select(strButton,strSection);
	}
}

function loadStartPage() {
	var blnStartPage = getArg("blnStartPage");
	
	if (blnStartPage == "true") {
		strButton = location.href.substring(location.href.lastIndexOf("/")+1,location.href.indexOf(".htm"));
		strButton = strButton.replace("pag_","btn_");
		
		if (strButton.lastIndexOf("_") != strButton.indexOf("_")) {
			strButton = strButton.substring(0,strButton.lastIndexOf("_"));
			//strFeature = strButton.replace('btn_','ftr_') + '.htm';
			//window.open(strFeature,"ib_features");
		}
	
		document.cookie="strPage=" + strButton;
		if (top.ib_topbar) {
			top.ib_topbar.display_buttons();
		}
	}
}

function openLink(strURL, strTarget, intWidth, intHeight) {
	strTarget = ((strTarget == "") || (!strTarget)) ? "_blank" : strTarget;
	strURL = ((strTarget == "_blank") && (strURL.indexOf("http://") < 0)) ? "http://" + strURL : strURL;
	strProperties = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
	
	switch (strTarget) {
		case "_blank":
		case "_self":
			strProperties = "";
			break;
		case "document":
			strProperties += ",width=450,height=500";
			break;
		case "image":
			intWidth = intWidth*1 + 40;
			intHeight = intHeight*1 + 35;
			strProperties += ",width=" + intWidth + ",height=" + intHeight;
			break;
		default:
			break;
	}
	
	window.open(strURL, strTarget, strProperties);
}

function formatCurrency(intPrice) {
	var i = parseFloat(intPrice);
	if (isNaN(i)) { i = 0.00; }
	var minus = '';
	if (i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if (s.indexOf('.') < 0) { s += '.00'; }
	if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return '$ ' + s;
}

function checkForDisabled(objSelect) {
	if (objSelect.options[objSelect.selectedIndex].disabled) {
		alert("sorry, this item is out of stock");
		objSelect.selectedIndex = 0;
	}
}

function isNumeric(value) {
	if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
	return true;
}

function isInteger(value) {
	return (value.toString().search(/^-?[0-9]+$/) == 0);
}


function doNothing() {}

//PAYPAL FUNCTIONS
function pplAddCart(strProductID) {
	if (eval('document.frmAddCart.' + strProductID + '_size.value') == '') {
		alert('Please select a size.');
		return;
	}
	if (eval('document.frmAddCart.' + strProductID + '_color.value') == '') {
		alert('Please select a color.');
		return;
	}
	if (eval('document.frmAddCart.' + strProductID + '_quantity.value') == '' || eval('document.frmAddCart.' + strProductID + '_quantity.value') == '0') {
		alert('Please enter a quantity greater than 0.');
		return;
	}
	if (isNaN(eval('document.frmAddCart.' + strProductID + '_quantity.value'))) {
		alert('Please enter a numeric quantity.');
		return;
	}
	
	eval('document.frmAddCart.item_name.value = document.frmAddCart.' + strProductID + '_name.value');
	eval('document.frmAddCart.amount.value = document.frmAddCart.' + strProductID + '_amount.value');

	eval('document.frmAddCart.quantity.value = document.frmAddCart.' + strProductID + '_quantity.value');
	eval('document.frmAddCart.os1.value = document.frmAddCart.' + strProductID + '_size.value');
	eval('document.frmAddCart.os2.value = document.frmAddCart.' + strProductID + '_color.value');
	document.frmAddCart.business.value = "iblieve.llc@gmail.com";

	//if (checkStock(strProductID,"submit"))
 		document.frmAddCart.submit();
}

function pplViewCart() {
	document.frmViewCart.business.value = "iblieve.llc@gmail.com";
	document.frmViewCart.submit()
}

function pplContribution() {
	document.frmContribution.item_name.value = "iB-LIEVE Contribution";
	document.frmContribution.business.value = "iblieve.llc@gmail.com";
	document.frmContribution.submit()
}
