// JavaScript Document
var baseURL = "http://clients.irisaaa.com";
var curRefreshURL = window.location.toString();

function userPreferences(){
	new Ajax.Request('/scripts/user_preferences.php',
					 {
						 method: 'get',
						 parameters: 'a=getForm',
						 onComplete: retGetPrefs
					 });
	function retGetPrefs(xmlObj){
		$('lightboxcontent').innerHTML = xmlObj.responseText;
		lightbox_activate();
	}
}

function saveUserPreferences(){
	var utz = $F('user_pref_tz');
	new Ajax.Request('/scripts/user_preferences.php',
					 {
						 method: 'get',
						 parameters: 'a=change&tz='+ utz,
						 onComplete: retSavePrefs
					 });
	function retSavePrefs(xmlObj){
		$('lightboxcontent').innerHTML = '';
		lightbox_deactivate();
		window.location.href = curRefreshURL;
	}
}


function toggleQuickLaunch(elementId){
	var element = document.getElementById(elementId);
	if(element.style.display=='none'){
		new Effect.Appear(elementId, { duration: .3 });
		
	} else {
		new Effect.Fade(elementId, { duration: .3 });
	}
}

function toggleDisplay(elementId){
//	var element = document.getElementById(elementId);
//	if(element.style.display=='none'){
//		element.style.display='';
//	} else {
//		element.style.display='none';
//	}
	Element.toggle(elementId);
}

function toggleHighlight(element,toggle){
	if(toggle=='on'){
		element.style.backgroundColor='#FFFBBC';
	} else if(toggle=='off') {
		element.style.backgroundColor='';
	}
}

function toggleClient(toggler,elementId){
	var element = document.getElementById(elementId);
	if(element.style.display=='none'){
		new Effect.Appear(elementId, { duration: .3 });
		toggler.innerHTML='[-]';
	} else {
		new Effect.Fade(elementId, { duration: .3 });
		toggler.innerHTML='[+]';
	}
}

function toggleRestrictionDetails(toggler,elementId){
	var element = document.getElementById(elementId);

	if(element.style.display=='none'){
		new Effect.Appear(elementId, { duration: .3 });
		//element.style.display='';
		toggler.src='images/magnifier_zoom_out.gif';
	} else {
		new Effect.Fade(elementId, { duration: .3 });
		//element.style.display='none';
		toggler.src='images/magnifier_zoom_in.gif';
	}
}

function toggleRestrictionDefaults(checkbox){
	var temp_limit;
	temp_limit = document.getElementById('limit_time').value;
	document.getElementById('limit_time').value = document.getElementById('limit_time_hidden').value;
	document.getElementById('limit_time_hidden').value = temp_limit;

	temp_limit = document.getElementById('limit_data_in').value;
	document.getElementById('limit_data_in').value = document.getElementById('limit_data_in_hidden').value;
	document.getElementById('limit_data_in_hidden').value = temp_limit;

	temp_limit = document.getElementById('limit_data_out').value;
	document.getElementById('limit_data_out').value = document.getElementById('limit_data_out_hidden').value;
	document.getElementById('limit_data_out_hidden').value = temp_limit;

	temp_limit = document.getElementById('limit_bandwidth_in').value;
	document.getElementById('limit_bandwidth_in').value = document.getElementById('limit_bandwidth_in_hidden').value;
	document.getElementById('limit_bandwidth_in_hidden').value = temp_limit;

	temp_limit = document.getElementById('limit_bandwidth_out').value;
	document.getElementById('limit_bandwidth_out').value = document.getElementById('limit_bandwidth_out_hidden').value;
	document.getElementById('limit_bandwidth_out_hidden').value = temp_limit;
		
	if(checkbox.checked==true){
		document.getElementById('limit_time').disabled='disabled';
		document.getElementById('limit_data_in').disabled='disabled';
		document.getElementById('limit_data_out').disabled='disabled';
		document.getElementById('limit_bandwidth_in').disabled='disabled';
		document.getElementById('limit_bandwidth_out').disabled='disabled';
		//document.getElementById('updateLimits').disabled='disabled';	
	} else {
		document.getElementById('limit_time').disabled='';	
		document.getElementById('limit_data_in').disabled='';	
		document.getElementById('limit_data_out').disabled='';	
		document.getElementById('limit_bandwidth_in').disabled='';	
		document.getElementById('limit_bandwidth_out').disabled='';	
		//document.getElementById('updateLimits').disabled='';	
	}
}

