// Replace the images inside the double-quotes to your own images
// You may have any number of images
adImages = new Array("../images/ad1.jpg","../images/ad2.jpg","../images/ad3.jpg","../images/ad4.jpg","../images/ad5.jpg")

// Replace the quotes to inside the double-quotes to your own quotes
// You may have any number of quotes but they must equal the number of images that rotate
quote = new Array("Brass Registers","Airflow Booster","Smoke & Monoxide Alarm","Universal Thermostat","Airflow Booster")

// Please remove this lineand the double-slashes at the beginning of the next line to add links to the rotating images
adURL = new Array ("www.atlantasupply.com/swscripts/NLNETUPD.OBJ?REQR_TYPE=O&REQR_ID=NEW+CUSTOMER&AUTH_ID=+&LOC_NO=001&NL_ORDER_NO=&PROD_CAT_NM=Brass+Registers+Special+Deal&PC=SC&SC=CS&REQUEST_ID=CCATSEL_AS2","www.atlantasupply.com/swscripts/NLNETUPD.OBJ?REQR_TYPE=O&REQR_ID=NEW+CUSTOMER&AUTH_ID=+&LOC_NO=001&STOCK_NO=EQ2&REQUEST_ID=CSTKDET","www.atlantasupply.com/swscripts/NLNETUPD.OBJ?REQR_TYPE=O&REQR_ID=NEW+CUSTOMER&AUTH_ID=+&LOC_NO=001&STOCK_NO=SD12000+++++++++&REQUEST_ID=CSTKDET","www.atlantasupply.com/swscripts/NLNETUPD.OBJ?REQR_TYPE=O&REQR_ID=NEW+CUSTOMER&AUTH_ID=+&LOC_NO=001&STOCK_NO=TS1F85+++++++++&REQUEST_ID=CSTKDET","www.atlantasupply.com/swscripts/NLNETUPD.OBJ?REQR_TYPE=O&REQR_ID=NEW+CUSTOMER&AUTH_ID=+&LOC_NO=001&STOCK_NO=EQ2&REQUEST_ID=CSTKDET")
adURLNL = new Array ("&LOC_NO=001&PROD_CAT_NM=Brass+Registers+Special+Deal&PC=SC&SC=CS&REQUEST_ID=CCATSEL_AS2","&LOC_NO=001&STOCK_NO=EQ2&REQUEST_ID=CSTKDET","&LOC_NO=001&STOCK_NO=SD7000+++++++++&REQUEST_ID=CSTKDET","&LOC_NO=001&STOCK_NO=TS1F85+++++++++&REQUEST_ID=CSTKDET","&LOC_NO=001&STOCK_NO=EQ2&REQUEST_ID=CSTKDET")
// Please remove this line to add links to the rotating images

thisAd = 0
imgCt = adImages.length
quoteCt = quote.length

function rotate() {
  if (document.images) {
    if (document.cycle.complete) {
	  thisAd++
	  if (thisAd == imgCt && thisAd == quoteCt) {
	    thisAd = 0
	  }
	  document.cycle.src = adImages[thisAd];
      window.defaultStatus = quote[thisAd];
	}
// This sets the interval to which the images and quotes are rotated. 1000 equals 1 second
	setTimeout("rotate()", 60000)
  }
}

// Please remove this lineand the double-slashes at the beginning of the next line to add links to the rotating images
function rotateLink() {
var nlsession = getCookie('SESSION_NO');
if ((nlsession == null) || (nlsession.length < 2))
{
thelink="http://" + adURL[thisAd]
}
else
{
thelink="http://www.gunold.com/swscripts/nlnetupd.obj?SESSION_NO=" + nlsession + adURLNL[thisAd]
}

window.parent.location.href = thelink

}
// Please remove this line to add links to the rotating images

function formpass(theform) {
var nlsession=getCookie('SESSION_NO');
if (nlsession == null)
{
theform.submit();
}
else
{
theform.SESSION_NO.value=nlsession;
theform.REQR_ID.value='98';
theform.submit();
}
}

function cjb()
{
alert ('this is a test from cjb');
}
/*
function setCookie(name, value) {

DelCookie('SESSION_NO');
  document.cookie = "nlbase=http://www.gunold.com/swscripts/nlnetupd.obj?";

  var nlsession=getCookie('SESSION_NO');
  if (nlsession == null)
   {
    expires = new Date()
    expiresIn = 3600000
    expires.setTime(expires.getTime() + expiresIn)
    domain = ".gunold.com"
    path= "/"

    document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/; domain=.gunold.com";

    <!--secure = false-->
    <!--((expires == null) ? "" : "; expires=" + expires.toGMTString()) +  -->
    <!--((path == null)    ? "" : "; path=" + path) +  -->
    <!--((domain == null)  ? "" : "; domain=" + domain); -->
    <!--((secure == null)  ? "" : "; secure");-->


    <!--alert ('setting cookie value');-->
    <!--alert (document.cookie);-->
  }
  else
    {
    <!--alert ('cookie value was already set');-->
    }
}
else
{
}
}
*/

