////////////////////////////////////////////////////// FORM SUBMIT  ////////////////////////////////////////////////////// 
$(document).ready(function() {
	/*$('#sendForm').click(function(){
		//alert('ee');
		var msg = '';
		var em = '';
		var j = 0;
		$('form#formcontact *[rel=form]').each(function(){
			if($(this).attr('alt') == 'Required' && $(this).val() == ''){
				j++;
				//alert($(this).attr('alt'));
				if(j != 1){
					msg += ', ';
				}
				msg += '\''+$(this).parent('div').parent('div').find('div').attr('alt')+'\'';
			}
			
			if($(this).parent('div').parent('div').find('div').attr('alt') == 'E-mail'){
				if(!validMail($(this).val())){
					//alert('ddd');
					em += "\n"+'Gelieve een correct e-mailadres in te vullen.';
				}
				//alert();
			}
		});
		if(msg != '' || em != ''){
			alert('Volgende velden zijn verplicht in te vullen: '+msg+'.'+em);
		}else{
			//alert('rr');
			$('form#formcontact').submit();
		}
	})*/
})

////////////////////////////////////////////////////// PUBLIC VARIABLES  ////////////////////////////////////////////////////// 

var slideshow_int = new Array();
var thumbs;
var minx;
var ttl;
var info_arr = new Array();
var photo_arr = new Array();
var photo_max_arr = new Array();
var photo_active = new Array(0,0,0,0,0);
 
  
 


////////////////////////////////////////////////////// TOOLBOX ////////////////////////////////////////////////////// 

function setResolution() {
	w = window.screen.availWidth;
	h = window.screen.availHeight;
	window.resizeTo(w,h);
	window.moveTo(0,0);
	window.focus();
}

function writeEmailAddress(nme, dom, cou, cla){
	   document.write("<a href='mailto:"+nme+"@"+dom+"."+cou+"' class="+cla+" >"+nme+"@"+dom+"."+cou+"</a>");
}

function changeTitle(tit){
	document.getElementById("changetitle").innerHTML = tit;
	document.title = document.getElementById("changetitle").innerHTML;
	document.getElementById("changetitle").innerHTML = "";
}


function hideDiv(id){
	document.getElementById(id).style.display="none";
}

function showDiv(id){
	document.getElementById(id).style.display="block";
}

function changeImg(id, img){
	document.getElementById(id).src = img;
}

function changeImgLnk(id, img){
	id.childNodes[0].src = img;
}
	
function removeWhiteSpace(id){
	//remove whitespace (FF sees whitespace as extra nodes)
	for(j=0; j<id.childNodes.length; j++){
		if(!id.childNodes[j].innerHTML){
			id.removeChild(id.childNodes[j]);
		}
	}
	return id;
}	

//change rel="external" to target="_blank" -> XHTML strict work around
function externalToBlank() {
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
	}
}

//snippet for fade in / out

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

	//determine the direction for the blending, if start and end are the same nothing happens
	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++;
        }
    }
}

//change the opacity for different browsers
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 + ")";
} 

//end snippet

//contact mail validate
function validMail(str){
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if(str.indexOf(at)==-1){return false;}
	if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false;}
	if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false;}
	if(str.indexOf(at,(lat+1))!=-1){return false;}
	if(str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false;}
	if(str.indexOf(dot,(lat+2))==-1){return false;}	
	if(str.indexOf(" ")!=-1){return false;}
	return true;		
}

//////////////////////////////////// RANDOM BACK //////////////////////////////////////////

function placeBackDiv(id, c, w, h){
	var obj = document.getElementById(id);
	obj.innerHTML = obj.innerHTML+'<div style="background:'+c+'; display:block; position:relative; float:left;  width:'+w+'px; height:'+h+'px;"></div>';
}
function buildBack(broken){
	var col_arr = new Array("0","1","2","3","4","5","6","7","8","9","C","D","E","F");
	var cont = document.getElementById("container");
	var co = "#EEEEEE";
	var wi = 0;
	var hc = cont.clientHeight+30;
	var hs = document.body.clientHeight;
	if(hs>hc){
		var he = hs;
	} else{
		var he = hc;
	}
	//var bcw = document.getElementById("backcontainer").clientWidth;
	var bcw = 2000;
	var totw = 0;
	for(i=0; i<200; i++){
		if(totw<bcw){
			var temp1 = Math.round(12);
			var temp2 = Math.round(Math.random()*13);
			var temp3 = col_arr[temp1]+col_arr[temp2];
			co = "#"+temp3+temp3+temp3;
			wi = 2+2*Math.floor(Math.random()*10);
			if(broken){
				he = 10+10*Math.floor(Math.random()*100);
				he /= 2;
			}
			placeBackDiv("backcontainer", co, wi, he*2);
			totw += wi;
		} else {
			break;
		}
	}
	//set back height & width;
	$('#back').css({'width' : '100%', 'height' : he+'px'})
 }
 function setBack(){
	var cont = document.getElementById("container");
	var hc = cont.clientHeight+30;
	var hs = document.body.clientHeight;
	//var ws= document.body.clientWidth;
	if(hs>hc){
		var he = hs;
	} else{
		var he = hc;
	}
	//set back height & width;
	$('#back').css({'width' : '100%', 'height' : he+'px'})
 }