function toggleAmenityFields(){
	var plantype = $F('type');
	if(plantype=='Paid'){
		Element.show( $('continuity').parentNode );
		Element.show( $('timespan_line').parentNode );
		Element.show( $('rate').parentNode );
	}
	if(plantype=='Amenity'){
		Element.hide( $('continuity').parentNode );
		Element.hide( $('timespan_line').parentNode );
		Element.hide( $('rate').parentNode );
	}
}

function changeContinuity(){
	if ($('continuity').value == 'Subscription'){
		$('timespan_line').style.display = 'none';
	} else {
		$('timespan_line').style.display = 'inline';
	}
}

function getXmlNodeValue(xmlNode){
	if(xmlNode.textContent){ return xmlNode.textContent; }
	else { return xmlNode.text; }
}

function addOption(selectBox,option){
	Try.these(
		function() { return selectBox.add(option,null); },
		function() { return selectBox.add(option,-1);	}
	);
}

function emptyOptions(selectBox){
	while (selectBox.length> 0) {
		selectBox.remove(0);
	} 
}

function updateAPList(){
	var selectBox = $('access_point_id');
	
	if( $F('realm_id') == 'All'){ selectBox.style.display='none'; } 
	else { 
		selectBox.style.display=''; 
		emptyOptions(selectBox);
		new Ajax.Request(
				'scripts/get_ap_list.php',
				{
					method: 'get',
					parameters: 'realmId='+$F('realm_id'),
					onComplete: populateOptions
				}										 
		);
		
	}
	
	function populateOptions(request){
		var xmldoc = request.responseXML;
		var nodes = xmldoc.getElementsByTagName('ap');
		var optionList = new Array(new Option('All Access Points','All') );

		for(var i=0; i < nodes.length; i++){
			optionList[optionList.length] = new Option( getXmlNodeValue(nodes[i]), nodes[i].getAttribute('id') );
		}		
		
		for(var i=0; i < optionList.length; i++){
			addOption( selectBox, optionList[i] );
		}	

	}
}

function updateAvailablePlans(location){
	
	new Ajax.Request(
		'scripts/get_plans.php',
		{
			method: 'get',
			parameters: 'location=' + location.value + '&disabledPlans=0',
			onComplete: updatePlans
		}
	);
	
	function updatePlans(request){
		Element.update('account_plan','');
		var doc = request.responseXML;
		var response = doc.getElementsByTagName('response')[0];
		if( response.getAttribute('count') > 0 ){
			var plans = response.getElementsByTagName('plan');
			for(var i=0; i < plans.length; i++){ 
				var option = new Option( getXmlNodeValue(plans[i]), plans[i].getAttribute('id') );
				addOption( $('account_plan'), option);
			}
		} else {
				var option = new Option( 'No plans available...','' );
				addOption( $('account_plan'), option);
		}
	}
}

function updateAvailableLocations(realm){
	
	new Ajax.Request(
		'scripts/get_ap_list.php',
		{
			method: 'get',
			parameters: 'realmId=' + realm.value + '&disabledPlans=0',
			onComplete: updatePlans
		}
	);
	
	function updatePlans(request){
		Element.update('account_location','');
		var doc = request.responseXML;
		var response = doc.getElementsByTagName('response')[0];
		if( response.getAttribute('count') > 0 ){
			addOption( $('account_location'), new Option('Select Location...',0));
			var plans = response.getElementsByTagName('ap');
			for(var i=0; i < plans.length; i++){ 
				var option = new Option( getXmlNodeValue(plans[i]), plans[i].getAttribute('id') );
				addOption( $('account_location'), option);
			}
		} else {
				var option = new Option( 'No locations available...','' );
				addOption( $('account_location'), option);
		}
	}
}



