/***********************************************
* Ajax Rotating Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//To include a page, invoke ajaxinclude(files_array, "ROTATETYPE") in the BODY of page.
//* file_array is the name of the array containing your list of files to include.
//* For "ROTATETYPE", valid values are "dailyw", "dailym", and "random", for each day of the week, each day of the month, and random, respectively.
//* Included file MUST be from the same domain as the page displaying it.

//Enter path to list of files to display.
//For rotatetype="dailyw", there must be 7 files, and for "dailym", 31 files. Otherwise, no restriction:

var includefiles=[


/* ***** Auction Ads ***** 
"ads/Auction_Ads/AuctionAds.html", */

/* ***** Commission Junction Advertisers  (4)  ***** */
"ads/Commission_Junction/Absinthe_Supply.html",
"ads/Commission_Junction/Clubs_of_America.html",
"ads/Commission_Junction/Mr_Beer.html",
//"ads/Commission_Junction/Wisconsin_Cheeseman.html",

/* ***** Google Affiliate Advertisers (5) ***** */
//"ads/Google_Affiliate/BarnesandNoble.html",
"ads/Google_Affiliate/MyOwnLabels.html",
//"ads/Google_Affiliate/Wine_Express.html",
//"ads/Google_Affiliate/Zagat.html",

/* ***** LinkShare Advertisers  (25)  ***** */
//"ads/LinkShare/Camping_World.html",
//"ads/LinkShare/International_Wine.html",
"ads/LinkShare/KegWorks.html",
//"ads/LinkShare/MyWines.html",
//"ads/LinkShare/SeaBear_Smokehouse.html",
//"ads/LinkShare/Soda_Club_USA.html",
//"ads/LinkShare/The_Wine_Messenger.html",
//"ads/LinkShare/Wine.html",

/* ***** ShareASale.com Advertisers ***** */
"ads/ShareASale/ABestKitchen.html",
"ads/ShareASale/MakeBeer.html",
//"ads/ShareASale/ReStockIt.html",

/* ***** TheBrewBlog Store ***** */
"ads/TheBrewBlog/TheBrewBlog_Store.html",

/* ***** WidgetBucks.com ***** */
//"ads/WidgetBucks/WidgetBucks.html",


]

var rootdomain="http://"+window.location.hostname

function ajaxinclude(files_array, rotatetype){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
var url=choosefile(files_array, rotatetype)
if (typeof files_array[url]=="undefined"){
document.write("Error: No file for this advertiser has been found.")
return
}
else
url=files_array[url]
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}

function choosefile(files_array, rotatetype){
var today=new Date()
var selectedfile=(rotatetype=="dailyw")? today.getDay() : rotatetype=="dailym"? today.getDate() : Math.floor(Math.random()*files_array.length)
if (rotatetype=="dailyw" && selectedfile==0) //if display type=="week days" and today is Sunday 
selectedfile=7
if (rotatetype=="dailyw" || rotatetype=="dailym")
selectedfile--  //remove 1 to sync with array index
return selectedfile
}
