$(function(){


  /* Date pickers */
  $("input.date").datepicker({dateFormat: 'yy-mm-dd'});
  $("input:text.datetime").datetimepicker({ timeFormat: 'hh:mm:ss', dateFormat: 'yy-mm-dd'});
  $("input.birthdate").datepicker("option", "changeMonth", true);
  $("input.birthdate").datepicker("option", "changeYear", true);

  $(".check_spelling").each(function () {
	  $(this).spellCheck();
  });
	
	if (!($.browser.msie && $.browser.version=="6.0")) {
		$(".glossymenu a").each(function() {
			$(this).qtip({
				content: $(this).attr("title"),
				position: {
					my: "left middle",
					at: "right middle"
				},
				events: {
					show: function(event, api) {
						$(".qtip").each(function() {$(this).qtip('hide');});
						if ($(".goog-te-gadget").length) {
							var tip=$(api.elements.tooltip);
							if (!tip.hasClass("fixed")) {
								tip.css("margin-top", tip.css("margin-top").split("px")[0]-20+"px");
								tip.addClass("fixed");
							}
						}
					}
				}
			});
		});
		$("#quick-search-top > form, #quick-search-bottom > form").qtip({
			content: 'Search all reports that contain the word/s specified.',
			show: 'mouseover',
			hide: 'mouseleave',
			position: {
				my: "left middle",
				at: "right middle"
			},
			events: {
				show: function(event, api) {
					$(".qtip").each(function() {$(this).qtip('hide');});
					var tip=$(api.elements.tooltip);
					if (!tip.hasClass("h-fixed")) {
						tip.css("margin-top", "9px");
						tip.addClass("h-fixed");
					}
					if (!tip.hasClass("fixed")&&$(".goog-te-gadget").length) {
						tip.css("margin-top", "-11px");
						tip.addClass("fixed");
					}
				}
			}
		});		
		$("#quick-search-top > form .go_btn").mousemove(function (e) {
			$("#quick-search-top > form").qtip("hide");
			e.preventDefault();
		});
		$("#quick-search-bottom > form .go_btn").mousemove(function (e) {
			$("#quick-search-bottom > form").qtip("hide");
			e.preventDefault();
		});
		$("#quick-search-top a[title], #quick-search-bottom a[title]").each(function() {
			$(this).qtip({
				content: $(this).attr("title"),
				position: {
					my: "left middle",
					at: "right middle"
				},
				events: {
					show: function(event, api) {
						$(".qtip").each(function() {$(this).qtip('hide');});
						if ($(".goog-te-gadget").length) {
							var tip=$(api.elements.tooltip);
							if (!tip.hasClass("fixed")) {
								tip.css("margin-top", tip.css("margin-top").split("px")[0]-20+"px");
								tip.addClass("fixed");
							}
						}
					}
				}
			});
		});
		$(".logo").each(function () {
			$(this).qtip({
				content: $(this).attr("title"),
				position: {
					my: "left middle",
					at: "right middle"
				},
				events: {
					show: function(event, api) {
						$(".qtip").each(function() {$(this).qtip('hide');});
						if ($(".goog-te-gadget").length) {
							var tip=$(api.elements.tooltip);
							if (!tip.hasClass("fixed")) {
								tip.css("margin-top", tip.css("margin-top").split("px")[0]-20+"px");
								tip.css("margin-left", tip.css("margin-left").split("px")[0]+11+"px");
								tip.addClass("fixed");
							}
						}
					}
				}
			});
		});
	}
});