function updateGraph(){

var end_date = $F('end_year') +"-"+ $F('end_month') +"-"+ $F('end_day');
var start_date = $F('start_year') +"-"+ $F('start_month') +"-"+ $F('start_day');

	if ($('type').value == 'Logins'){
		//var download_url = "generate_login_report.php?client_id=" + $('client_id').value + "&ap_id=" + $('access_point_id').value + "&back_increment=" + $('back_increment').value + "&back_units=" + $('back_units').value + "&timezone=" + $('timezone_select').value;
		var download_url = "generate_login_report.php?client_id=" + $('client_id').value + "&realm_id=" + $('realm_id').value + "&ap_id=" + $('access_point_id').value + "&end_date="+ end_date +"&start_date="+ start_date +"&tz="+ $('time_zone').value;
		window.location = download_url;
	} else if ($('type').value == 'Transactions') {
		var oparams = '';
		if($('report_show_positive_values')){
			if($('report_show_positive_values').options[$('report_show_positive_values').selectedIndex].value != 'all'){
				oparams = '&oparams='+ $('report_show_positive_values').options[$('report_show_positive_values').selectedIndex].value;
			}
		}
		var download_url = "generate_transaction_report.php?client_id=" + $('client_id').value + "&ap_id=" + $('access_point_id').value + "&start_date="+ start_date +"&tz="+ $('time_zone').value +"&end_date="+ end_date + oparams;
		window.location = download_url;
	} else if ($('type').value == 'RevenueByPlanCSV') {
		var download_url = "generate_revenuebyplancsv_report.php?client_id=" + $('client_id').value + "&ap_id=" + $('access_point_id').value + "&start_date="+ start_date +"&tz="+ $('time_zone').value +"&end_date="+ end_date;
		window.location = download_url;
	} else if ($('type').value == 'RefundsCSV') {
		var download_url = "generate_refunds_report.php?client_id=" + $('client_id').value + "&ap_id=" + $('access_point_id').value + "&start_date="+ start_date +"&tz="+ $('time_zone').value +"&end_date="+ end_date;
		window.location = download_url;
	} else if ($('type').value == 'Commissions') {
		var download_url = "generate_commissions_report.php";
		window.open(download_url);
	} else if ($('type').value == 'PrepaidCards') {
		var oparams = '';
		if($('report_show_by_date')){
			if($F('report_show_by_date') != 'totals'){
				oparams = '&oparams='+ $F('report_show_by_date');
			}
		}
		var download_url = "generate_prepaid_report.php?client_id=" + $('client_id').value + "&ap_id=" + $('access_point_id').value + "&start_date="+ start_date +"&tz="+ $('time_zone').value +"&end_date="+ end_date + oparams;
		window.open(download_url);
	} else if ($('type').value == 'ConnectionsByAP') {
		$('graph_main').src = '/images/indicator.gif';
		
		var newSource='generate_graph_pie.php?redraw=true'; // The new source string for the graph image
		newSource+='&type='+$('type').value;
		newSource+='&end_date='+ end_date;
		newSource+='&start_date='+ start_date;
		newSource+='&client_id='+$('client_id').value;
		newSource+='&realm_id='+$('realm_id').value;
		newSource+='&access_point_id='+$('access_point_id').value +'&tz='+ $('time_zone').value;
			
		$('graph_main').src = newSource;
	} else {
		$('graph_main').src = '/images/indicator.gif';
		
		var newSource='generate_graph.php?redraw=true'; // The new source string for the graph image
		newSource+='&type='+$('type').value;
		newSource+='&end_date='+ end_date;
		newSource+='&start_date='+ start_date;

		newSource+='&client_id='+$('client_id').value;
		newSource+='&realm_id='+$('realm_id').value;
		newSource+='&access_point_id='+$('access_point_id').value +'&tz='+ $('time_zone').value;

		$('graph_main').src = newSource;
	}
}

function runCommissionReport(step){
	switch(step){
		case 1:
			download_url = 'generate_commissions_report.php';
			window.location = download_url;
			break;
		case 2:
			$('btnRunCRept').value = 'Proceeding to Step 2';
			$('btnRunCRept').disabled = true;
			$('cr_status_text').innerHTML = 'Please be patient while we calculate your totals.';
			var aplist = '';
			for(var i=0;i<$('locations').options.length;i++){
				if($('locations').options[i].selected){
					aplist += $('locations').options[i].value +',';
				}
			}
			if(aplist == ''){
				alert("You must select at least one location");
				$('btnRunCRept').disabled = false;
				$('btnRunCRept').value = 'Proceed';
				return;
			} else {
				aplist = aplist.substring(0,aplist.length-1);
			}
			var download_url = "generate_commissions_report.php?action=step2&ap_id=" + aplist + "&start_month=" + $F('start_month') + "&start_year=" + $F('start_year') +"&start_day=" + $F('start_day') +"&tz="+ $('time_zone').value +"&end_day="+$F('end_day') +"&end_month="+$F('end_month') +"&end_year="+$F('end_year');
			window.location = download_url;
			break;
		default:
			alert("blah");
	}
}

/* =================== Lightbox Scripts ============================= */

