function sz(t) {
	a = t.value.split('\n');
	b = 1;
	for(x = 0;x < a.length; x++) {
		if(a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
	}
	b += a.length;
	if(b > t.rows) t.rows=b;
}
function toggle_leftmenu_panel(ref) {
	$(".menu-level-0 ul").hide("slow");
	$("#"+ref).show("slow");
}
function toggle_cta_panel() {
	if(document.getElementById('cta_panel').className == "show")
		document.getElementById('cta_panel').className="hide";
	else
		document.getElementById('cta_panel').className="show";
}
function toggle_social_panel() {
	if(document.getElementById('social_cta_panel').className == "show")
		document.getElementById('social_cta_panel').className="hide";
	else
		document.getElementById('social_cta_panel').className="show";
}
function toggle_challenge() {
	if(document.getElementById('challenge').className == "show")
		document.getElementById('challenge').className="hide";
	else {
		document.getElementById('challenge').className="show";
		window.location='#eop';
	}
}
function addToFavorites(pageName, urlAddress) {
	if (window.sidebar) // Mozilla Firefox Bookmark
		window.sidebar.addPanel(pageName, urlAddress,"");
	else if( window.external ) // IE Favorite
		window.external.AddFavorite(urlAddress, pageName);
	else if(window.opera && window.print) // Opera Hotlist
		return true;
}
// Page ready function
$(document).ready(function () {
	$(".tools").click(function() {
		toggle_cta_panel();
	});
	$(".newWindow").click(function() {
		var newWindow = window.open(this.getAttribute('href'), '_blank');
		newWindow.focus();
		return false;
	});
	$(".dropdown").click(function() {
		$("#footer-design > ul > li > ul").toggle();
		return true;
	});
	$(".challenge").click(function() {
		$("#challenge").toggle();
		return false;
	});
	$(".formTab").click(function() {
		formTab();
		return false;
	});
	$(".challenge").hover(
		function() {
				$(this).addClass('selected');
			},
		function() {
				$(this).removeClass('selected');
			}
	);
	$("#topmenu-design > ul > .menu-level-0").hover(
		function() {
				$(this).addClass('selected');
				$('.' + $(this).attr('id')).show();
			},
		function() {
				$(this).removeClass('selected');
				$('.' + $(this).attr('id')).hide();
			}
		);
	$("#topmenu-design > ul > li > ul > .menu-level-2").hover(
		function() {
				$(this).addClass('selected');
			},
		function() {
				$(this).removeClass('selected');
			}
		);
	if(!($.browser.msie && /6.0/.test(navigator.userAgent))) {
		$(".menu-level-0 > div > div").css('height', '15px');
		$(".menu-level-0 > div > div").css('line-height', '15px');
	}
	if($.browser.msie) {
		if(document.getElementById('formObj') != null) {
			var data = document.getElementById('formObj').getAttribute('data');
			$("#formObj").replaceWith('<iframe src="' + data + '" style="width:608px;height:535px;border:none" allowTransparency="true" frameborder="0" scrolling="no"></iframe>');
		}
	}
//	$(".thickbox").hover(
//		function() {
//				$(this).find('.thumbnail').show();
//			},
//		function() {
//				$(this).find('.thumbnail').hide();
//			}
//		);
});