
/** Chart utils **/
var loading_chart= '{ "elements": [ { "type": "bar", "values": [ 1 ], "colour": "#ffffff" } ], "bg_colour": "#FFFFFF", "title": { "text": "Loading...", "style": "{font-size: 20px; font-family: Arial; font-weight: bold; color: #A2ACBA; text-align: center;}" }, "tooltip": { "shadow": false, "stroke": 0, "colour": "#ffffff", "background": "#ffffff", "title": "{font-size: 14px; color: #ffffff}" }, "x_axis": { "colour": "#ffffff", "grid-colour": "#ffffff", "steps": 1, "labels": { "labels": "", "colour": "#ffffff" } }, "y_axis": { "colour": "#ffffff", "grid-colour": "#ffffff", "min": 0, "max": 10, "steps": 20, "labels": { "text": "" } } } }';

function findSWF(movieName)
{
	if (navigator.appName.indexOf("Microsoft")!= -1)
	{
    	return window[movieName];
  	} else {
	    return document[movieName];
	}
}


/** Datatable plugins **/
jQuery.fn.dataTableExt.oSort['formatted-num-desc'] = function(x,y)
{
	 x = x.replace(/[^\d\-\.\/]/g,'');
	 y = y.replace(/[^\d\-\.\/]/g,'');
	 if(x.indexOf('/')>=0)x = eval(x);
	 if(y.indexOf('/')>=0)y = eval(y);
	 return x/1 - y/1;
}

jQuery.fn.dataTableExt.oSort['formatted-num-asc'] = function(x,y)
{
	 x = x.replace(/[^\d\-\.\/]/g,'');
	 y = y.replace(/[^\d\-\.\/]/g,'');
	 if(x.indexOf('/')>=0)x = eval(x);
	 if(y.indexOf('/')>=0)y = eval(y);
	 return y/1 - x/1;
}

jQuery.fn.dataTableExt.oSort['mysql-date-desc'] = function(x,y)
{
	x = x.replace(/-/g, '' );
	y = y.replace(/-/g,'');
	if(x.indexOf('/')>=0)x = eval(x);
	if(y.indexOf('/')>=0)y = eval(y);
	return x/1 - y/1;
}

jQuery.fn.dataTableExt.oSort['mysql-date-asc'] = function(x,y)
{
	 x = x.replace(/-/g,'');
	 y = y.replace(/-/g,'');
	 if(x.indexOf('/')>=0)x = eval(x);
	 if(y.indexOf('/')>=0)y = eval(y);
	 return y/1 - x/1;
}

jQuery.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, callback )
{
	oSettings.sAjaxSource = sNewSource;
	this.fnClearTable( this );
	this.oApi._fnProcessingDisplay( oSettings, true );
	var that = this;

	$.getJSON( oSettings.sAjaxSource, null, function(json) {
		/* Got the data - add it to the table */
		for ( var i=0 ; i<json.aaData.length ; i++ )
		{
			that.oApi._fnAddData( oSettings, json.aaData[i] );
		}

		oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
		that.fnDraw( that );
		that.oApi._fnProcessingDisplay( oSettings, false );
		eval( callback );
	} );
}