function lightbox_activate(){
	this.prepareIE('auto', 'auto');
	$('overlay').style.display='block';
	$('lightbox').style.display='block';
	$('lightbox').style.left = ((document.getElementsByTagName('body')[0].clientWidth/2)-($('lightbox').clientWidth/2)-100);
	$('lightbox').style.top = ((document.getElementsByTagName('body')[0].clientHeight/2)-($('lightbox').clientHeight/2));
	if(((document.getElementsByTagName('body')[0].clientHeight/2)-($('lightbox').clientHeight/2)) < 0){
		$('lightbox').style.top = 75;
	}
	$('lightbox_deactivate').focus();

}

function lightbox_deactivate(){
	this.prepareIE("auto", "auto");
	this.hideSelects("visible");
	Element.hide('overlay');
	Element.hide('lightbox');
}

function prepareIE(height, overflow){
    var bod = document.getElementsByTagName('body')[0];
    bod.style.height = height;
    bod.style.overflow = overflow;

    var htm = document.getElementsByTagName('html')[0];
    htm.style.height = height;
    htm.style.overflow = overflow; 
}


function hideSelects(visibility){
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].style.visibility = visibility;
	}
}

/* =================== DYNAMIC UPDATES! ============================= */

function xmlhttp(method, script, async, data, oncomplete){
	var request;
	if (window.XMLHttpRequest){
		request = new XMLHttpRequest;
	} else if (ActiveXObject){
		request = new ActiveXObject("MSXML2.XMLHTTP.3.0");
	}
	request.open(method, script, async);
	if (method == "POST"){
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}
	if (async){
		request.onreadystatechange = function (){
			if (request.readyState == 4){
				oncomplete(request);
			}
		};
	}
	request.send(data);
	return request;
}

function change_timezone(){
	setcookie('timezone', document.getElementById('timezone_select').value, 3650);
	window.location.reload();
}

function setcookie(name, value, expires){
	var now = new Date();
	var expire_date = new Date();
	var new_cookie;
	
	expire_date.setTime(now.getTime() + 86400000 * expires);
	new_cookie = name + "=" + escape(value) + ((expires == null) ? "" : "; expires=" + expire_date.toGMTString());
	document.cookie = new_cookie;
}

function update_data(post_elements, update_script){
	var request;
	var post_string_parts;
	
	post_string_parts = new Array();
	for (var i = 0; i < post_elements.length; i++){
		if(!$(post_elements[i])){
			alert(post_elements[i]);
			return 'exists';
		}
		post_string_parts.push(encodeURIComponent(post_elements[i]) + "=" + encodeURIComponent(document.getElementById(post_elements[i]).value));
	}
	request = xmlhttp("POST", "scripts/" + update_script, false, post_string_parts.join("&"));
	return request;
}


/*--------------------Update Client Information-----------------------------------*/
function update_client_account(){
	var request;
	request = update_data(new Array("client_id", "client_name", "username", "notes"), "update_client_account.php");
	alert(request.responseText);
}

function update_client_contact(){
	var request;
	request = update_data(new Array("client_id", "contact_name", "contact_phone", "address", "city", "state", "zip"), "update_client_contact.php");
	alert(request.responseText);
}



/*---------------------Update AP Information---------------------------------------------*/
function create_new_ap(){
	var request;
	request = update_data(new Array("client_id", "new_nas_id", "new_hardware_model"), "create_new_ap.php");
	alert(request.responseText);
}

function update_ap_account(){
	var request;
	request = update_data(new Array("ap_id", "access_point_name", "username", "notes"), "update_ap_account.php");
	alert(request.responseText);	
}

function update_ap_contact(){
	var request;
	request = update_data(new Array("ap_id", "contact_name", "contact_phone", "address", "city", "state", "zip"), "update_ap_contact.php");
	alert(request.responseText);
}

function update_ap_hardware(){
	var request;
	request = update_data(new Array("ap_id", "hardware_model", "ssid", "external_IP", "internal_IP"), "update_ap_hardware.php");
	alert(request.responseText);
}

/*function update_ap_limits(){
	var request;
	request = update_data(new Array("ap_id", "limit_time", "limit_data_in", "limit_data_out", "limit_bandwidth_in", "limit_bandwidth_out"), "update_ap_limits.php");
	alert(request.responseText);
}*/

