//*********************************************************************************************************** GLOBAL VARS

var global_MASCompanyCode = "VET"		// change to "BIO" for production
var numberOfAds = "3";
var ebusinessInitialPageToDisplay = "estylez_logout.aspx" //+ global_MASCompanyCode;

//************************************************************************************************ Template Header & Footer

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];}}
}

MM_preloadImages('layout_images/btn_ppe_down.gif','layout_images/btn_emergency_down.gif','layout_images/btn_facility_down.gif','layout_images/btn_signage_down.gif','layout_images/btn_controlled_resources_down.gif','btn_human_resources_down.gif')

function drawEstylezHeader()
{

strHeader = "";
strHeader += "    <!--This table is used to make the screen strech to 100 percent for the height-->    ";
strHeader += "    <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"table_height_stretch\">";
strHeader += "  	<tr>";
strHeader += "        <td class=\"drop_shadow_container_left\">&nbsp;</td>";
strHeader += "        <td>";
strHeader += "        <!--** Start of Header Section -------------------------------------------------------------------->";
strHeader += "<div id=\"printdata\">";
strHeader += "    	<table cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%;\" border=\"0\">";
strHeader += "	    <tr>";
strHeader += "	    <td>";
strHeader += "			<!--This div is needed because of IE rending of tables, it is putting an extra space that we do not want so we are putting the width in this div instead-->";
strHeader += "			<div class=\"table_header_container_left_cell\">";
strHeader += "			<!--White box area with logo and welcome to image -->		";
if (eBusinessUserType == '1')
{
	if (userDiv == '00')
	{
		strHeader += "   	 		<div class=\"logo_image_midwest\"><a href=\"index.aspx\"><img src=\"/layout_images/logo_midwest_swine.jpg\" alt=\"Midwest Swine Vet\" /></a></div>";
	}
	else
	{
		strHeader += "   	 		<div class=\"logo_image_vetpro\"><a href=\"index.aspx\"><img src=\"/layout_images/logo_vetpro.jpg\" alt=\"Veterinary Provisions\" /></a></div>";	
	}
}
else
{
strHeader += "   	 		<div class=\"logo_image_vetpro\"><a href=\"index.aspx\"><img src=\"/layout_images/logo_vetpro.jpg\" alt=\"Veterinary Provisions\" /></a></div>";	
}
strHeader += "    		<div class=\"logo_text_welcome_to\"><img src=\"/layout_images/title_welcome_to.gif\" alt=\"Welcome To\" /></div>";
strHeader += "    		</div>";
strHeader += "		</td>	 	";
strHeader += "		<td class=\"table_header_container_right_cell\">";

strHeader += "	    <!--This cell has the rest of the header section: quick links, login info, searching & top categories-->		";
strHeader += "		<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"width: 100%;\">";
strHeader += "  		<tr>";
strHeader += "  			<td class=\"logo_text_company\">";
strHeader += "				<div>";
if (eBusinessUserType == '1')
{
	if (userDiv == '00')
	{
		strHeader += "				    <img src=\"/layout_images/title_midwest_swine.gif\" alt=\"Midwest Swine\" />";
	}
	else
	{
		strHeader += "				    <img src=\"/layout_images/title_vet_pro.gif\" alt=\"Veterinary Provisions\" />";
	}
}
else
{
strHeader += "				    <img src=\"/layout_images/title_vet_pro.gif\" alt=\"Veterinary Provisions\" />";
}
strHeader += "				</div>";
strHeader += "			</td>	";
strHeader += "   		 	<td class=\"top_menu_quick_links\">";

strHeader += "				    <img src=\"/layout_images/black_arrow.gif\" alt=\"arrow\" />&nbsp;<a class=\"toplink\" href=\"index.aspx\">home</a> 	";
strHeader += "			        <div><img src=\"/layout_images/black_arrow.gif\" alt=\"arrow\" />&nbsp;<a class=\"toplink\" href=\"estylez_ps.aspx\">shop now</a></div>";
strHeader += "			        <div><img src=\"/layout_images/black_arrow.gif\" alt=\"arrow\" />&nbsp;";
if (eBusinessUserType == '1')
{
strHeader += "<a class=\"toplink\" href=\"/IW_Customer.m4p.pvx?;CUSTOMER\">my account</a>";
}
else
{
strHeader += "<a class=\"toplink\" href=\"/IW_User.m4p.pvx?;PROFILE?company=VPI\">my account</a>";
}
strHeader += "                  </div>				    ";
strHeader += "				    <div><img src=\"/layout_images/black_arrow.gif\" alt=\"arrow\" />&nbsp;<a class=\"toplink\" href=\"/IW_InquiryARInvoice.m4p.pvx?;INV_INQ_OPTIONS\">order tracking</a></div>";
strHeader += "				    <div><img src=\"/layout_images/black_arrow.gif\" alt=\"arrow\" />&nbsp;<a class=\"toplink\" href=\"eStylez_Search.aspx\">advanced search</a></div>";
strHeader += "				    <div><img src=\"/layout_images/black_arrow.gif\" alt=\"arrow\" />&nbsp;";
if (eBusinessUserType == '1')
{
strHeader += "<a class=\"toplink\" href=\"https://www.midwestswinevets.com/IW_ShoppingCartOrder.m4p.pvx?;SUBMIT_SO\">shopping cart</a>";
}
else
{
strHeader += "<a class=\"toplink\" href=\"/IW_ShoppingCartStore.m4p.pvx?;SC_STEP1?company=VPI\">shopping cart</a>";
}
strHeader += "                    </div>";
strHeader += "			</td>";
strHeader += "    		<td class=\"vertical_line\"></td>";
strHeader += "    		<td class=\"login_search_area\">";
strHeader += "		   	    <div class=\"search_box_padding\">";
strHeader += "<form id=\"frmSearch\" name=\"frmSearch\" onsubmit=\"javascript:search()\" action=\"estylez_ps.aspx\" style=\"margin:0px; padding:0px;\">";
strHeader += "	<input type=\"text\" id=\"txtSearch\" value=\" search products\" name=\"txtSearch\" class=\"search_textbox\" onkeydown=\"return jumpToCtrlOnCR(event, 'btnTargetSearch');\">";
strHeader += "&nbsp;";

strHeader += "<input type=\"button\" name=\"btnTargetSearch\" id=\"btnTargetSearch\" style=\"border-width:0px;border-style:none;background-image:url(layout_images/btn_go_red.gif);width:31px;height:26px; vertical-align: top;\" onclick=\"search();\" \\>";

strHeader += "</form>";
strHeader += "				</div>";
strHeader += "			    <div class=\"horziontal_line\"><img src=\"/layout_images/spacer.gif\" alt=\"\"/></div>";

strHeader += "			    <div class=\"login_area_padding\">";

if (eBusinessUserType == '2' || eBusinessUserType == '' )
{
strHeader += "  <form style=\"margin:0px; padding:0px;\" action=\"IW_Login.m4p.pvx?;login_submit\" method=\"post\" name=\"TestForm\" id=\"TestForm\" onSubmit=\"return (checkForm(this))\">";
strHeader += "				    <div class=\"div_logged_in_out\">";
strHeader += "					    <span class=\"b2b_title\">Login</span>&nbsp;<input type=\"text\" id=\"UserID\" name=\"UserID\" class=\"textbox_login\">";
strHeader += "					    &nbsp;<span class=\"b2b_title\">Password</span>					";
strHeader += "					    <input type=\"password\" name=\"Password\" id=\"Password\" onkeydown=\"return jumpToCtrlOnCRLogin(event, 'btnTargetLogin');\" class=\"textbox_login\">&nbsp;";

//Button to login to website via b2c templates
strHeader += "<input type=\"button\" name=\"btnTargetLogin\" id=\"btnTargetLogin\" style=\"border-width:0px;border-style:none;background-image:url(layout_images/btn_go_black.gif);width:31px;height:26px;vertical-align: top;\" onclick=\"b2clogin();\" \>";

strHeader += "					    <div class=\"new_customer_forgot_password\">";
strHeader += "					    	<a href=\"/IW_Login.m4p.pvx?;UID_REQUEST\" class=\"toplink\">forgot password <img src=\"/layout_images/btn_next.gif\" class=\"img_align\" alt=\"forgot password\" /></a>";
strHeader += "					    </div>	";
strHeader += "					</div></form>";
}
else if (eBusinessUserType == '3')
{
strHeader += "<div style=\"height: 58px;\"></div>";	
}
else
{
strHeader += "					<div class=\"div_logged_in_out\">";
strHeader += "				        <div class=\"div_logout\">";
strHeader += "                          <a href=\"javascript:logoutB2B()\" class=\"b2blink\">Logout</a>";
strHeader += "                      </div>";
strHeader += "				        <div class=\"b2b_title\">Welcome Back</div>";
strHeader += 							getUserNameFromCookie()
strHeader += "                      <div class=\"dea_info\">";

if (userDEALicense == "")
{
strHeader += "                      	&nbsp;";
}
else
{
strHeader += "<b>Lic #:</b> ";
strHeader += userDEALicense
}

if (userDEAExpDate == "")
{
strHeader += "                      	&nbsp;";
}
else
{
strHeader += "&nbsp;&nbsp;&nbsp;<b>Date:</b> ";
strHeader += userDEAExpDate
}

strHeader += "                      </div>";
strHeader += "				    </div>";
}
strHeader += "	    	    </div>  			";
strHeader += "		    </td>";
strHeader += "  		</tr>";
strHeader += "		</table>";

strHeader += "	    <div class=\"horziontal_line\"><img src=\"/layout_images/spacer.gif\" alt=\"\"/></div>";

strHeader += "    	<div class=\"top_categories\">  				  			";
strHeader += "		    <a href=\"estylez_ps.aspx?searchmode=category&searchcatcontext=~MANUFTOP\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage(\'imgMan\',\'\',\'/layout_images/btn_man_down.gif\',1)\"><img id=\"imgMan\" alt=\"Manufactures\" src=\"/layout_images/btn_man.gif\" Width=\"85\" height=\"11\" /></a>									";
strHeader += "		    <a href=\"estylez_ps.aspx?searchmode=category&searchcatcontext=~VACCINETOP\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage(\'imgVac\',\'\',\'/layout_images/btn_vac_down.gif\',1)\"><img id=\"imgVac\" alt=\"Vaccines\" src=\"/layout_images/btn_vac.gif\" Width=\"55\" Height=\"11\" /></a>									";
strHeader += "            <a href=\"estylez_ps.aspx?searchmode=category&searchcatcontext=~ANTIBTOP\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage(\'imgAnt\',\'\',\'/layout_images/btn_ant_down.gif\',1)\"><img id=\"imgAnt\" alt=\"Antibiotics\" src=\"/layout_images/btn_ant.gif\" width=\"66\" height=\"11\" /></a>									";
strHeader += "		    <a href=\"estylez_ps.aspx?searchmode=category&searchcatcontext=~PHARMSTOP\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage(\'imgPhar\',\'\',\'/layout_images/btn_phar_down.gif\',1)\"><img id=\"imgPhar\" alt=\"Pharmaceuticals\" src=\"/layout_images/btn_phar.gif\" width=\"104\" height=\"11\" /></a>				";
strHeader += "            <a href=\"estylez_ps.aspx?searchmode=category&searchcatcontext=~SPECIESTOP\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage(\'imgSpecies\',\'\',\'/layout_images/btn_species_down.gif\',1)\"><img id=\"imgSpecies\" alt=\"Species\" src=\"/layout_images/btn_species.gif\" width=\"42\" height=\"11\" /></a>																";
strHeader += "		    <a href=\"estylez_ps.aspx?searchmode=category&searchcatcontext=~SUNDTOP\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage(\'imgSundries\',\'\',\'/layout_images/btn_sundries_down.gif\',1)\"><img id=\"imgSundries\" alt=\"Sundries\" src=\"/layout_images/btn_sundries.gif\" width=\"51\" height=\"11\" /></a>	";
strHeader += "  		</div>";

strHeader += "	</td>";
strHeader += "	</tr>";
strHeader += "	</table>";
strHeader += " </div>";

strHeader += "	</td>";
strHeader += "    <td class=\"drop_shadow_container_right\"></td>";
strHeader += "  	</tr> ";

strHeader += "	<!--middle row where most of the content will be located-->";
strHeader += "	<tr>";
strHeader += "    <td class=\"drop_shadow_container_left\">&nbsp;</td>";
strHeader += "    <td style=\"height: 100%;\"> ";

strHeader += "		<!--Main Content Area-->";
strHeader += "		<table cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%; height: 100%;\" border=\"0\">";
strHeader += "		<tr>";
strHeader += "			<td class=\"title_image_products\">";
strHeader += "			    <div>";
strHeader += "					<img src=\"/layout_images/title_our_products.gif\" alt=\"our products\" />";
strHeader += "				</div>			";
strHeader += "			</td>";
strHeader += "		    <td class=\"title_image_display\">				";
strHeader += "		        <div>";
if (eBusinessUserType == '1')
{
	if (userDiv == '00')
	{
		strHeader += "		          <img ID=\"imgStoreCompany\" src=\"/layout_images/title_midwest_store.gif\" alt=\"Midwest Swine\" />";
	}
	else
	{
		strHeader += "		          <img ID=\"imgStoreCompany\" src=\"/layout_images/title_vet_pro_store.gif\" alt=\"Veterinary Provisions\" />";	
	}
}
else
{
strHeader += "		          <img ID=\"imgStoreCompany\" src=\"/layout_images/title_vet_pro_store.gif\" alt=\"Veterinary Provisions\" />";	
}
strHeader += "				</div>";
strHeader += "			</td>";
strHeader += "		    <td class=\"title_image_shopping_cart\">";
strHeader += "				<div>";
strHeader += "			    	<img src=\"/layout_images/title_shopping_cart.gif\" alt=\"shopping carts\" />";
strHeader += "				</div>		";
strHeader += "		    </td>";
strHeader += "		</tr>";
strHeader += "		<tr>		";
strHeader += "		    <td class=\"table_main_display_left_cell\">	";

strHeader += "		<div id=\"printdata2\">";
strHeader += "		    <div style=\"padding-top: 2px;\">";
strHeader += "			<!--TODO:HTML Hack because I cannot figure out why this is 15px instead of 17px-->";
strHeader += 				drawTopLevelCats();
strHeader += "          </div>";

strHeader += "			<div class=\"padding_between_products_and_more_link\">";
strHeader += "			    <div class=\"title_image_more_links\">";
strHeader += "				    <div>";
strHeader += "					    <img src=\"/layout_images/title_information_links.gif\" alt=\"more links\" />";
strHeader += "				    </div>	";
strHeader += "			    </div>";

strHeader += "			    <div id=\"more_links_div\">	";
if (eBusinessUserType == '2')
//This is a b2c user so they are not logged in (vetpro customer)
{
strHeader += "			            <a href=\"/IW_Help.m4p.pvx?;HELP_TOC?company=VPI\" class=\"mainlink\">estore help</a>";
}
else
{
//This is a b2b user so they ARE logged in (Midwest Swine)
strHeader += "                        <a href=\"/IW_Help.m4p.pvx?;HELP_TOC\" class=\"mainlink\">Estore Help</a>";
strHeader += "                        <div><a href=\"/IW_Customer.m4p.pvx?;CREDIT\" class=\"mainlink\">Credit</a></div>";
strHeader += "                        <div><a href=\"/IW_InquirySOOpen.m4p.pvx?;SO_INQ_OPTIONS\" class=\"mainlink\">Open Orders</a></div>";
strHeader += "                        <div><a href=\"/IW_InquirySOHist.m4p.pvx?;SO_HIST_INQ_OPTIONS\" class=\"mainlink\">History orders</a></div>";
strHeader += "                        <div><a href=\"/IW_AddItems.m4p.pvx?;ADDITEMS\" class=\"mainlink\">Quick Order</a></div>";
strHeader += "                        <div><a href=\"/IW_Customer.m4p.pvx?;SHIP_TO_BROWSE\" class=\"mainlink\">Ship To</a></div>";
strHeader += "                        <div><a href=\"/IW_User.m4p.pvx?;UID\" class=\"mainlink\">User Accounts</a></div>";
strHeader += "                        <div><a href=\"/docs.aspx\" class=\"mainlink\">Documents and Forms</a></div>";
}
strHeader += "			        <div><a href=\"howto.aspx\" class=\"mainlink\">How to Pages</a></div>			        ";
strHeader += "			        <div><a href=\"shipping.aspx\" class=\"mainlink\">Shipping & Returns</a></div>";
strHeader += "			        <div><a href=\"staff.aspx\" class=\"mainlink\">Staffing Information</a></div>			        							";

strHeader += "			    </div>";

strHeader += "		    </div>";
strHeader += "   </div>";
strHeader += "		</td>";
strHeader += "		<!--<td class=\"drop_shadow_inner_wall_left\"></td>-->";
strHeader += "		<td class=\"table_main_display_center_cell\">";
strHeader += "            <div class=\"div_main_display_area\">";
strHeader += "            <!-- Where all of the conent for the website will go -->";

	document.write(strHeader);
	
	//We are losing cookie state so we only want to set on certain pages
	if (eBusinessSummaryCart == 'Y')
	{
		setCookieData("userID",eBusinessUserId)
	}
}


