// JavaScript Document

//SlideShow

//Set Slideshow speed
var slideShowSpeed = 5000;
//Set Slideshow Fade Durration
var crossFadeDuration = 10;
var slideTimeOut;
var slideCount = 0;
var preLoad= new Array();
var slidePlace;
var path;

//Get the path to root

function setPath(PATH_TO_ROOT){
if (PATH_TO_ROOT == "PATH_TO_ROOT"){
	path = null;
	} else {
	path=PATH_TO_ROOT;
	}
}

function slideShow () {
   var i;
   slidePlace=slideShow.arguments.length;
   for (i=0; i < slidePlace; i++) {
      preLoad[i]=new Image();
      preLoad[i].src=("siteImages/"+arguments[i]);
   }
  runSlideShow()
}

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[slideCount].src;
   if (document.all){
     document.images.SlideShow.filters.blendTrans.Play();
   }
   slideCount = slideCount + 1;
   if (slideCount > (slidePlace-1)){
   	   slideCount=0; 
      slideTimeOut = setTimeout('runSlideShow()', slideShowSpeed); }
}

function loadGallery (IMAGES) {
gallery= new Array();
var i;
for (i=0; i < loadGallery.arguments.length; i++) {
      gallery[i]=new Image();
      gallery[i].src=("siteImages/" + arguments[i]);
   }
}

function showStatus(message){
window.status = message;
}


//Gallery Pop up

function galleryPopup(IMAGE) {
//load image into image object
pic = new Image();
pic.src = ("siteImages/" + IMAGE);
//Create popup window with image and close button
viewer=window.open('','viewer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=100,height=100,left=200,top=50');
viewer.document.open();
viewer.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
viewer.document.write("<html>\n");
viewer.document.write("<head>\n");
viewer.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\r");
viewer.document.write("<title>Gallery</title>\n");
viewer.document.write("<link href=\"css/gallery.css\" rel=\"stylesheet\" type=\"text/css\"/>\n");
viewer.document.write("<script language=\"javascript\" type=\"text/javascript\"><!--\n");
viewer.document.write("function resize() {\n");
viewer.document.write("  if (document.images[0]) window.resizeTo(document.images[0].width+75, document.images[0].height+100);\n");
viewer.document.write("  self.focus();\n");
viewer.document.write("}\n");
viewer.document.write("//--></script>\n");
viewer.document.write("</head>\n");
viewer.document.write("<body onload=\"resize();\" class=\"gallery_body\">\n");
viewer.document.write("<table align=\"center\" class=\"gallery_imagetable\">\n");
viewer.document.write("<tr>\n");
viewer.document.write("<td align=\"center\" valign=\"top\"><img src=\"siteImages/" + IMAGE + "\" alt=\"\"/></td>\n");
viewer.document.write("</tr>\n");
viewer.document.write("<tr>\n");
viewer.document.write("<td align=\"center\" valign=\"middle\"><a href=\"#\" onclick=\"window.close()\">- Click here to close window -</a></td>\n");
viewer.document.write("</tr>\n");
viewer.document.write("</table>\n");
viewer.document.write("</body>\n");
viewer.document.write("</html>\n");
viewer.document.close();


}


//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,title) {
var html ="<html>\n";
html+="<head>\n";
html+="<title>Coupon</title>\n";
html+="<script language=\"JavaScript\" src=\"includes/utilities.js\"></script>\n";
html+="<link href=\"css/sitebuilder_template.css\" rel=\"stylesheet\" type=\"text/css\">\n";
html+="</head>\n";
html+="<body class=\"coupon-print\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n";
html+="<table width=\"400\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">\n";
html+="<tr>\n";
html+="<td valign=\"top\"><table width=\"380\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"coupon-print-border\">\n";
html+="<tr>\n";
html+="<td valign=\"top\"><table width=\"378\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";
html+="<tr class=\"coupon-print-titlebar\">\n";
html+="<td colspan=\"2\" valign=\"top\"><p class=\"coupon-title\">" + companyname + "</p></td>\n";
html+="</tr>\n";
html+="<tr>\n";
html+="<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";
html+="<td width=\"228\" align=\"center\" valign=\"middle\"><p class=\"coupon-print-price\">"+title+"</p><p class=\"coupon-print-price\">" + price + "</p>\n";
html+="<p class=\"coupon-print-description\">" + description + "</p></td>\n";
html+="</tr>\n";
html+="<tr>"; 
html+="<td valign=\"top\" align=\"center\"><p class=\"coupon-print-exception\">" + exception + "</p></td>\n";
html+="</tr>\n";
html+="<tr>\n";
html+="<td align=\"center\" valign=\"top\"><p class=\"coupon-print-text\"><strong>Expires: " + expire + "</strong></p></td>\n";
html+="</tr>\n";
html+="<tr>\n"; 
html+="<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";
html+="</tr>\n";
html+="</table></td>\n";
html+="</tr>\n";
html+="</table></td>\n";
html+="</tr>\n";
html+="</table>\n";
html+="</body>\n";
html+="</html>\n";
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);
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;
} 
}