function update_ap_limits(){
	var request;
	var post_string_parts;
	var post_elements;

	post_elements = new Array("ap_id", "limit_time", "limit_data_in", "limit_data_out", "limit_bandwidth_in", "limit_bandwidth_out");
	post_string_parts = new Array();
	for (var i = 0; i < post_elements.length; i++){
		post_string_parts.push(encodeURIComponent(post_elements[i]) + "=" + encodeURIComponent(document.getElementById(post_elements[i]).value));
	}
	post_string_parts.push("client_default=" + document.getElementById('use_client_defaults_checkbox').checked);
	request = xmlhttp("POST", "scripts/update_ap_limits.php", false, post_string_parts.join("&"));
	alert(request.responseText);
}

/*-------------------------Update Plan Info--------------------------------*/
function create_new_plan(){
	var request;
	var result;
	if ($("new_plan_name").value == ''){
		alert("Please choose a name for your new plan.");
	} else {
		request = update_data(new Array("realm_id","new_plan_name"), "create_new_plan.php");
		result = request.responseXML.getElementsByTagName('result').item(0);
		window.location = baseURL +"/edit_plan.php?id=" + result.getAttribute('plan_id');
	}
}

function update_plan_information(){
	var request;
	request = update_data(new Array("plan_id", "plan_name", "description", "notes"), "update_plan_information.php");
	Element.update('status_message',request.responseText);	
}

function update_plan_details(){
	var request;
	request = update_data(new Array("plan_id", "visibility", "type", "continuity", "timespan_amount", "timespan_unit", "rate", "voip_cost", "async_logins"), "update_plan_details.php");
	Element.update('status_message',request.responseText);	
}

function update_plan_access_points(){
	var request;
	var fields = new Array("plan_id");
	
	elements = document.getElementsByName("access_points[]");
	for(i=0; i<elements.length; i++){
		if(elements[i].checked==true){
			fields.push('access_point_' + elements[i].value);
		}
	}
	
	request = update_data(fields, "update_plan_access_points.php");
	Element.update('status_message',request.responseText);	
}

function update_plan_roaming(){
	var request;
	var fields = new Array("plan_id");
	
	elements = document.getElementsByName("roaming_realms[]");
	for(i=0; i<elements.length; i++){
		if(elements[i].checked==true){
			fields.push('realm_' + elements[i].value);
		}
	}
	
	request = update_data(fields, "update_plan_roaming.php");
	Element.update('status_message',request.responseText);	
}

function update_plan_limits(){
	var request;
	request = update_data(new Array("plan_id", "limit_time", "limit_data_in", "limit_data_out", "limit_bandwidth_in", "limit_bandwidth_out", "limit_restriction_length"), "update_plan_limits.php");
	Element.update('status_message',request.responseText);	
}

function disable_plan(){
	var request;
	request = update_data(new Array("plan_id", "disable_plan"), "disable_plan.php");
	if ($('disable_plan').value == "Enable Plan"){
		$('disable_plan').value = "Disable Plan";
	} else {
		$('disable_plan').value = "Enable Plan";
	}
}

function generate_prepaid_cards(){
	var request;
	request = update_data(new Array("plan_id", "prepaid_cards_number"), "generate_prepaid_cards.php");
	//alert(request.responseText);
	var xreq = request.responseXML;
	var aryAccounts = xreq.getElementsByTagName('account');
	var newPage = "<pre>USERNAME,PASSWORD\n";
	for(var i=0;i<aryAccounts.length;i++){
		newPage += aryAccounts[i].attributes[0].value +","+ aryAccounts[i].attributes[1].value +"\n";
	}
	var nwin = window.open('','MyWin');
	nwin.document.write(newPage);
	Element.update('status_message','You generated '+ $('prepaid_cards_number').value +' prepaid cards');
   	$('prepaid_cards_number').value = '';
}

/*-------------------------Update User Info--------------------------------*/

function update_user_account_information(){
	var request, fields;
	fields = new Array("user_id", "username", "notes", "email", "phone", "fname", "lname", "address", "city","state","zip", "secret_question", "secret_answer","origusername");
	request = update_data(fields, "update_user_account_information.php");
	return request;
}

function create_new_user(){
	var request;
	var result;
		request = update_data(new Array("username","fname","lname","address","state","zip","city","email","phone","password","secret_question","secret_answer","notes","realm_id"), "create_new_user.php");
		result = request.responseXML.getElementsByTagName('result').item(0);
		switch (result.getAttribute('message')){
			case 'success':
				return result.getAttribute('user_id');
				break;
			case 'duplicate':
				return 'exists';
				break;
		}
}

