/***********************************************
* 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 offer1=["/ajaxfiles/mini-convertible.htm", "/ajaxfiles/mini-cooper-s.htm", "/ajaxfiles/mini.htm",   "/ajaxfiles/volvo-c70-navigation.htm", "/ajaxfiles/mini-121208.htm","/ajaxfiles/bmw/bmw-1series-130109-2.htm", "/ajaxfiles/bmw/bmw-3series-130109.htm", "/ajaxfiles/bmw/bmw-7series-130109.htm", "/ajaxfiles/bmw/bmw-x6series-130109.htm", "/ajaxfiles/bmw/bmw-6series-130109.htm", "/ajaxfiles/volvo-c70-navigation.htm", "/ajaxfiles/volvo-v50-servicing.htm", "/ajaxfiles/volvo-xc60.htm", "/ajaxfiles/volvo-s80.htm","/ajaxfiles/motability/motab-honda-civicse.htm", "/ajaxfiles/motability/motab-bmw-116ies-210808.htm", "/ajaxfiles/motability/volvo-v70.htm", "/ajaxfiles/mini/mini-190109.htm"]

var offer2=["/ajaxfiles/home/mini-150808.htm", "/ajaxfiles/mini-cooper.htm", "/ajaxfiles/bmw/bmw-1series-130109.htm", "/ajaxfiles/bmw/bmw-5series-130109-2.htm", "/ajaxfiles/bmw/bmw-x3series-130109.htm","/ajaxfiles/bmw/bmw-3series-130109-2.htm", "/ajaxfiles/volvo-c30-0.htm", "/ajaxfiles/volvo-s40-servicing.htm", "/ajaxfiles/volvo-xc60-59.htm", "/ajaxfiles/volvo-v70.htm", "/ajaxfiles/motability/motab-honda-jazzse.htm", "/ajaxfiles/motability/motab-bmw-318ies-210808.htm", "/ajaxfiles/motability/mini-190109.htm", "/ajaxfiles/mini/mini-190109-2.htm"]

var offer3=["/ajaxfiles/mini-clubman.htm", "/ajaxfiles/mini-one.htm", "/ajaxfiles/bmw/bmw-3series-130109-2.htm", "/ajaxfiles/bmw/bmw-5series-130109.htm", "/ajaxfiles/bmw/bmw-x3series-130109-2.htm", "/ajaxfiles/bmw/bmw-x5series-130109.htm", "/ajaxfiles/volvo-c30-insurance.htm", "/ajaxfiles/volvo-s60-servicing.htm", "/ajaxfiles/volvo-xc90-69.htm", "/ajaxfiles/volvo-xc70.htm", "/ajaxfiles/volvo/volvo-drive-140109.htm", "/ajaxfiles/motability/volvo-c30.htm", "/ajaxfiles/motability/volvo-v50-190109.htm"]

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 day 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
}