var fadeimages=new Array()

// Image Rotation - Normal
// fadeimages[0]=["path/to/image.jpg", "path/to/default.htm", "Link Text"]

var feature1_Year = "2012"     // Year you want your content to start displaying. Four digits.
var feature1_Month = "01"  // Month you want your content to start displaying. Two digits.
var feature1_Day = "05"      // Day you want your content to start displaying. Two digits.

var feature2_Year = "2012"     // Year you want your content to start displaying. Four digits.
var feature2_Month = "12"  // Month you want your content to start displaying. Two digits.
var feature2_Day = "01"      // Day you want your content to start displaying. Two digits.

var feature3_Year = "2012"     // Year you want your content to start displaying. Four digits.
var feature3_Month = "12"  // Month you want your content to start displaying. Two digits.
var feature3_Day = "30"      // Day you want your content to start displaying. Two digits.

var default_Year = "2012"  // Year you want your content to stop displaying. Four digits.
var default_Month = "12"   // Month you want your content to stop displaying. Two digits.
var default_Day = "31"     // Day you want your content to stop displaying. Two digits.

// Added #2, #3 for running current, future x2 and then expired ads for banner
var feature1_Date = feature1_Year + feature1_Month + feature1_Day;  // puts START year, month, and day together.
var feature2_Date = feature2_Year + feature2_Month + feature2_Day;  // puts START year, month, and day together.
var feature3_Date = feature3_Year + feature3_Month + feature3_Day;  // puts START year, month, and day together.
var default_Date = default_Year + default_Month + default_Day;  // puts EXPIRE year, month, and day together.

var nowDate = new Date();
var day = nowDate.getUTCDate();
var month = nowDate.getUTCMonth();
var correctedMonth = month + 1;  //month - JavaScript starts at "0" for January, so we add "1"

if (correctedMonth < 10) {  /* if less than "10", put a "0" in front of the number. */
  correctedMonth = "0" + correctedMonth;
}
   
if (day < 10) {  /* if less than "10", put a "0" in front of the number. */
  day = "0" + day;
}

var year = nowDate.getYear();  /* Get the year. Firefox and Netscape might use century bit, and two-digit year. */
if (year < 1900) {
  year = year + 1900;  /*This is to make sure Netscape AND FireFox doesn't show the year as "107" for "2007." */
}

var GMTdate = year + "" + correctedMonth + "" + day;  //corrected month GMT date.


// --- Feature 1: Scheduled Banner ----------------------

// original --> if ((GMTdate <= default_Date) && (GMTdate >= goLiveDate)) {	
if ((GMTdate < default_Date) && (GMTdate < feature3_Date) && (GMTdate < feature2_Date) && (GMTdate >= feature1_Date)) {
	// http://www.holidayrambler.com/holidayrambler/products/endeavor
	fadeimages[0]=["images/home/2012endeavor-intro.jpg", "http://www.sicardrv.com/inventory/rv-details.asp?VEHICLE_NO=402598", "Introducting the new 2012 Endeavor by Holiday Rambler!"]
	fadeimages[1]=["images/home/2012endeavor-intro.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2012&syeart=2012&sstatus=%25New%25&ssearch=Endeavor&stype=&DoSearch=&ssdealerno=4000", "Introducting the new 2012 Endeavor by Holiday Rambler!"]
	fadeimages[2]=["images/home/fleetwoodprograms.jpg", "http://www.sicardrv.com/sales_specials.asp", "Fleetwood Owner Loyalty &amp; Referral Programs!"]
	fadeimages[3]=["images/home/fleetwoodloyalty.jpg", "http://www.sicardrv.com/sales_specials.asp", "Fleetwood Owner Loyalty &amp; Referral Programs!"]
	fadeimages[4]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
	fadeimages[5]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
}

// --- Feature 2: Scheduled Banner ----------------------

else if ((GMTdate < default_Date) && (GMTdate < feature3_Date) && (GMTdate >= feature2_Date)) {
	fadeimages[0]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
	fadeimages[1]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
}


// --- Feature 3: Scheduled Banner ----------------------

else if ((GMTdate < default_Date) && (GMTdate >= feature3_Date)) {
	fadeimages[0]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
	fadeimages[1]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
}


// --- Default: Default Banner ----------------------

else if (GMTdate >= default_Date) {
	fadeimages[0]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
	fadeimages[1]=["images/home/201112jaycosale.jpg", "http://www.sicardrv.com/inventory/RV-Inventory.asp?syearf=2011&syeart=2011&sstatus=%25New%25&ssearch=Jayco&DoSearch=&ssdealerno=4000", "All new 2011 Jayco's have been repriced and are now on sale!"]
}


//else if (GMTdate >= default_Date) {
//fadeimages[0]=["images/home/featuredunit.jpg", "http://www.sicardrv.com/sales_specials.asp", "Click here to see our Featured Units!"]
//fadeimages[1]=["images/home/partsstore1.jpg", "http://www.sicardrv.com/inventory/parts-inventory.asp", "Click here to visit our online Parts Store!"]
//fadeimages[2]=["images/home/b_1.jpg", "", ""]
//fadeimages[3]=["images/home/b_2.jpg", "", ""]
//fadeimages[4]=["images/home/b_3.jpg", "", ""]
//fadeimages[5]=["images/home/b_4.jpg", "", ""]
//fadeimages[6]=["images/home/b_5.jpg", "", ""]
//fadeimages[7]=["images/home/facebook.jpg", "http://www.facebook.com/SicardRV", "Click here to follow us on Facebook!"]
//fadeimages[8]=["images/home/twitter.jpg", "http://www.twitter.com/SicardRV", "Click here to follow us on Twitter!"]
//}


var fadebgcolor="black"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
//Open Link in New Window
//slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'

//Opens Link in Current Window
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="_self">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
// crossobj.style.KhtmlOpacity=obj.degree/100
crossobj.style.KhtmlOpacity=this.degree/100
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}

