
function customizeheader()
{
	var strURL = document.location.toString().toLowerCase();
	//alert(strURL);
	//var strTitle = document.getElementById("HeaderCustomization_PageTitle").value;
	//alert(strTitle);
	//switch (strTitle)
	//{
	//	case "About Us": document.getElementById("imgAboutUs").src = "images/nav/top_aboutus_on.gif" 
	//}
	
	if (strURL.indexOf("store_locator") != -1)
		document.getElementById("imgWhereToShop").src = document.getElementById("imgWhereToShop").src.replace("off", "on");
	if (strURL.indexOf("catalog") != -1)
		document.getElementById("imgProducts").src = document.getElementById("imgProducts").src.replace("off", "on");
	if (strURL.indexOf("product_line") != -1)
		document.getElementById("imgProducts").src = document.getElementById("imgProducts").src.replace("off", "on");
	if (strURL.indexOf("content_news") != -1)
		document.getElementById("imgCBKintheNews").src = document.getElementById("imgCBKintheNews").src.replace("off", "on");
	if (strURL.indexOf("showroom") != -1)
		document.getElementById("imgVisitaShowroom").src = document.getElementById("imgVisitaShowroom").src.replace("off", "on");
	
	if (strURL.indexOf("sc_editshoppingcart") != -1)
		document.getElementById("imgShoppingBag").src = document.getElementById("imgShoppingBag").src.replace("off", "on");
	if (strURL.indexOf("sc_shoppingcartreview") != -1)
		document.getElementById("imgShoppingBag").src = document.getElementById("imgShoppingBag").src.replace("off", "on");
	if (strURL.indexOf("sc_orderbysku") != -1)
		document.getElementById("imgCBKwikOrder").src = document.getElementById("imgCBKwikOrder").src.replace("off", "on");
		
	if (strURL.indexOf("my_account") != -1)
		document.getElementById("imgMyAccount").src = document.getElementById("imgMyAccount").src.replace("off", "on");
	if (strURL.indexOf("my_order") != -1)
		document.getElementById("imgMyAccount").src = document.getElementById("imgMyAccount").src.replace("off", "on");
	if (strURL.indexOf("account_summary") != -1)
		document.getElementById("imgMyAccount").src = document.getElementById("imgMyAccount").src.replace("off", "on");
	if (strURL.indexOf("paynow") != -1)
		document.getElementById("imgMyAccount").src = document.getElementById("imgMyAccount").src.replace("off", "on");
	if (strURL.indexOf("sc_addressmanagement") != -1)
		document.getElementById("imgMyAccount").src = document.getElementById("imgMyAccount").src.replace("off", "on");
	if (strURL.indexOf("sc_addeditsingleaddress") != -1)
		document.getElementById("imgMyAccount").src = document.getElementById("imgMyAccount").src.replace("off", "on");
	if (strURL.indexOf("whos_my_sales_rep") != -1)
		document.getElementById("imgMySalesRep").src = document.getElementById("imgMySalesRep").src.replace("off", "on");
	if (strURL.indexOf("useful_links") != -1)
		if (document.getElementById("imgUsefulLinks")!= null)
		{
			document.getElementById("imgUsefulLinks").src = document.getElementById("imgUsefulLinks").src.replace("off", "on");
		}
	if (strURL.indexOf("my_account") != -1)
		document.getElementById("imgMyAccount").src = document.getElementById("imgMyAccount").src.replace("off", "on");
		
	if (strURL.indexOf("contact_us") != -1)
		document.getElementById("imgContactUs").src = document.getElementById("imgContactUs").src.replace("off", "on");
	if (strURL.indexOf("site_map") != -1)
		document.getElementById("imgSiteMap").src = document.getElementById("imgSiteMap").src.replace("off", "on");
	if (strURL.indexOf("consumer_ad") != -1)
		document.getElementById("imgConsumerAd").src = document.getElementById("imgConsumerAd").src.replace("off", "on");
	if (strURL.indexOf("retailer_newsletters.aspx") != -1)
		document.getElementById("imgNewsLetters").src = document.getElementById("imgNewsLetters").src.replace("off", "on");
	if (strURL.indexOf("designers") != -1)
		document.getElementById("imgDesigners").src = document.getElementById("imgDesigners").src.replace("off", "on");
	if (strURL.indexOf("employment_opportunities") != -1)
		document.getElementById("imgEmployment").src = document.getElementById("imgEmployment").src.replace("off", "on");
}

