/***********************************************
* 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/honda/080210/civic-1.htm","/ajaxfiles/honda/080210/civic-5dr.htm","/ajaxfiles/honda/080210/civic-5dr-2.htm","/ajaxfiles/honda/080210/civic-5dr-3.htm","/ajaxfiles/honda/080210/civic-5dr-4.htm","/ajaxfiles/fiat/030210/500-1.htm","/ajaxfiles/fiat/030210/grade-punto-1.htm","/ajaxfiles/fiat/030210/500-2.htm","/ajaxfiles/alfa-romeo/030210/mito-1.htm","/ajaxfiles/alfa-romeo/030210/mito-2.htm","/ajaxfiles/bmw/030210/bmw-5.htm","/ajaxfiles/bmw/030210/bmw-2.htm","/ajaxfiles/bmw/030210/bmw-1.htm","/ajaxfiles/mini/030210/one-1.htm","/ajaxfiles/volvo/030210/c30-1.htm","/ajaxfiles/volvo/030210/c30-2.htm","/ajaxfiles/volvo/030210/c70-1.htm","/ajaxfiles/volvo/030210/c70-2.htm","/ajaxfiles/volvo/030210/xc60-1.htm","/ajaxfiles/volvo/030210/xc60-2.htm"]

var offer2=["/ajaxfiles/honda/080210/civic-type-s.htm","/ajaxfiles/honda/080210/civic-type-s-2.htm","/ajaxfiles/honda/080210/civic-type-s-3.htm","/ajaxfiles/honda/080210/civic-type-r.htm","/ajaxfiles/honda/080210/civic-type-r-2.htm","/ajaxfiles/fiat/030210/500c-1.htm","/ajaxfiles/fiat/030210/doblo-1.htm","/ajaxfiles/alfa-romeo/030210/mito-4.htm","/ajaxfiles/alfa-romeo/030210/mito-3.htm","/ajaxfiles/bmw/030210/3-series-touring.htm","/ajaxfiles/bmw/030210/3-series-saloon.htm","/ajaxfiles/bmw/030210/3-series-coupe.htm","/ajaxfiles/bmw/030210/3-series-coupe-2.htm","/ajaxfiles/mini/030210/one-1-clubman.htm","/ajaxfiles/volvo/030210/s40-1.htm","/ajaxfiles/volvo/030210/s40-2.htm","/ajaxfiles/volvo/030210/s60-1.htm","/ajaxfiles/volvo/030210/s60-2.htm","/ajaxfiles/volvo/030210/xc60-3.htm","/ajaxfiles/volvo/030210/xc70-1.htm"]

var offer3=["/ajaxfiles/honda/080210/cr-v-1.htm","/ajaxfiles/honda/080210/cr-v-2.htm","/ajaxfiles/honda/080210/cr-z-1.htm","/ajaxfiles/honda/080210/cr-z-2.htm","/ajaxfiles/honda/080210/cr-z-3.htm","/ajaxfiles/fiat/030210/bravo-1.htm","/ajaxfiles/fiat/030210/multipla-1.htm","/ajaxfiles/fiat/030210/bravo-2.htm","/ajaxfiles/alfa-romeo/030210/giulietta-1.htm","/ajaxfiles/bmw/030210/3-series-convertible.htm","/ajaxfiles/bmw/030210/3-series-convertible-2.htm","/ajaxfiles/bmw/030210/1-series-convertible.htm","/ajaxfiles/bmw/030210/3-series-coupe.htm","/ajaxfiles/mini/030210/one-1-convertible.htm","/ajaxfiles/volvo/030210/s80-1.htm","/ajaxfiles/volvo/030210/s80-2.htm","/ajaxfiles/volvo/030210/v50-1.htm","/ajaxfiles/volvo/030210/v50-2.htm","/ajaxfiles/volvo/030210/xc70-2.htm","/ajaxfiles/volvo/030210/xc90-2.htm"]

var offer4=["/ajaxfiles/honda/080210/jazz-1.htm","/ajaxfiles/honda/080210/jazz-2.htm","/ajaxfiles/honda/080210/jazz-3.htm","/ajaxfiles/honda/080210/insight-1.htm","/ajaxfiles/honda/080210/insight-2.htm","/ajaxfiles/honda/080210/insight-3.htm","/ajaxfiles/fiat/030210/panda-1.htm","/ajaxfiles/fiat/030210/qubo-1.htm","/ajaxfiles/alfa-romeo/030210/giulietta-2.htm","/ajaxfiles/bmw/030210/1-series-5.htm","/ajaxfiles/bmw/030210/1-series-3.htm","/ajaxfiles/volvo/030210/v60-1.htm","/ajaxfiles/volvo/030210/v60-2.htm","/ajaxfiles/volvo/030210/v70-1.htm","/ajaxfiles/volvo/030210/v70-2.htm","/ajaxfiles/volvo/030210/xc90-1.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
}

