$(function() {
    $("dl.index").find("dd:gt(15)").addClass("hide");
    $("dl.index:not(.skip) dt").append("<span class='more'><span>ver todos</span></span>");
    $("span.more span").click(function(){
        $(this)
            .parents("dl.index:first")
            .find("dd")
            .removeClass("hide");

        $(this).parents("span:first").remove();
    });

	if ($.browser.safari) {
		var q = document.getElementById('q');
		
		$("#search-submit").hide();
		
		if (q) {
			q.setAttribute('placeholder', 'Busca...');
			q.setAttribute('type', 'search');
			q.setAttribute('results', 5);
			q.setAttribute('autosave', 'br.com.simplesideias');
		}
	} else {
		var label = 'Buscar...';

		$('#q').each(function(){
			var onFocus = function() {
				if (this.value == label) {
					this.value = '';
				}

				$(this).removeClass('placeholder');
			};

			var onBlur = function() {
				if (this.value == '') {
					this.value = label;
				}

				$(this).addClass('placeholder');
			};

			$(this)
				.focus(onFocus)
				.blur(onBlur);
		});

		var value = $('#q').val();

		if (value == "" || value == label) {
			$('#q')
				.val(label)
				.addClass('placeholder');
		}
	}
	
	var css_name = null;
	var ua = navigator.userAgent;
	var matches = null;
	
	if (ua.match(/firefox/i)) {
		css_name = 'firefox';
	} else if (ua.match(/safari/i)) {
		css_name = 'safari';
	} else if (matches = ua.match(/msie (\d+)/i)) {
		css_name = 'ie ie' + matches[1];
	} else if (ua.match(/opera/i)) {
		css_name = 'opera';
	} else if (ua.match(/mozilla/)) {
		css_name = 'mozilla';
	}
	
	if (css_name) {
		$('body').addClass(css_name);
	}
});

if (top !== self) {
	top.location.replace(self.location.href);
}