var BASE_URL = 'http://www.internetcenter.com.br/internetcenter';

$(document).ready(function(){
	$('#addgoogle').click(function(){ redirect('http://fusion.google.com/add?source=atgs&feedurl=http%3A//www.internetcenter.com.br/internetcenter/noticias/rss.php'); });
});
var getHeigth = function(){
	var v = $('#leftcolumn').get(0).offsetHeight;
	if($('#contentwrapper').get(0).offsetHeight > v)
		v = $('#contentwrapper').get(0).offsetHeight;
	if($('#rightcolumn').get(0).offsetHeight > v)
		v = $('#rightcolumn').get(0).offsetHeight;
	return v;
}

var setHeigth = function(val){
	$('#leftcolumn').height(val);
	$('#contentwrapper').css("min-height",val);
	$('#rightcolumn').height(val);
}

function getGets(){
	var string = document.location.search;
	var getVars = [];
	tGet = [];//global
	getVars = string.substr(1, string.length);
	getVars = getVars.split('&');
	var t, n, tmpV;
	for (t=0,n=getVars.length;t<n;t++){
		tmpV=getVars[t].split('='); tGet[tmpV[0]]=tmpV[1];
	}
}

function redirect(url){
	document.location.href = url;
}

function bannerPopUp(div, tIni, tFim){
	banner = new Banner();
	$('#'+div+' a').before('<div class="barra"><span>Fechar</span><img id="iconClose" src="'+BASE_URL+'/static/images/close_toolbar.gif" alt="Fechar Banner" title="Fechar Banner"/></div>');
	$('#'+div).Draggable({ handle: 'div' });
	$('#iconClose').click(function(){ banner.hide() });

	banner.setDiv(div);
	banner.setTFim(tFim);
	setTimeout('banner.show()',tIni);
}

function Banner(div){
	var div;
	var fim;
	
	this.setDiv = function(val){
		div = val;
	}
	
	this.setTFim = function(val){
		fim = val;
	}
	
	this.show = function(){
		$('#'+div).fadeIn("slow");
		setTimeout('banner.hide()',fim);
	}
	
	this.hide = function(){
		$('#'+div).fadeOut("slow");
	}
}

function styleButtons(el,r){
	if(el == undefined) el = 'button';
	if(r == undefined) r = true;
    
    if(r == true){
	    $(el).each(function(i){
	        $(this).addClass('button');
	        $(this).before('<img class="img-style" src="'+BASE_URL+'/static/images/button_left.gif" border="0"/>');
	        $(this).after('<img class="img-style" src="'+BASE_URL+'/static/images/button_right.gif" border="0"/>');
	
        	$(this).focus( function() {
            	$(this).addClass('buttonHover');
            	$(this).prev().attr('src',''+BASE_URL+'/static/images/button_left_xon.gif');
            	$(this).next().attr('src',''+BASE_URL+'/static/images/button_right_xon.gif');
        	});	
        	$(this).blur( function() {
            	$(this).removeClass('buttonHover');
            	$(this).prev().attr('src',''+BASE_URL+'/static/images/button_left.gif');
            	$(this).next().attr('src',''+BASE_URL+'/static/images/button_right.gif');
        	});
	        
	        $(this).mouseover( function() {
	            $(this).addClass('buttonHover');
	            $(this).prev().attr('src',''+BASE_URL+'/static/images/button_left_xon.gif');
	            $(this).next().attr('src',''+BASE_URL+'/static/images/button_right_xon.gif');
	        });
	        $(this).mouseout( function() {
	            $(this).removeClass('buttonHover');
	            $(this).prev().attr('src',''+BASE_URL+'/static/images/button_left.gif');
	            $(this).next().attr('src',''+BASE_URL+'/static/images/button_right.gif');
	        });
	        
	    });
    }else if(r == false){
    	$(el).each(function(i){
    		$(this).removeClass('button');
    		$(this).prev().remove();
    		$(this).next().remove();
    	});
    }
}

function fontSize(v){
	var fonte = new Array();
	fonte[0] = "10px";
	fonte[1] = "11px";
	fonte[2] = "12px";
	fonte[3] = "13px";
	fonte[4] = "14px";
	fonte[5] = "15px";
	
	if(v){
		if(i>=0 && i<5) i++;
		$('#contentcolumn .noticia p').css( "font-size", fonte[i]);
	}	
	else{
		if(i>0 && i<=5) i--;
		$('#contentcolumn .noticia p').css( "font-size", fonte[i]);
	}
}

function gerarURL(str) {
	var from = " ÀÁÃÂÉÊÍÓÕÔÚÜÇàáãâéêíóõôúüç':;,.\\/|\"?!@#$%^&*(){}[]_~=";
	var to = "+AAAAEEIOOOUUCaaaaeeiooouuc";
	var pos, carac, retval = '';
	
	if(str){
		for (var i=0; i < str.length; i++){
			carac = str.charAt(i);
			pos  = from.indexOf(carac);
			if (pos > -1)
				retval += to.charAt(pos);
			else
				retval += str.charAt(i);
		}
		return retval.toUpperCase()+'.html';
	}
	else
		return '';
}

Number.prototype.formatMoney = function(c, d, t){ //Serve para formatar um number em formato dinheiro
var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t,
i = parseInt(n = (+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
return (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t)
+ (c ? d + (n - i).toFixed(c).slice(2) : "");
}; 

