/* Array aller Bildernamen */
var namen=new Array("http://www.forrodedomingo.de/pages/images/top_pics/Bild1_1.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_2.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_3.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_4.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_5.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_6.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_7.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_8.jpg",
					"http://www.forrodedomingo.de/pages/images/top_pics/Bild1_9.jpg");

 /* Definition des Bilder-Arrays */
var bilder=new Array();


function rand(range) {
	return Math.ceil(Math.random() * 1000) % range + 1;
}					
										

 /* Laedt die Bilder */  
function lade() {
  var i;                     
  for (i=0;i<namen.length;i++)   {
    bilder[i]=new Image();   /* neues Image-Objekt erzeugen */
    bilder[i].src=namen[i];  /* Quelldateiname des Bildes setzen */
  }
}

 /* zeigt ein Bild an */
function zeige(nr) {
var picName="x"+rand(namen.length);
  document.images[picName].src=bilder[nr].src;
    /* Bild austauschen */
   changePics(nr+1); 
}

/* Tauscht Bild */
function changePics(i){
	var j = i;
	if (j >= namen.length) {
		j = 0;
	}
	var methodName = "zeige("+j+")";
	window.setTimeout(methodName,2000);
	
}

function toggle (divId, aId,aPage) {

	if (document.getElementById(divId).className == 'hidden') {
		document.getElementById(divId).className = 'visible';
		document.getElementById(aId).firstChild.nodeValue = 
			document.getElementById(aId).firstChild.nodeValue.replace(/\+/,"-");
		ajaxUpdater(divId,aPage);
	} else {
		document.getElementById(divId).className = 'hidden';
		document.getElementById(aId).firstChild.nodeValue =
			document.getElementById(aId).firstChild.nodeValue.replace(/\-/,"+");
	}
	
}

function parseWindowLocation(aLocation)
{
var re = /[?&]([^=]+)=([^&]+)/g;
var maches = null;
var urlParts = new Array();
maches = aLocation.match(re);
if(maches != null)
{
for(var i=0;i< maches.length;i++)
{
var urlPart = maches[i].split("=");
urlParts[urlPart[0].substr(1)] = urlPart[1];
}
}
return urlParts;
}

function initWindow() {
	var $GET = parseWindowLocation(window.location.href);
	if ($GET['open'] != null) {
		toggle('div'+$GET['open'],'a'+$GET['open'], '../gallerie/'+$GET['open']+'/thumbs'+$GET['open']+'.php');
	}
}

function openWindow(target) {
	window.open(target, "Bild", "width=680,height=700,scrollbars=yes");
}