// JavaScript Document

// mootools functions //

//---------------------------------------------------------------------------------------------------------------------------------//

//set_loading_message("Bezig met laden van pagina...");

/*function set_loading_message(msg) {
 	please_wait = msg;
}*/

//=======================CHECK INPUT IF NUMBER============================//
function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	} else {
		return true;
	}

}

//=======================CHECK IF INPUT IN PHONE-NUMBER============================//
function isPhoneNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == 32 || charCode == 40 || charCode == 41 || charCode == 43) {
		return true;
	} else if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	} else {
		return true;
	}

}

//=======================RETURN A POPUP============================//
var win=null;
function popup(mypage,myname,w,h,pos,infocus) {
	if(pos=="random") {
		myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center") {
		myleft=(screen.width)?(screen.width-w)/2:100;
		mytop=(screen.height)?(screen.height-h)/2:100;
	} else if((pos!='center' && pos!="random") || pos==null) {
		myleft=0;
		mytop=20;
	}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes";
	win=window.open(mypage,myname,settings);
	win.focus();	
}

//=======================MENU MOUSEOVER============================//
function menu(action,button) {
	if(action == 'over') {		
		document.getElementById(button.id).src='../../../buttons/but_'+button.id+'_o.gif';
	}
	if(action == 'out') {
		document.getElementById(button.id).src='../../../buttons/but_'+button.id+'.gif';
	}
}

//=======================IMAGE MOUSEOVER============================//
function image(action,imageID) {
	if(action == 'over') {		
		document.getElementById(imageID).src='../../../buttons/but_'+imageID+'_o.gif';
	}
	if(action == 'out') {
		document.getElementById(imageID).src='../../../buttons/but_'+imageID+'.gif';
	}
}
//=======================SLIDESHOW MOUSEOVER============================//
function slideThumb(action,imageID,newWidth,newHeight,newMargin) {
	if(action == 'over') {
		document.getElementById(imageID.id).style.borderColor='#A3ADB5';
		document.getElementById(imageID.id).style.filter = "alpha(opacity:50)";
		document.getElementById(imageID.id).style.MozOpacity = 0.5;
		document.getElementById(imageID.id).style.opacity = 0.5;
	}
	if(action == 'out') {
		document.getElementById(imageID.id).style.borderColor='#7D8995';
		document.getElementById(imageID.id).style.filter = "alpha(opacity:100)";
		document.getElementById(imageID.id).style.MozOpacity = 1;
		document.getElementById(imageID.id).style.opacity = 1;
	}
}

//=======================FORM INPUT FOCUS============================//
function fieldFocus(element,styleClass) {
	document.getElementById(element.id).className = styleClass+'Focus';
}
function fieldBlur(element,styleClass) {
	document.getElementById(element.id).className = styleClass;
}

//=======================SWITCH BACKGROUNDCOLOR============================//
function switchBG(element,color) {
	document.getElementById(element).style.backgroundColor = '#'+color;
}
function switchColor(element,color) {
	document.getElementById(element).style.color = '#'+color;
}

function setFile(value) {
	if(value=='') {
		document.getElementById('jpg').style.display='none';
		document.getElementById('jpg').style.height='0px';
		document.getElementById('jpg').style.overflow='hidden';
		
		document.getElementById('swf').style.display='none';
		document.getElementById('swf').style.height='0px';
		document.getElementById('swf').style.overflow='hidden';
	}
	
	if(value=='jpg') {
		document.getElementById('jpg').style.display='block';
		document.getElementById('jpg').style.height='auto';
		document.getElementById('jpg').style.overflow='auto';
		
		document.getElementById('swf').style.display='none';
		document.getElementById('swf').style.height='0px';
		document.getElementById('swf').style.overflow='hidden';
	}
	if(value=='swf') {
		document.getElementById('jpg').style.display='none';
		document.getElementById('jpg').style.height='0px';
		document.getElementById('jpg').style.overflow='hidden';
		
		document.getElementById('swf').style.display='block';
		document.getElementById('swf').style.height='auto';
		document.getElementById('swf').style.overflow='auto';
	}
}

