function $id(id){
	if(document.getElementById){
		return document.getElementById(id);
	}else if(document.all){
		return document.all[id];
	}else if(document.layers){
		return document.layers[id];
	}
};

function loadTime() {

	setTimeout("loadTime()", 1000);
	myDate = new Date();
	 
	//Collect times  
	hours = myDate.getHours();
	minutes = myDate.getMinutes();
	seconds = myDate.getSeconds();
	
	//Add 0 at front
	if (hours < 10)   hours   = "0" + hours;
	if (minutes < 10) minutes = "0" + minutes;
	if (seconds < 10) seconds = "0" + seconds;
	   
	//Output the time
	$id("time-display").innerHTML = hours+":"+minutes+":"+seconds;
   
}

function loadDate() {
	
	myDate = new Date();
	
	var days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
	var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
	
	//Get day [text]
	date = days[myDate.getDay()];
	number = myDate.getDate();
	year = myDate.getFullYear();
	
	//Get month [text]
	month = months[myDate.getMonth()];
	
	//Output date
	$id('date-display').innerHTML = date+' '+number+', '+month+' '+year+',';

}

function sortWidth() {	

	width = $(window).width();
	
	if (width < 1050) {
		
		$("body").css({'font-size' : '11px'});
		$("h1").css({'font-size' : '14px'});
		$("h2").css({'font-size' : '13px'});
		$(".header h1").css({'font-size' : '16px'});
		$(".main-text").css({'font-size' : '11px'});
		$(".topbar").css({'font-size' : '11px'});		
		$(".tableborder").css({'font-size' : '10px'});
		$(".small").css({'font-size' : '10px'});
		$(".header-small").css({'font-size' : '10px'});	
	 
	}
	
    return false;

}

function listShow(){

	this.List = new Array();
	
	this.ShowHide = function(id){	
		
		for(x = 0; x <= this.List.length; x++) {
			if($id(this.List[x]) != null) {	
				if(this.List[x] == id){					
					var e = $id(id);
					if(e.style.display == 'none') {
						$id('img_' + id).src = imgurl + 'navigation-on.gif';
						$('#' + id).slideDown('slow');					
					} else {						
						$('#' + id).slideUp('slow');
						$id('img_' + id).src = imgurl + 'navigation-off.gif';
					}								
				} else {				
					$('#' + this.List[x]).slideUp('slow');
					$id('img_' + this.List[x]).src = imgurl + 'navigation-off.gif';
				}
			}		
		}
		
	};		
	
	this.Initialize = function(reference){
		$id('img_' + reference).src = imgurl + 'navigation-on.gif';
		$('#' + reference).slideDown('slow');
	};

};

function closeBox() {
	jQuery(document).trigger('close.facebox');
}

function refreshConsole(){	
	$.get(indexurl + "id="+Math.random(), { 
		  page: "radioFrame"
		},
  		function(mainText){		
    		$('#artistFrame').html(mainText);	
			setTimeout('refreshConsole();', 2000);
  		}
	);	
} 

function showRadio(){
	this.list = new Array();	
	this.option = function(id){		
		for(x = 0; x <= this.list.length; x++) {		
			if($id(this.list[x]) != null) {		
				if(this.list[x] == id){	
					$('#' + this.list[x]).show();		
					$('#tab-' + this.list[x] + ' a').addClass("tabbed");
				} else {				
					$id(this.list[x]).style.display = 'none';		
					$('#tab-' + this.list[x] + ' a').removeClass("tabbed");
				}		
			}		
		}		
	};	
	this.init = function(id){
		this.option(this.list[id]);
	}
};

function sendRadioMail(theForm) {

	/* SEND MAIL */
	$.post(rooturl + "sendMail.php", {
		sName: theForm.sName.value,
		sEmail: theForm.sEmail.value,
		sMessage: theForm.sMessage.value,
		sSend: true
     }, function(pageLoaded){		 
			jQuery.facebox(pageLoaded);
	 });

	return false;

}

function handleConnection() {

	/* SEND MAIL */
	$.post(rooturl + "pages/handleConnection.php", {
		'uField': $('#username').val(),
		'uData': $('#password').val()
     });

	return true;

}

function checkDelete() {	
	check = confirm('Are you sure?');	
	if(check) {
		return true;
	}	
	return false;	
}
