function upload_functie(){
	/*<![CDATA[*/
	$(document).ready(function(){
	/* example 1 */
	var button = $('#button1'), interval;

	new Ajax_upload(button,{
		action: 'uploadscript.php?album=<?=$_GET["album"]?>&albumid=<?=$_GET["id"]?>', // I disabled uploads in this example for security reasons
		//action: 'upload.htm', 
		name: 'myfile',
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			button.text('Uploading');
			// If you want to allow uploading only 1 file at time,
			// you can disable upload button
			this.disable();
			// Uploding -> Uploading. -> Uploading...
			interval = window.setInterval(function(){
				var text = button.text();
				if (text.length < 13){
					button.text(text + '.');					
				} else {
					button.text('Uploading');				
				}
			}, 200);
		},
		onComplete: function(file, response){
			// for debuging, activate alert.
			//alert(response);
			button.text('Upload');
						
			window.clearInterval(interval);
						
			// enable upload button
			this.enable();
			$("#show_fotos").load("../album/test.php?albumid=<?=$_GET['id']?>");
			
			// add file to the list
			$('<li></li>').appendTo('#example1 .files').text(file);						
		}
	});
 

		
	});/*]]>*/
}


function ajaxRequest(url, targetdiv, para) {
	new Ajax.Request(url, {
			method: 'post',
			parameters:   para ,
			onSuccess: function(page_request) { loadpage(page_request, targetdiv); },
			onFailure: function() { alert("There was an error with the connection");}
	});
}

function loadpage(page_request, containerid){
	result = page_request.responseText;
	var s = "", r = /<script>([\s\S]+)<\/script>/mi;

	// <script> tags must be executed apart with eval(s)
	if (result.match(r)){
		s = RegExp.$1; // extract script
		result = result.replace(r, "");
	}


	// Put result in a targetdiv
	if (containerid!='' && document.getElementById(containerid)) {
		document.getElementById(containerid).innerHTML = result;
	}
	
	
	eval(s); // execute script
}

function checkFormFields(errordiv,formfields) {
	var result = true;
	var fields = formfields.split(',');
	for (var i=0; i<fields.length; i++) {
		field = fields[i];
		var elm = document.getElementById(field);
		if (elm.value=='') {
				result = false;
				elm.className = 'input_error';
		} else {
				elm.className = 'input';
		}		
	}
	// Error display
	if (result==false) {
		var targetDiv = document.getElementById(errordiv);
		if (targetDiv) {
			document.getElementById('errordiv').style.visibility	=	"visible";	
			targetDiv.innerHTML = "Bepaalde verplichte velden zijn niet ingevoerd. Uw wijzigingen zijn nog niet opgeslagen.";
		}
	}

	// Result
	return result;
}

function displayTab(tab,panel,tablink) {
	// Set all div panels except current to display:none
	var divCollection = document.getElementsByTagName("div");
	for (var i=0; i<divCollection.length; i++) {
		if (divCollection[i].getAttribute("id")) {
			// Get length
			var iLen = divCollection[i].getAttribute("id").length;
	
			// Search for _panel
			if (iLen>6 && divCollection[i].getAttribute("id").substring(iLen, iLen-6)=="_panel") {
	
				// Set specified panel to display:block and all others panels to display:none
				if (divCollection[i].getAttribute("id")==panel) {				
					divCollection[i].style.display = 'block';
				} else {
					divCollection[i].style.display = 'none';
				}
			}
	
			// Search for _tab: remember we have 3 subtabs: left / center / right
			tab_left   = tab + "_left";
			tab_center = tab + "_center";
			tab_right  = tab + "_right";
		
			if (iLen>9 && divCollection[i].getAttribute("id").substring(iLen, iLen-9)=="_tab_left") {
				// Set specified tab to display:block and all others panels to display:none
				if (divCollection[i].getAttribute("id")==tab_left) {				
					divCollection[i].className = 'tab_page_left_selected';
				} else {
					divCollection[i].className = 'tab_page_left';
				}
			}
			
			if (iLen>11 && divCollection[i].getAttribute("id").substring(iLen, iLen-11)=="_tab_center") {
				// Set specified tab to display:block and all others panels to display:none
				if (divCollection[i].getAttribute("id")==tab_center) {				
					divCollection[i].className = 'tab_page_center_selected';
				} else {
					divCollection[i].className = 'tab_page_center';
				}
			}
		
			if (iLen>10 && divCollection[i].getAttribute("id").substring(iLen, iLen-10)=="_tab_right") {
				// Set specified tab to display:block and all others panels to display:none
				if (divCollection[i].getAttribute("id")==tab_right) {				
					divCollection[i].className = 'tab_page_right_selected';
				} else {
					divCollection[i].className = 'tab_page_right';
				}
			}
		}
	}
	
	
	var linkCollection = document.getElementsByTagName("a");
	for (var i=0; i<linkCollection.length; i++) {
		if (linkCollection[i].getAttribute("id")) {
			// Get length
			var iLen = linkCollection[i].getAttribute("id").length;
			
			// Search for _link
			if (iLen>5 && linkCollection[i].getAttribute("id").substring(iLen, iLen-5)=="_link") {
		
				// Set specified panel to display:block and all others panels to display:none
				if (linkCollection[i].getAttribute("id")==tablink) {				
					linkCollection[i].style.color = '#4873ff';											
				} else {
					linkCollection[i].style.color = '#808080';
				}
			}
		}
	}
}

function disableButton(id) {
	document.getElementById(id).disabled = true;
	document.getElementById('errordiv').style.visibility	=	"visible";	
}

function enableButton(id) {
	document.getElementById(id).disabled = false;
	document.getElementById('errordiv').style.visibility	=	"hidden";	

}

function showdivs() {
	document.getElementById("divStayTopLeft").style.visibility="visible";
	document.getElementById("mlwaas").style.visibility="visible";
	document.getElementById("mldeletebox").style.visibility="visible";
}

function hidedivs() {
	document.getElementById("divStayTopLeft").style.visibility="hidden";
	document.getElementById("mlwaas").style.visibility="hidden";
	document.getElementById("mldeletebox").style.visibility="hidden";
}