function drawEstylezFooter()
{

strFooter = "";
strFooter += "</div>";
strFooter += "		</td>";
strFooter += "	";
strFooter += "		<td style=\"width: 220px;\" class=\"drop_shadow_inner_wall_left\">";
strFooter += "		<div id=\"printdata3\">";
strFooter += "		<div class=\"summary_cart_div\">			";
strFooter += " 			<div id=\"summarycart\"></div>";
strFooter += "		</div>";
strFooter += "		";
strFooter += "		<div class=\"title_image_news\">";
strFooter += "			<div>";
strFooter += "				<img src=\"/layout_images/title_important.gif\" alt=\"important news\" />";
strFooter += "			</div>					";
strFooter += "		</div>";

strFooter += "		<div class=\"news_padding\">	";
//strFooter += "			This is where we could put events or other information.";
//strFooter += "			<br /><br />";
//strFooter += "			Welcome to the new and improved website for Vet Pro.  We hope that you enjoy looking around and find what you are looking for.						";
//strFooter += "			<div class=\"div_events_link\"><a href=\"events.aspx\" class=\"mainlink\"><img src=\"/layout_images/black_arrow_white_background.gif\" alt=\"arrow\" />&nbsp;learn more</a></div>";

//Casey type news here
strFooter += " ";

strFooter += "		</div>";
strFooter += "		</div>";
strFooter += "		</td>";
strFooter += "		</tr>";
strFooter += "		</table>";
strFooter += "	</td>";
strFooter += "    <td class=\"drop_shadow_container_right\"></td>";
strFooter += "  	</tr> ";

strFooter += "	<!--bottom row: this will only have links, address contact information and terms of use-->";
strFooter += "	<tr>";
strFooter += "    <td class=\"drop_shadow_container_left\">&nbsp;</td>";
strFooter += "    <td> ";
strFooter += "		<div class=\"bottom_area_div\">";
strFooter += "		 	";
strFooter += "			<div class=\"bottom_area_links\">					";
strFooter += "			    <a href=\"sitemap.aspx\" class=\"mainlink\">sitemap</a> <span class=\"small\">/</span>";
strFooter += "			    <a href=\"privacy.aspx\" class=\"mainlink\">privacy notice</a> <span class=\"small\">/</span> ";
strFooter += "			    <a href=\"terms.aspx\" class=\"mainlink\">conditions of use</a> <span class=\"small\">/</span> ";
strFooter += "			    <a href=\"contact.aspx\" class=\"mainlink\">contact us</a>";
strFooter += "			";
strFooter += "			    <div class=\"bottom_area_copyright\">";
strFooter += "				    &copy; copyright 2008 Veterinary Provisions, Inc. All Right Reserved";
strFooter += "			    </div>";
strFooter += "							";
strFooter += "			    <div class=\"bottom_area_terms\">";
strFooter += "				    Use of this website signifies your agreement to the <a href=\"#\" class=\"toplink\">Terms of Use</a> ";
strFooter += "			    </div>";
strFooter += "		    </div>";
strFooter += "			";
strFooter += "		    <div class=\"bottom_area_contact\">			";
strFooter += "			    <div class=\"b2b_title\">:: address</div>";
strFooter += "			    1200 Hwy 3 South<br />";
strFooter += "			    Northfield, MN 55057<br />			";
strFooter += "			    <a href=\"http://maps.google.com/maps?hl=en&um=1&ie=UTF-8&q=1200+S+Hiway+3+Northfield,+MN+55057&fb=1&sa=X&oi=local_group&resnum=4&ct=image\" target=\"_blank\" class=\"bottomlink\">map it</a>";
strFooter += "			    ";
strFooter += "			    <br /><br />";
strFooter += "			    p: 507.645.5370<br />";
strFooter += "			    t: 888.863.9376<br />";
strFooter += "		    </div>						";
strFooter += "		</div>";
strFooter += "	</td>";
strFooter += "    <td class=\"drop_shadow_container_right\"></td>";
strFooter += "  	</tr> ";
strFooter += "</table>";

if (eBusinessSummaryCart == 'Y')
{
strFooter += "<script type=\"text/javascript\">var tempUserID=getCookieData(\'userID\');comet_drawSummaryCart(tempUserID);</script>";
}

	document.write(strFooter)
}

