/***********************************************
* 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:

// For testing only get rid of these later
var f1=["../list/feature1.html"]
var f2=["../list/feature2.html"]
var f3=["../list/feature3.html"]
var f4=["../list/feature4.html"]
var f5=["../list/feature5.html"]
var f6=["../list/feature6.html"]
var f7=["../list/feature7.html"]
var f8=["../list/feature8.html"]
var f9=["../list/feature9.html"]
var f10=["../list/feature10.html"]
var f11=["../list/feature11.html"]
var f12=["../list/feature12.html"]
var f13=["../list/feature13.html"]
var f14=["../list/feature14.html"]
var f15=["../list/feature15.html"]
var f16=["../list/feature16.html"]
var f17=["../list/feature17.html"]
var f18=["../list/feature18.html"]
var f19=["../list/feature19.html"]
var f20=["../list/feature20.html"]
var f21=["../list/feature21.html"]
var f22=["../list/feature22.html"]
var f23=["../list/feature23.html"]
var f24=["../list/feature24.html"]
var f25=["../list/feature25.html"]
// end of testing

var top_feature=["../list/feature1.html", "../list/feature2.html", "../list/feature3.html", "../list/feature4.html", "../list/feature5.html", "../list/feature6.html", "../list/feature7.html", "../list/feature8.html", "../list/feature9.html", "../list/feature10.html", "../list/feature11.html", "../list/feature12.html", "../list/feature13.html"]
var bot_feature=["../list/feature14.html", "../list/feature15.html", "../list/feature16.html", "../list/feature17.html", "../list/feature18.html", "../list/feature19.html", "../list/feature20.html", "../list/feature21.html", "../list/feature22.html", "../list/feature23.html", "../list/feature24.html", "../list/feature25.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 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
}
