%@ page import="com.fry.ocp.util.RequestUtil,
com.fry.wp.multisite.util.i18n.I18NUtil"%>
<%
/*
Copyright (C) 2002 Fry Inc., All Rights Reserved.
Purpose:
Generates the client-side javascript include file for
common utility functions that we'll use for doing image
roll-overs, redirects, popup windows, etc.
*/
%>
<%@ taglib uri="/WEB-INF/ocp-site.tld" prefix="site" %>
<%@ taglib uri="/WEB-INF/ocp-util.tld" prefix="util" %>
var BrowserUtil = function() {};
BrowserUtil.getEvent = function(evtObj) {
var navAgent = navigator.userAgent.toLowerCase();
var evt = null;
if ((window.event != null) && (navAgent.indexOf("mac") == -1)) {
// Internet Explorer
evt = window.event;
// * IE 6 standards-compliant mode document.documentElement reassignment
if (document.documentElement && document.documentElement.clientWidth) {
evt.getViewportAxisX = document.documentElement.clientWidth;
evt.getViewportAxisY = document.documentElement.clientHeight;
evt.getViewportOffsetX = document.documentElement.scrollLeft;
evt.getViewportOffsetY = document.documentElement.scrollTop;
evt.getPageCoordX = evt.clientX + document.documentElement.scrollLeft;
evt.getPageCoordY = evt.clientY + document.documentElement.scrollTop;
} else if (document.body) {
evt.getViewportAxisX = document.body.clientWidth;
evt.getViewportAxisY = document.body.clientHeight;
evt.getViewportOffsetX = document.body.scrollLeft;
evt.getViewportOffsetY = document.body.scrollTop;
evt.getPageCoordX = evt.clientX + document.body.scrollLeft;
evt.getPageCoordY = evt.clientY + document.body.scrollTop;
}
evt.getEventType = evt.type;
} else if (evtObj != null) {
// EOMB
evt = evtObj;
evt.getViewportAxisX = self.innerWidth;
evt.getViewportAxisY = self.innerHeight;
evt.getViewportOffsetX = self.pageXOffset;
evt.getViewportOffsetY = self.pageYOffset;
evt.getPageCoordX = evt.pageX;
evt.getPageCoordY = evt.pageY;
evt.getEventType = evt.type;
}
return evt;
}
Effects = function() {}
Effects.popLayer = function(objId,objState,objPos,objOffsetX,objOffsetY,objWidth,evtObj) {
// * objState parameter must be "show" or "hide"
// * objPos parameter must be "center" or "relative" or undefined
var posX = 0;
var posY = 0;
var elementSelect = document.getElementsByTagName("select");
var newPopLayer = document.getElementById(objId);
if (objWidth != "") {
newPopLayer.style.width = objWidth + "px"
} else {
objWidth = newPopLayer.offsetWidth;
}
var layerWidth = newPopLayer.offsetWidth;
var layerHeight = newPopLayer.offsetHeight;
var newEventObject = new BrowserUtil.getEvent(evtObj);
if (objPos == "center") {
posX = Math.round(newEventObject.getViewportAxisX/2) + newEventObject.getViewportOffsetX - Math.round(layerWidth/2);
posY = Math.round(newEventObject.getViewportAxisY/2) + newEventObject.getViewportOffsetY - Math.round(layerHeight/2);
} else {
posX = newEventObject.getPageCoordX + objOffsetX;
posY = newEventObject.getPageCoordY + objOffsetY;
}
if (objState == "show") {
for (i = 0; i < elementSelect.length; i++) {
elementSelect[i].style.visibility = "hidden";
}
document.getElementById("wrapper").style.visibility == "hidden;"
if (objPos == "relative") {
if (Number(posX) + Number(layerWidth) > Number(newEventObject.getViewportAxisX)) {
posX = posX - objWidth - objOffsetX*2;
}
if (Number(posY) + Number(layerHeight) > Number(newEventObject.getViewportAxisY)) {
posY = posY - layerHeight - objOffsetY*2;
}
}
newPopLayer.style.left = posX + "px";
newPopLayer.style.top = posY + "px";
newPopLayer.style.visibility = "visible";
} else if (objState == "hide") {
for (i = 0; i < elementSelect.length; i++) {
elementSelect[i].style.visibility = "visible";
}
document.getElementById("wrapper").style.visibility == "visible;"
newPopLayer.style.left = 0 + "px";
newPopLayer.style.top = 0 + "px";
newPopLayer.style.visibility = "hidden";
}
}
Effects.toggleTabs = function(strImgList,strDivList,imgExtOn,imgExtOff,imgToTurnOn,divToTurnOn) {
var imgArray = strImgList.split("|");
var divArray = strDivList.split("|");
for (i = 0; i < imgArray.length; i++) {
// * turn images to "off" state
imgTab = document.getElementById(imgArray[i]);
imgTabPath = imgTab.src.substr(0,imgTab.src.lastIndexOf('/')) + '/';
imgTab.src = imgTabPath + imgArray[i] + imgExtOff;
// * turn layers to "off" state
divLayer = document.getElementById(divArray[i]);
divLayer.style.display = "none";
}
// * turn image and layer to "on" state
// * image ID (imgToTurnOn) and image name should match
document.getElementById(imgToTurnOn).src = imgTabPath + imgToTurnOn + imgExtOn;
document.getElementById(divToTurnOn).style.display = "block";
}
Effects.modDisplay = function(strNoneList,strInlineList,strBlockList) {
var strNoneList = strNoneList.split("|");
var strInlineList = strInlineList.split("|");
var strBlockList = strBlockList.split("|");
for (i = 0; i < strNoneList.length; i++) {
if (strNoneList != "") {
document.getElementById(strNoneList[i]).style.display = "none";
}
}
for (i = 0; i < strInlineList.length; i++) {
if (strInlineList != "") {
document.getElementById(strInlineList[i]).style.display = "inline";
}
}
for (i = 0; i < strBlockList.length; i++) {
if (strBlockList != "") {
document.getElementById(strBlockList[i]).style.display = "block";
}
}
}
function passValue(objId,objIdValToPass, disableFromElement) {
var fromElement = document.getElementById(objId);
var toElement = document.getElementById(objIdValToPass);
toElement.value = fromElement.value;
}
function showMore(qtyInputName, modelInputName, strNoneList,strInlineList,strBlockList) {
Effects.modDisplay(strNoneList,strInlineList,strBlockList);
var element1 = document.getElementById(qtyInputName);
var element2 = document.getElementById(modelInputName);
element1.name="";
element2.name="";
element1.value="";
element2.value="";
}
function dropMenu(objId,objIdParent,objState,objEvt) {
var objEvt = objEvt ? objEvt : window.event;
var objEvtTarget = objEvt.relatedTarget ? objEvt.relatedTarget : objEvt.toElement
var boolNotParent = true;
var elementSelect = document.getElementsByTagName("select");
if (objState == "on") {
for (i = 0; i < elementSelect.length; i++) {
elementSelect[i].style.visibility = "hidden";
}
// Safari/Mozilla Bug: Parent must be set to "visible" as well.
document.getElementById(objIdParent).style.visibility = "visible";
document.getElementById(objId).style.visibility = "visible";
} else if (objState == "off") {
var parentObjId = objEvtTarget;
while (parentObjId && parentObjId.parentNode && boolNotParent == true) {
if (parentObjId.id == objId) {
boolNotParent = false;
}
parentObjId = parentObjId.parentNode;
}
if (boolNotParent == true) {
for (i = 0; i < elementSelect.length; i++) {
elementSelect[i].style.visibility = "visible";
}
// Safari/Mozilla Bug: Parent must be set to "hidden" as well.
document.getElementById(objIdParent).style.visibility = "hidden";
document.getElementById(objId).style.visibility = "hidden";
}
}
}
function printPage() {
if (window.print) {
window.print();
} else {
alert("Please use [ File >> Print ] in order to print this page.");
}
}
function showTabCom(objComDivId) {
var imgPath = ""
var objComDivArr = new Array("tab-more-info","tab-files","tab-email-friend","tab-products");
for (i = 0; i < objComDivArr.length; i++) {
if (document.getElementById(objComDivArr[i] + "-img")) {
document.getElementById(objComDivArr[i] + "-img").src = imgPath + objComDivArr[i] + "-off.gif";
document.getElementById(objComDivArr[i]).style.display = "none";
}
}
document.getElementById(objComDivId + "-img").src = imgPath + objComDivId + ".gif";
document.getElementById(objComDivId).style.display = "block";
}
utilityBrowserVer = parseInt(navigator.appVersion);
function imgOn(imgName) {
if (utilityBrowserVer >= 3) {
imgOnString = eval(imgName + "_on.src");
document.images[imgName].src = imgOnString;
}
}
function imgOff(imgName) {
if (utilityBrowserVer >= 3) {
imgOffString = eval(imgName + "_off.src");
document.images[imgName].src = imgOffString;
}
}
function goToLink(address) {
var linkURL = address.options[address.selectedIndex].value;
window.top.location.href = linkURL;
address.selectedIndex=0;
}
/*
* This function launches a new web browser window to a specified width, height and features.
* Features string is a comma separated window's feature needed for this new window. For Instance
* If a new window needs a toolbar the feature string must be "toolbar" like needs scroll bar and
* and toolbar then it must be "toolbar,scrollbar". Note that the order of the feature is not required.
* Also it's case insensitive. Therefore, "scrollbar,toolbar" is identical to "Toolbar,ScrollBar".
*
* If the features string is ommitted then all the features are turned off. To turn all the features on
* use the word "all" for features instead of specifying each feature.
*/
function openWindow(url,winName,width,height){
var winRef = window.open(url, winName, "height=" + height + ",width=" + width + ",status=yes,toolbar=no,menubar=no,location=no,directories=no,resizable=yes,scrollbars=yes,titlebar=no");
}
function openNamedWindow(address, name, width, height, features)
{
/* Find out what features need to be enable
*
*/
if(features)
features = features.toLowerCase();
else
features = "";
var toolbar = (features == "all" ? 1 : 0);
var menubar = (features == "all" ? 1 : 0);
var location = (features == "all" ? 1 : 0);
var directories = (features == "all" ? 1 : 0);
var status = (features == "all" ? 1 : 0);
var scrollbars = (features == "all" ? 1 : 0);
var resizable = (features == "all" ? 1 : 0);
if(features != "all")
{
//split features
var feature = features.split(",");
for(i = 0; i < feature.length; i++)
{
if(feature[i] == "toolbar")
toolbar = 1;
else if(feature[i] == "menubar")
menubar = 1;
else if(feature[i] == "location")
location = 1;
else if(feature[i] == "directories")
directories = 1;
else if(feature[i] == "status")
status = 1;
else if(feature[i] == "scrollbars")
scrollbars = 1;
else if(feature[i] == "resizable")
resizable = 1;
}
}
features = "toolbar=" + toolbar + ",";
features += "menubar=" + menubar + ",";
features += "location=" + location + ",";
features += "directories=" + directories + ",";
features += "status=" + status + ",";
features += "scrollbars=" + scrollbars + ",";
features += "resizable=" + resizable;
var newWindow = window.open(address, name, 'width=' + width + ',height=' + height + ',"' + features + '"');
newWindow.focus();
}
function confirmWindow(url, text) {
if (confirm(text)) {
window.go = url;
window.location = url;
}
}
function setOperation(opType,needSubmit,addressIndex) {
document.addUpdateDeleteAddressForm.operation.value = opType;
if(addressIndex)
document.addUpdateDeleteAddressForm.selectedAddressIndex.value = addressIndex;
if(needSubmit) {
if(opType == "EDIT")
window.location="<%= RequestUtil.getContextPath(request,"/user/address_book.jsp?addressIndex=") %>" + addressIndex;
else
document.addUpdateDeleteAddressForm.submit();
}
}
function setAddTo(addToType) {
document.productForm.addTo.value = addToType;
}
// This is an example of sending product data from the server
// to the client, then formatting the variants on the client-side
// based on certain criteria.
function cbFormatter(list, attribute, opt)
{
// Get the price for this variant.. If this is the primary list, get all related
// variants from the group and get their prices as well so we can build a range.
var pvds = list.productVariantDropdownSupport;
// Get all of the product variants for this attribute
var variantGroup = attribute.getVariant().getProductVariantGroup();
var groupVariants = variantGroup.getAllVariants()
// Are all of the prices the same within the group?
var lowGroupPrice = 999999.00;
var highGroupPrice = -1.00;
for (var idx = 0; idx < groupVariants.length; idx++)
{
lowGroupPrice = groupVariants[idx].numericPrice < lowGroupPrice ? groupVariants[idx].numericPrice : lowGroupPrice;
highGroupPrice = groupVariants[idx].numericPrice > highGroupPrice ? groupVariants[idx].numericPrice : highGroupPrice;
}
// Are all of the prices the same within the variant?
var variants = variantGroup.getVariantsMatching(attribute.name, attribute.value);
var lowVariantPrice = 999999.00;
var highVariantPrice = -1.00;
var lowVariantDisplay = variants[0].displayPrice;
var highVariantDisplay = variants[0].displayPrice;
for (var idx = 0; idx < variants.length; idx++)
{
// Display really needs to be done before the re-assignment...
lowVariantDisplay = variants[idx].numericPrice < lowVariantPrice ? variants[idx].displayPrice : lowVariantDisplay;
lowVariantPrice = variants[idx].numericPrice < lowVariantPrice ? variants[idx].numericPrice : lowVariantPrice;
highVariantDisplay = variants[idx].numericPrice > highVariantPrice ? variants[idx].displayPrice : highVariantDisplay;
highVariantPrice = variants[idx].numericPrice > highVariantPrice ? variants[idx].numericPrice : highVariantPrice;
}
if (lowGroupPrice != highGroupPrice)
{
// Primary list should display a range
if (pvds.isPrimary)
if (lowVariantPrice != highVariantPrice)
opt.text = opt.text + " " + lowVariantDisplay + " - " + highVariantDisplay;
else
opt.text = opt.text + " " + attribute.getVariant().displayPrice;
else // Secondary lists should show exact price
opt.text = opt.text + " " + attribute.getVariant().displayPrice;
}
return opt;
}
/* This function is called when a subject is changed so that actual subject text can be
* stored in to a hidden subject field. Since value of the subject list is a keyword define
* in the command configuration file to identify it's email address.
*/
function setSubject(thisRef)
{
var formRef = document.forms["contactUsForm"];
//set subject value
formRef.elements["subject"].value = (thisRef.options[thisRef.selectedIndex]).text;
}
function showDiv(divName) {
document.getElementById(divName).style.visibility = 'visible';
document.getElementById(divName).style.display = 'block';
}
function hideDiv(divName) {
document.getElementById(divName).style.visibility = 'hidden';
document.getElementById(divName).style.display = 'none';
}
var defaultKeywordValues = new Array('<%=I18NUtil.getString(request, "findProducts.enterModelNumberKeyword(s)", "Enter model # or keyword(s)")%>','<%=I18NUtil.getString(request, "findProducts.enterModelNumber", "Enter Model #")%>');
var defaultKeywordValue = "";
function focus_keyword(field)
{
var i = 0;
for( var i=0; i < defaultKeywordValues.length; i++ )
{
if( field.value == defaultKeywordValues[i] )
{
defaultKeywordValue = defaultKeywordValues[i];
field.value = '';
}
}
}
function blur_keyword(field)
{
if( field.value == '' && defaultKeywordValue != '' )
field.value = defaultKeywordValue;
defaultKeywordValue = '';
}
var defaultContractValues = new Array('<%=I18NUtil.getString(request, "findContracts.enterContractNumber", "Enter Contract #")%>', '<%=I18NUtil.getString(request, "findContracts.optional", "optional")%>');
var defaultContractValue = "";
function focus_contractField(field){
defaultContractValue = focus_field(field, defaultContractValues, defaultContractValue);
field.setAttribute('maxLength', 10);
}
function focus_field(field, defaultValues, originalValue)
{
var returnVal = originalValue;
for( var i=0; i < defaultValues.length; i++ )
{
if( field.value == defaultValues[i] )
{
field.value = '';
returnVal = defaultValues[i];
}
}
return returnVal;
}
function blur_contractField(field){
blur_field(field, defaultContractValue);
field.setAttribute('maxLength', 16);
}
function blur_field(field, defaultValue)
{
if( field.value == '' && defaultValue != '' ) {
field.maxLength = defaultValue.length;
field.value = defaultValue;
}
defaultValue = '';
}
function encode(str) {
var result = "";
for (i = 0; i < str.length; i++) {
if (str.charAt(i) == " ") result += "+";
else result += str.charAt(i);
}
return result;
}
function decode(str) {
return str.replace(/\+/g, " ");
}
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function hidePrice(){
var div = document.getElementById('showHidePrice');
Set_Cookie( "hidePrices", "true",null,'/',null,null);
if (div != null){
div.innerText = 'Show Product Prices';
}
}
function showPrice(){
var div = document.getElementById('showHidePrice');
Set_Cookie( 'hidePrices', 'false',null,'/',null,null);
if (div != null){
div.innerText = 'Hide Product Prices';
}
}
function toggleHidePrice(){
var hide = readCookie('hidePrices');
if (hide == 'true')
showPrice();
else
hidePrice();
window.location.reload();
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function IsInteger(sText)
{
var ValidChars = "0123456789";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
function getDate () {
var today=new Date();
return ((today.getMonth() + 1)+"/"+today.getDate()+"/"+today.getFullYear());
}
function calendarPopup(date, functionName) {
var popupURL = "?calendarDate=" + date + "&functionName=" + functionName;
openNamedWindow(popupURL, "Calendar_Window", 220, 220 );
}
/* Tab code */
var panels = new Array('panel1', 'panel2', 'panel3', 'panel4', 'panel5', 'panel6');
var tabs = new Array('tab1', 'tab2', 'tab3', 'tab4', 'tab5', 'tab6');
var selectedTab = null;
function showPanel(tab, name)
{
if (selectedTab)
{
selectedTab.className = 'tab';
selectedTab.style.paddingTop = '';
selectedTab.style.paddingBottom = '';
}
else {
for(j = 0; j < tabs.length; j++)
{
if (document.getElementById(tabs[j]))
document.getElementById(tabs[j]).className='tab';
}
}
selectedTab = tab;
selectedTab.className = 'tabSelected';
for(i = 0; i < panels.length; i++)
{
document.getElementById(panels[i]).style.display = (name == panels[i]) ? 'block':'none';
}
return false;
}
// dropdown menu for left nav Jump To code
ns4 = document.layers
ie4 = document.all
nn6 = document.getElementById && !document.all
function hideObject()
{if (ns4)
{document.n1.visibility = "hide";
document.n1.display = "none"; }
else if (ie4) {
document.all['n1'].style.visibility = "hidden";
document.all['n1'].style.display = "none"; }
else if (nn6) {
document.getElementById('n1').style.visibility = "hidden";
document.getElementById('n1').style.display = "none"; }
}
// Show/Hide functions for pointer objects
function showObject(id) {
if (ns4) {
document.n1.visibility = "show";
document.n1.display = "block"; }
else if (ie4) {
document.all['n1'].style.visibility = "visible";
document.all['n1'].style.display = "block"; }
else if (nn6) {
document.getElementById('n1').style.visibility = "visible";
document.getElementById('n1').style.display = "block"; }
}
// menu rollover code
window.onload = function()
{
freeFloatingArr = document.getElementById("ffm") ? document.getElementById("ffm").getElementsByTagName("DIV") : [];
freeFloatingMenu();
}
function freeFloatingMenu()
{
for (i = 0; i < freeFloatingArr.length; i++)
{
if (freeFloatingArr[i].className == "ffm_drop_wrapper")
{
// render dropshadow(s) and menu offset
freeFloatingArr[i].getElementsByTagName("div")[0].style.width = freeFloatingArr[i].getElementsByTagName("li")[0].offsetWidth + 2 + "px";
freeFloatingArr[i].getElementsByTagName("div")[0].style.height = freeFloatingArr[i].getElementsByTagName("li")[0].offsetHeight + 2 + "px";
freeFloatingArr[i].getElementsByTagName("div")[1].style.width = freeFloatingArr[i].getElementsByTagName("div")[0].offsetWidth + 2 + "px";
freeFloatingArr[i].getElementsByTagName("div")[1].style.height = freeFloatingArr[i].getElementsByTagName("div")[0].offsetHeight + 1 + "px";
freeFloatingArr[i].getElementsByTagName("div")[1].style.left = "-1px";
if (freeFloatingArr[i].getElementsByTagName("li")[0].className.indexOf("right") != -1)
{
freeFloatingArr[i].getElementsByTagName("li")[0].style.left = freeFloatingArr[i].getElementsByTagName("img")[0].offsetWidth - freeFloatingArr[i].getElementsByTagName("li")[0].offsetWidth + "px";
}
// attach mouseover events
freeFloatingArr[i].onmouseover = function()
{
if (typeof hideMenuTimeout != "undefined")
{
window.clearTimeout(hideMenuTimeout);
menuHide.objRef = prevMenu;
if (prevMenu != this.getElementsByTagName("li")[0])
{
menuHide();
}
}
menuShow.objRef = this.getElementsByTagName("li")[0];
showMenuTimeout = window.setTimeout("menuShow()",500);
}
freeFloatingArr[i].onmouseout = function()
{
window.clearTimeout(showMenuTimeout);
menuHide.objRef = this.getElementsByTagName("li")[0];
hideMenuTimeout = window.setTimeout("menuHide()",1000);
prevMenu = this.getElementsByTagName("li")[0];
}
}
}
}
var menuShow = function()
{
menuShow.objRef.style.visibility = "visible";
updateSelectVisibility("hidden");
}
var menuHide = function()
{
menuHide.objRef.style.visibility = "hidden";
updateSelectVisibility("visible");
}
function updateSelectVisibility(vis) {
// only do this if we're running under IE6
if (navigator.userAgent.search("MSIE 6.")>-1){
var selects = document.getElementsByTagName("select");
if (selects != null) {
for (i=0;i0&&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&&i0&&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";
document.getElementById("productImage").innerHTML = url;
/* Change swatch status */
var statusContent;
for (var i = 0; i < imgSize; i++) {
var variantId = "swatch" + i;
if (variantId != swatchId) {
statusContent = document.getElementById(variantId).innerHTML;
statusContent = statusContent.replace("_on.gif", "_off.gif");
document.getElementById(variantId).innerHTML = statusContent;
} else {
statusContent = document.getElementById(swatchId).innerHTML;
statusContent = statusContent.replace("_off.gif", "_on.gif");
document.getElementById(swatchId).innerHTML = statusContent;
}
}
}