﻿// ----------Utilities.js ---------- 
var path; //Get the path to root 
function setPath(PATH_TO_ROOT){
path=PATH_TO_ROOT;
} 

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this

// to add more images, just continue
// the pattern, adding to the array below

            Pic[0] = 'siteImages/slideshow.jpg'
            Pic[1] = 'siteImages/pro.jpg'
            Pic[2] = 'siteImages/lawn.jpg'


// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length
var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }

   j = j + 1

   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}


//Cross Browser Print
function printIt(){ 
if (window.print) {
window.print() ; 
} else {
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(6, 2); 
}
} 
function setStatus (MESSAGE) {
window.status = MESAGE;
}
//Coupon Popup 
function couponPopup(companyname,street,city,state,zip,price,description,exception,expire) {
coupon=window.open('','viewer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=300,left=200,top=50');
coupon.document.open();
coupon.document.write("<html>\n");
coupon.document.write("<head>\n");
coupon.document.write("<title>Coupon</title>\n");
coupon.document.write("<script language=\"JavaScript\" src=\"includes/utilities.js\"></script>\n");
coupon.document.write("<link href=\"" + path + "css/sitebuilder_template.css\" rel=\"stylesheet\" type=\"text/css\">\n");
coupon.document.write("</head>\n");
coupon.document.write("<body class=\"coupon-print\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n");
coupon.document.write("<table width=\"400\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">\n");
coupon.document.write("<tr>\n");
coupon.document.write("<td valign=\"top\"><table width=\"380\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"coupon-print-border\">\n");
coupon.document.write("<tr>\n");
coupon.document.write("<td valign=\"top\"><table width=\"378\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n");
coupon.document.write("<tr class=\"coupon-print-titlebar\">\n");
coupon.document.write("<td colspan=\"2\" valign=\"top\"><p class=\"coupon-title\">" + companyname + "</p></td>\n");
coupon.document.write("</tr>\n");
coupon.document.write("<tr>\n");
coupon.document.write("<td width=\"150\" rowspan=\"4\" valign=\"middle\"><p class=\"coupon-print-text\"><strong>Redeemable At:</strong><br>" + street +"<br>" + city + ", " + state+ ", " + zip +"</p></td>\n");
coupon.document.write("<td width=\"228\" align=\"center\" valign=\"middle\"><p class=\"coupon-print-price\">" + price + "</p>\n");
coupon.document.write("<p class=\"coupon-print-description\">" + description + "</p></td>\n");
coupon.document.write("</tr>\n");
coupon.document.write("<tr>"); 
coupon.document.write("<td valign=\"top\" align=\"center\"><p class=\"coupon-print-exception\">" + exception + "</p></td>\n");
coupon.document.write("</tr>\n");
coupon.document.write("<tr>\n");
coupon.document.write("<td align=\"center\" valign=\"top\"><p class=\"coupon-print-text\"><strong>Expires: " + expire + "</strong></p></td>\n");
coupon.document.write("</tr>\n");
coupon.document.write("<tr>\n"); 
coupon.document.write("<td align=\"right\" valign=\"middle\"><input name=\"Print\" type=\"button\" onClick=\"printIt()\" value=\"Print\"><input name=\"close\" type=\"button\" onClick=\"window.close()\" value=\"Close\"></td>\n");
coupon.document.write("</tr>\n");
coupon.document.write("</table></td>\n");
coupon.document.write("</tr>\n");
coupon.document.write("</table></td>\n");
coupon.document.write("</tr>\n");
coupon.document.write("</table>\n");
coupon.document.write("</body>\n");
coupon.document.write("</html>\n");
coupon.document.close();
} 
//Namo preloader and image swap 
function na_preload_img()
{ 
var img_list = na_preload_img.arguments;
if (document.preloadlist == null) 
document.preloadlist = new Array();
var top = document.preloadlist.length;
for (var i=0; i < img_list.length-1; i++) {
document.preloadlist[top+i] = new Image;
document.preloadlist[top+i].src = img_list[i+1];
} 
} 

function na_change_img_src(name, nsdoc, rpath, preload)
{ 
var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
if (name == '')
return;
if (img) {
img.altsrc = img.src;
img.src = rpath;
} 
} 

function na_restore_img_src(name, nsdoc)
{
var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
if (name == '')
return;
if (img && img.altsrc) {
img.src = img.altsrc;
img.altsrc = null;
} 
}
