$(document).ready(function(){
						   
	/* live - addon */
	(function(){
	
		var special = jQuery.event.special,
			uid1 = 'D' + (+new Date()),
			uid2 = 'D' + (+new Date() + 1);
	
		jQuery.event.special.focus = {
			setup: function() {
				var _self = this,
					handler = function(e) {
						e = jQuery.event.fix(e);
						e.type = 'focus';
						if (_self === document) {
							jQuery.event.handle.call(_self, e);
						}
					};
	
				jQuery(this).data(uid1, handler);
	
				if (_self === document) {
					/* Must be live() */
					if (_self.addEventListener) {
						_self.addEventListener('focus', handler, true);
					} else {
						_self.attachEvent('onfocusin', handler);
					}
				} else {
					return false;
				}
	
			},
			teardown: function() {
				var handler = jQuery(this).data(uid1);
				if (this === document) {
					if (this.removeEventListener) {
						this.removeEventListener('focus', handler, true);
					} else {
						this.detachEvent('onfocusin', handler);
					}
				}
			}
		};
	
		jQuery.event.special.blur = {
			setup: function() {
				var _self = this,
					handler = function(e) {
						e = jQuery.event.fix(e);
						e.type = 'blur';
						if (_self === document) {
							jQuery.event.handle.call(_self, e);
						}
					};
	
				jQuery(this).data(uid2, handler);
	
				if (_self === document) {
					/* Must be live() */
					if (_self.addEventListener) {
						_self.addEventListener('blur', handler, true);
					} else {
						_self.attachEvent('onfocusout', handler);
					}
				} else {
					return false;
				}
	
			},
			teardown: function() {
				var handler = jQuery(this).data(uid2);
				if (this === document) {
					if (this.removeEventListener) {
						this.removeEventListener('blur', handler, true);
					} else {
						this.detachEvent('onfocusout', handler);
					}
				}
			}
		};
	
	})();
	
	/* nav */

	// fix first nav
	$("#nav ul ul li:first-child a span").css("border-top","none");

	/* blog promo */
	$("#blogPromo .blogPromoArticles div:last-child").css("border-bottom","none");

	/* define protected items */
	
	// shut down all forum links to public members
	$("#forumPromo a").addClass("public_member");

	/* protect items */
	
	// protect and update each
	var url;
	$("a.protected,.protected a").each(function(index) {
		url = $(this).attr("href");		
//		alert(url+"  IS PROTECTED.");
		$(this).addClass("cb84");
		$(this).attr("href",template_url+"/ajax/signin.php?url="+escape(url));			
	});

	// colorbox
	$(".cb84").colorbox({width:"845px", height:"425px", iframe:true, opacity:"0.75"});

	/* input - default text */
	
	$("input, textarea").each(function(index) {
		if($(this).attr("title") !== "") {
			$(this).addClass("defaultText");
		}		
	});

    $(".defaultText").live("focus",function(srcc) {
        if($(this).val() == $(this)[0].title) {
            $(this).removeClass("defaultTextActive");
            $(this).val("");
//	        if($(this).attr("name") == "password") {
//				$(this).attr("type","password"); // need to upgrade JQ
//			}
    	}
    });
    
    $(".defaultText").live("blur",function() {
        if($(this).val() == "") {
            $(this).addClass("defaultTextActive");
            $(this).val($(this)[0].title);
//	        if($(this).attr("name") == "password") {
//				$(this).attr("type") = "text";
//			}
		}
    });
    
    $(".defaultText").blur();     
	
	/* form submit by enter */
		
//	$('input').live('keypress', function (e) {
//		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)){
//			$('input[type=image]').click();
////			$('button[type=submit]').click();
//		}
//	});
	
});

function cb(href) {
	$.colorbox({width:"845px", height:"425px", iframe:true, opacity:"0.75", href: href});
}

function a(URL,txt){
    document.write('<a target="_blank" href="'+URL+'">'+txt+'</a>');
}
