$(document).ready(function(){
	
	if ($.browser.msie && $.browser.version <= 6) msie6 = true; else msie6 = false;
	
	$(".corner").corner("7px");
	
	$("ul.faqs li.q").append("<a href=\'#top\' style=\'float:right;\'>Top ^</a>");
	
	$("table.list").each(function(){
		$(this).find("tbody tr:odd").addClass("odd");
		$(this).find("tbody tr:even").addClass("even");
	});
	if (!msie6) {
		
		$("ul.sf-menu > li > a").addClass("topLevel");
		
		$("ul.sf-menu li a.topLevel").append("<div></div>"); // add in special underline div
		$("ul.sf-menu li:hover a.topLevel, .sf-menu li a.selected").css("borderBottom", "0");
		$("ul.sf-menu li ul").css("paddingTop", "0"); // reset menu state if javascript enabled
		$("ul.sf-menu li ul").css("top", "2.3em"); // reset menu state if javascript enabled
		
		$("ul.sf-menu li.selected").parents("li").addClass("selected");
	
		$("#bodycopy").prepend($("#shadowTop"));
		$("#bodycopy").prepend($("#shadowLeft"));
		$("#bodycopy").append($("#shadowRight"));
		$("#bodycopy").append($("#shadowBottom"));
		
		// START menu scripts
			$("ul.sf-menu li:first").addClass("first");
			$("ul.sf-menu li:last").addClass("last");
			$("#footer ul li:first").addClass("first");
			$("#footer ul li:last").addClass("last");
		// END menu scripts	
		if ($.browser.msie) {
			$(".small_corner").corner("3px cc:#2ea8cd");
		} else { 
			$(".small_corner").corner("3px");
		}
	}
	
	resetFancyBox();
	
	Cufon.replace('h1:not(#boiler-plate h1), .h1, .cufon, .btn button, .sf-menu a.topLevel', { fontFamily: 'Myriad Pro' });
	Cufon.replace('.h2, .cufon-alt', { fontFamily: 'Segoe' });
	
});

function resetFancyBox() {
	
	$(".fancyme").each ( function() {
		
		f_width = 600;// default width
		f_height = 520;// default height
		showClose = true;// default show close button
		showTitle = true;// default show title
		
		fancyclasses = $(this).attr("class");
		
		fancyclasses_arr = fancyclasses.split(" ");
		$.each(fancyclasses_arr, function() {
			first_letters = this.substr(0,2);
			rest_letters = this.substr(2, this.length - 2);
			if (first_letters == "w-") {
				f_width = 1 * (rest_letters);
			} else if (first_letters == "h-") {
				f_height = 1 * (rest_letters);
			} else if (first_letters == "c-") {
				showClose = rest_letters;
				if (showClose == "false") showClose = false;
			} else if (first_letters == "t-") {
				showTitle = rest_letters;
				if (showTitle == "false") showTitle = false;
			}
		});
		$(this).fancybox({
			'hideOnContentClick': false,
			'autoDimensions': false,
			'width': f_width,
			'height': f_height,
			'showCloseButton': showClose,
			'titleShow': showTitle,
			'onClosed': function(e) {
				$("#feedback").insertAfter("#footer");
				$("#feedback").hide();
				closeFancyBox();
			},
			'onComplete': function(e) {
				$("#fancy_form input:visible:enabled:first").focus();
				Cufon.refresh();
				resetFancyBox();
				$("#feedback").hide();
				$("#feedback").insertAfter("#fancybox-inner");
			}
		});
		
		thisHref = $(this).attr("href");
		if (thisHref.indexOf("?") > 0) {
			operand = "&";
		} else {
			operand = "?";
		}
		thisHref+=operand + "content_only=1";
		$(this).attr("href", thisHref);
	});
	
	$("table.list").each(function(){
		$(this).find("tbody tr:odd").addClass("odd");
		$(this).find("tbody tr:even").addClass("even");
		$(this).trigger("update");
	});
	
}

function closeFancyBox() {
}

function check_privacy_status() {
	if (document.getElementById("register_box").style.display != "none" && document.getElementById("privacy").checked == false) {
		alert("To continue, please tick the box that states you have read, understood and agree to the terms and conditions, and the privacy policy.");
		return false;
	}
}
