/* Default intro images */

var websitepath = "http://eyescan.work.tribalnet.nl/";
var imagePath = "Content/Images/intro/"
var images = new Array();
images[0] = "1.jpg";
images[1] = "2.jpg";
images[2] = "3.jpg";
images[3] = "4.jpg";
images[4] = "5.jpg";
images[5] = "6.jpg";
images[6] = "7.jpg";

/* Text changer - light version.
Let your text's font size customizable.
by Marco Rosella - http://www.centralscrutinizer.it/en/design/js-php/text-changer
                v0.2 - May 18, 2006
*/

window.onload = function(){

	if (!window.isEditor)
	{
	textChanger.init(); 
	initIntro();
	initTextfields();
	initCrumble();
	textChanger.init();
	}
}

var textChanger = {
	cpanel : 'textchanger',  //set here the id of the element (div, p) within you want to insert the control panel
	element : 'container',   	 //set here the id of the element (div, p) within you want to change the text
	defaultFS : 5,         //set here the default font size in 'em'
	init: function() {
		
		var incr = document.getElementById('fontsmaller');
		incr.onclick = function(){textChanger.changeSize(-1); return false;};
		var decr = document.getElementById('fontbigger');
		decr.onclick = function(){textChanger.changeSize(1); return false;};
		var reset= document.getElementById('fontnormal');
		reset.onclick = function(){textChanger.changeSize(0); return false;};

	} ,

	changeSize: function(val) {
		var el = document.getElementById(textChanger.element);
		var size = el.style.fontSize.substring(0,3);
		var fSize = parseFloat(size,10);
		if (val == 1) {
			fSize += 10;
			if (fSize > 140) fSize = 140;
		} 
		if (val == -1) {
			fSize -= 10;
			if (fSize < 70) fSize = 70;
		}		
		if (val == 0) {
			fSize = 100;
		}

		el.style.fontSize = fSize + '%';
		textChanger.updateCookie(fSize);
		} ,
		
	updateCookie: function(vl) {
		var today = new Date();
		var exp = new Date(today.getTime() + (365*24*60*60*1000)); //the cookie will expire in one year  
		document.cookie = 'textChangerL=size=' + vl + ';' +'expires=' + exp.toGMTString() + ';' +'path=/';
	} ,

	getCookie: function() { 
		var cname = 'textChangerL=size=';	
		var start = document.cookie.indexOf(cname);
		var len = start + cname.length;
		if ((!start) && (cname != document.cookie.substring(0,cname.length))) {return null;}
		if (start == -1) return null;
		var end = document.cookie.indexOf(";",len);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(len, end));
	}
}

function initIntro()
{
	var img = document.getElementById("FLD_PLTJ");
	if (img != null && img.src == websitepath +"images/system/space.gif")
	{
		var nr = images.length;
		if (images.length > 0)
		{
			var rand_no = Math.floor((nr-0)*Math.random()) + 0;
			img.src=imagePath + images[rand_no];
		}
		else
			alert("Er kon geen random plaatje worden getoond, omdat er geen plaatjes gedefinieerd zijn");
	}
}

function initTextfields()
{
	var body = document.getElementsByTagName("body");
	body = body[0];
	
	list = body.getElementsByTagName("input");
	list2 = body.getElementsByTagName("textarea");
	list3 = body.getElementsByTagName("select");
	
	for (var i = 0; i < list.length; i++)
	{
		list[i].onfocus = function()
		{
			this.style.borderColor="#666666";
		};
		list[i].onblur = function()
		{
			this.style.borderColor="#C4C1AA";
		};
	}
	
	for (var i = 0; i < list2.length; i++)
	{
		list2[i].onfocus = function()
		{
			this.style.borderColor="#666666";
		};
		list2[i].onblur = function()
		{
			this.style.borderColor="#C4C1AA";
		};
	}
	
	for (var i = 0; i < list3.length; i++)
	{
		list3[i].onfocus = function()
		{
			this.style.borderColor="#666666";
		};
		list3[i].onblur = function()
		{
			this.style.borderColor="#C4C1AA";
		};
	}
}

function initCrumble()
{
	var el = document.getElementById("path");
	if (el != null)
	{
		el.style.display="none";
		dest = document.getElementById("pathbox");
		
		if (dest != null)
		{
			dest.innerHTML = el.innerHTML;
		}
	}
}

function doSearch()
{
  var el = document.getElementById("SEARCHTXT");
  if (el!=null) if (el.value != null) if (el.value != "") {
      to(56,"SEARCH="+el.value);
  }
}

function keydown(e) {
  if (e==null) return;
  try 
  {
    var keyCode = e.keyCode;
  }
  catch(e) 
  {
    alert(e.message);
  }
  if (keyCode==null) keyCode=e.which;
  if (keyCode==13) {
    try 
    {
	    if (e.cancelBubble!=null) e.cancelBubble=true;
	    if (e.returnValue!=null) e.returnValue=false;
	    if (e.keyCode!=null) e.keyCode=0;
	    if (e.which!=null) e.which=0;
    }
    catch(e)
    {
    }
    doSearch();
    return false;
  };
}

function pckeydown(el,e) {
  if (e==null) return;
  try 
  {
    var keyCode = e.keyCode;
  }
  catch(e) 
  {
    alert(e.message);
  }
  if (keyCode==null) keyCode=e.which;
  if (keyCode==13) {
    try 
    {
	    if (e.cancelBubble!=null) e.cancelBubble=true;
	    if (e.returnValue!=null) e.returnValue=false;
	    if (e.keyCode!=null) e.keyCode=0;
	    if (e.which!=null) e.which=0;
    }
    catch(e)
    {
    }
    el.parent.submit();
    return false;
  };
}