// JavaScript Document

function showSubmenu(which) {
document.getElementById(which).style.marginLeft='0px';
}

function hideSubmenu(which) {
document.getElementById(which).style.marginLeft='-10000px';
document.getElementById(which+'2').style.marginLeft='-10000px';
}


function sourceSwitch (which) {
document.getElementById('mainslide').src='../resources/images/onze_roofvogels/'+which+'.jpg';
document.getElementById('birdname').innerHTML=which.slice(0,-3);
}

function sourceSwitch2 (which) {
document.getElementById('mainslide').src='../resources/images/demonstratie/'+which+'.jpg';	
}

function sourceSwitch3 (which) {
document.getElementById('mainslide').src='resources/images/jacht/'+which+'.jpg';	
}



function ScrollPDPContent (direction) {

var pdpmovement = 68; //movement per click
var pdpscrollcontent = 'pdpscrollcontent'; //define the content div Id
var pdpscrollwindow = 'pdpscrollwindow'; //define the scrollwindow div Id

var thePDPContent = document.getElementById(pdpscrollcontent);
var thePDPWindow = document.getElementById(pdpscrollwindow);
var scrollWindowHeight = parseInt(thePDPWindow.offsetHeight);
var scrollContentHeight = parseInt(thePDPContent.offsetHeight);
var scrollContentTopMargin = thePDPContent.style.marginTop;
//var leftButton = document.getElementById("leftbutton").style.visibility;
//var rightButton = document.getElementById("rightbutton").style.visibility;


	if (direction == "top") {
		
		var currentPDPPosition = parseInt(scrollContentTopMargin)-68;
		var endPDPPositionCalculated = scrollContentHeight - scrollWindowHeight;
		var endPDPPosition = parseInt('-'+endPDPPositionCalculated);
		
		if (currentPDPPosition > endPDPPosition ) {
			
			pdpmoving =  parseInt(scrollContentTopMargin) - parseInt(pdpmovement);
			document.getElementById("bottombutton").style.visibility = 'visible';
			
			
			movePDPLeft(pdpmoving);		
					
		}
		else if (currentPDPPosition <= endPDPPosition) {
		document.getElementById("topbutton").style.visibility = 'hidden';
		}
	}
	
	if (direction == "bottom") {
		var currentPDPPosition = parseInt(scrollContentTopMargin);
		var endPDPPositionCalculated = scrollContentHeight - scrollWindowHeight;
		var endPDPPosition = parseInt(endPDPPositionCalculated);
		
		if (currentPDPPosition < 0 ) {
			
			pdpmoving =  parseInt(scrollContentTopMargin) + parseInt(pdpmovement);
			document.getElementById("topbutton").style.visibility = 'visible';	

			movePDPRight(pdpmoving);			
					
		}
		else if (currentPDPPosition >= 0) {
		document.getElementById("bottombutton").style.visibility = 'hidden';	
		}
	}		


}



function movePDPLeft (pdpmove) {

var pdpmovement = 68; //movement per click
var pdpscrollcontent = 'pdpscrollcontent'; //define the content div Id
var pdpscrollwindow = 'pdpscrollwindow'; //define the scrollwindow div Id

var thePDPContent = document.getElementById(pdpscrollcontent);
var thePDPWindow = document.getElementById(pdpscrollwindow);
var scrollWindowHeight = parseInt(thePDPWindow.offsetHeight);
var scrollContentHeight = parseInt(thePDPContent.offsetHeight);
var scrollContentTopMargin = thePDPContent.style.marginTop;

var currentPDPPosition = parseInt(scrollContentTopMargin)-68;
var endPDPPositionCalculated = scrollContentHeight - scrollWindowHeight;
var endPDPPosition = parseInt('-'+endPDPPositionCalculated);

currentpdppos =  parseInt(document.getElementById("pdpscrollcontent").style.marginTop);


	if (currentpdppos > pdpmove) {
		
		pdpmover=parseInt(pdpmove);
		
		setTimeout("document.getElementById('pdpscrollcontent').style.marginTop = parseInt(document.getElementById('pdpscrollcontent').style.marginTop)-10+'px';movePDPLeft (pdpmover);", 15);
		if (currentPDPPosition <= endPDPPosition) {
		document.getElementById("topbutton").style.visibility = 'hidden';
		}
	}
	
}

function movePDPRight (pdpmove) {
var pdpmovement = 68; //movement per click
var pdpscrollcontent = 'pdpscrollcontent'; //define the content div Id
var pdpscrollwindow = 'pdpscrollwindow'; //define the scrollwindow div Id

var thePDPContent = document.getElementById(pdpscrollcontent);
var thePDPWindow = document.getElementById(pdpscrollwindow);
var scrollWindowHeight = parseInt(thePDPWindow.offsetHeight);
var scrollContentHeight = parseInt(thePDPContent.offsetHeight);
var scrollContentTopMargin = thePDPContent.style.marginTop;

var currentPDPPosition = parseInt(scrollContentTopMargin)-68;
var endPDPPositionCalculated = scrollContentHeight - scrollWindowHeight;
var endPDPPosition = parseInt('-'+endPDPPositionCalculated);

currentpdppos =  parseInt(document.getElementById("pdpscrollcontent").style.marginTop);

	if (currentpdppos < pdpmove) {
	
		pdpmover=parseInt(pdpmove);
		
		setTimeout("document.getElementById('pdpscrollcontent').style.marginTop = parseInt(document.getElementById('pdpscrollcontent').style.marginTop)+10+'px';movePDPRight (pdpmover);", 15);
		if (currentPDPPosition >= '-78') {
		document.getElementById("bottombutton").style.visibility = 'hidden';	
		}
	}

}

/*function sourceSwitch (which) {
document.getElementById('mainslide').src='resources/images/onze_vogels/'+which+'.jpg';	
}*/





function CheckForms (buttonValue,formName) {
var obj = document.getElementsByClassName("text checkit");
	var showError=false;
	var emailError=false;	

	for(i=0;i<obj.length;i++) {

	if (obj[i].value == 0) { 

		obj[i].style.border="1px solid #FF0000";
			showError=true;
		}
		else {
			if (obj[i].name == "MAILFROM") {
				
			    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

				if(pattern.test(obj[i].value)) {         
					obj[i].style.border="1px solid #807D5E";	   
				}
				else {   
					obj[i].style.border="1px solid #FF0000";
					emailError=true;
					showError=true;
				}
			}
			else {
			obj[i].style.border="1px solid #807D5E";
			}
		}
	}	
	
	if (showError == true) {

		var errorMessage="<p>Het formulier werd nog niet verzonden. Gelieve";
		if (emailError == true) {
			errorMessage+=" een geldig e-mailadres te gebruiken en";		
		}
		errorMessage+=" alle velden die in het rood zijn gemarkeerd te vervolledigen en nogmaals op '"+buttonValue+"' te klikken om opnieuw te verzenden.</p>";
		document.getElementById('errorMessage').innerHTML=errorMessage;
		document.getElementById('errorMessage').style.display="inline";
	}
	else {
		document.getElementById('errorMessage').style.display="none";
		document.getElementById(formName).submit();
	}
	
	showError=false;
	emailError=false;
	
} 



document.getElementsByClassName = function (c) { 

var r = new Array()
var j = 0 
var o = document.getElementsByTagName("*") 
for(i=0;i<o.length;i++) { 
if(o[i].className == c) { 
r[j]=o[i];j++; 
} 
} 
return r; 
} 
