
OFC = {};

OFC.jquery = {
    name: "jQuery",
    version: function(src) { return $('#'+ src)[0].get_version() },
    rasterize: function (src, dst) { $('#'+ dst).replaceWith(OFC.jquery.image(src)) },
    image: function(src) { return "<img src='data:image/png;base64," + $('#'+src)[0].get_img_binary() + "' />"},
    popup: function(src,Width,Height) {
			var cierra = false;
			if(Width == ""){
				Width = window.parent.document.body.clientWidth;
				cierra = true;
			}
			if(Height == ""){
				Height = window.parent.document.body.clientHeight;
				cierra = true;
			}
		 	var izquierda = (screen.availWidth - Width) / 2;
			var arriba = (screen.availHeight - Height) / 2;
			var opciones =",toolbar='NO'"+
						 ",titlebar='NO'"+
						 ",location='NO'"+
						 ",status='NO'"+
						 ",menubar='NO'"+
						 ",resizable=no"+
						 ",scrollbars=no"+
						 ",width=" + Width +
						 ",height=" + Height +
						 ",left=" + izquierda +
						 ",top=" + arriba;
		if(cierra == true){
		 window.parent.close();				 
		}
		var img_win = window.open('','Imagen', opciones);
        with(img_win.document) {
            write('<html><head><title>Charts: Exportar imagen<\/title><script type="text\/javascript">var BASE64_DATA = \/^data:.*;base64\/i;	var base64Path = "base64.php";	function fixBase64(img) { if (BASE64_DATA.test(img.src)) {	img.src = base64Path + "?" + img.src.slice(5);	} }; onload = function() {	for (var i = 0; i < document.images.length; i++) {	fixBase64(document.images[i]); } };	<\/script><\/head><body>' + OFC.jquery.image(src) + '<\/body><\/html>');
//			write('<html><head><title>Charts: Export as Image<\/title><script type="text\/javascript">function getImageSrc(base64Src)	{ return base64Src; }<\/script> <!--[if gte IE 5]>	<script type="text\/javascript">	function getImageSrc(base64Src)	{ return ""'+(window.base64Path?base64Path:"")+'"?" + base64Src.slice(5); }	<\/script><![endif]-->	<\/script><\/head><body>' + OFC.jquery.image(src) + '<\/body><\/html>');
		}
     }
}


/*
// Using an object as namespaces is JS Best Practice. I like the Control.XXX style.
//if (!Control) {var Control = {}}
//if (typeof(Control == "undefined")) {var Control = {}}
if (typeof(Control == "undefined")) {var Control = {OFC: OFC.jquery}}

// setup the interface method in your initialization function
private function init()
{
	ExternalInterface.addCallback('getScreenshot',
		interfaceIn_getScreenshot);
}

// this is the function that gets called by Javascript.  it returns
// the screenshot data as a base64-encoded string
private function interfaceIn_getScreenshot()
{
	var w:Number = 50;
	var h:Number = 50;

	var screenshotData:BitmapData = new BitmapData(w, h);
	screenshotData.draw(this);

	return Base64.encodeByteArray(PNGEncoder.encode(screenshotData));
}

// a regular expression to test for Base64 data	*/