
function abrepop(arquivo, largura, altura){
	alturascr = window.screen.availHeight;
	largurascr = window.screen.availWidth;

	pontoesq = parseInt(largurascr/2) - parseInt(largura/2);
	pontotop = parseInt(alturascr/2) - parseInt(altura/2);
	
	checkformw = window.open(arquivo,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, menubar=no, width=" + largura + ", height=" + altura);
	checkformw.moveTo(pontoesq,pontotop);
	checkformw.focus;
}

var tplDestaqueTabDias = {
		setTab : function(id)
		{
			$("#tpl-destaque-tab-1").hide();
			$("#tpl-destaque-tab-2").hide();
			$("#tpl-destaque-tab-3").hide();
			$("#tpl-destaque-tab-" + id).show();

			$("div.tpl-destaque span.btns a.ativo").removeClass('ativo');
			if (id == 1) {
				$("div.tpl-destaque span.btns a.ontem").addClass('ativo');			
			} else if (id == 2) {
				$("div.tpl-destaque span.btns a.hoje").addClass('ativo');			
			} else {
				$("div.tpl-destaque span.btns a.amanha").addClass('ativo');		
			}
			
			$("#tpl-destaque-tab-" + id + " img").each(
						function (i)
						{
							if (!this.getAttribute('src') && this.getAttribute('tmp'))
							{
								var tSrc = document.createAttribute('src');
								this.setAttributeNode(tSrc);
								var oImg = this;
								var tImg = document.createElement('img');
								tImg.src = this.getAttribute('tmp');
								tImg.onload = function() {
									oImg.src = tImg.src
								};
							}
						}
					);
		}
		
}

var HTTP_HOST = window.location.host;
function emLocalhost() {
    return HTTP_HOST == 'localhost' || HTTP_HOST == 'preview';
}
/**
 * http://snippets.dzone.com/posts/show/5629
 */
function friendlyUrl(u) {
    var url = u.toLowerCase() // change everything to lowercase
        .replace(/^\s+|\s+$/g, "") // trim leading and trailing spaces		
        .replace(/[_|\s]+/g, "-") // change all spaces and underscores to a hyphen
        .replace(/[^a-z0-9-]+/g, "") // remove all non-alphanumeric characters except the hyphen
        .replace(/[-]+/g, "-") // replace multiple instances of the hyphen with a single instance
        .replace(/^-+|-+$/g, "") // trim leading and trailing hyphens				
		
    return url;
}