//=======================HEADER FADER============================//
/*var imageNR = 0;
var start = 0;
function headerImage(container1,container2,fadeFirst,fadeTime,showSeconds,imagePath,imageArray) {
		amount = imageArray.length;
	if(amount == 1) {
		document.getElementById(container1).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
		setOpacity(document.getElementById(container1),100);
	} else {
		var delay = 0;
		var newArray = '';
		for(i=0;i<amount;i++) {
			if(i!=0) {
				var newArray = newArray+',';
			}
			var newArray = newArray+'"'+imageArray[i]+'"';
		}
		if(BrowserDetect.browser == "Explorer" && BrowserDetect.version <= 6) {
			var doFade = false;
		} else {
			var doFade = true;
		}
		if(start == 0 && fadeFirst == 'yes') {
			document.getElementById(container1).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
			if(doFade == true) {
				setOpacity(document.getElementById(container1),0);
				fadeIn(container1,0);
			}
			delay = fadeTime*1000;
		} else if(start == 0 && fadeFirst == 'no') {
			document.getElementById(container1).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
			if(doFade == true) {
				setOpacity(document.getElementById(container1),100);
			}
			delay = fadeTime*1000;
		} else if(imageNR%2==0) {
			if(imageNR == 0) {
				if(doFade == true) {
					document.getElementById(container1).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
					document.getElementById(container2).style.backgroundImage='url('+imagePath+imageArray[amount-1]+')';
					fadeIn(container1,0);
					fadeOut(container2,100);
				} else {
					document.getElementById(container1).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
					document.getElementById(container2).style.backgroundImage='';
				}
				delay = fadeTime*1000;
			} else {
				if(doFade == true) {
					document.getElementById(container1).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
					setOpacity(document.getElementById(container1),0);
					fadeIn(container1,0);
					fadeOut(container2,100);
				} else {
					document.getElementById(container1).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
					document.getElementById(container2).style.backgroundImage='none';
				}
				delay = fadeTime*1000;
			}
		} else {
			if(doFade == true) {
				document.getElementById(container2).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
				setOpacity(document.getElementById(container2),0);
				fadeIn(container2,0);
				fadeOut(container1,100);
			} else {
				document.getElementById(container1).style.backgroundImage='none';
				document.getElementById(container2).style.backgroundImage='url('+imagePath+imageArray[imageNR]+')';
			}
			delay = fadeTime*1000;
		}
		start = 1;
		if(imageNR == (amount-1)) {
			imageNR=0;
		} else {
			imageNR = imageNR+1;
		}
		delay = delay + (showSeconds*1000);
		setTimeout("headerImage('"+container1+"','"+container2+"','"+fadeFirst+"',"+fadeTime+","+showSeconds+",'"+imagePath+"',Array("+newArray+"))",delay);
	}
}*/
/*function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.MozOpacity = opacity/100;
	obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")",100);
		}
	}
}
function fadeOut(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity >= 0) {
			setOpacity(obj, opacity);
			opacity -= 10;
			window.setTimeout("fadeOut('"+objId+"',"+opacity+")",100);
		}
	}
}*/

//=======================PORTFOLIO FADE IN============================//
/*function fadeInPortfolio(objId,opacity,finalOpacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= finalOpacity) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeInPortfolio('"+objId+"',"+opacity+","+finalOpacity+")",90);
		}
	}
}*/

//=======================PORTFOLIO DO FADE============================//
/*function getItem(catID,itemID) {
	var container = document.getElementById('container');

	var popup = document.createElement('div');
	popup.id = 'portfolioPopup';
	container.appendChild(popup);
	popup.innerHTML = showItem(catID,itemID);
	if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version <= 6) {
		opacity = (100 == 100)?99.999:100;
		document.getElementById('portfolioPopup').style.filter = "alpha(opacity:"+opacity+")";
		document.getElementById('portfolioPopup').style.MozOpacity = opacity/100;
		document.getElementById('portfolioPopup').style.opacity = opacity/100;
	} else {
		fadeInPortfolio('portfolioPopup',20,100);
	}
}*/
/*function hideItem(divName) {
  var container = document.getElementById('container');
  var popup = document.getElementById(divName);  
  container.removeChild(popup);
}*/

//=======================PORTFOLIO SLIDER============================//
function moveSlide(direction,objId,defPos,speed,lMax,rMax) {
	if (document.getElementById) {
    	var obj = document.getElementById(objId);
		var pos = obj.style.left.split('px');
		if(pos[0] == '') {
			pos[0] = defPos;
		}
		if(direction == 'right') {
			var newPos = parseFloat(pos[0])-parseFloat(speed);
			obj.style.left = newPos+'px';
			timeout=setTimeout("moveSlide('"+direction+"','"+objId+"',"+defPos+","+speed+")",100);
		}
		if(direction == 'left') {
			var newPos = parseFloat(pos[0])+parseFloat(speed);
			obj.style.left = newPos+'px';
			timeout=setTimeout("moveSlide('"+direction+"','"+objId+"',"+defPos+","+speed+")",100);
		}
	}
}
function moveStop() {
	clearTimeout(timeout);
}

//=======================AJAX============================//
/*var xmlHttp

function showItem(catID,itemID) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url='getItem.php';
	url=url+"?id="+catID+"&iid="+itemID;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
function stateChanged() {
	if (xmlHttp.readyState==4) {
		document.getElementById('portfolioPopup').innerHTML=xmlHttp.responseText;
	}
}
	
function GetXmlHttpObject()	{
	var xmlHttp=null;
	try	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try	{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}*/

//=======================BROWSER DETECTION============================//
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
