<!--

var url;

var upper_page = '';
var upper_page_old = '';
var upper_image = '';
var global_mode;

var http = getXmlHttpRequestObject();
var url  = "";
var geenajax = "0";
var image_array = Array();
var tekst_array = Array();

function getXmlHttpRequestObject() {


    if(window.XMLHttpRequest){
        return new XMLHttpRequest();
    }else if(window.ActiveXObject){
        return new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        //alert("Explorer error");
    } 

}

function handleHttpResponse() {

    if(http.readyState == 4){

		if (global_mode == 'pageinfo') {

		      if (upper_page != 'say-3') {
			  var results = http.responseText; 
			  document.getElementById('content').innerHTML = '<div class="content-tekst">'+results+'</div>';
		      } else {
			  var results = http.responseText; 
			  show_contact_form(results);
		      }

		} else {
	
		 rs = http.responseText.split("{}");

          	 image_array = rs[0].split("~"); 		
          	 tekst_array = rs[1].split("~"); 		
		 insert_images ();

		}

 } 


}



function handleHttpEmail() {

    if(http.readyState == 4){

	//Bedankt bericht afdrukken
	document.getElementById('contact-right').innerHTML = 'Thank you for your message,<br>	We will process your e-mail as soon as possible.<br>';
    } 

}



function show_contact_form(tekst) {

	document.getElementById('content').innerHTML = '';

	////DIV OPBOUWEN
	var con_holder = document.createElement('div');
	con_holder.className = 'content-tekst';
	con_holder.id = 'contact-tekst';
	document.getElementById('content').appendChild(con_holder);

	////Eerst de rechter kolom opbouwen met de input velden
	var con_right = document.createElement('div');
	con_right.className = 'contact-right';
	con_right.id = 'contact-right';
	con_holder.appendChild(con_right);

	///NAME
	con_right.appendChild(createdivtitle("NAME: *"));
	con_right.appendChild(createdivinput ("contact-name"));

	///COMPANY
	con_right.appendChild(createdivtitle("COMPANY:"));
	con_right.appendChild(createdivinput ("contact-company"));

	///COMPANY
	con_right.appendChild(createdivtitle("E-MAIL: *"));
	con_right.appendChild(createdivinput ("contact-email"));

	///MESSAGE
	con_right.appendChild(createdivtitle("MESSAGE: *"));
	con_right.appendChild(createdivtextarea("contact-message"));

	///BUTTON
	con_right.appendChild(createdivtitle("&nbsp;"));
	var con_bt = document.createElement('div');
	con_bt.id = 'contact-send';
	con_bt.innerHTML = '<a href="javascript:send_mail();"><img src="images/image_send.jpg" alt="Send"></a><br><br><div class="contact-title">&nbsp;</div><div>All fields with * are required</div>';
	con_right.appendChild(con_bt);

	////Dan de linker kolom vullen met de tekst
	var con_left = document.createElement('div');
	con_left.className = 'contact-left';
	con_left.innerHTML = tekst;
	con_holder.appendChild(con_left);

	document.getElementById('content').appendChild(con_holder);


}

function createdivtitle (tekst) {
	var con_tn = document.createElement('div');
	con_tn.className = 'contact-title';
	con_tn.innerHTML = tekst;

return con_tn;
}

function createdivinput (tekst) {
	var con_tn = document.createElement('div');

	var input = document.createElement('input');
	input.name = tekst;
	input.id = tekst;
	input.className = 'contact-input';

	con_tn.appendChild(input);

return con_tn;
}

function createdivtextarea (tekst) {
	var con_tn = document.createElement('div');

	var input = document.createElement('textarea');
	input.name = tekst;
	input.id = tekst;
	input.className = 'contact-textarea';

	con_tn.appendChild(input);

return con_tn;
}

function getpage() {

 try {

  http.open("GET", url , true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);  

 } catch(e) {
  //alert('Error');
 }



}


function image_over (imagelink , afbeeldingel) {

	if (global_mode == "images") {
		document.getElementById("say-1").src ='images/navigatie_category_over.png';
	} else {
		document.getElementById("say-1").src ='images/navigatie_category.png';
	}

	afbeeldingel.src='images/'+imagelink+'.png';
	document.getElementById(upper_page).src ='images/'+ upper_image+'_over.png';
}

