// _Utilities.js ----------

//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, Caption, Alt) {
//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=yes,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=utf-8\" />\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+150);\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=\""+ Alt +"\"/></td>\n");
viewer.document.write("</tr>\n");
viewer.document.write("<tr>\n");
viewer.document.write("<td align=\"center\" valign=\"middle\">" + Caption + "<br /><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 = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
html += "<html>";
html += "<head>";
html += "	<title>"+companyname+" Coupon</title>";
html += "	<link href=\"css/coupon_print.css\" rel=\"stylesheet\" type=\"text/css\" />";
html += "   <script language=\"JavaScript\" src=\"includes/utilities.js\"></script>\n";
html += "</head>";
html += "<body>";
html += "<div id=\"coupon-print-main\">";
html += "	<div id=\"coupon-print-titlebar\">"+companyname+"</div>";
html += "		<div id=\"coupon-print-body\">";
html += "		<div id=\"coupon-print-price\">"+price+"</div>";
html += "		<div id=\"coupon-print-description\">";
html += "			<div id=\"coupon-print-logo\"></div>"
html += description;	
html += "			<div id=\"coupon-print-exceptions\"><strong>Exceptions:</strong><br />"+exception+"</div>";
html += "		</div>";
html += "	</div>";
html += "	<div id=\"coupon-print-redeem\"><strong>This coupon is redeemable at:</strong><br />"
html += "		<strong>"+companyname+"</strong> -  "+street+" - "+city+", "+state+", "+zip;
html += "	</div>";
html += "	<div id=\"coupon-print-footer\">";
html += "		<div id=\"coupon-print-expires\">Expires: "+expire+"</div>";
html += "		<div id=\"coupon-print-print\"><a href=\"#\" onClick=\"printIt();\">Print This Coupon</a> - <a href=\"#\" onclick=\"window.close();\">Close Window</a></div>"
html += "	</div>";
html += "</div>";
html += "</body>";
html += "</html>";

coupon=window.open('','viewer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=450,height=400,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;
} 
}


//The version is used specificly for the styling.htm document. harcodes some test images so they don't need to be copied with every site.
function testPopup(IMAGE, Caption, Alt) {
//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=yes,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+150);\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=\"" + IMAGE + "\" alt=\""+ Alt +"\"/></td>\n");
viewer.document.write("</tr>\n");
viewer.document.write("<tr>\n");
viewer.document.write("<td align=\"center\" valign=\"middle\">" + Caption + "<br /><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();


}