var nT = 'Skriv dit navn...';
var eT = 'Skriv din e-mail...';
var sT = $("#prettysearch").val();

function emptyDefaults() {
	var n = $("#tcsubscribe_name").val(); 
	var e = $("#tcsubscribe_email").val();
	var s = $("#prettysearch").val();
	
	if(n == nT) $("#tcsubscribe_name").val("");
   	if(e == eT) $("#tcsubscribe_email").val("");
   	if(s == sT) $("#prettysearch").val("");
   	
   	return true;
}


/* SuckerFish */
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover); 

/*
* Fontsize manipulation
*
* 	Copyright (c) 2008 Claus Bruun (badmf@clausbruun.dk)
*
* Needs jquery.cookie.pack.js
* Needs jquery 1.2.2
*
* All fonts-sizes to be manipulated should be relative to body's font-size
* Link to make font larger is id='fontLarger'
* Link to make font smaller is id='fontSmaller'
*
*/
$(function() {

	var COOKIE_NAME = 'supahFontSize';
	// Clear cookie (if you need to test)
	// $.cookie(COOKIE_NAME, null);

	// Get fontsize from cookie, if we dont got it then set it from CSS and set cookie
	var fontSize = $.cookie(COOKIE_NAME);
	var fontSizeCSS = parseInt($("body").css("font-size"));
	if(!fontSize) {
		fontSize = fontSizeCSS;
		$.cookie(COOKIE_NAME, fontSize, { expires: 0, path: '/' });
	} else if(fontSize != fontSizeCSS) {
		$("body").css("font-size", fontSize + "px");
	}

	// Set larger font
	$('#fontLarger').click(function() { 
		fontSize = $.cookie(COOKIE_NAME);
		fontSize++;
		// Set fontsize & cookie
		$("body").css("font-size", fontSize + "px");
		$.cookie(COOKIE_NAME, fontSize, { expires: 0, path: '/' });
		return false;
	});

	// Set smaller font
	$('#fontSmaller').click(function() { 
		fontSize = $.cookie(COOKIE_NAME);
		fontSize = fontSize - 1;
		// Set fontsize & cookie
		$("body").css("font-size", fontSize + "px");
		$.cookie(COOKIE_NAME, fontSize, { expires: 0, path: '/' });
		return false;
	});


	var n = $("#tcsubscribe_name").val(); 
	var e = $("#tcsubscribe_email").val();
	var s = $("#prettysearch").val();

	// If we just loaded the page
   	if(n == "") $("#tcsubscribe_name").val(nT);
   	if(e == "") $("#tcsubscribe_email").val(eT);
   	if(s == "") $("#prettysearch").val(sT);
   	
   	// If the user unblurs
   	$("#tcsubscribe_name").blur(function(){ if($("#tcsubscribe_name").val() == "") $("#tcsubscribe_name").val(nT); });
   	$("#tcsubscribe_email").blur(function(){ if($("#tcsubscribe_email").val() == "") $("#tcsubscribe_email").val(eT); });
   	$("#prettysearch").blur(function(){ if($("#prettysearch").val() == "") $("#prettysearch").val(sT); });
   	
   	$("#tcsubscribe_name").focus(function(){
   		if($(this).attr("value") == nT){
   			$(this).attr("value", "");
   		}
   	});
   	$("#tcsubscribe_email").focus(function(){
   		if($(this).attr("value") == eT){
   			$(this).attr("value", "");
   		}
   	});
   	$("#prettysearch").focus(function(){
   		if($(this).attr("value") == sT){
   			$(this).attr("value", "");
   		}
   	});
   	
   	/* Equalize box height */
   	
 	$("div.flexible_threecols").each(function (i){
 		var hB = 0;
 		$(this).find("div.content").each(function (i){
 			if ($(this).height() > hB) {
 				hB = $(this).height();
 			}
 		});
 		$(this).find("div.content").height(hB);
 	});

	/* Equalize box height: flexible_twocols */
 	$("div.flexible_twocols").each(function (i){
 		var hB = 0;
 		$(this).find("div.content").each(function (i){
 			if ($(this).height() > hB) {
 				hB = $(this).height();
 			}
 		});
 		$(this).find("div.content").height(hB);
 	});

 	
 	/* Set height of left column */
 	var mainH = $("div#normal-col").height();
 	var offset = 22;
 	var leftH = mainH - offset;
 	$("div.sub-left-col").height(leftH);
   	
});