// JavaScript Document - Monken Auto - 2-8-2010 DLB
// Copyright 2010 Creative Design POB 96 Centralia IL All Rights Reserved
// Integrated functions for rollovers and determining image size as per screen width

blnImg = document.images

function Create(Name) {
  Rollovers[Name]=new Rollover(Name);
}

function Setup(Name) {
  Replace[Name]=new sizeImg(Name);
}

function sizeImg(Name) {
	 this.name = Name;
	 this.smImg = new Image;
	 this.lgImg = new Image;
	 this.smImg.src = "images/AutoLogos.gif"
	 this.lgImg.src = "images/AutoLogos-lg.gif"
}

function Rollover(Name) {
    this.name       = Name;
	this.btnImg     = new Image;
	this.ovrImg     = new Image;
	this.btnImg.src = "images/btn-"+Name+".gif";
	this.ovrImg.src = "images/ovr-"+Name+".gif";
}
	
function Btn(Name) {
  if (blnImg) {
    document[Name].src = Rollovers[Name].btnImg.src;
  }
}

function Ovr(Name) {
  if (blnImg) {
    document[Name].src = Rollovers[Name].ovrImg.src;
  }
} 

function pageWidth() {
  return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 

function chooseImg(Name) {
  browserWidth = pageWidth();
  if(blnImg) {
	var imgmap = document.getElementById("autologos");
    if(browserWidth > 1248) {
		document[Name].src = Replace[Name].lgImg.src;
		imgmap.setAttribute("useMap","#autoMaplg");
	}
	else {
		document[Name].src = Replace[Name].smImg.src;
		imgmap.setAttribute("useMap","#autoMapsm");
	}
  }
}

if (blnImg) {
      Rollovers = new Object;
	  Create("home");
	  Create("newvehicles");
	  Create("usedvehicles");
	  Create("location");
	  Create("details");
	  Create("budget");
	  Create("financing");
	  Create("question");
	// Initiate auto logos images for size per window width
	  Replace = new Object;
	  Setup("autologos");
}

 