var activeText="";
var currText=new Array();
currText[0]="geen";
var noo=0;
var currno=0;
var xPos=0;
var currentPhoto;
var topShoe=new Array(120,120,70,90,100,100,80,70,90,100);
var leftShoe=new Array(2,0,12,7,10,10,8,7,9,10);


function popDetail(dir,naam) {
	newwin = window.open("foto.php?dir="+dir+"&naam="+naam, "newwin", "width=300, height=300, location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=yes, scrollbars=YES");
	newwin.focus;
}

function popInfo(dir,naam) {
	newwin = window.open("info.html", "newwin", "width=380, height=600, location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=yes, scrollbars=YES");
	newwin.focus;
}

function writeIt(text,id){
  if (document.getElementById){
          x = document.getElementById(id);
          x.innerHTML = text;
  }
  else if (document.all){
          x = document.all[id];
          x.innerHTML = text;
  }
  else if (document.layers){
          x = document.layers[id];
          text2 = '<P CLASS="testclass">' + text + '</P>';
          x.document.open();
          x.document.write(text2);
          x.document.close();
  }
}

function chooseRandom(myLowNum, myHighNum) {
	var myRange = myHighNum - myLowNum + 1;
	var result = Math.floor(myRange * Math.random());
	result += myLowNum;
	return result;
};

function shuffleArray(myArray) {
	var myRandomPosition;
	var myChoice;
	for (x=(myArray.length - 1); x > 0; x--) {
		myRandomPosition = chooseRandom(1, x);
		myChoice = myArray[myRandomPosition];
		myArray[myRandomPosition] = myArray[x];
		myArray[x] = myChoice;
	};
};

function showText(no,Titel,xPos,i){
	var y = getObj("hdr");
	writeIt(Titel, "hdr");
	y.left =xPos;	
	y.visibility = 'visible';
	noo="h"+i;
	if(currno!=noo){
		document.images[noo].src="gfx/huisjes/"+no+"_mo.gif";
	}
}

function resetTitel(){
	if(currText[0]!="geen"){
		writeIt(currText[0], "hdr");
		var y = getObj("hdr");
		y.left =currText[1];	
		y.visibility = 'visible';
	}
	else{
		writeIt("", "hdr");
	}
}

//let op i en no zijn omgekeerd hiero!! 
function showShoe(i, no,xPos,dir,Titel){
		var x = getObj("calli");
		x.visibility = 'hidden';

		currText[0]=Titel;
		currText[1]=xPos;
		noo="h"+no;
		if(currno!=0){
			document.images[currno].src="gfx/huisjes/"+curri+".gif";
		}
		document.images[noo].src="gfx/huisjes/"+i+"_mo.gif";
		currno=noo;
		curri=i;
		
		shoeimg="shoeanim"+no;
		shoediv="shoe"+no;
		document.images[shoeimg].src="gfx/shoe.gif";
		var x = getObj(shoediv);
		x.left = xPos+leftShoe[i];	
		yPos=topShoe[i];
		x.top = yPos;
		x.visibility = 'visible';

		shuffleArray(work[no]);
		workHTML='<table name="dingdong" id="dingdong" cellspacing="0" cellpadding="0">';
		workHTML+='<tr>';
		workHTML+='<td width="300" class="tekst2" valign="top">';
		workHTML+=work[no][0];
		workHTML+='</td>';
		var worklength=work[no].length;
		for (i=1; i < work[no].length; i++) { 
			workHTML+='<td valign="top"><a href=javascript:popDetail("'+dir+'","'+work[no][i]+'") onfocus="this.blur()"><img src="gfx/'+dir+'/small/'+work[no][i]+'" alt="" hspace="10" border="0" style="border:1px solid #818181;" ></a></td>';
		}
		workHTML+='</tr>';
		workHTML+='<tr>';
		workHTML+='<td width="300"><img src="gfx/nix.gif" width="300" height="1" alt="" border="0"></td>';
		workHTML+='<td colspan="2"></td>';
		workHTML+='</tr>';
		workHTML+='</table>';
	
		writeIt(workHTML,"tekst");
		
		var y = getObj("tekst");
		y.left = xPos;	
		y.visibility = 'visible';
		activeText=currText;
		//tableW = document.getElementById("dingdong").offsetWidth;
		tableW=136*worklength+650;
		if(tableW+xPos>contentW_minimum){
			contentW=tableW+xPos;
		}
		else{
			contentW=contentW_minimum-350;
		}
		test=parseFloat(-contentL/contentW);
		dragL=(contentClipW*test)+14;
		//alert(dragL);
		scrollLength = ((scrollW-dragW)/(contentW-contentClipW));
		moveTo();
}


function hideHouse(no,i){
	if(allowInteract){
		noo="h"+i;
		if(currno!=noo){
		document.images[noo].src="gfx/huisjes/"+no+".gif";
		}
	}
}

function getObj(name){
  if (document.getElementById){
    return document.getElementById(name).style;
  }
  else if (document.all){
    return document.all[name].style;
  }
  else if (document.layers){
    return document.layers[name];
  }
  else return false;
}	