﻿
function showHome()
{
	innerContentUpdate("styles/cbc/static/_default.html");
}
function showTerms()
{
	innerContentUpdate("styles/cbc/static/_terms.html");
}
function showBrochure()
{
	innerContentUpdate("styles/cbc/static/_brochure.html");
}
function showAbout()
{
	innerContentUpdate("styles/cbc/static/_aboutus.html");
}
function showFaq()
{
	innerContentUpdate("styles/cbc/static/_faq.html");
}
function showTradeShows()
{
	innerContentUpdate("styles/cbc/static/_tradeshows.html");
}
function cbcOnFirstLoad(bLoggedIn)
{
	bResizeWindow = false;
	onFirstLoad();
	if (bLoggedIn)
	{
		innerContentUpdate("styles/cbc/static/_loggedin.html");
	}
	else
	{
		
		innerContentUpdate("styles/cbc/static/_default.html");
	}		
}

function resizeDefaultWindow()
{

}

function resizeWindow()
{
	//resizeScrollables();
}

function resizeScrollables()
{
	var objDivs = document.getElementsByTagName("div");
	var objFooter = document.getElementById("footer");
	var objDiv;
	var iBodyBottom;
	return;
	for (i = 0; i < objDivs.length; i++)
	{
		objDiv = objDivs[i];
		
		if (objDiv.className == "scrollable")
		{
			iBodyBottom = findTop(objFooter);
			
			var iNewSize = iBodyBottom - findTop(objDiv) - 60;
			var iHeight = findBottom(objDiv) - findTop(objDiv);
			
			var iDifference = Math.abs(iHeight - iNewSize);
			
			if (iNewSize > 200 && iHeight != iNewSize && iDifference > 60)
			{
				objDiv.style.height = iNewSize;
			}
		
		}	
	}
	
	return true;
}

function getProductsByCategory(strCode)
{
	var objAjax = new CAjax();
		
	if (objAjax.open("dynamic/products.php?mode=SEARCH&text=" + strCode + "&action=CATEGORY" + "&offset=0", true))
	{
	
		var objDiv = g_objTabs.addTab("searchResultsDiv", "Search Results", true, true);
		
		objDiv.innerHTML = objAjax.getResponse();
	}
	
}

function pageSearch(iOffset, bRange) 
{
	var objAjax = new CAjax();

	if (objAjax.open("dynamic/products.php?mode=SEARCH&text=" + getFormValue("searchString") + "&action=productgroup&inner=true" + "&offset=" + iOffset + "&byRange=" + bRange, true))
	{
	
		var objDiv = document.getElementById("productResults");
		objDiv.innerHTML = objAjax.getResponse();
	}
}

function pageSearchText(iOffset, bRange, strAction) 
{
	var objAjax = new CAjax();
	_quickSearch(getFormValue("searchString"), strAction, iOffset, bRange);
}

function showInnerProducts(strCode, iOffset, bRange)
{
	var objAjax = new CAjax();

	if (objAjax.open("dynamic/products.php?mode=SEARCH&text=" + strCode + "&action=productgroup&inner=true" + "&offset=" + iOffset + "&byRange=" + bRange, true))
	{
	
		var objDiv = document.getElementById("productResults");
		objDiv.innerHTML = objAjax.getResponse();
	}
	return true;
}

function _showAccount(bShowAccountStatus)
{
	var objContent = document.getElementById("innerContent");
	var objAjax = new CAjax();

	if (objAjax.open("dynamic/accountStatus.php", true))
	{
		objContent.innerHTML = objAjax.getResponse();
	}

	endLoading();
}

function NewProducts(bWithBar)
{
    startLoading("_NewProducts(" + bWithBar + ")");
}

function _NewProducts(bWithBar)
{
	var objAjax = new CAjax();

	if (bWithBar != 1)
	{
		bWithBar = 0;
	}
	
	var objDiv = document.getElementById('productContent');
	
	if (!objDiv)
	{
		objDiv = document.getElementById('innerContent');
	}
	
	if (objAjax.open("dynamic/showNewProducts.php?withBar=" + bWithBar, true))
	{
		objDiv.innerHTML = objAjax.getResponse();
	}
	endLoading();
}

function Specials()
{
	startLoading("_Specials()");
}

function _Specials()
{
	var objContent = document.getElementById("innerContent");
	var objAjax = new CAjax();

	if (objAjax.open("dynamic/showSpecials.php", true))
	{
		objContent.innerHTML = objAjax.getResponse();
	}
	endLoading();
}

function innerReplace(strUrl)
{
	startLoading("_innerReplace('" + strUrl + "')");
}

function _innerReplace(strUrl)
{
	var objContent = document.getElementById("innerContent");
	var objAjax = new CAjax();

	if (objAjax.open(strUrl, true))
	{
		objContent.innerHTML = objAjax.getResponse();
	}
	endLoading();
	
	scrollTo(0,0);
}







