//D League JavaScript Document
//******************************************************************************
//エリア名を取得
//******************************************************************************
function l_divs_list(area_id)
{

	var parameter	= $H({area_id:area_id}).toQueryString();
	
	//AJAXファイルを指定
	//ajax_file_path 	= './ajax/l_area_name.php';

	new Ajax.Request(
			'./ajax/l_area_name.php',
			{
				method			:'post',
				postBody		:parameter,
				onComplete		:function(httpObject){
					
					get_l_divs_list(area_id,httpObject.responseText);
				},
				onFailure		:function(reg,header){
					
					get_l_divs_list(area_id,false);

				}
			}
	);
}

//******************************************************************************
//デビジョン一覧を取得
//******************************************************************************
function get_l_divs_list(area_id,area_name) {

	var parameter	= $H({area_id:area_id}).toQueryString();
	
	//AJAXファイルを指定
	//ajax_file_path 	= './ajax/l_divs_list.php';

	new Ajax.Request(
			'./ajax/l_divs_list.php',
			{
				method			:'post',
				postBody		:parameter,
				onComplete		:function(httpObject){
					
						add_gritter(area_name,httpObject.responseText);
				},
				onFailure		:function(reg,header){
					
						add_gritter(area_name,false);

				}
			}
	);
}

//******************************************************************************
//デビジョン一覧を取得
//******************************************************************************
function add_gritter(area_name,divs_list) {

	jQuery(document).ready(function($){
			
			var gritter_id = $.gritter.add({
				// (string | mandatory) the heading of the notification
				title: "" + area_name +"",
				// (string | mandatory) the text inside the notification
				text: "" + divs_list +"",
				// (bool | optional) if you want it to fade out on its own or just sit there
				sticky: false, 
				// (int | optional) the time you want it to be alive for before fading out
				time: 15000
		
			});

			$.gritter.remove(gritter_id-1,'');
			return false;
	});
}