function ShowTOC(CatalogIndex)
{
	//document.location.replace("ViewCatalog.aspx?Left=1&Right=-1&CatalogIndex=" + CatalogIndex);
	//window.parent.getElement('selCatalog').value = CatalogIndex + 1;
	//document.location.replace("CatalogView.aspx?CatalogIndex=" + CatalogIndex + "&ShowPage=ViewCatalog.aspx?Left=1:amp:Right=-1");
	
	window.name="myWindow";
	window.open("CatalogView.aspx?CatalogIndex=" + CatalogIndex + "&ShowPage=ViewCatalog.aspx?Left=1:amp:Right=-1", 'CatalogViews', 'top=0, left=0, width=910, height=650');
	
	//neptune
	//window.open("../cbkPageFlipperConsumer/CatalogView.aspx?CatalogIndex=" + CatalogIndex + "&ShowPage=ViewCatalog.aspx?Left=1:amp:Right=-1", 'CatalogViews', 'top=0, left=0, width=950, height=660');
	
	//aurora
	//window.open("http://216.109.88.112/cristina/CatalogView.aspx?CatalogIndex=" + CatalogIndex + "&ShowPage=ViewCatalog.aspx?Left=1:amp:Right=-1", 'CatalogViews', 'top=0, left=0, width=950, height=660');
	
	
	//var winCatalog = window.open("CatalogView.aspx?CatalogIndex=" + CatalogIndex + "&ShowPage=ViewCatalog.aspx?Left=1:amp:Right=-1", 'CatalogViews', 'top=100, left=100, width=910, height=590');
	//winCatalog.focus();
	//winCatalog.location.reload(true);
}

function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);
 
	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

function PrintPageWithoutButton()
{
	document.getElementById("lblprint").style.visibility = "hidden"; 
	document.getElementById("lblbuttons").style.visibility = "hidden"; 
	
	window.print();
	
	document.getElementById("lblprint").style.visibility = "visible";
	document.getElementById("lblbuttons").style.visibility = "visible";
}

function ToStoreLocator()
{
	var zip = document.getElementById("txtStoreZip").value;
						
	var intValue = parseInt(zip);
	if (!isNaN(intValue))
		window.location.replace("store_locator.aspx?zip=" + zip);
	else
		window.location.replace("store_locator.aspx");
}
function ShowCatalogSimplified2(CatalogOID, SupplierID, ticket)
{
	ShowCatalog2(CatalogOID, SupplierID, ticket, "ViewCatalog.aspx?Left=1:amp:Right=-1:amp:CatalogOID=" + CatalogOID);
	
}

function ShowCatalog2(CatalogOID, SupplierID, Password, ShowPage)
{
	var intWidth = screen.width;
	//var width = 980;
	var width = 978;
	var height = 686;
	
	var useragent = navigator.userAgent.toLowerCase();
	if (useragent.indexOf("safari") != -1)
	{
	    width = 320;
	    height = 500;
	}
	

	var property = "top=0, left=0, resizable=1, width=" + width + ", height=" + height;
	//alert(property);
	var wincatalog = window.open("http://www.activemerchandiser.com/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=" + SupplierID + "&ShowPage=" + ShowPage + "&Password=" + Password + "&Rand=" + Math.random(), 'CatalogViews', property);
	//	var wincatalog = window.open("OpenPage.aspx?CatalogOID=" + CatalogOID + "&SupplierID=168664&ShowPage=" + ShowPage + "&Password=" + Password, 'ActiveMerchandiser', property);
	wincatalog.focus();
}



function searchonenter(evt)
{
	var keyCode = 0;
	var ret_val = true;

	if (evt) 
	{
		keyCode = evt.keyCode || evt.which;
	}
	else 
	{  
		keyCode = window.event.keyCode;
	}
   
	//Allow searching for ENTER key only
	if (keyCode == 13)
	{	
		//alert(keyCode);
		tosearchresult();
	}

}


function tosearchresult()
{
	var SearchEntry = document.getElementById("txtQuickSearch").value;

	if (SearchEntry != "")
		window.location.replace("search_results.aspx?Type=QuickSearch&Entry=" + SearchEntry);
	else
		window.location.replace("search_results.aspx?Type=QuickSearch&Entry=");
}
					
						  
function cleartext(inputBox){
	if (inputBox.defaultValue==inputBox.value)
	inputBox.value = ""
} 

function doenter()
{
	if (event.keyCode == 13)
	{
		event.returnValue = false;
		event.cancel = true;             
		// these two lines stops the event activated by the enter
		//document.getElementById('btnSubmit').click();
		tosearchresult();
	}
}