function create_user_account(){
	var request = update_data(new Array("user_id","account_realm","account_plan","account_start_year","account_start_month","account_start_day","account_start_hour","account_start_minute","account_start_second","account_stop_year","account_stop_month","account_stop_day","account_stop_hour","account_stop_minute","account_stop_second"), "create_user_account.php");
	return request;
}

function cancel_subscription(account_id){
	var request;
	request = xmlhttp("POST", "/scripts/cancel_subscription.php", false, "account_id=" + account_id);
	//Element.update('status_message',request.responseText);	
	return request.responseText;
}

function disable_account(account_id){
	var request;
	request = xmlhttp("POST", "/scripts/disable_account.php", false, "account_id=" + account_id +"&user_id="+ $('user_id').value);
	//Element.update('status_message',request.responseText);	
	//document.location.href = 'edit_user.php?id=' + $F('user_id');
	return request.responseText;
}

function logout_user(){
	var request;
	request = xmlhttp("POST", "scripts/logout_user.php", false, "user_id=" + $('user_id').value);
	//Element.update('status_message',request.responseText);
	return true;
}
function logout_mac(){
	var request;
	request = xmlhttp("POST", "scripts/logout_mac.php", false, "mac=" + $('mac').value);
	Element.update('status_message',request.responseText);
}

/*-----------------------Transaction Functions------------------------------------*/

function issue_refund(){
	var request;
	request = update_data(new Array("transaction_id", "refund_amount"), "issue_refund.php");
	Element.update('status_message',request.responseText);	
}

function void_transaction(){
	var request;
	var c;
	c = confirm("This will void the transaction");
	if (c){
		request = update_data(new Array("transaction_id", "refund_amount"), "void_transaction.php");
		Element.update('status_message',request.responseText);
	}
}

function viewAllTransactions(realm,limit){
	new Ajax.Request(
					 "scripts/get_transaction_list.php",
					 {
						 	method: 'get',
							parameters: 'realm='+ realm +'&limit='+ limit,
							onComplete: retViewTransactions
					 }
					 );
	function retViewTransactions(xmlObj){
		$('transaction_list').innerHTML = xmlObj.responseText;
	}
}

function do_trans_search(){
	var sdate = $('trans_search_syr').value +'-'+ $('trans_search_smo').value +'-'+ $('trans_search_sd').value +' 00:00:00';
	var edate = $('trans_search_eyr').value +'-'+ $('trans_search_emo').value +'-'+ $('trans_search_ed').value +' 23:59:59';
	var realmId = $('realm_id').value;
	
	new Ajax.Request(
					 "scripts/transaction_search.php",
					 {
						 	method: 'post',
							parameters: 'realmId='+ realmId +'&sdate='+ sdate +'&edate='+ edate,
							onComplete: retTransSearch
					 }
					 );
	function retTransSearch(xmlObj){
		$('trans_result').innerHTML = xmlObj.responseText;
	}
}
/* ================================================================== */

function submit_user_search(){
	var request = update_data(new Array("fnamei","lnamei","realm_id"),"user_search.php");
	Element.update('user_search_results',request.responseText);
}

function getLoadingHTML(){
 	var strHTML = '<hr><center><h1>Search Results</h1><br><br><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="150" height="40" id="LOADING" align="middle">';
		strHTML += '<param name="allowScriptAccess" value="sameDomain" />';
		strHTML += '<param name="movie" value="/images/LOADING.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/images/LOADING.swf" quality="high" bgcolor="#ffffff" width="150" height="40" name="LOADING" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		strHTML += '</object>';
	return strHTML;
 }
function getProcessingHTML(){
 	var strHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="150" height="40" id="LOADING" align="middle">';
		strHTML += '<param name="allowScriptAccess" value="sameDomain" />';
		strHTML += '<param name="movie" value="/images/processing.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/images/processing.swf" quality="high" bgcolor="#ffffff" width="150" height="40" name="LOADING" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		strHTML += '</object>';
	return strHTML;
 }
 
 
function showReportVars(typ){
	if($('report_show_positive_values')){
		$('report_show_positive_values').style.display = 'none';
	}
	if($('report_show_by_date')){
		$('report_show_by_date').style.display = 'none';
	}

	switch(typ){
		case 'Transactions':
			if($('report_show_positive_values')){
				$('report_show_positive_values').style.display = 'inline';
			}
			break;
		case 'PrepaidCards':
			if($('report_show_by_date')){
				$('report_show_by_date').style.display = 'inline';
			}
			break;
		default:
			break;
	}
}

