function switch_chart (chart,additional_vars)
{
	// <![CDATA[		
	var so = new SWFObject("http://feedfry.net/lib/js/amline/amline.swf", "amline", "100%", "300", "8", "#FFFFFF");
	so.addVariable("path", "http://feedfry.net/lib/js/amline/");
	so.addVariable("settings_file", escape("http://feedfry.net/xmlstats.php?m="+chart+"&"+additional_vars+"&settings"));  // you can set two or more different settings files here (separated by commas)
	so.addVariable("data_file", escape("http://feedfry.net/xmlstats.php?m="+chart+"&"+additional_vars));
	//	so.addVariable("chart_data", "");                                       // you can pass chart data as a string directly from this file
	//	so.addVariable("chart_settings", "");                                   // you can pass chart settings as a string directly from this file
	//	so.addVariable("additional_chart_settings", "");                        // you append some chart settings to the loaded ones
	//  so.addVariable("loading_settings", "LOADING SETTINGS");                 // you can set custom "loading settings" text here
	//  so.addVariable("loading_data", "LOADING DATA");                         // you can set custom "loading data" text here
	so.addVariable("preloader_color", "#999999");
	so.write("feedchart");
	// ]]>

	
	var current;
	current = $('cc_current').innerHTML;
	$('cc_'+current).className="";
	$('cc_'+chart).className="selected";
	
	$('cc_current').innerHTML=chart;
}

function toggler(enable_id,varholder,enabled_class,disabled_class)
{
	varholder=document.getElementById(varholder);
	currently_activated=varholder.value;
	
	if (currently_activated != '' && currently_activated != enable_id)
	{
		ca_el=document.getElementById(currently_activated);
		ca_el.className=disabled_class;
		varholder.value='';
	}
	
	enable_el=document.getElementById(enable_id);
	
	//deactivate
	if (enable_el.className == enabled_class)
	{
		enable_el.className = disabled_class;
		varholder.value = '';
	}
	else
	{
		//activate
		enable_el.className=enabled_class;
		varholder.value=enable_id;
	}
}

function change_cat(cat_name)
{
	feed_cat=document.getElementById('feed_cat');
	
	if (feed_cat.value != '' && feed_cat.value != cat_name)
	{
		oldlink=document.getElementById(feed_cat.value);
		oldlink.style.fontWeight='normal';
		oldlink.style.color='#00c';
		feed_cat.value='';
	}
	
	link=document.getElementById(cat_name);
	if (link.style.fontWeight=='bold')
	{
		link.style.fontWeight='normal';
		link.style.color='#00c';
		feed_cat.value='';
	}
	else
	{
		link.style.fontWeight='bold';
		link.style.color='#c00';
		feed_cat.value=cat_name;
	}
}	
	
function toggle_ele(ele_name)
{
	$(ele_name).toggle();
}
function showdelete(post) {

Lightview.show({
  href: '#delete'+post,
  rel: 'inline',
  title: 'Delete Post?',
  caption: 'Please Confirm',
  options: {
    height:60,
	width:150
  }
});

}	

function switch_color(color)
{
	//get current color
		var current_color=document.getElementById('feedcolor_h').value;
	
	//unselect currently selected color
		if (selected_box = document.getElementById('color'+current_color))
		{
			selected_box.className='feedcolorSelectBox';
		}
		
	//select colorbox
		if (this_box = document.getElementById('color'+color))
		{
			this_box.className='feedcolorSelectBox_selected';
		}
		
	//update feedcolor box
		document.getElementById('feedcolor').value=color;
		document.getElementById('feedcolor_h').value=color;
		document.getElementById('color_ex').style.backgroundColor='#'+color;
}

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 

	function newpost(form_id)
	{
		new Ajax.Request('index.php?m=newpost', {method: 'post', 	
			parameters: $(form_id).serialize(true)
		});
		form=document.getElementById(form_id);
		
		update_forum();
		form.post_text.value='';
	}
	
	function deletepost(post_id)
	{
		new Ajax.Request('index.php?m=deletepost&p='+post_id+'&do', { method:'get' });
		Lightview.hide();
		new Effect.PhaseOut(document.getElementById('post'+post_id));
	}
function base64_encode( data ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Tyler Akins (http://rumkin.com)
    // +   improved by: Bayron Guevara
    // +   improved by: Thunder.m
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)        
    // -    depends on: utf8_encode
    // *     example 1: base64_encode('Kevin van Zonneveld');
    // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
 
    // mozilla has this native
    // - but breaks in 2.0.0.12!
    //if (typeof window['atob'] == 'function') {
    //    return atob(data);
    //}
        
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, enc="", tmp_arr = [];
    data = utf8_encode(data);
    
    do { // pack three octets into four hexets
        o1 = data.charCodeAt(i++);
        o2 = data.charCodeAt(i++);
        o3 = data.charCodeAt(i++);
 
        bits = o1<<16 | o2<<8 | o3;
 
        h1 = bits>>18 & 0x3f;
        h2 = bits>>12 & 0x3f;
        h3 = bits>>6 & 0x3f;
        h4 = bits & 0x3f;
 
        // use hexets to index into b64, and append result to encoded string
        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
    } while (i < data.length);
    
    enc = tmp_arr.join('');
    
    switch( data.length % 3 ){
        case 1:
            enc = enc.slice(0, -2) + '==';
        break;
        case 2:
            enc = enc.slice(0, -1) + '=';
        break;
    }
 
    return enc;
}

function utf8_encode ( str_data ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)        
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
 
    str_data = str_data.replace(/\r\n/g,"\n");
    var tmp_arr = [], ac = 0;
 
    for (var n = 0; n < str_data.length; n++) {
        var c = str_data.charCodeAt(n);
        if (c < 128) {
            tmp_arr[ac++] = String.fromCharCode(c);
        } else if((c > 127) && (c < 2048)) {
            tmp_arr[ac++] = String.fromCharCode((c >> 6) | 192);
            tmp_arr[ac++] = String.fromCharCode((c & 63) | 128);
        } else {
            tmp_arr[ac++] = String.fromCharCode((c >> 12) | 224);
            tmp_arr[ac++] = String.fromCharCode(((c >> 6) & 63) | 128);
            tmp_arr[ac++] = String.fromCharCode((c & 63) | 128);
        }
    }
    
    return tmp_arr.join('');
}