//*********************************************************************************************************** COOKIE FUNCTIONS

function getCookieData(labelName)
// returns cookie data from corresponding label, or null if label does not exist.
{
	var cookieData 		= document.cookie;		// grab the data once
	var cookieEnd;

	for (i=0; i < cookieData.length; i++)
	{
		var j = i + labelName.length;
		if (cookieData.substring(i,j) == labelName)
		{
			cookieEnd = cookieData.indexOf(";",j)
			if (cookieEnd == -1) { cookieEnd = cookieData.length; }
			
			return unescape(cookieData.substring(j+1, cookieEnd))
		}
	}
	return null;
}

function delCookieData(labelName)
// deletes specific cookie by label name
{
	document.cookie = labelName + "=" + ";expires=Thursday, 01 Jan 1970 00:00:01 GMT;";
	return null;
}

function setCookieData(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

//*********************************************************************************************************** ISM FUNCTIONS



function logoutB2B()
{
	if (window.confirm("This will end your currnet session."))
	{
	
        delCookieData("userID")    
		logoutEbusinessUser(ebusinessInitialPageToDisplay);
	}
}

function b2clogin()
{
  document.TestForm.submit()
}

function logoutEbusinessUser()
// Logs out user: deletes Ebusiness cookies and sends to home page.
// Accepts optional URL parameter to direct control of the page.
{
	delCookieData("GUID")
	delCookieData("ebusinessUserName")
	delCookieData("mas_customer")
	delCookieData("mas_division")

	// Do we have our optional "where to go" parameter?
	if (logoutEbusinessUser.arguments.length > 0)
	{
		parent.location.href = logoutEbusinessUser.arguments[0]
	}
}

function getUserNameFromCookie()
// Extracts user name from ebusiness user name cookie.
{
	if (getCookieData("ebusinessUserName"))
	{ 

	return  getCookieData("ebusinessUserName").substring(0, getCookieData("ebusinessUserName").indexOf("~~")) + '&nbsp' }
	else
		{ return "" }

}

function displayBanner()
{
//Gets a random number to display the ads on the top menu bar.
var ranNum = Math.floor(Math.random()* numberOfAds ) + 1;
var imageName = "<img src='/images/ads/sample_ad" + ranNum  + ".gif' alt='Hot Product Deals from Empire Safety & Supply' style='width: 200px; height: 210px;'>"

document.write(imageName)
}

function search()
{
var strSearch 
strSearch = 'estylez_ps.aspx?searchmode=keyword&searchkeyword=' + escape(document.getElementById("txtSearch").value)

document.location = strSearch
}


function jumpItem()
{

	if (document.getElementById("txtPartNo").value == '')
	{
		alert("please enter an item number");
	}
	else
	{
		var strItem
		strItem = 'estylez_item.aspx?item=' + escape(document.getElementById("txtPartNo").value)

	document.location = strItem
	}
}


function jumpToCtrlOnCRLogin(evt, ctrl_id)
// General-purpose keypress handler--sets focus to a control when Enter (CR) is pressed.
// Note that this function does NOT consume the CR char--it'll stil act on the control given
// focus.  Add "return false;" to function to consume the CR...
{
  evt = evt || event;
  if ((evt.keyCode | evt.which) == 13)
  {
    document.TestForm.elements[ctrl_id].focus();
  }
}


function jumpToCtrlOnCR(evt, ctrl_id)
// General-purpose keypress handler--sets focus to a control when Enter (CR) is pressed.
// Note that this function does NOT consume the CR char--it'll stil act on the control given
// focus.  Add "return false;" to function to consume the CR...
{
  evt = evt || event;
  if ((evt.keyCode | evt.which) == 13)
  {
    document.frmSearch.elements[ctrl_id].focus();
  }
}

//*********************************************************************************************************** TOP TABBED MENU

var global_MenuImgPath = "/layout_images/";

function drawTopMenu()
{
	var sOut = "";

	for (var i=0; i < global_aTopMenuList.length; i++)
	{
	/*
		sOut += "<span class='topMenuItem'>";
		sOut += "<a href='" + global_aTopMenuList[i][2] + "' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage(\"topMenuImg" + i + "\",\"\",\"" + global_MenuImgPath + global_aTopMenuList[i][1] + "\",1)'>";
		sOut += "<img src='" + global_MenuImgPath + global_aTopMenuList[i][0] + "' name='topMenuImg" + i + "'>";
		sOut += "</a>";
		sOut += "</span>";
	*/
	
		sOut += "<span class='topMenuItem'>";
		//sOut += "<div class='topMenuItem_test'>"
		sOut += "<a href='" + global_aTopMenuList[i][1] + "'>";
		sOut += global_aTopMenuList[i][0];
		sOut += "</a>";
		//sOut += "</div>";
		sOut += "</span>";
	}
	
	document.write(sOut);
}



//*********************************************************************************************************** UTILITY FUNCTIONS

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

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 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_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;
}

