/***********************************************
* 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 include_rotate_img=[
"./ajaxfiles/rotate_img_1.htm", 
"./ajaxfiles/rotate_img_2.htm", 
"./ajaxfiles/rotate_img_3.htm", 
"./ajaxfiles/rotate_img_5.htm",
"./ajaxfiles/rotate_img_6.htm", 
"./ajaxfiles/rotate_img_7.htm", 
"./ajaxfiles/rotate_img_8.htm", 
"./ajaxfiles/rotate_img_9.htm", 
"./ajaxfiles/rotate_img_10.htm",
"./ajaxfiles/rotate_img_11.htm", 
"./ajaxfiles/rotate_img_12.htm", 
"./ajaxfiles/rotate_img_13.htm", 
"./ajaxfiles/rotate_img_14.htm", 
"./ajaxfiles/rotate_img_15.htm",
"./ajaxfiles/rotate_img_16.htm", 
"./ajaxfiles/rotate_img_17.htm", 
"./ajaxfiles/rotate_img_18.htm", 
"./ajaxfiles/rotate_img_19.htm", 
"./ajaxfiles/rotate_img_20.htm",
"./ajaxfiles/rotate_img_21.htm", 
"./ajaxfiles/rotate_img_22.htm", 
"./ajaxfiles/rotate_img_23.htm", 
"./ajaxfiles/rotate_img_24.htm", 
"./ajaxfiles/rotate_img_25.htm",
"./ajaxfiles/rotate_img_26.htm", 
"./ajaxfiles/rotate_img_27.htm", 
"./ajaxfiles/rotate_img_28.htm", 
"./ajaxfiles/rotate_img_29.htm", 
"./ajaxfiles/rotate_img_30.htm",
"./ajaxfiles/rotate_img_31.htm", 
"./ajaxfiles/rotate_img_32.htm", 
"./ajaxfiles/rotate_img_33.htm", 
"./ajaxfiles/rotate_img_34.htm", 
"./ajaxfiles/rotate_img_35.htm",
"./ajaxfiles/rotate_img_36.htm", 
"./ajaxfiles/rotate_img_37.htm", 
"./ajaxfiles/rotate_img_38.htm", 
"./ajaxfiles/rotate_img_39.htm", 
"./ajaxfiles/rotate_img_40.htm"
]

var include175_forum=[
"./ajaxfiles/rotate175_forum07.htm", 
"./ajaxfiles/rotate175_forum08.htm", 
"./ajaxfiles/rotate175_forum09.htm", 
"./ajaxfiles/rotate175_forum10.htm" 
]

var include175_agonyuncle=[
"./ajaxfiles/rotate175_agonyuncle60.htm", 
"./ajaxfiles/rotate175_agonyuncle61.htm", 
"./ajaxfiles/rotate175_agonyuncle62.htm", 
"./ajaxfiles/rotate175_agonyuncle63.htm", 
"./ajaxfiles/rotate175_agonyuncle64.htm", 
"./ajaxfiles/rotate175_agonyuncle65.htm", 
"./ajaxfiles/rotate175_agonyuncle66.htm", 
"./ajaxfiles/rotate175_agonyuncle67.htm", 
"./ajaxfiles/rotate175_agonyuncle68.htm"
]

var include175_article_teasers=[
"./ajaxfiles/rotate175_article_teasers01.htm", 
"./ajaxfiles/rotate175_article_teasers02.htm",
"./ajaxfiles/rotate175_article_teasers03.htm"
]

var include175_article_text_teasers=[
"./ajaxfiles/rotate175_article_text_teaser01.htm", 
"./ajaxfiles/rotate175_article_text_teaser02.htm", 
"./ajaxfiles/rotate175_article_text_teaser03.htm", 
"./ajaxfiles/rotate175_article_text_teaser04.htm", 
"./ajaxfiles/rotate175_article_text_teaser05.htm", 
"./ajaxfiles/rotate175_article_text_teaser06.htm", 
"./ajaxfiles/rotate175_article_text_teaser07.htm", 
"./ajaxfiles/rotate175_article_text_teaser08.htm", 
"./ajaxfiles/rotate175_article_text_teaser09.htm", 
"./ajaxfiles/rotate175_article_text_teaser10.htm" 
]

var include175_forsale_top=[
"./ajaxfiles/rotate175_forsale39.htm",
"./ajaxfiles/rotate175_forsale41.htm",
"./ajaxfiles/rotate175_forsale43.htm"
]

var include175_forsale_bottom=[
"./ajaxfiles/rotate175_forsale44.htm",
"./ajaxfiles/rotate175_forsale42.htm",
"./ajaxfiles/rotate175_forsale40.htm"
]

var include175_books=[
"./ajaxfiles/rotate175_book01.htm",
"./ajaxfiles/rotate175_book03.htm",
"./ajaxfiles/rotate175_book04.htm",
"./ajaxfiles/rotate175_book05.htm",
"./ajaxfiles/rotate175_book06.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
}
