
$(document).ready(function(){
    

	$(".accordion").accordion({ autoHeight: false });

	/*
	 *	
	 *		Add Main Tabs
	 *		@TODO: Add cookies. When user clicks on link menu remains open for a couple of seconds.
	 *
	 */

	$("#tabs").tabs({
		event: "mousemove",
		selected: null,
		cache: true,
		unselect: true,
		collapsible: false,
		select: function(event, ui) { 
			$(".menus").show(); 
			$(".navcontainer").removeClass("whitebottom").addClass("nowhitebottom"); 
		},
		fx: {}
	}).removeClass("ui-corner-all");
	/*
	 * Sloppy
	 */
	$(".navsingle").live('click', function(){
		window.location.href = '/forms/contactus/';
	});
	
	$(".navcontainer").live('mouseleave',function(){
		$("#tabs").tabs('option', 'selected', -1).tabs( "abort");
		$(".menus").stop(true,true).slideUp({duration: 250, easing: 'jswing', complete: function(event, ui){
		
			$("#tabs .ui-tabs-selected").removeClass("ui-state-active").removeClass("ui-tabs-selected");
			$(".navcontainer").removeClass("nowhitebottom").addClass("whitebottom");			
		 	}
		 });

	});
	
	/*
	 *	
	 *		End Main Tabs
	 *
	 */
	
	$("a[name='authenticate']").click(function() {

		$("#loginform").dialog({ modal: true, width: '340', title: "Access", resizable: false, focus: function(event, ui) { $("#login").focus(); }});
		if($("#loginform").length!=0){
			return false;
		}
	});
	
	$(".email").click(function() {
		$("#emailform").dialog({modal: true,title: "Webmail Login",width: '340', height: '230', resizable: false, focus: function(event, ui) { $("#weblogin").focus(); }});
		
		return false;
	});
	/*
	 *	
	 *		Add to top for .centerContent > h1 > a
	 *
	 */
	 $(".centerContent > h1 > a").parent().addClass("bottomline").append($("<div>").addClass("totop").html('<a href="#" class="ui-icon ui-icon-arrowreturn-1-n"></a>'));
	 $("thead > tr > th").parent().parent().parent().find("tbody > tr > th").append($("<div>").addClass("thtotop").html('<a href="#" class="ui-iconwhite ui-icon-arrowreturn-1-n"></a>'));
});
/*
 *
 *	Create popup
 *
 */
function popup(loc, w, h, type){
	if(loc.length != 0){
		$("body").append($("<iframe src='"+loc+"' style='width: width: 96% !important;'></iframe>").attr("id","popuptemp"));
																
		$( "#popuptemp" ).dialog({
			resizable: false,
			width: w,
			height: h,
			modal: true,
			open: function(){
				$("#popuptemp").width("96%");	
			},
			close: function(){
				$("#popuptemp").remove();
			}
		});
	}
	
}

