function open_upload_window() {
	c = window.open('upload.php?','upload_window','height=350,width=640,menubar=no,location=no,resizable=no,scrollbars=no,status=no,toolbar=no,directories=no');
}

function delete_album(id) {
	if(confirm("Are you sure you want to delete this album?"))
		document.location = "albums.php?delete=" + id;
}

function delete_photo(album,id) {
	if(confirm("Are you sure you want to delete this photo?"))
		document.location = "albums.php?show="+ album + "&deletephoto=" + id;
}

var total_files_uploading = 0;
var total_bytes = 0;
var c_files = new Array();

function $(id) {
	return document.getElementById(id);
}

function newpost_button() {
	$("chat_newpost_table").style.display = "";
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable)
      return pair[1];
  } 
}

function updatePcnt() {
	if(total_bytes != 0)
		pc = Math.round(100 * (c_total+c_total_file) / total_bytes);
	else
		pc = 0;
	
	$("dataText").innerHTML = "" + (Math.round((c_total+c_total_file)/1024)) + "kb / " + (Math.round(total_bytes/1024)) + "kb";
	$("progressText").innerHTML = "" + pc + "%";
	$("progressBar").style.width = "" + (pc*.8) + "%";
	
	if(pc==100)
		setStatus("processing images... please wait...");
}

var is_uploading = false;

function setStatus(txt) {
	$("statusText").innerHTML = txt;
}


function file_dialog_start_function () {
	total_bytes = 0;
	c_total_file = 0;
	c_total = 0;
	
	$("uploaderDiv").style.display = "";
	updatePcnt();
}

function file_queued_function(fileObj) {
	total_bytes += fileObj.size;
}

function file_queue_error_function() {
	
}

function file_dialog_complete_function() {
	setStatus("uploading...");
	swfu.startUpload();
}

function upload_start_function() {

}

function upload_progress_function(fileObj, complete, total) {
	c_total_file = complete;
	
	updatePcnt();
}

function upload_error_function(fileObj, code, msg) {
	alert("Error " + code + ": " + msg);
}

function upload_success_function() {
	
}

function upload_complete_function() {
	c_total += c_total_file;
	c_total_file = 0;
	updatePcnt();
	
	if(c_total == total_bytes) {
		var c_album = getQueryVariable("show");
		setTimeout("document.location = \"?show=" + c_album + "\";", 50);
	} else 
		swfu.startUpload();
}


function uploadCancel() {
	var u_btn = $("uploadButton");
	u_btn.value = "upload pics to this album";
	$("uploaderDiv").style.display = "none";
}