function setCookie(name, value){
  expires = new Date()
  expiresIn = 1000 * 60 * 750;
  expires.setTime(expires.getTime() + expiresIn)
  //domain = ".gunold.com"
  path= "/"
//  document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/; domain=.gunold.com";
  document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";

}

function setNew(name,value) {
expire = new Date()
expiresIn = 3600000
document.cookie = "nlbase=http://www.gunold.com/swscripts/nlnetupd.obj?";
 document.cookie = name + "=" + escape(value) +
  ((expires == 3600000) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == "/")    ? "" : "; path=" + path) +
  ((domain == ".gunold.com")  ? "" : "; domain=" + domain) +
  ((secure == null)  ? "" : "; secure");
}

function sayCookie(name)
  {
  myval = getCookie(name)
  alert (myval)
  }

function allCookie()
  {
  myval = document.cookie
  alert (myval)
  }
function setLink(nlvars1,nlvars2)
  {

  <!--nlbase="http://@VAR_FORM_ACTION_URL_@?"-->
  var baseref=getCookie('nlbase');
  var nlsession=getCookie('SESSION_NO');
  var link1=nlvars1
  var link2=nlvars2

    if (baseref == null)
	{
	baseref = "http://www.gunold.com/swscripts/nlnetupd.obj?"
	}

    if ((nlsession == null) || (nlsession.length < 2))
    {
    newlink = baseref + link1 + "&" + link2
    <!--alert ('session is null')-->
}
    else
    {
    <!--alert ('session is not null')-->
    newlink = baseref + "SESSION_NO=" + nlsession + "&" + link2
    }

  <!--alert (newlink); -->
  window.location=newlink;
  }

function getCookie(name)
  {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    <!--return unescape(dc.substring(begin + prefix.length, end));-->
    myval = unescape(dc.substring(begin + prefix.length, end));
/*alert("getting cookie: " + name + " value is: " + myval);*/
    return myval;
}

function test(){

alert("If you see this message the Javascript source file is fine");

}
function DelCookie(name)
{
domain = ".gunold.com"
path= "/"
document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/; domain=.gunold.com";

}
function linkbuild() {

var thelink = new String(parent.window.location);
var baseref=getCookie('nlbase');
thelink = thelink.replace(baseref,"");
var mystart = thelink.indexOf('SESSION_NO');
var myend = thelink.indexOf('&') + 1;
var remove = thelink.substring(mystart, myend);

thelink = thelink.replace(remove,"");

mystart = thelink.indexOf('NL_ORDER_NO');
myend = thelink.indexOf('&') + 1;
remove = thelink.substring(mystart,myend);

thelink = thelink.replace(remove,"");

var nlsession = getCookie(nlsession);

if (nlsession == null)
    {
    newlink = baseref + thelink;
    }
    else
    {
    newlink = baseref + "SESSION_NO=" + nlsession + "&" + thelink;
    }
new_window = open("","displayWindow","width=600,height=200,left=10,top=10");
new_window.document.write("<html><body><table width='100%' height='100%' border='0'><tr><a href=\"javascript:pushlink('" + newlink + "')\">javascript:pushlink('" + newlink + "')</a></td></tr></table></body></html>");

}

function pushlink(thelink) {

var passlink = new String(thelink);
var baseref=getCookie('nlbase');
var nlsession=getCookie('SESSION_NO');

    if (nlsession == null)
    {
    newlink = passlink

    }
    else
    {

    newlink = passlink + "&SESSION_NO=" + nlsession
    }

parent.window.location = newlink;
}

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_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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function validateInt(theval, theform, thefield) {

if (isInteger(theval))
    {
      return true;
    }
    {
      alert('This field must be a whole number.')
      eval ('document.' + theform + "." + thefield + ".value = 1");
      return false;
      }

}

function isInteger (s)
   {
      var i;

      if (isEmpty(s))
      if (isInteger.arguments.length == 1) return true;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }

   function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }

   function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }

function whichScript() {

alert('This script file is located at /\/\southware/\Southware/\swm\/CGI-BIN/\script.js');
}


function setNewCookie(name,value) {

    expires = new Date()
    expiresIn = 3600000
    expires.setTime(expires.getTime() + expiresIn)
    domain = ".gunold.com"
    path= "/"
    document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/; domain=.gunold.com";

}

function makeRequest(url) {
var http_request = false;
    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        return false;
    }
    <!--http_request.onreadystatechange = alertContents;-->
    http_request.open('GET', url, false);
    http_request.send(null);

}

