// JavaScript Document created by i-Concept
//Basic Ajax Routine- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: Jan 15th, 06'
var nItems = new Array();

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
				nItems=myajax.responseXML.getElementsByTagName("item");
				temp_text += "<table width='100%' cellpadding='0' cellspacing='0'>";
				for (var i=0; i<nItems.length; i++){
					temp_text += "<tr width='97%'><td>";
					temp_text += "<a href='"+nItems[i].getElementsByTagName("link")[0].firstChild.nodeValue+"'>";
					temp_text += "<img src='images/pijlnieuws.gif' align='right' border='0'>";
					temp_text += "</a></td><td class='rss_td'>";
					temp_text += "<a href ='#' onClick='getItemLink("+i+");'>";
					temp_text += nItems[i].getElementsByTagName("title")[0].firstChild.nodeValue;
					temp_text += "</a></td></tr>";
				}
				temp_text += "</table>";
			} else {
				temp_text = "Er kunnen geen nieuws items getoond worden";
			}
			GetE('nieuwsbox').innerHTML = temp_text; // De HTML in de DIV zetten
			// getItemLink(1);
		}
	}
}
//
//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
//				items=myajax.responseXML.getElementsByTagName("item");
//				temp_text += "<table width='100%' cellpadding='0' cellspacing='0'>";
//				for (var i=0; i<items.length; i++){
//					temp_text += "<tr width='97%'><td>";
//					temp_text += "<a href='"+items[i].getElementsByTagName("link")[0].firstChild.nodeValue+"'>";
//					temp_text += "<img src='../images/pijlnieuws.gif' align='right' border='0'>";
//					temp_text += "</a></td><td class='rss_td'>";
//					temp_text += "<a href ='"+items[i].getElementsByTagName("link")[0].firstChild.nodeValue+"'>";
//					temp_text += items[i].getElementsByTagName("title")[0].firstChild.nodeValue;
//					temp_text += "</a></td></tr>";
//				}
//				temp_text += "</table>";
//			} else {
//				temp_text = "Er kunnen geen nieuws items getoond worden";
//			}
//			GetE('nieuwsbox').innerHTML = temp_text; // De HTML in de DIV zetten
//		}
//	}
//}

function Len(str)
  {  return String(str).length;  }

function processGetImage(){
	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
				nItems=myajax.responseXML.getElementsByTagName("item");
				for (var i=0; i<nItems.length; i++){
					temp_text += "<a href='"+nItems[i].getElementsByTagName("link")[0].firstChild.nodeValue+"' title='"+nItems[i].getElementsByTagName("title")[0].firstChild.nodeValue+"' class='nieuws_berichten2'>";
					temp_text += nItems[i].getElementsByTagName("title")[0].firstChild.nodeValue;
					temp_text += "</a><br />";
					myNode = nItems[i].getElementsByTagName("enclosure")[0].firstChild;
					if (myNode != null) {
						temp_text += nItems[i].getElementsByTagName("description")[0].firstChild.nodeValue;
						temp_text += "&nbsp;<a href='"+nItems[i].getElementsByTagName("link")[0].firstChild.nodeValue+"' title='"+nItems[i].getElementsByTagName("title")[0].firstChild.nodeValue+"'>";
						temp_text += "<img src='../images/nieuwsblok.jpg' alt='Lees Meer' border='0' align='left' /></a><br/><br/><br/>";
					} else {
						temp_text += nItems[i].getElementsByTagName("description")[0].firstChild.nodeValue;
						temp_text += "&nbsp;<a href='"+nItems[i].getElementsByTagName("link")[0].firstChild.nodeValue+"' title='"+nItems[i].getElementsByTagName("title")[0].firstChild.nodeValue+"'>";
						temp_text += "<img src='../images/nieuwsblok.jpg' alt='Lees Meer' border='0' align='left' /></a><br/><br/><br/>";
					}
				}
			} else {
				temp_text = "Er kunnen geen nieuws items getoond worden";
			}
			GetE('rss_data').innerHTML = temp_text; // De HTML in de DIV zetten
		}
	}
}

//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)
}

function txtOnFocus (obj) {
        obj.style.backgroundImage = '';
}

function txtOnBlur (obj) {
        if (obj.value == '')
            {
                obj.style.backgroundImage = 'url(../images/wwachter.gif)';
                        obj.style.backgroundRepeat = 'no-repeat';
                        obj.style.backgroundPositon = 'left center';
            }
}


function getItemLink(itemLink){
	var temp_text = "";
	var myItem = nItems[itemLink];

	temp_text+="<strong>"+myItem.getElementsByTagName("title")[0].firstChild.nodeValue+"</strong><br /><br />";
	temp_text+=myItem.getElementsByTagName("description")[0].firstChild.nodeValue;
	temp_text+="<br /><a href='"+myItem.getElementsByTagName("link")[0].firstChild.nodeValue+"'>Lees meer</a>";
	GetE('rssdatabox').innerHTML = temp_text; // De HTML in de DIV zetten
}


function getpage(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)
return page_request.responseText;
}

function checkConcept(){
	var res = '';
	var conceptImg = document.getElementById('conceptImg');
	if(conceptImg != null){
		var conceptName = conceptImg.src.split("/");
		conceptName = conceptName[conceptName.length-1];
		conceptName = conceptName.split(".");
		conceptName = conceptName[0];
		var res = getpage('checkConceptPicture.cfm?src='+conceptName);
		if(res=='true'){
			conceptImg.onclick = function(){
				document.location.href=conceptName + '.htm';
			}
				document.getElementById('conceptImg').style.cursor = 'pointer';
		}
	}
	return res;
}

window.onload = function(){
	checkConcept();
}