$(document).ready(function(){
	 
	//	Refresh CAPTCHA
	$("#captcha_refresh_image").click(function(){
		var numRand = Math.floor(Math.random()*10000001);
		$("#captcha_png").attr("src", "/captcha.png?num="+numRand);
	});

	var hide_dd = 0;

	$("ul.subnav").parent().append("<span></span>");
	$("ul.topnav").live('click', function() {
		$("ul.subnav").slideDown('fast').show();

		$("ul.subnav").live('click', function() {
			hide_dd = 1;
		});

		if (hide_dd == 1) {
			$("ul.subnav").slideUp('fast');
			hide_dd = 0;
		}
		else
		{
			$("ul.topnav li span").parent().hover(
				function() {},
				function(){
					$("ul.subnav").slideUp('fast');
				}
			);
		}
	});

	$("#fp_search").focus();

	$("#show_login_box").click(function(){
		var link_id = $(this).attr('id');

		if ($('#login_box').is(':visible') == true) {
			$('#login_box').slideUp();
			$('#open_close_login').attr('src', '/images/open_login.png');
		} else {
			$('#login_box').slideDown();
			$('#open_close_login').attr('src', '/images/close_login.png');
		}

		return false;
	});

	$('#fp_search').keyup(function(event){
		if (event.keyCode == '13') {
			$('#index_search_form').submit();
		}
	});
});

function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


/*this.vtip = function() {
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 10; // y distance from mouse

    $(".vtip").unbind().hover(
        function(e) {
            this.t = this.title;
            this.title = '';
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);

            $('body').append( '<p id="vtip"><img id="vtipArrow" />' + this.t + '</p>' );

            $('p#vtip #vtipArrow').attr("src", '/images/vtip_arrow.png');
            $('p#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn();

        },
        function() {
            this.title = this.t;
            $("p#vtip").fadeOut("slow").remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);

            $("p#vtip").css("top", this.top+"px").css("left", this.left+"px");
        }
    );

};

jQuery(document).ready(function($){vtip();})*/