/******************************** Info Popup ********************************************/

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function showInfoPopup(oSender, strContent, xOffset, yOffset)
{	
	// Insert the content into the div
	document.getElementById("divInfoPopup").innerHTML = strContent;
	
	// Position the div based on the caller's position
	document.getElementById("divInfoPopup").style.left = (findPos(oSender)[0] + xOffset) + "px";
	document.getElementById("divInfoPopup").style.top = (findPos(oSender)[1] + yOffset) + "px";
	
	// Display the div
	document.getElementById("divInfoPopup").style.display ="block"
	
	startObjectFadeIn(document.getElementById("divInfoPopup"));
}

function hideInfoPopup()
{
	startObjectFadeOut(document.getElementById("divInfoPopup"));
	(hideInfoPopup.arguments[0]) ? document.getElementById("divInfoPopup").style.display = "none" : doNothing();
}

function doNothing() {}

var global_iFadeStep = 5		// By what percent should I change the opacity per cycle?
var global_iFadeRate = 1		// How long should a fade cycle be (msec)?

var global_iCurrentOpacity = 0
var global_oTimerOpacity
var global_oTarget


function startObjectFadeIn(oTarget)
{
	global_oTarget = oTarget									// has to be accessible to the timer after this function has lost scope
	clearInterval(global_oTimerOpacity)
	global_oTimerOpacity = setInterval("doObjectFade('in')",global_iFadeRate)
}

