function popUp(URL, WIDTH, HEIGHT) {
	Wnd=window.open(URL,"a","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + WIDTH + ",height=" + HEIGHT + ",alwaysRaised=1,dependent=1,directories=no,personalbar=0");
	if (Wnd.opener==null)
		Wnd.opener = window;
		Wnd.opener.name = "popup";
		Wnd.focus();
}

function submit_cfo_Form() {
	document.pl_cfo_form.submit();
}

function change_topnavi_bg(id, value) {
	document.getElementById(id).style.backgroundColor = value;
}

function change_cfo_background(id, value) {
	document.getElementById("ambi").className = "ambiente"+value;
	document.getElementById("ambi_image").className = "ambiente_image"+value;
	document.pl_cfo_form[id].value = value;
	document.pl_cfo_form.submit();
}

function change_cfo_option(id, value) {
	document.pl_cfo_form[id].value = value;
	document.pl_cfo_form.submit();
}

function change_search_option(id, value) {
	document.pl_search_form[id].value = value;
	document.pl_search_form.submit();
}

function change_search_option_and_reset(id, value) {
	if (id == 'timeline') {
		document.pl_search_form['color'].value = '';
		document.pl_search_form['q'].value = '';
		document.pl_search_form[id].value = value;
	} else if (id == 'color') {
		document.pl_search_form['timeline'].value = 'Alle Fotos';
		document.pl_search_form['q'].value = '';
		document.pl_search_form[id].value = value;
	} else if (id == 'q') {
		document.pl_search_form['timeline'].value = 'Alle Fotos';
		document.pl_search_form['color'].value = '';
	}

	document.pl_search_form.submit();
}

function change_icon(id, src) {
	icon = document.getElementById(id);
	icon.src = src;
}

function new_comment() {
	value = prompt("Geben Sie bitte hier Ihren Kommentar ein.", "");
	document.new_comment["comment"].value = value;
	document.new_comment.submit();
}

function add_comment() {
	document.getElementById("commentform").style.display = 'inline';
	document.getElementById("comment_first").style.display = 'none';
}

function show_colorBox() {
	document.getElementById("colorBox").style.display='block';
}

function hide_colorBox() {
	document.getElementById("colorBox").style.display='none';
}

function show_colorPicker(feld, title)
{
	document.getElementById("colorBox").style.display='block';
	document.getElementById("colorBox_title").innerHTML = title+' ausw&auml;hlen';
	document.gallery_design["whichColor"].value = feld;
}

function change_color(color)
{
	var feld = document.getElementById('whichColor').value;
	document.gallery_design[feld].value = color;
	hide_colorBox();

	document.gallery_design.submit();
}

function deliver_disabled(value) {
	document.order_payment.deliver_gender[0].disabled = value;
	document.order_payment.deliver_gender[1].disabled = value;
	document.order_payment.deliver_gender[2].disabled = value;
	document.order_payment.deliver_firstname.disabled = value;
	document.order_payment.deliver_lastname.disabled = value;
	document.order_payment.deliver_company.disabled = value;
	document.order_payment.deliver_street.disabled = value;
	document.order_payment.deliver_housenr.disabled = value;
	document.order_payment.deliver_zip.disabled = value;
	document.order_payment.deliver_town.disabled = value;
	document.order_payment.deliver_country.disabled = value;
	if (value == true) {
		var display_value = 'none';
	} else {
		var display_value = 'inline';
	}
	document.getElementById('deliver_headline').style.display = display_value;
	document.getElementById('deliver_gender_name').style.display = display_value;
	document.getElementById('deliver_gender').style.display = display_value;
	//document.getElementById('deliver_title_name').style.display = display_value;
	//document.getElementById('deliver_title').style.display = display_value;
	document.getElementById('deliver_firstname_name').style.display = display_value;
	document.getElementById('deliver_firstname').style.display = display_value;
	document.getElementById('deliver_lastname_name').style.display = display_value;
	document.getElementById('deliver_lastname').style.display = display_value;
	document.getElementById('deliver_company_name').style.display = display_value;
	document.getElementById('deliver_company').style.display = display_value;
	document.getElementById('deliver_street_name').style.display = display_value;
	document.getElementById('deliver_street').style.display = display_value;
	document.getElementById('deliver_zip_name').style.display = display_value;
	document.getElementById('deliver_zip').style.display = display_value;
	document.getElementById('deliver_country_name').style.display = display_value;
	document.getElementById('deliver_country').style.display = display_value;
}


// ruft den Lade-Status ueber AJAX ab und setzt die Breite des Ladebalkens entsprechend
function getProgress(id, sid, redirect){
	var myRequest = new Ajax.Request('upload_getprogress.php?id=' + id, {
	onSuccess: function(transport) {
		var splitted = transport.responseText.split("/");
		prozent = splitted[0] / splitted[1] * 100;
		document.getElementById('progressinner1').style.width = (prozent ) + "%";
		document.getElementById('progressinner2').style.width = (100 - prozent ) + "%";
		if (splitted[1] > 1048576) {
			document.getElementById('progresscurrent').innerHTML = Math.round((splitted[0]/1048576)*100)/100+' von '+Math.round((splitted[1]/1048576)*100)/100+' MB';
		} else {
			document.getElementById('progresscurrent').innerHTML = Math.round((splitted[0]/1024)*100)/100+' von '+Math.round((splitted[1]/1024)*100)/100+' kB';
		}
		// Solange wieder aufrufen bis der Upload abgeschlossen ist
		if (prozent != 100) {
			setTimeout("getProgress('" + id + "', '" + sid + "', '" + redirect + "')", 500);
		} else {
			document.location.href = redirect+".php?SID=" + sid;
		}
	}
	});
}

// Startet die Aktualisierung des Ladebalkens
function startProgress(filename, id, sid, redirect) {
	// Eine Datei wurde ausgewaehlt?
	if (filename) {
	    // Anzeigen des Ladebalkens
	    document.getElementById("progresslabel").style.display="block";
	    document.getElementById("progressouter").style.display="block";

	    setTimeout("getProgress('" + id + "', '" + sid + "', '" + redirect + "')", 500);
	}
}