﻿Cufon.replace('div.buzzwords p',{textShadow: 'rgba(0,0,0,0.4) 1px 1px'});
Cufon.replace('h1',{textShadow: 'rgba(0,0,0,0.4) 1px 1px'});
Cufon.replace('h2');
Cufon.replace('h3,label');
Cufon.replace('button',{textShadow: 'rgba(0,0,0,0.4) 1px 1px'});
Cufon.replace('code');
$("html").addClass("JS")

$(function(){
//	$("div.buzzwords").hide();	// search field nicer (more style in the future)
	$("html").removeClass("JS");
	Cufon.now();
	$("div.buzzwords").css({
		paddingTop: (124 - ($("div.buzzwords").height())/2) + "px"
	});
	fixTopSearch();	
	$(".sociable img").mouseenter(function(){
		var index = $(".sociable img").index(this);
		$(".sociable img:not(:eq(" + index + "))").fadeTo("fast",0.33)
		$(this).fadeTo("fast",1)
	})
	$(".sociable ul").css({
		display:"list"
	}).mouseleave(function(){
		$("img",this).fadeTo("fast",1)
	})
	$(".avatars img").mouseenter(function(){
		var index = $(".avatars img").index(this);
		$(".avatars img:not(:eq(" + index + "))").fadeTo("fast",0.33)
		$(this).fadeTo("fast",1)
	})
	$(".avatars").mouseleave(function(){
		$("img",this).fadeTo("fast",1)
	})
	
	
	// links to new windows and popups
	$("a[rel=external]").attr("title",windowTitle);
	$("a[rel=external]").attr("target","_blank");
	$("a[rel=popup]").attr("title",popupTitle);
	$("a[rel=popup]").click(function(){
		theHref = $(this).attr("href");
		$(this).attr("href","javascript:void(0)");
		var popupWidth, popupHeight
		var relSplit = $(this).attr("rel").split("|");
		if(relSplit[1]){
			popupWidth = relSplit[1];
			popupHeight = relSplit[2];
		} else {
			popupWidth = 435;
			popupHeight = 350;
		}
		popMeUp(theHref,popupWidth,popupHeight)
		
		
		
	});	
	
	
	$("abbr[title]").each(function(){
		$(this).css("position","relative");
		$(this).append("<span>" + $(this).attr("title") + "</span>");
		$(this).attr("title","")
		$("span",this).css({
			position:"absolute",
			background:"#eee",
			border:"1px solid #c33",
			position:"absolute",
			right:"-1em",
			top:"1.7em",
			zIndex:3,
			width:"17em",
			padding:"0.2em 1em"
		});	
		$("span",this).hide();
		$(this).hover(function(){
			$("span",this).fadeIn("200");
			$(this).css("z-index","2");
		},function(){
			$("span",this).fadeOut("400");
			$(this).css("z-index","1");
		})

	})
})


// functions

function fixTopSearch(){
	$("#topSearch label").each(function(){
		$(this).hide()
		var searchText = $(this).text();
		$(this).siblings("input:first").val(searchText);
		$(this).siblings("input:first").focus(function(){
			if($(this).val() == searchText){
				$(this).val("")
			}
		});
		$(this).siblings("input:first").blur(function(){
			if(jQuery.trim($(this).val()) == ""){
				$(this).val(searchText)
			}
		});
	})

}


function popMeUp(strURL,strWidth,strHeight) {
	theWin = window.open(strURL, 'popupWin', "scrollbars,resizable,height=" + strHeight + ",width=" + strWidth);
	theWin.focus()
}