function sendOrderConf(nlorder, mailcc, mailfrom) {

var mailto = getCookie('email');
var myurl = "http://www.gunold.com/nlhtml/gu_nlhtml/gunlorder.asp?nlorder=" + nlorder + "&MailTo=" + mailto + "&MailCC=" + mailcc + "&MailFrom=" + mailfrom;
makeRequest(myurl);

}

function setLinkHome(nlvars1,nlvars2)
  {

  <!--nlbase="http://@VAR_FORM_ACTION_URL_@?"-->
  var baseref=getCookie('nlbase');
  var nlsession=getCookie('SESSION_NO');
  var link1=nlvars1
  var link2=nlvars2

    if (baseref == null)
	{
	baseref = "http://www.gunold.com/swscripts/nlnetupd.obj?"
	}

    if ((nlsession == null) || (nlsession.length < 2))
    {
    newlink = baseref + link1 + "&" + link2 + "&REQUEST_ID=MAIN"
    <!--alert ('session is null')-->
}
    else
    {
    <!--alert ('session is not null')-->
    newlink = baseref + "SESSION_NO=" + nlsession + "&" + link2 + "&REQUEST_ID=MAIN2"
    }

  <!--alert (newlink); -->
  window.location=newlink;
  }

function setCookieFromDiv(id,cName) {

var objDiv = document.getElementById(id);

if (!(objDiv)) {
	return false;
	}

var cValue = objDiv.value;
setNewCookie(cName,cValue);

}

function deleteCookie(name) {
	document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/;";
}

function validateInteger(el) {
if(!(isInteger(el.value))) {
  alert('This field must be a whole number.')
  el.value = 0;
  return false;
}
}

function qtyChange(el) {
//alert('Any scripts added here are called upon QTY change.')
validateInteger(el);

confirmResaleCertificate(el); //UNCOMMENT THIS WHEN READY - CJB
}

function popUPConfirmResaleCertificate(el) {
if((getCookie("resale_cert") =="true") || (getCookie("resale_cert") == "links") || (getCookie("resale_cert") == "pdf")) return true;
el.value = 0;
var newwindow = window.open('http://www.gunold.com/nlhtml/gu_nlhtml/resale_cert.htm','resale_cert','height=500,width=500,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=no');
newwindow.focus();
}

function jumpAnchor(sAnchor) {
var sCurrentHash = window.location.hash;
var sCurrentURL = window.location.href;
var rg=new RegExp(sCurrentHash,'i');

if(sCurrentURL.search(rg) != -1) {
  sReplaceRG = new RegExp(sCurrentHash, 'gi');
  var sNewURL = sCurrentURL.replace(sReplaceRG,"");
}
window.location = sNewURL + sAnchor;
}

function confirmResaleCertificate(el) {
if((getCookie("resale_cert") =="true") || (getCookie("resale_cert") == "links") || (getCookie("resale_cert") == "pdf")) return true;
//el.value = 0
loadCenterDiv("500","500","lightbox-certificate", "lightbox");
}

function loadCenterDiv(Xwidth,Yheight,divid,newclass){
// First, determine how much the visitor has scrolled

var scrolledX, scrolledY;
if( self.pageYoffset ) {
scrolledX = self.pageXoffset;
scrolledY = self.pageYoffset;
} else if( document.documentElement && document.documentElement.scrollTop ) {
scrolledX = document.documentElement.scrollLeft;
scrolledY = document.documentElement.scrollTop;
} else if( document.body ) {
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrollTop;
}

// Next, determine the coordinates of the center of browser's window

var centerX, centerY;
if( self.innerHeight ) {
centerX = self.innerWidth;
centerY = self.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
centerX = document.documentElement.clientWidth;
centerY = document.documentElement.clientHeight;
} else if( document.body ) {
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
}

// Xwidth is the width of the div, Yheight is the height of the
// div passed as arguments to the function:
var leftoffset = scrolledX + (centerX - Xwidth) / 2;
var topoffset = scrolledY + (centerY - Yheight) / 2;
// The initial width and height of the div can be set in the
// style sheet with display:none; divid is passed as an argument to // the function

var o=document.getElementById(divid);
var r=o.style;
r.position='absolute';
r.top = topoffset + 'px';
r.left = leftoffset + 'px';
r.display = "block";

if(newclass) o.className = newclass;
}


function hideDiv(el) {
if(document.getElementById(el)) {
   document.getElementById(el).style.display="none";
}
}

function validateCertificate(oForm) {
if((getCookie("resale_cert") =="true") || (getCookie("resale_cert") == "links") || (getCookie("resale_cert") == "pdf")) return true;
loadCenterDiv("500","500","lightbox-certificate", "lightbox");
return false;
}