/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* This copyright notice must stay intact for legal use
* Modified for autowidth and optional starting positions in
* http://www.dynamicdrive.com/forums/showthread.php?t=11839 by jschuer1 8/5/06
***********************************************/

 //1) Set width of the "neutral" area in the center of the gallery.
var restarea=6;
 //2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed=6;
 //3) Set to maximum width for gallery - must be less than the actual length of the image train.
var maxwidth=1000;
 //4) Set to 1 for left start, 0 for right, 2 for center.
var startpos=2;
 //5) Set message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg='<span style="font-size: 11px;">Click to start your appliance part search</span>';

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

////NO NEED TO EDIT BELOW THIS LINE////////////

var iedom=document.all||document.getElementById, scrollspeed=0, movestate='', actualwidth='', cross_scroll, ns_scroll, statusdiv, loadedyes=0, lefttime, righttime;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function creatediv(){
statusdiv=document.createElement("div")
statusdiv.setAttribute("id","statusdiv")
document.body.appendChild(statusdiv)
statusdiv=document.getElementById("statusdiv")
statusdiv.innerHTML=endofgallerymsg
}

function positiondiv(){
var mainobjoffset=getposOffset(crossmain, "left"),
menuheight=parseInt(crossmain.offsetHeight),
mainobjoffsetH=getposOffset(crossmain, "top");
statusdiv.style.left=mainobjoffset+(menuwidth/2)-(statusdiv.offsetWidth/2)+"px";
statusdiv.style.top=menuheight+mainobjoffsetH+"px";
}

