﻿/// <reference path="C:\projects\_jQuery\jquery-vsdoc.js"/>
var init_h;
 // perform JavaScript after the document is scriptable.
$(document).ready(function () {
	$("body").attr("id", "top");

	//default search field text
	var active_color = '#464646'; // Colour of user provided text
	var inactive_color = '#464646'; // Colour of default text
	$("input.ow_sbox").css("color", inactive_color);
	var default_values = new Array();
	$("input.ow_sbox").focus(function () { if (!default_values[this.id]) { default_values[this.id] = this.value; } if (this.value == default_values[this.id]) { this.value = ''; this.style.color = active_color; } $(this).blur(function () { if (this.value == '') { this.style.color = inactive_color; this.value = default_values[this.id]; } }); });

	init_h = $(".container_in").height();

	//check if logged in to OW
	if (typeof OneWeb.Admin === "undefined") {
		//if NOT logged in

		//quick guide panel hacks for IE7
		if ($.browser.msie && parseInt($.browser.version) <= 7) {
			$("#quickguide").css({"top":"3000px"});
			quickGuide(false);
			$(".quickguide_tab").click(function () {
				quickGuide(true);
			});
			$(".pagination a").live("click", function () {
				setTimeout("if ($('.container_in').height() != init_h) { quickGuide(false); }", 600);
			});
			$(".directory_alphalinks a").live("click", function () {
				setTimeout("if ($('.container_in').height() != init_h) { quickGuide(false); }", 600);
			});

			//content tabs
			$("#ui-tabs").tabs({
				fx: { opacity: "toggle", effect: "fade", fadeOutSpeed: 2 },
				select: function (event, ui) {
					if ($('.container_in').height() != init_h) { $("#quickguide").css({ "top": "5000px" }); }
				},
				show: function (event, ui) {
					//stupid IE7 fix
					setTimeout("if ($('.container_in').height() != init_h) { quickGuide(false); }", 600);
				}
			});
		} else {
			$("#quickguide").css({ "bottom": "-250px" });
			$(".quickguide_tab").click(function () {
				if (!$("#quickguide").hasClass("opened")) {
					$("#quickguide").animate({
						bottom: "0"
					}, 500, 'swing', function () {
						$("#quickguide").addClass("opened");
						$("#qg_toggle").text("-");
					});
				} else {
					$("#quickguide").animate({
						bottom: "-250px"
					}, 100, 'swing', function () {
						$("#quickguide").removeClass("opened");
						$("#qg_toggle").text("+");
					});
				}
			});
			//content tabs
			$("#ui-tabs").tabs({
				fx: { opacity: "toggle", effect: "fade", fadeOutSpeed: 2 }
			});
		}

	}

	//only do when logged in to OW
	if (typeof OneWeb.Admin != "undefined") {
		$(".tabbed_content_header,.ui-tabs-hide").css({ "display": "block" });
		$(".container_in").css({ "overflow": " " });
		$("#quickguide").removeClass("public");
	}
});

function quickGuide(toggle) {
	//alert(init_h);
	var h = $(".container_in").height();
	var opened = (h - 288);
	var closed = (h - 38);
	//alert("h= " + h + "/ o= " + opened + "/ c=" + closed);
	$("#quickguide").css({ "top": h + "px" });
	if (toggle) {
		if (!$("#quickguide").hasClass("opened")) {
			$("#quickguide").animate({
				top: opened + "px"
			}, 500, 'swing', function () {
				$("#quickguide").addClass("opened");
				$("#qg_toggle").text("-");
			});
		} else {
			$("#quickguide").animate({
				top: closed + "px"
			}, 100, 'swing', function () {
				$("#quickguide").removeClass("opened");
				$("#qg_toggle").text("+");
			});
		} 
	} else {
		//reposition without toggling - for IE7 bug
		$("#quickguide").animate({
			top: closed + "px"
		}, 500, 'swing', function () {
			$("#quickguide").removeClass("opened");
			$("#qg_toggle").text("+");
		});
	}
	init_h = h;
}


