var t;
$(document).ready(function(){
	
    //Initialise the switching menu
    $("#tabs").tabs();
	
	
	var focusTab = document.getElementsByName("focusAlertTab")[0].value;
	if (focusTab == "focusTabAlert")
	{
		$("#tabs").tabs('select', 1);
	}
	else
	{
		$("#tabs").tabs('select', 0);
	}
	
   
	
	//Closes the filter box
	function closeFilter(){
		$("#dashboard_filter").removeClass("open");
	};
	
	
	//Check to see if any submenu items are active and apply .disabled to them
	$(".haschildren .active").parent().parent().addClass("disabled");
	$(".haschildren .active").parent().parent().addClass("open");
	
	//Toggles the submenus open and closed, only if they don't have .disabled applied to them
	$(".haschildren:not(.disabled).menu-toggle-button").click(function(){
		$(this).parent().toggleClass("open");
		return false;
	});
	$(".haschildren.disabled .menu-toggle-button").click(function(){
		return false;
	});
	
	
	//Behavior for the filter box
	$("#filter_current").click(function(){
		$("#dashboard_filter").toggleClass("open");
		return false;
	});
	
	$("#dashboard_filter").mouseleave(function(){
		t=setTimeout(closeFilter,400);
	});
	
	$("#dashboard_filter").mouseenter(function(){
		clearTimeout(t);
	});
	
	$(".alerts-selectall").click(function(){
		$("input:checkbox").attr('checked', true);
		return false;
	});
	$(".alerts-deselectall").click(function(){
		$("input:checkbox").attr('checked', false);
		return false;
	});
});

/**
** Function connecttoServer method to pass the request to the server and waits for response synchronously
** Author: Arora ch
** Date	16/04/2010
** Remodeled by: Kirupagaran DEVARAJAN
** Remodeled Date: 1/10/2010
** accepts a argument of type string contain url.
**/
function connecttoServer(url){
	splitUrl = url.split("/");
	pageId = splitUrl[splitUrl.length-2];
	var ajaxObj = new RequestServer();
	i=ajaxObj.connectToServer(url,"string");
	if(i==2){
		document.getElementById("result_"+pageId).innerHTML="<img height='15' width='15' src='http://www.ewb.org.au/assets/default/images/tick.png'>";
	 }
	 else{
		document.getElementById("result_"+pageId).innerHTML="<img height='15' width='15' src='http://www.ewb.org.au/assets/default/images/cross.png'>";
	}
}

function selectall(count){

	var select_arr=new Array();
	for (var i=1;i<=count ;count++ )
	{
		i=i+'';
		var ele=document.getElementById(i);
		ele.checked=true;
		alert(ele.value);
		select_arr[i]=ele.value;
	}

}
