// Ação Jovem - jose.valim@gmail.com
var loadStatusText = '<img src="http://www.acaojovemlbv.com.br/images/loading.gif" alt="Carregando" style="float: left; padding-right: 5px;" /><div style="padding: 2px;">Carregando...</div>'
function $teste(id){
	return document.getElementById(id)
}
function animationpack(elementId, attribute){
	var timer = null
	var self = this
	this.stepCount = 0	
	this.steps = 10
	this.duration = 500 //ms
	this.toValue = 0
	this.fromValue = 100
	this.increment = 0
	this.interval = 0
	this.callBackFunction = null
	this.start = animationStart
	this.element = $teste(elementId)
	var cssFilters = (typeof(this.element.filters) == 'object') ? true : false
	
	function animationStart(from,to,callBackFunc){
		if(timer)
			clearTimeout(timer)
		else
			this.fromValue = from
		this.toValue = to
		this.callBackFunction = callBackFunc 
		this.interval = this.duration/this.steps
		this.increment = (this.toValue-from)/this.steps
		this.stepCount = Math.abs(Math.round((this.fromValue-from)/this.interval))
		this.element = $teste(elementId)
		changeValue(this.fromValue)
		timer = setTimeout(animationStep, this.interval)
	}

	function animationStep(){
		self.stepCount++
		self.fromValue += self.increment
		if (self.stepCount < self.steps){
			changeValue(self.fromValue)
			timer = setTimeout(animationStep, self.interval)	
		}
		else animationStop()
	}	

	function animationStop(){
		if (timer)
		{
			clearTimeout(timer)
			changeValue(self.toValue)
		}
		timer = null
		if (typeof(self.callBackFunction) == 'function') eval('new self.callBackFunction')
	}

	function changeValue(value){
		switch(attribute){
			case 'alpha':
				if(cssFilters && self.element.filters.alpha)
					self.element.filters.alpha.opacity = value
				else
					self.element.style.MozOpacity = value/100
				break
			case 'height':
				break
		}
	}
}
function ajaxpack() {
	var self = this
	this.response = null
	this.callBackFunc = null
	this.ajaxObj = createAjaxObj()
	this.returnType = 'txt' //txt or xml	
	this.fileRequest = fileAjaxRequest
	this.getRequest = getAjaxRequest

	function fileAjaxRequest(filepath, callBackFunc){
		this.ajaxObj=createAjaxObj()
		if (this.ajaxObj){	
			this.callBackFunc = callBackFunc
			this.ajaxObj.onreadystatechange=readyStateSend
			this.ajaxObj.open('GET', filepath, true)
			this.ajaxObj.send(null)
		}			
	}

	function getAjaxRequest(url, parameters, callBackFunc){
		this.ajaxObj=createAjaxObj()
		if (this.ajaxObj){
			this.callBackFunc=callBackFunc;			
			this.ajaxObj.onreadystatechange=readyStateSend;
			this.ajaxObj.open('GET', url+"?ajaxcachebust="+new Date().getTime()+(parameters == '' ? '' : '&'+parameters), true);
			this.ajaxObj.send(null)
		}
	}

	function readyStateSend() {
		if (self.ajaxObj.readyState == 4){
			if(self.ajaxObj.status == '200' || window.location.href.indexOf("http")==-1) {
				self.response = (self.returnType == 'xml' ? self.ajaxObj.responseXML : self.ajaxObj.responseText);
				if (typeof(self.callBackFunc) == 'function') eval('new self.callBackFunc')
			}
			else alert('Ajax: Page not found')
		}			
	}

	function createAjaxObj(){
		var httprequest=false;
		if (window.XMLHttpRequest){ // if Mozilla, Safari etc
			httprequest=new XMLHttpRequest()
			if (httprequest.overrideMimeType)
				httprequest.overrideMimeType('text/xml')
		}
		else if (window.ActiveXObject){ // if IE
			try {
				httprequest=new ActiveXObject("Msxml2.XMLHTTP")
			} 
			catch (e){
				try{
					httprequest=new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch (e){}
			}
		}
		return httprequest
	}
}
function fn_galeria_idioma(p_ci,p_galeria) {
	abrePopup('http://www.ds.boavontade.com/inc/galeriaTeste.php?sg='+p_galeria+'&ci='+p_ci,'',600,490);
}