//Basic Ajax Routine- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: Jan 15th, 06'

function GetE( elementId )
{
	return document.getElementById( elementId )  ;
}

function createAjaxObj(){
var httprequest=false
	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
	}
	else if (window.ActiveXObject){ // if IE
		try {
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
		try{
			httprequest=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e){}
		}
	}
	return httprequest
}

var ajaxpack=new Object()
ajaxpack.basedomain="http://"+window.location.hostname
ajaxpack.ajaxobj=createAjaxObj()
ajaxpack.filetype="txt"
ajaxpack.addrandomnumber=0 //Set to 1 or 0. See documentation.

ajaxpack.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
	if (ajaxpack.addrandomnumber==1) //Further defeat caching problem in IE?
		var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
	if (this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange=callbackfunc
		this.ajaxobj.open('GET', url+"?"+parameters, true)
		this.ajaxobj.send(null)
	}
}

ajaxpack.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
	if (this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange = callbackfunc;
		this.ajaxobj.open('POST', url, true);
		this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.ajaxobj.setRequestHeader("Content-length", parameters.length);
		this.ajaxobj.setRequestHeader("Connection", "close");
		this.ajaxobj.send(parameters);
	}
}
function processGet(){
	var myajax=ajaxpack.ajaxobj
	var myfiletype=ajaxpack.filetype
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
			var temp_text = ""; // Tijdelijke text variabele (hier staat de string met de content in
			if (myfiletype=="xml") { // het XML object
				xmlItems=myajax.responseXML.getElementsByTagName("item");
				temp_text += '<p>';
				for (var i=0; i<xmlItems.length; i++){
					temp_text += '<a href="'+xmlItems[i].getElementsByTagName('link')[0].firstChild.nodeValue+'">';
					temp_text += '&raquo; '+filterDate(xmlItems[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue)+' '+xmlItems[i].getElementsByTagName("title")[0].firstChild.nodeValue;
					temp_text += '</a><br />';
				}
				temp_text += '</p>';
			} else {
				temp_text = "Er kunnen geen nieuws items getoond worden";
			}
			GetE('rss_data').innerHTML = temp_text; // De HTML in de DIV zetten
			showItem(xmlItems[0]);
		}
	}
}

function showItem(xObj) {
	var outputString = '<p><table cellpadding="0" cellspacing="0"><tr><td>';
	imgNode = xObj.getElementsByTagName("enclosure")[0].firstChild;
	if (imgNode != null) {
		outputString += '<a href="'+xObj.getElementsByTagName('link')[0].firstChild.nodeValue+'" title="'+xObj.getElementsByTagName('title')[0].firstChild.nodeValue+'">';
		outputString += '<img src="'+xObj.getElementsByTagName('enclosure')[0].firstChild.nodeValue+'" border="0" id="img_rss">';
		outputString += '</a>';
	}
	outputString += '<a href="'+xObj.getElementsByTagName('link')[0].firstChild.nodeValue+'" id="link_newstitle">';
	outputString += xObj.getElementsByTagName("title")[0].firstChild.nodeValue;
	outputString += '</a><br />'
	outputString += xObj.getElementsByTagName("description")[0].firstChild.nodeValue+'<br />';
	outputString += '<a href="'+xObj.getElementsByTagName('link')[0].firstChild.nodeValue+'" title="'+xObj.getElementsByTagName('title')[0].firstChild.nodeValue+'">Lees verder &raquo;</a>';
	outputString += '</td></tr></table></p>'

	GetE('rss_data2').innerHTML = outputString; // De HTML in de DIV zetten
}

function getPageName(path){
	thisPage = path.substring(path.lastIndexOf('/') + 1);
	thisPage = thisPage.replace(window.location.search,"");
	return thisPage;
}

function Len(str)
  {  return String(str).length;  }

function processGetImage(){
	var myajax=ajaxpack.ajaxobj
	var myfiletype=ajaxpack.filetype
	var thisPath = getPageName(window.location.href);
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
			var temp_text = ""; // Tijdelijke text variabele (hier staat de string met de content in
			if (myfiletype=="xml") { // het XML object
				items=myajax.responseXML.getElementsByTagName("item");
				for (var i=0; i<items.length; i++){
					 titleClass = '';
					temp_text += '<p><table cellpadding="0" cellspacing="0"><tr><td>';
					imgNode = items[i].getElementsByTagName("enclosure")[0].firstChild;
					if (imgNode != null) {
						temp_text += '<a href="'+items[i].getElementsByTagName('link')[0].firstChild.nodeValue+'" title="'+items[i].getElementsByTagName('title')[0].firstChild.nodeValue+'">';
						temp_text += '<img src="'+items[i].getElementsByTagName('enclosure')[0].firstChild.nodeValue+'" border="0" id="img_rss">';
						temp_text += '</a>';
					}
					if(thisPath==getPageName(items[i].getElementsByTagName('link')[0].firstChild.nodeValue)){
						titleClass = ' class="active"';
					}
					temp_text += '<a href="'+items[i].getElementsByTagName('link')[0].firstChild.nodeValue+'" title="'+items[i].getElementsByTagName('title')[0].firstChild.nodeValue+'" id="link_newstitle"><strong '+titleClass+'>'+items[i].getElementsByTagName("title")[0].firstChild.nodeValue+'</strong></a><br />';
					temp_text += items[i].getElementsByTagName("description")[0].firstChild.nodeValue+'<br />';
					temp_text += '<a href="'+items[i].getElementsByTagName('link')[0].firstChild.nodeValue+'" title="'+items[i].getElementsByTagName('title')[0].firstChild.nodeValue+'">Lees verder &raquo;</a>';
					temp_text += '</td></tr></table></p>';
				}
			} else {
				temp_text = "Er kunnen geen nieuws items getoond worden";
			}
			GetE('rss_data').innerHTML = temp_text; // De HTML in de DIV zetten
		}
	}
}

