
var currenttime = new Date();
var ctime;

var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var serverdate=new Date(currenttime);

function padlength(what){
	
	var output=(what.toString().length==1)? "0"+what : what;
	return output;
	}


function updates() {
	
	update_spot()
	update_coin();
	get_time();
	get_userCount();
	update_charts_med();
	reload_ads();
	return false;
	
	}
	
function update_spot(){
	
	var rand = Math.floor(Math.random()*11546);
	new Ajax('/items/new/spot.html?rand='+rand, {
		update: 'spot_hold',
		evalScripts: true
	}).request();
	
}

function get_time(){
	
	var rand = Math.floor(Math.random()*11546);
	new Ajax('/items/new/time.html?rand='+rand, {
		update: 'time',
		evalScripts: true
	}).request();
	
}

function get_userCount(){
	var rand = Math.floor(Math.random()*11546);
	new Ajax('/items/userCount.php?rand='+rand, {
		update: 'userCount',
		evalScripts: true
	}).request();
}

function update_coin(){
	
	var rand = Math.floor(Math.random()*11546);
	new Ajax('/items/new/all_coins.html?rand='+rand, {
		update: 'coin_hold',
		evalScripts: true,
		postBody: 'rand='+rand
	}).request();
	return false;

}

function reload_ads() {
	
	var rand = Math.floor(Math.random()*11546);
	new Ajax('/items/ad_2.php', {
		update: 'ads',
		evalScripts: true,
		postBody: 'rand='+rand
	}).request();
	return false;
}

function update_charts_med(){
	
	var rand = Math.floor(Math.random()*11546);
	
	$('gold_d').src = 'http://www.coininfo.com/charts/gold_med.png?'+rand;
	$('silver_d').src = 'http://www.coininfo.com/charts/silver_med.png?'+rand;
	
}

function update_charts(){
	
	var rand = Math.floor(Math.random()*11546);
	new Ajax('/items/charts.php', {
		postBody: 'rand='+rand,
		update: 'charts',
		evalScripts: true
	}).request();
	return false;
	
}

function update_allcharts(){
	
	var rand = Math.floor(Math.random()*11546);
	new Ajax('/items/allcharts.php', {
		postBody: 'rand='+rand,
		update: 'charts',
		evalScripts: true
	}).request();
	return false;
	
}

function off() {

	$$('.tabs li a').each(function(el){
		$(el.id).className = '';
		});
}



window.addEvent('load', function(){
	setInterval("updates()", 60000);
});	




/* Deal with cookies */
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}

function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
			} 
		}
	return "";
	}