function image_out (imagelink , afbeeldingel) {
	afbeeldingel.src='images/'+imagelink+'.png';
	document.getElementById(upper_page).src ='images/'+ upper_image+'_over.png';

	if (global_mode == "images") {
		document.getElementById("say-1").src ='images/navigatie_category_over.png';
	} else {
		document.getElementById("say-1").src ='images/navigatie_category.png';
	}
}


function load_page (mode,pageid,category,naamid) {

	image_array = false;
	tekst_array = false;

	global_mode = mode;

	upper_page_old = upper_page;

	if (upper_page_old) {
		var normal_image = get_image_name (upper_page_old);
		document.getElementById(upper_page_old).src ='images/'+ normal_image +'.png';
	}


	upper_page = naamid;

	upper_image = get_image_name (naamid);

	document.getElementById(upper_page).src ='images/'+ upper_image +'_over.png';

	if (mode == "images") {
		document.getElementById("say-1").src ='images/navigatie_category_over.png';
	} else {
		document.getElementById("say-1").src ='images/navigatie_category.png';
	}


	url = 'showpage.php?mode='+mode+'&id='+pageid+'&cat_id='+category+'&sid='+Math.random();

	document.getElementById('content').scrollLeft=0;
	$('#meer-info').html('');

	getpage();

}


function get_image_name (naamid) {
	tempstring = document.getElementById(naamid).src;
	tempstring2 = tempstring.split("images/");

	tempstring3 = tempstring2[1].replace(/.png/i, "");
	string = tempstring3.replace(/_over/i, "");


return string;
}


function image_left () {
	insert_images ();
	//document.getElementById('content').scrollLeft-=864;
}

function image_right () {
	document.getElementById('content').scrollLeft+=864;
	//alert(document.getElementById('content').scrollLeft + document.getElementById('content').scrollWidth);
}


function insert_images () {

	document.getElementById('content').innerHTML = '';

	var image_holder = document.createElement('div');
	image_holder.id = 'content-holder';

	document.getElementById('content').appendChild(image_holder);

	///nu images invoegen
	var arLen=image_array.length;
	for ( var i=0, len=arLen; i<len; ++i ){
	
		var image_html = document.createElement('div');
		image_html.className = 'image-holder';
		image_html.innerHTML = ''+image_array[i]+'';

		document.getElementById('content-holder').appendChild(image_html);
	}

	///Teller erin zetten
	var teller_div = document.createElement('div');
	teller_div.id = 'teller';

	if (arLen == 0 || arLen == 1) {
		teller_div.style.display = 'none';
	}

	document.getElementById('content').appendChild(teller_div);

	$('#meer-info').html('<span class="meer-info-title">INFO IMAGE:</span><br>'+tekst_array[0]);

	initiate_slideshow ();
}

function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 


}



function send_mail () {
	cname = document.getElementById('contact-name').value;
	ccompany = document.getElementById('contact-company').value;
	cemail = document.getElementById('contact-email').value;
	cmessage = document.getElementById('contact-message').value;

	var error = false;
   
	if (cname == "") {
		error = true;
	}

	if (cmessage == "") {
		error = true;
	}

	if (!isValidEmail(cemail)) {
		error = true;
	}

	cname = encodeURI(cname);
	ccompany = encodeURI(ccompany);
	cemail = encodeURI(cemail);
	cmessage = encodeURI(cmessage);

	if (error == true) {
		document.getElementById('contact-send').innerHTML= '<a href="javascript:send_mail();"><img src="images/image_send.jpg" alt="Send"></a><br><br><div class="contact-title">&nbsp;</div><div>Please fill in the required fields *</div>';
	} else {

		 try {
		  http.open("GET", 'showpage.php?mode=email&cemail='+cemail+'&cname='+cname+'&ccompany='+ccompany+'&cmessage='+cmessage+'&sid='+Math.random() , true);
		  http.onreadystatechange = handleHttpEmail;
		  http.send(null);  
		 } catch(e) {
		  //alert('Error');
		 }
	}
}


		function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
		function setContent() {
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var contentElement = document.getElementById('maincontainer');
					var contentHeight = contentElement.offsetHeight;
					if (windowHeight - contentHeight > 0) {
						contentElement.style.position = 'relative';
						contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
					}
					else {
						contentElement.style.position = 'static';
					}
				}
			}
		}

		window.onresize = function() {
			setContent();
		}


-->
