var _AdFontSizeMin = 1;
var _AdFontSizeMax = 9;

var AdTextoTamanhoAumentar=function(classe){
	var elementos = YAHOO.util.Dom.getElementsByClassName(classe);
	if (elementos.length>0) {
		for (i in elementos) {
			_AdAlteraTamanhoFonte(elementos[i],true);
		}
	}
	return false;
}
var AdTextoTamanhoDiminuir=function(classe){
	var elementos = YAHOO.util.Dom.getElementsByClassName(classe);
	if (elementos.length>0) {
		for (i in elementos) {
			_AdAlteraTamanhoFonte(elementos[i],false);
		}
	}
	return false;
}
	var _AdAlteraTamanhoFonte=function(el,aumenta) {
		var fsize, nsize;
		fsize = el.className.match(/AdFontSize-([0-9]+)/);
		nsize=(fsize)?parseInt(fsize[1]):2;
		nsize=(aumenta)?nsize+1:nsize-1;
		nsize=(nsize>_AdFontSizeMax)?_AdFontSizeMax:
				(nsize<_AdFontSizeMin)?_AdFontSizeMin:nsize;
		el.className = el.className.replace(/AdFontSize-([0-9]+)/,'');
		el.className+=" AdFontSize-"+nsize;
	}

var AdBrowserAddFavoritos = function(title, url) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	} else if(window.opera && window.print) { // Opera Hotlist
		return true;
	}
}


var AdFormatNumber = {
	format: function(expression, decimalPlaces, includeLeadingDigit, negativeValuePrefix, negativeValueSuffix, thousandsSeparator, decimalSeparator) {
		var value, vector, pos, n;
		value = Math.round(expression * Math.pow(10, decimalPlaces));
		if (value >= 0) negativeValuePrefix = negativeValueSuffix = "";
		vector = Math.abs(value).toString().split("");
		pos = vector.length - decimalPlaces;
		if (pos < 0) pos--;
		for (n = pos; n < 0; n++)
			vector.unshift("0");
		vector.splice(pos, 0, decimalSeparator);
		while (pos > 3) {
			pos -= 3;
			vector.splice(pos, 0, thousandsSeparator);
		}
		if ((vector[0] == decimalSeparator) && includeLeadingDigit)
			vector.unshift("0");
		return negativeValuePrefix + vector.join("") + negativeValueSuffix;
	},
	
	real: function(valor) {
		return "R$ "+AdFormatNumber.format(valor, 2, true, '-', '', '.', ',');
	}
}

var AdQS = function(index){
	index = index.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+index+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}

var AdDom = {
	$: function(s) {
		if (typeof(s)=="string")
			s = document.getElementById(s);
		return s;
	},
	
	$P: function(s, tag) {
		recurse = true;
		e=s;
				
		while (recurse==true) {
			parentE = e.parentNode;
			if (typeof(parentE)=="undefined") {recurse=false; p=e;}
			if (typeof(parentE.tagName)!="undefined" && parentE.tagName.toUpperCase()==tag.toUpperCase()) {
				recurse=false; p=parentE;
			}
			e=parentE;
		}
		return p;
	},
	
	remove: function(el) {
		el = AdDom.$(el);
		if (el.parentNode){
			el.parentNode.removeChild(el);
		}
	}
}

var AdJson = function(string) {
	return YAHOO.lang.JSON.parse(string);
}