// JavaScript Document
//alert('niyi');

function loadSchedule (day,mode) {
	
	if(day == false){
		switch(mode){
				case 'prev':
					day = $('prev').value
					break
				case 'next':
					day = $('next').value
					break
		}
	}
	msgContent =  '&nbsp;&nbsp;<p style="margin-left:100px"><img src="images/loader.gif" alt="Loading..."  align="middle" /></p><p style="margin-left:15px"><font size=2 color="#000">Loading <em><b>'+Capital(day)+' </b></em>schedule... Please wait</font></p><p style="margin-left:15px"><a href=\'#\' onclick=\'closeMessage();return false\'>Cancel</a></p>';
	displayStaticMessage(msgContent,false);
	
	var url    = 'sch.php';
	var rand   = Math.random(9999);
	var pars   = 'day=' + day + '&rand=' + rand+'&action=AddToPlayList'+'&ky='+ky;
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showSchedule} );
}		

function Capital(value) {
  if (value != "") {
    var firstLetter = value.substring(0, 1).toUpperCase();
    var restOfWord = value.substring(1, value.length).toLowerCase();
    value = firstLetter + restOfWord;
  }

  return value;
}		
function showSchedule (originalRequest) {
	closeMessage();
	var response  = originalRequest.responseText.split('|@@@|');
	if(response[0] == '0'){
		//Something happened.. show our modal message dialog
		displayStaticMessage('<p style="margin-left:15px"><h3>'+response[1]+'</h3></p>'+"<p><a href=\'#\' onclick=\'closeMessage();return false\'>Close</a></p>",'modalDialog_contentDiv_error');
		return false;
	}
	if(response[0] == "1"){
		$('div_schedule').innerHTML = response[4];
		$('div_header').innerHTML = Capital(response[3])+" Schedule";
		$('prev').value = response[1];
		$('next').value = response[2];
	}
	//close our modal dialog
	
	return false;
	
}
function showLoad () {
	//$('clearCart').style.display = "none";
	//$('loading').style.display = "block";
	// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
	showHideLayers(FloatingLayer,'','show');
	alert(FloatingLayer);
}



function displayMessage(url)
{
	
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(400,200);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}

function displayStaticMessage(messageContent,cssClass)
{
	msgObj.setHtmlContent(messageContent);
	msgObj.setSize(300,150);
	msgObj.setCssClassMessageBox(cssClass);
	msgObj.setSource(false);	// no html source since we want to use a static message here.
	msgObj.setShadowDivVisible(false);	// Disable shadow for these boxes	
	msgObj.display();
	//return false;
	
	
}

function closeMessage()
{
	msgObj.close();	
}