window.onload = function() {
	var l = document.getElementsByTagName('A');
	var d = document.getElementsByTagName('DIV');
	var c = new Array();
	var i, o, par;
	var j = 0;
	var k=0;

	if(document.getElementById('flash')) {
		var flash;
		flash = new fx.Combo('flash', {height: false, opacity: true, duration: 600});
		for(i=0; i<l.length; i++) {
			switch (l[i].className) {
			case "selezionato":
				l[i].onclick = function() {
					ridimensiona();
					flash.toggle();
				}
			break;
			case "close":
				l[i].onclick = function() {
					flash.toggle();
				}
			break;
			}
		}
		ridimensiona();
	}

	if(document.getElementById('widthbox')) {

		/* if(thumbnailnum > maxthumbvisible) {
			document.getElementById('back').innerHTML = '<div id="leftmore"></div>';
			
		}
		
		if(thumbnailnum > maxthumbvisible){
			document.getElementById('more').innerHTML= '<div id="rightmore"></div>';
		} */

		for(i=0; i<l.length; i++) {
			switch (l[i].className) {
			case "qui":
				l[i].onclick = function() {
					thisid = Number(this.title);
					thiswidth = imggallery[thisid][1];
					thisheight = imggallery[thisid][2];
					thispos = imggallery[thisid][8];
					getstarted(Number(thiswidth), Number(thisheight), 'imgloader', Number(thispos), Number(thispos), current_imgid);
				}
			break;

			case "prev":
				l[i].onclick = function() {
					previmage(current_imgid);	
				}
			break;
			
			case "next":
				l[i].onclick = function() {
					nextimage(current_imgid);	
				}
			break;
			
			case "info":
				l[i].onclick = function() {
					loadinfo();
				}
			break;
			
			case "thumb":
				l[i].onclick = function() {
					thumbs();
				}
			break;
		
			case "back":
				l[i].onclick = function() {
					checkbutton(addposition('minus'));
					movethumbs('plus');
				}
			break;	

			case "more":
				l[i].onclick = function() {
					checkbutton(addposition('plus'));
					movethumbs('minus');
				}
			break;	
			}
		}
		loadfirstimage();
		document.getElementById('photocount').innerHTML="1 / "+tempgallery.length+" " + tit[0]
	}
	
	for (i=0; i<l.length; i++) {
		if (l[i].className == "ext") {
			l[i].target = "_blank";
		}
		if (l[i].href == document.baseURI) {
			l[i].href = "javascript:void(null);"
		}
	}
}
