// ----------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){
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/default_images" + arguments[i]);
   }
}


//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('./page_holder.htm','viewer','height=300,width=400,left=200,top=50,toolbar=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,hotkeys=1');
coupon.document.write("<html>\n");
coupon.document.write(" <head>\n");
coupon.document.write("  <title>coupon</title>\n");
coupon.document.write("  <link onload=\"javascript:window.print();\" href=\"\/http:\/\/www.myerstires.com\/css\/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\">\n");
coupon.document.write("     <table width=\"380\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"coupon-print-border\"></td>\n");
coupon.document.write("      <tr>\n");
coupon.document.write("       <td valign=\"top\">\n");
coupon.document.write("        <table width=\"378\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"></td>\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>\n"); 
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>" + 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=\"close\" type=\"button\" onClick=\"window.close();\" value=\"Close\"></td>\n");
coupon.document.write("         </tr>\n");
coupon.document.write("        </table>\n");
coupon.document.write("       </td>\n");
coupon.document.write("      </tr>\n");
coupon.document.write("     </table>\n");
coupon.document.write("    </td>\n");
coupon.document.write("   </tr>\n");
coupon.document.write("  </table>\n");
coupon.document.write(" </body>\n");
coupon.document.write("</html>\n");
}

//Dreamweaver preloader and image swap

function MM_swapImgRestore() { 
  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() { 
  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) { 
  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() { 
  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];}
}