function ChangeFrameClient(OID)
{
	//alert(OID);
	if (OID == -1)
	{
		document.getElementById('imgtop_left').src = "images/spacer.gif";
		document.getElementById('imgtop_right').src = "images/spacer.gif";
		document.getElementById('imgbottom_left').src = "images/spacer.gif";
		document.getElementById('imgbottom_right').src = "images/spacer.gif";
		
		cellBckImg('tdtop', "images/spacer.gif");
		cellBckImg('tdbottom', "images/spacer.gif");
		cellBckImg('tdleft', "images/spacer.gif");
		cellBckImg('tdright', "images/spacer.gif");
	}
	else
	{
		document.getElementById('imgtop_left').src = "images/frames/" + OID + "_top_left.jpg";
		document.getElementById('imgtop_right').src = "images/frames/" + OID + "_top_right.jpg";
		document.getElementById('imgbottom_left').src = "images/frames/" + OID + "_bottom_left.jpg";
		document.getElementById('imgbottom_right').src = "images/frames/" + OID + "_bottom_right.jpg";
				
		cellBckImg('tdtop', "images/frames/" + OID + "_top.jpg");
		cellBckImg('tdbottom', "images/frames/" + OID + "_bottom.jpg");
		cellBckImg('tdleft', "images/frames/" + OID + "_left.jpg");
		cellBckImg('tdright', "images/frames/" + OID + "_right.jpg");
	}
}
			
function cellBckImg(idcell, imgName) 
{ 
	//alert(imgName);
	document.getElementById(idcell).style.background = "url(" + imgName + ")"; 
} 
		


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
    }
  }
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
  }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function cbk_preloadimages() {
	MM_preloadImages('images/designers/rotate_1.gif','images/designers/rotate_2.gif',
					'images/designers/rotate_3.gif','images/designers/rotate_4.gif')
}



function ShowCatalogSimplified(CatalogOID, ticket)
{
	ShowCatalog(CatalogOID, ticket, "ViewCatalog.aspx?Left=1:amp:Right=-1:amp:CatalogOID=" + CatalogOID);
	
}
/*
function ShowCatalog(CatalogOID, Password, ShowPage)
{
	var width = 970;
	var height = 656;
	var property = "top=0, left=0, width=" + width + ", height=" + height;
	//alert(ShowPage);
	//var wincatalog = window.open("http://209.155.0.87/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=8&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	var wincatalog = window.open("http://www.activemerchandiser.com/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=5&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	//var wincatalog = window.open("http://localhost/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	wincatalog.focus();
}*/

function ShowCatalog(CatalogOID, Password, ShowPage)
{
//alert(CatalogOID);
var intWidth = screen.width;
	var width = 970;
	var height = 656;
	if (intWidth > 1500)
	{
		width = 1415;
		height = 944;
	}
	
	if (intWidth < 1024)
	{
		width = 748;
		height = 512;
	}
	//alert(CatalogOID);
	var property = "top=0, left=0, width=" + width + ", height=" + height;
	//alert(ShowPage);
	//var wincatalog = window.open("http://209.155.0.87/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=300001&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	var wincatalog = window.open("http://www.activemerchandiser.com/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=187099&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	//var wincatalog = window.open("http://localhost/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=300001&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	wincatalog.focus();
}


function openVideo(VideoID) {
	var wincatalog =window.open('Videos.aspx?VideoID='+ VideoID ,'fd','width=525,height=650,scrollbars=0');
	wincatalog.focus();
	}

function ShowPDFPortFolio(skulist, PageTitle)
{

	var intWidth = screen.width;
	var width = 970;
	var height = 656;
	/*if (intWidth > 1500)
	{
		width = 1415;
		height = 944;
	}
	
	if (intWidth < 1024)
	{
		width = 748;
		height = 512;
	}  */
	var property = "top=100, left=100, width=" + width + ", height=" + height;
	//alert(ShowPage);
	//var wincatalog = window.open("http://209.155.0.87/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=300001&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	
	var wincatalog = window.open("ChooseOptions.aspx?skulist=" + skulist + "&PageTitle=" + PageTitle, 'SullivansPDFPortfolio', property);
	//var wincatalog = window.open("http://localhost/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	wincatalog.focus();
}

function ShowPDFBuilder(URL)
{


	var intWidth = screen.width;
	var width = 970;
	var height = 656;
	if (intWidth > 1500)
	{
		width = 1415;
		height = 944;
	}
	
	if (intWidth < 1024)
	{
		width = 748;
		height = 512;
	}
	var property = "top=0, left=0, width=" + width + ", height=" + height;
	//alert(ShowPage);
	//var wincatalog = window.open("http://209.155.0.87/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&SupplierID=300001&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	var wincatalog = window.open(URL, 'PDFBuilder', property);
	//var wincatalog = window.open("http://localhost/activemerchandiser/CatalogView.aspx?CatalogOID=" + CatalogOID + "&ShowPage=" + ShowPage + "&Password=" + Password, 'CatalogViews', property);
	window.close();
	wincatalog.focus();
	
	
}