function startObjectFadeOut(oTarget)
{
	//alert(oTarget.id);
	global_oTarget = oTarget									// has to be accessible to the timer after this function has lost scope
	clearInterval(global_oTimerOpacity)
	global_oTimerOpacity = setInterval("doObjectFade('out')",global_iFadeRate)
}

function setObjectOpacity(iOpacity)
// Sets the opacity of oTarget based on a 0-100 index where 0 is transparent and 100 is opaque.
{
	// Are we in IE?
	if (window.global_oTarget.filters) { global_oTarget.filters.alpha.opacity = iOpacity }
	else { global_oTarget.style.MozOpacity = iOpacity / 100 }
	
}

function doObjectFade(strFadeDirection)
// Handles actually changing the opacity of the object depending on if we're 
// fading in or out.  Clears timer if we're done fading.
{
	// Are we fading in and we're not maxed out yet?
	if (strFadeDirection == "in" && global_iCurrentOpacity < 100)
	{
		setObjectOpacity(global_iCurrentOpacity += global_iFadeStep)
	}
	// Are we fading out and we haven't bottomed out?
	else if (strFadeDirection == "out" && global_iCurrentOpacity > 0)
	{
		setObjectOpacity(global_iCurrentOpacity -= global_iFadeStep)
	}
	else if (window.global_oTimerOpacity)
	{
		clearInterval(global_oTimerOpacity)
		global_iCurrentOpacity = (strFadeDirection == "in") ? 100 : 0
		if (strFadeDirection == "out") { global_oTarget.style.display = "none" }
	}
}

// ********************************************************************************************************