function filterDate(ufdate) {
	if(ufdate.length == 8) {
		var toFilterDate = new String(ufdate);
		fYear = toFilterDate.substr(0,4);
		fMonth = toFilterDate.substr(4,2);
		fDay = toFilterDate.substr(6,2);
		filteredDate = fDay + '-' + fMonth + '-' + fYear;
		return filteredDate;
	} else {
		var todayDate = new Date();
		filteredDate = todayDate.getDate() + '-' + todayDate.getMonth() + '-' + todayDate.getYear();
		return filteredDate;
	}
	
}

//ACCESSIBLE VARIABLES (for use within your callback functions):
//1) ajaxpack.ajaxobj //points to the current ajax object
//2) ajaxpack.filetype //The expected file type of the external file ("txt" or "xml")
//3) ajaxpack.basedomain //The root domain executing this ajax script, taking into account the possible "www" prefix.
//4) ajaxpack.addrandomnumber //Set to 0 or 1. When set to 1, a random number will be added to the end of the query string of GET requests to bust file caching of the external file in IE. See docs for more info.

//ACCESSIBLE FUNCTIONS:
//1) ajaxpack.getAjaxRequest(url, parameters, callbackfunc, filetype)
//2) ajaxpack.postAjaxRequest(url, parameters, callbackfunc, filetype)

///////////END OF ROUTINE HERE////////////////////////


//////EXAMPLE USAGE ////////////////////////////////////////////
/* Comment begins here

//Define call back function to process returned data
function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){ //if request of file completed
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ if request was successful or running script locally
if (myfiletype=="txt")
alert(myajax.responseText)
else
alert(myajax.responseXML)
}
}
}

/////1) GET Example- alert contents of any file (regular text or xml file):

ajaxpack.getAjaxRequest("example.php", "", processGetPost, "txt")
ajaxpack.getAjaxRequest("example.php", "name=George&age=27", processGetPost, "txt")
ajaxpack.getAjaxRequest("examplexml.php", "name=George&age=27", processGetPost, "xml")
ajaxpack.getAjaxRequest(ajaxpack.basedomain+"/mydir/mylist.txt", "", processGetPost, "txt")

/////2) Post Example- Post some data to a PHP script for processing, then alert posted data:

//Define function to construct the desired parameters and their values to post via Ajax
function getPostParameters(){
var namevalue=document.getElementById("namediv").innerHTML //get name value from a DIV
var agevalue=document.getElementById("myform").agefield.value //get age value from a form field
var poststr = "name=" + encodeURI(namevalue) + "&age=" + encodeURI(agevalue)
return poststr
}

var poststr=getPostParameters()

ajaxpack.postAjaxRequest("example.php", poststr, processGetPost, "txt")
ajaxpack.postAjaxRequest("examplexml.php", poststr, processGetPost, "xml")

Comment Ends here */

/***********************************************
* Ajax 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("afile.htm") in the BODY of page
//Included file MUST be from the same domain as the page displaying it.

var rootdomain="http://"+window.location.hostname

function ajaxinclude(url) {
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
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)
}


/* Deze functie is een standaard functie om e-mail te controleren 
	 Het heeft niets met XML en AJAX te maken
*/

function isEmail(form) {
  var field = form.vanmail;
  var str = field.value;
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
    var reg1 = new RegExp(reg1str);
    var reg2 = new RegExp(reg2str);
    if (!reg1.test(str) && reg2.test(str)) {
      return true;
    }
    field.focus();
    field.select();
    return false;
  } else {
    if(str.indexOf("@") >= 0)
      return true;
    field.focus();
    field.select();
    return false;
  }
}

function setTekst(obj, tekst) {
	var naam = obj.value;
	if (naam == tekst) {
		obj.value = '';
	} else if (naam == '') {
		obj.value = tekst;
	}
}

function showButton(obj){
	obj.style.width=84+'px';
	document.getElementById('seachButton').style.display='inline';
}

function searchWord(){
	var word = document.getElementById('word').value;
		document.location.href='http://www.i-concept.nl/search/searchmain.cfm?SearchString='+word;
}
function getLink(obj){
	var olink = obj.options[obj.options.selectedIndex].value;
	document.location.href=olink;
}


var fadebgcolor="white"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=1500
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}

