/**
 * 
 * All content on this website (including text, images, source
 * code and any other original works), unless otherwise noted,
 * is licensed under a Creative Commons License.
 * 
 * http://creativecommons.org/licenses/by-nc-sa/2.5/
 * 
 * Copyright (C) 2004-2010 Open-Xchange, Inc.
 * Mail: info@open-xchange.com 
 * 
 * @author Stefan Preuss <stefan.preuss@open-xchange.com>
 * 
 */

var corewindow=parent.corewindow;

function callback_new(cb) {
	if (cb) {
		if (cb.data && cb.data.length && !cb.error) {
			oxFile=cb.data["0"];
			var URL = window.location.protocol + "//" + window.location.host
				+corewindow.AjaxRoot + "/file?action=get&session="
				+corewindow.session+"&id="+oxFile;
  			document.getElementById("src").value = URL;
  			if (ImageDialog.getImageData) ImageDialog.getImageData();  			
  			disableOXBG();
		} else if (cb.error) {
			alert(corewindow.formatError(cb));
		} else {
			alert("There was an unexcpeted error while uploading the image to the server!");
		}
	} else {
		alert("The Server didn't respond.");
	}
}

function sendOXFile() {
	if (document.getElementById("file").value != "") {
		document.forms["mailUploadImage"].submit();
	} else {
		alert(corewindow._("Please choose a file!"));
	}
}

function disableOXBG() {
	if(corewindow.IE6 && document.getElementById('align')) {
		document.getElementById('align').style.visibility = "visible";
		document.body.style.margin = "8px";
	}
	document.getElementById("oxmainBG").style.display = "none";
	document.getElementById("oxmain").style.display = "none";
}