function showhidediv(what){
if (endofgallerymsg!="") {
positiondiv();
statusdiv.style.visibility=what;
}
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function moveleft(){
if (loadedyes){
movestate="left";
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
lefttime=setTimeout("moveleft()",10);
}

function moveright(){
if (loadedyes){
movestate="right";
if (iedom&&parseInt(cross_scroll.style.left)<0){
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
righttime=setTimeout("moveright()",10);
}

function motionengine(e){
var mainobjoffset=getposOffset(crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=mainobjoffset-dsocx;
var leftbound=(menuwidth-restarea)/2;
var rightbound=(menuwidth+restarea)/2;
if (curposy>rightbound){
scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(righttime);
if (movestate!="left") moveleft();
}
else if (curposy<leftbound){
scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(lefttime);
if (movestate!="right") moveright();
}
else
scrollspeed=0;
}


function contains_ns6(a, b) {
if (b!==null)
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function stopmotion(e){
if (!window.opera||(window.opera&&e.relatedTarget!==null))
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
clearTimeout(lefttime);
clearTimeout(righttime);
movestate="";
}
}


function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer;
if(typeof crossmain.style.maxWidth!=='undefined')
crossmain.style.maxWidth=maxwidth+'px';
menuwidth=crossmain.offsetWidth;
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery;
actualwidth=document.getElementById? document.getElementById("trueContainer").offsetWidth : document.all['trueContainer'].offsetWidth;
if (startpos)
cross_scroll.style.left=(menuwidth-actualwidth)/startpos+'px';
crossmain.onmousemove=function(e){
motionengine(e);
}




crossmain.onmouseout=function(e){
stopmotion(e);
showhidediv("hidden");
}
}
loadedyes=1
if (endofgallerymsg!=""){
creatediv();
positiondiv();
}
if (document.body.filters)
onresize()
}
window.onload=fillup;

onresize=function(){
if (typeof motioncontainer!=='undefined'&&motioncontainer.filters){
motioncontainer.style.width="0";
motioncontainer.style.width="";
motioncontainer.style.width=Math.min(motioncontainer.offsetWidth, maxwidth)+'px';
}
menuwidth=crossmain.offsetWidth;
cross_scroll.style.left=startpos? (menuwidth-actualwidth)/startpos+'px' : 0;
}

<!--
	var mac = navigator.appVersion.indexOf("Mac")>-1 
	var opera = navigator.userAgent.indexOf("Opera")>-1 
	
if (navigator.appName == "Netscape" && parseFloat(navigator.appVersion) < 5.00 && !mac){
			document.write ("<link rel=\"stylesheet\" href=\"/retail/ns_style_v5.css\" type=\"text/css\">")
	} else {
	document.write ("<link rel=\"stylesheet\" href=\"/retail/ie_style_v5.css\" type=\"text/css\">")
}
//-->
<!--  
		//document.write (navigator.appName + '###' + navigator.userAgent) 
		//document.write("The value of navigator.appCodeName is " + navigator.appName) 
var displaySage = true 
var mac = navigator.appVersion.indexOf("Mac")>-1 
var loc = window.location 
if ((navigator.userAgent.indexOf("Netscape6/6.1") != -1) || (loc.hostname.indexOf("netsagecentral.com") != -1) || mac) { 
		displaySage = false 
} 
//--> 
 
function ReviewSearch() {       
                        var cKeyword = document.fmodlookup.modelnum.value; 
                        var cSearchType, nManufacturers_id, cManufacturerCode; 
                        var i; 
 
                        if(cKeyword.length < 3) { 
                                alert('Please enter a model number of at least 3 characters.'); 
                                document.fmodlookup.modelnum.focus(); 
                                return false; 
                        } 
 
        return true; 
 
} 
function ReviewParts() {        
                        var cKeyword = document.fpartlookup.prod.value; 
                        var cSearchType, nManufacturers_id, cManufacturerCode; 
                        var i; 
 
                        if(cKeyword.length < 1) { 
                                alert('The part number search field was left blank.  Please enter a valid part number.'); 
                                document.fpartlookup.prod.focus(); 
                                return false; 
                        } 
 
        return true; 
 
} 

<!-- Child Wnd -->
var childWnd; 
function openBC(varSettings) 
{ 
childWnd = open('http://www.apwagner.com.asp?settings=' +  
varSettings,'childWindow','toolbar=no,scrollbars=yes,resizable=no,width=570,height=600,top=120,left=150') 
if (childWnd.opener == null) childWnd.opener = self; 
} 
<!-- END Child Wnd -->

<!-- Validate Submit -->
function validate_submit()
{ 
var thisForm = document.vendquery; 
thisForm.submit(); 
} 
 
function validate_update()
{ 
var thisForm = document.frmUpdate; 
thisForm.submit(); 
} 
 
function validate_form( formname )
{ 
var thisForm = formname; 
thisForm.submit(); 
} 
 
function validate_textfield() 
        { 
                var thisForm = document.partquery; 
                var search_text = thisForm.qpart.value; 
                if (search_text) 
                { 
                        thisForm.submit(); 
                        return true ; 
                } 
                else 
                { 
                        alert("Please enter a part number to search for"); 
                } 
                        } 

<!-- End Validate Submit --> 
 
<!-- Begin 
var sfname = ""; 
var slname = ""; 
var semail = ""; 
var sareacode = ""; 
var sphone1 = ""; 
var sphone2 = ""; 
var saddress = ""; 
var saddress2 = ""; 
var scity = ""; 
var sstate = ""; 
var scountry = ""; 
var sstateindex = 0; 
var scountryindex = 0; 
var szipcode = ""; 
var sfaxareacode = ""; 
var sfax1 = ""; 
var sfax2 = ""; 
 
function InitSaveVariables(form) { 
sfname = form.sfname.value; 
slname = form.slname.value; 
semail = form.semail.value; 
sareacode = form.sareacode.value; 
sphone1 = form.sphone1.value; 
sphone2 = form.sphone2.value; 
saddress = form.saddress.value; 
saddress2 = form.saddress2.value; 
scity = form.scity.value; 
szipcode = form.szipcode.value; 
sstateindex = form.sstate.selectedIndex; 
sstate = form.sstate[sstateindex].value; 
scountryindex = form.SCountryCode.selectedIndex; 
sfaxareacode = form.sfaxareacode.value; 
sfax1 = form.sfax1.value; 
sfax2 = form.sfax2.value; 
} 
 
function ShipToBillPerson(form) { 
if (form.shipsame.checked) { 
InitSaveVariables(form); 
form.sfname.value = form.bfname.value; 
form.slname.value = form.blname.value; 
form.semail.value = form.bemail.value; 
form.sareacode.value = form.bareacode.value; 
form.sphone1.value = form.bphone1.value; 
form.sphone2.value = form.bphone2.value; 
form.saddress.value = form.baddress.value; 
form.saddress2.value = form.baddress2.value; 
form.scity.value = form.bcity.value; 
form.szipcode.value = form.bzipcode.value; 
form.sstate.selectedIndex = form.bstate.selectedIndex; 
form.SCountryCode.selectedIndex = form.BCountryCode.selectedIndex; 
form.sfaxareacode.value = form.bfaxareacode.value; 
form.sfax1.value = form.bfax1.value; 
form.sfax2.value = form.bfax2.value; 
} 
else { 
form.sfname.value = sfname; 
form.slname.value = slname; 
form.semail.value = semail; 
form.sareacode.value = sareacode; 
form.sphone1.value = sphone1; 
form.sphone2.value = sphone2; 
form.saddress.value = saddress; 
form.saddress2.value = saddress2; 
form.scity.value = scity; 
form.szipcode.value = szipcode;        
form.sstate.selectedIndex = sstateindex; 
form.SCountryCode.selectedIndex = scountryindex; 
form.sfaxareacode.value = sfaxareacode; 
form.sfax1.value = sfax1; 
form.sfax2.value = sfax2; 
   } 
} 
//  End --> 

<!-- Pop Up
function popUp(url) { 
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450'); 
self.name = "mainWin"; 
} 
//  End Pop Up --> 


<!-- Begin  email Check
function emailCheck (emailStr) { 
/* The following pattern is used to check if the entered e-mail address 
   fits the user@domain format.  It also is used to separate the username 
   from the domain. */ 
var emailPat=/^(.+)@(.+)$/ 
/* The following string represents the pattern for matching all special 
   characters.  We don't want to allow special characters in the address.  
   These characters include ( ) < > @ , ; : \ " . [ ]    */ 
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 
/* The following string represents the range of characters allowed in a  
   username or domainname.  It really states which chars aren't allowed. */ 
var validChars="\[^\\s" + specialChars + "\]" 
/* The following pattern applies if the "user" is a quoted string (in 
   which case, there are no rules about which characters are allowed 
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com 
   is a legal e-mail address. */ 
var quotedUser="(\"[^\"]*\")" 
/* The following pattern applies for domains that are IP addresses, 
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal 
   e-mail address. NOTE: The square brackets are required. */ 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ 
/* The following string represents an atom (basically a series of 
   non-special characters.) */ 
var atom=validChars + '+' 
/* The following string represents one word in the typical username. 
   For example, in john.doe@somewhere.com, john and doe are words. 
   Basically, a word is either an atom or quoted string. */ 
var word="(" + atom + "|" + quotedUser + ")" 
// The following pattern describes the structure of the user 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$") 
/* The following pattern describes the structure of a normal symbolic 
   domain, as opposed to ipDomainPat, shown above. */ 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$") 
/* Finally, let's start trying to figure out if the supplied address is   valid. *//* Begin with the coarse pattern to simply break up user@domain into   different pieces that are easy to analyze. */var matchArray=emailStr.match(emailPat) 
if (matchArray==null) { 
  /* Too many/few @'s or something; basically, this address doesn't 
     even fit the general mould of a valid e-mail address. */ 
        alert("Email address seems incorrect (check @ and .'s)") 
        return false 
} 
var user=matchArray[1] 
 var domain=matchArray[2] 
// See if "user" is valid  
if (user.match(userPat)==null) { 
    // user is not valid 
    alert("The username doesn't seem to be valid.") 
    return false 
} 
/* if the e-mail address is at an IP address (as opposed to a symbolic 
    host name) make sure the IP address is valid. */ 
var IPArray=domain.match(ipDomainPat) 
if (IPArray!=null) { 
    // this is an IP address 
          for (var i=1;i<=4;i++) { 
            if (IPArray[i]>255) { 
                alert("Destination IP address is invalid!") 
                return false 
            } 
    } 
    return true 
} 
// Domain is symbolic name 
var domainArray=domain.match(domainPat) 
if (domainArray==null) { 
        alert("The email address domain name doesn't seem to be valid.") 
    return false 
} 
/* domain name seems valid, but now make sure that it ends in a   three-letter word (like com, edu, gov) or a two-letter word,   representing country (uk, nl), and that there's a hostname preceding    the domain or country. */ 
/* Now we need to break up the domain to get a count of how many atoms   it consists of. */ 
var atomPat=new RegExp(atom,"g") 
var domArr=domain.match(atomPat) 
var len=domArr.length 
if (domArr[domArr.length-1].length<2 ||  
    domArr[domArr.length-1].length>3) { 
   // the address must end in a two letter or three letter word. 
   alert("The email address must end in a three-letter domain, or two letter country.") 
   return false 
} 
// Make sure there's a host name preceding the domain. 
if (len<2) { 
   var errStr="This email address is missing a domain name" 
   alert(errStr) 
   return false 
} 
return true; 
} 
//  End --> 
<!-- Default input text clear on click
/* 
 * Cross-browser event handling, by Scott Andrew
 */
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

/* 
 * Kills an event's propagation and default action
 */
function knackerEvent(eventObject) {
    if (eventObject && eventObject.stopPropagation) {
        eventObject.stopPropagation();
    }
    if (window.event && window.event.cancelBubble ) {
        window.event.cancelBubble = true;
    }
    
    if (eventObject && eventObject.preventDefault) {
        eventObject.preventDefault();
    }
    if (window.event) {
        window.event.returnValue = false;
    }
}

/* 
 * Safari doesn't support canceling events in the standard way, so we must
 * hard-code a return of false for it to work.
 */
function cancelEventSafari() {
    return false;        
}

/* 
 * Cross-browser style extraction, from the JavaScript & DHTML Cookbook
 * <http://www.oreillynet.com/pub/a/javascript/excerpt/JSDHTMLCkbk_chap5/index5.html>
 */
function getElementStyle(elementID, CssStyleProperty) {
    var element = document.getElementById(elementID);
    if (element.currentStyle) {
        return element.currentStyle[toCamelCase(CssStyleProperty)];
    } else if (window.getComputedStyle) {
        var compStyle = window.getComputedStyle(element, '');
        return compStyle.getPropertyValue(CssStyleProperty);
    } else {
        return '';
    }
}

/* 
 * CamelCases CSS property names. Useful in conjunction with 'getElementStyle()'
 * From <http://dhtmlkitchen.com/learn/js/setstyle/index4.jsp>
 */
function toCamelCase(CssProperty) {
    var stringArray = CssProperty.toLowerCase().split('-');
    if (stringArray.length == 1) {
        return stringArray[0];
    }
    var ret = (CssProperty.indexOf("-") == 0)
              ? stringArray[0].charAt(0).toUpperCase() + stringArray[0].substring(1)
              : stringArray[0];
    for (var i = 1; i < stringArray.length; i++) {
        var s = stringArray[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1);
    }
    return ret;
}

/*
 * Disables all 'test' links, that point to the href '#', by Ross Shannon
 */
function disableTestLinks() {
  var pageLinks = document.getElementsByTagName('a');
  for (var i=0; i<pageLinks.length; i++) {
    if (pageLinks[i].href.match(/[^#]#$/)) {
      addEvent(pageLinks[i], 'click', knackerEvent, false);
    }
  }
}

/* 
 * Cookie functions
 */
function createCookie(name, value, days) {
    var expires = '';
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        var expires = '; expires=' + date.toGMTString();
    }
    document.cookie = name + '=' + value + expires + '; path=/';
}

function readCookie(name) {
    var cookieCrumbs = document.cookie.split(';');
    var nameToFind = name + '=';
    for (var i = 0; i < cookieCrumbs.length; i++) {
        var crumb = cookieCrumbs[i];
        while (crumb.charAt(0) == ' ') {
            crumb = crumb.substring(1, crumb.length); /* delete spaces */
        }
        if (crumb.indexOf(nameToFind) == 0) {
            return crumb.substring(nameToFind.length, crumb.length);
        }
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, '', -1);
}

/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements.
 */
addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\binput\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}

//  End --> 