galleryPS = new Array();
currentPic = 1;
tab = 1;
thisHost = 'http://www.vincenthuibers.nl/';
map = 'normaal';
strFlashcode = '<p>&nbsp;</p>'
			+'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="872" height="200" id="flash" align="middle">'
			+'<param name="allowScriptAccess" value="sameDomain" />'
			+'<param name="allowFullScreen" value="false" />'
			+'<param name="movie" value="./pix/gallery_wio/groenstestad.swf" />'
			+'<param name="quality" value="high" />'
			+'<param name="bgcolor" value="#000000" />'
			+'<embed src="./pix/gallery_wio/groenstestad.swf" quality="high" bgcolor="#000000" width="872" height="200" name="flash" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
			+'</object>';



window.onload = function () {

  if (document.getElementById('emlspan')) {
	document.getElementById('emlspan').innerHTML = "info@vincenthuijbers.nl";
  }

  if (document.getElementById('gallery')) {
    map = 'gallery';
    initGal(1);
    initGalButtons();
  }
  if (document.getElementById('gallery_wio')) {
    map = 'gallery_wio';
    initGal(1);
    initGalButtons();
  }



  if (document.getElementById('verderVrijwerk')) {

    document.getElementById('verderVrijwerk').onmouseover = function() {
		  this.style.cursor = 'pointer';
		  document.getElementById('verderVrijwerk').style.color = '#466663';
	}

    document.getElementById('verderVrijwerk').onclick = function() {
		if(document.getElementById('gal_1').style.display == 'block') {
			document.getElementById('gal_1').style.display = 'none';
			document.getElementById('gal_2').style.display = 'block';

			initGal(2);
    		initGalButtons()


		} else {
			window.location=thisHost+'graffiti-werk-in-opdracht';
		}
	}

    document.getElementById('verderVrijwerk').onmouseout = function() {
		  this.style.cursor = 'default';
		  document.getElementById('verderVrijwerk').style.color = '#222222';
	}

  }




  if (document.getElementById('verderWIO')) {

    document.getElementById('verderWIO').onmouseover = function() {
		  this.style.cursor = 'pointer';
		  document.getElementById('verderWIO').style.color = '#466663';
	}

    document.getElementById('verderWIO').onclick = function() {
		if(document.getElementById('gal_1').style.display == 'block') {
			document.getElementById('gal_1').style.display = 'none';
			document.getElementById('gal_2').style.display = 'block';

			initGal(2);
    		initGalButtons()


		} else {
			window.location=thisHost+'workshop-graffiti';
		}
	}

    document.getElementById('verderWIO').onmouseout = function() {
		  this.style.cursor = 'default';
		  document.getElementById('verderWIO').style.color = '#222222';
	}

  }







  if (document.getElementById('sluiten')) {
	var btnSluit = document.getElementById('sluiten');

	btnSluit.onmouseover=function(){
		this.style.cursor = 'pointer';
		btnSluit.src = thisHost+'/pix/sluiten_on.gif';
	}

	btnSluit.onmouseout=function(){
		btnSluit.src = thisHost+'/pix/sluiten.gif';
	}

	btnSluit.onclick=function(){
		document.getElementById('fotogroot').style.visibility = 'hidden';
		document.getElementById('fotogroot').src = thisHost+'pix/galerij/wit.png';
		document.getElementById('flashcontent').innerHTML = '';
		document.getElementById('fotolijst').style.visibility = 'hidden';
	}
  }




  if (document.getElementById('sluitenTwee')) {
	var btnSluit = document.getElementById('sluitenTwee');

	btnSluit.onmouseover=function(){
		this.style.cursor = 'pointer';
		btnSluit.src = thisHost+'/pix/sluiten_on.gif';
	}

	btnSluit.onmouseout=function(){
		btnSluit.src = thisHost+'/pix/sluiten.gif';
	}

	btnSluit.onclick=function(){
		document.getElementById('fotogroot').style.visibility = 'hidden';
		document.getElementById('fotogroot').src = thisHost+'pix/galerij/wit.png';
		document.getElementById('flashcontent').innerHTML = '';
		document.getElementById('fotolijst').style.visibility = 'hidden';
	}
  }







}






function initGal(tabIn) {

	  tab = tabIn;
	  currentPic = 1;

	  var btn=document.getElementById('gal_'+tab).getElementsByTagName("IMG");

	  for(var i=0;i<btn.length;i++) {

		btn[i].onmouseover=function() {
		  if(this.alt != 'na') {
		  this.style.cursor = 'pointer';
		  opacity(this.id, 100, 50, 128);

		  document.getElementById('miniText').innerHTML = document.getElementById('desc_'+this.id.substr(5)).innerHTML;
		  }
		}
		btn[i].onmouseout=function() {
		  if(this.alt != 'na') {
		  opacity(this.id, 50, 100, 768);
		  document.getElementById('miniText').innerHTML = '';
		  }
		}
		btn[i].onclick=function() {
		  if(this.alt != 'na') {
		  showPic(this.id.substr(5));
		  }
		}
	  }


}




