galleryPS = new Array();
currentPic = 0;
currentSubMenu = '';
buffer = '';



window.onload = function () {

	if(document.getElementById("player")) {
		flowplayer("player", thisHost+"inc/flowplayer-3.1.5.swf", {
			clip:  {
				autoPlay: true,
				autoBuffering: false
			}
		});
	}

	if(document.getElementById('visualHolder') && (slideShow.length > 1) ) {
		nextPic = setTimeout("picCycle()", 3500);
		document.getElementById('visualimg').onmouseover=function() {
			this.style.cursor = 'pointer';
		}
		document.getElementById('visualimg').onclick=function() {
			window.location= slideShowUrl[1];
		}
	}

	if (document.getElementById('emailSpan')) {
	  document.getElementById('emailSpan').innerHTML = "info@agmistructures.nl";
	}

	if (document.getElementById('submitSpan')) {
	  document.getElementById('submitSpan').innerHTML = "<input type='submit' value='Versturen' style='border:1px solid'>";
  	}


	if (document.getElementById('menuTop')) {
		var arrBtn = document.getElementById('menuTop').getElementsByTagName('TD');
		for (var i = 0; i < arrBtn.length; i++) {

			if(arrBtn[i].className=='off') {

				arrBtn[i].onmouseover=function() {
				  this.className='on';
				}

				arrBtn[i].onmouseout =function() {
				  this.className='off';
				}
			}
		}
	}



	if (document.getElementById('subMenuTop')) {
		var arrBtn = document.getElementById('subMenuTop').getElementsByTagName('TD');
		for (var i = 0; i < arrBtn.length; i++) {

				arrBtn[i].onmouseover=function() {
					if(this.className=='off') {
				 		this.className='on';
					}

					showSubSubmenu(this.id);
				}

				if(arrBtn[i].className=='off') {
					arrBtn[i].onmouseout =function() {
							this.className='off';
					}
				}

		}
	}


}


/* EINDE ONLOAD		*/




function showSubSubmenu(strId) {


	restoreSubmenu();


	if( document.getElementById(strId+'_holder') ) {
		document.getElementById(strId+'_holder').style.display = 'block';

		currentSubMenu = strId+'_holder';
	}

	initBtn(strId);

}



function restoreSubmenu() {

	if( document.getElementById(currentSubMenu) ) {
	document.getElementById(currentSubMenu).style.display = 'none';
	}


}




function initBtn(strId) {

	if (document.getElementById(strId+'_holder')) {
		var arrBtn = document.getElementById(strId+'_holder').getElementsByTagName('TD');
		for (var i = 0; i < arrBtn.length; i++) {

				arrBtn[i].onmouseover=function() {
					if(this.className=='subOff') {
				 		this.className='subOn';
					}
				}


				arrBtn[i].onmouseout=function() {
					if(this.className=='subOn') {
				 		this.className='subOff';
					}
				}

		}
	}

}



function hoverOn(el) {
	el.className='on';
}

function hoverOff(el) {
	el.className='off';
}



function goTo(strUrl) {
	window.location= strUrl;
}




function showSheet(strEl) {
	sheet = document.getElementById(strEl);
	sheet.style.display='block';
}



function hideSheet(strEl) {
	sheet = document.getElementById(strEl);
	sheet.style.display='none';
}




function picCycle() {


	  if(nextPic != 'undefined') { clearTimeout(nextPic); }

		currentSlide++;

		if(currentSlide > (slideShow.length - 1)) {
		  currentSlide=0;
		}

		currentSRC = document.getElementById('visualimg').src;
		document.getElementById('visual').style.backgroundImage='url('+currentSRC+')';

		changeOpac(0, 'visualimg');
		document.getElementById('visualimg').style.visibility='hidden';
		document.getElementById('visualimg').src=slideShow[currentSlide];
		document.getElementById('visualimg').style.visibility='visible';

		document.getElementById('visualimg').onclick=function() {
			window.location= slideShowUrl[currentSlide];
		}

		opacity('visualimg', 0, 100, 600);

		nextPic = setTimeout("picCycle()", 3500);
}






function opacity(id, opacStart, opacEnd, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}




function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}






function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}



function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}


function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}





function isNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}





function asyncReq(type, actie, params, doel, doelnaam, onReady, onReadyVar) {

	if (typeof xmlHttp == 'undefined') {
		if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		  }
			requestHandle(xmlHttp, type, actie, params, doel, doelnaam, onReady, onReadyVar);

	} else {
			if (window.ActiveXObject) {
				xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
			} else if (window.XMLHttpRequest) {
				xmlHttp2 = new XMLHttpRequest();
			  }
			requestHandle(xmlHttp2, type, actie, params, doel, doelnaam, onReady, onReadyVar);
	  }
}



function requestHandle(xmlHttpObj, type, actie, params, doel, doelnaam, onReady, onReadyVar) {

	if(type == "GET") {
		actie = actie+'?'+params;
	}

  xmlHttpObj.open(type, actie, true);
    xmlHttpObj.onreadystatechange = function () {

		if((xmlHttpObj.readyState == 4) && (xmlHttpObj.status == 200)) {
				if((doel == 'dom') && document.getElementById(doelnaam)) {
     			  document.getElementById(doelnaam).innerHTML = xmlHttpObj.responseText;
     			  if(onReady != '') {
					 window[onReady](onReadyVar);
				  }
				}

				else if(doel == 'buffer') {
     			  buffer = xmlHttpObj.responseText;
     			  if(onReady != '') {
					 window[onReady](onReadyVar);
				  }
				}

				else if(doel == 'mce') {
				  	var inst = tinyMCE.getInstanceById(doelnaam);
					inst.execCommand("mceInsertContent", false, ''+xmlHttpObj.responseText);
				}
		}
	}

	if(type == "GET") {
    	xmlHttpObj.send(null);
	} else {
    	xmlHttpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    	xmlHttpObj.send(params);
	}
}