function initGalButtons() {


  if (document.getElementById('vorige')) {
	var btnVorige = document.getElementById('vorige');

	btnVorige.onmouseover=function(){
		this.style.cursor = 'pointer';
		btnVorige.src = thisHost+'pix/vorige_on.gif';
	}

	btnVorige.onmouseout=function(){
		btnVorige.src = thisHost+'pix/vorige.gif';
	}

	btnVorige.onclick=function(){
		navigateGal(-1);
	}
  }




  if (document.getElementById('volgende')) {
	var btnVolgende = document.getElementById('volgende');

	btnVolgende.onmouseover=function(){
		this.style.cursor = 'pointer';
		btnVolgende.src = thisHost+'pix/volgende_on.gif';
	}

	btnVolgende.onmouseout=function(){
		btnVolgende.src = thisHost+'pix/volgende.gif';
	}

	btnVolgende.onclick=function(){
		navigateGal(1);
	}
  }






  if (document.getElementById('vorigeTwee')) {
	var btnVorige = document.getElementById('vorigeTwee');

	btnVorige.onmouseover=function(){
		this.style.cursor = 'pointer';
		btnVorige.src = thisHost+'pix/vorige_on.gif';
	}

	btnVorige.onmouseout=function(){
		btnVorige.src = thisHost+'pix/vorige.gif';
	}

	btnVorige.onclick=function(){
		navigateGal(-1);
	}
  }




  if (document.getElementById('volgendeTwee')) {
	var btnVolgende = document.getElementById('volgendeTwee');

	btnVolgende.onmouseover=function(){
		this.style.cursor = 'pointer';
		btnVolgende.src = thisHost+'pix/volgende_on.gif';
	}

	btnVolgende.onmouseout=function(){
		btnVolgende.src = thisHost+'pix/volgende.gif';
	}

	btnVolgende.onclick=function(){
		navigateGal(1);
	}
  }





}


function navigateGal(pos) {

// ingesteld voor 15 foto's per pagina/album


	currentPic = parseInt(currentPic)+parseInt(pos);


		if(currentPic == 0) {
			currentPic = 30;
		}
		if(currentPic > 30) {
			currentPic = 1;
		}


/*
	if(tab == 2) {
		if(currentPic == 15) {
			currentPic = 30;
		}
		if(currentPic > 30) {
			currentPic = 16;
		}
	} else {
		if(currentPic == 0) {
			currentPic = 15;
		}
		if(currentPic > 15) {
			currentPic = 1;
		}
	}
*/


	if( (map == 'gallery_wio') && (currentPic == 1) ){
		document.getElementById('fotogroot').src = '';
		document.getElementById('flashcontent').innerHTML = strFlashcode;
	} else {
		showPic(currentPic);
		document.getElementById('flashcontent').innerHTML = '';
	}

	setText(currentPic);

}



function showPic(fotoNr) {

	currentPic = parseInt(fotoNr);


	var folderAdd = map.substr(7);
	var foto = document.getElementById('fotogroot');

	/*if((fotoNr == 1) && (folderAdd == "_wio")) {

		foto.src='';
		document.getElementById('flashcontent').innerHTML = strFlashcode;
		setText(fotoNr);


		setTimeout("document.getElementById('fotolijst').style.visibility = 'visible'", 150);
		setTimeout("document.getElementById('fotogroot').style.visibility = 'visible'", 150);

	} else {*/

		// settings
		foto.src = './pix/gallery'+folderAdd+'/'+fotoNr+'.jpg';

		setText(fotoNr);

		//effecten
		setTimeout("document.getElementById('fotolijst').style.visibility = 'visible'", 150);
		setTimeout("document.getElementById('fotogroot').style.visibility = 'visible'", 150);
	//}
}



function setText(nr) {
		if(document.getElementById('desc_'+nr)) {
			document.getElementById('imgText').innerHTML = document.getElementById('desc_'+nr).innerHTML;
		}
}



function asyncReq(type, actie, params, doel, doelnaam) {
	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);

	} else {
			if (window.ActiveXObject) {
				xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
			} else if (window.XMLHttpRequest) {
				xmlHttp2 = new XMLHttpRequest();
			  }
			requestHandle(xmlHttp2, type, actie, params, doel, doelnaam);
	  }


}



function requestHandle(xmlHttpObj, type, actie, params, doel, doelnaam) {
	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;
				}

				else if(doel == 'buffer') {
     			  buffer = xmlHttpObj.responseText;
				}
		}
	}

	if(type == "GET") {
    	xmlHttpObj.send(null);
	} else {
    	xmlHttpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    	xmlHttpObj.send(params);
	}
}






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 + ")";
}


