function contentGallery(alias) {
		removeInputs();
		generateBackGround(true);
		div = $("popup_gallery");
		$("galleryType").value = "default";
		//insere botão de fechar, caso não exista
		if(!$("popup_close")) {
			var a = document.createElement("a");
			a.setAttribute("id", "popup_close");
			a.setAttribute("title", "fechar janela");
			a.setAttribute("href", "#");
			
			//botão de fechar
			a.onclick = function() {
				removeInputs();
				new Effect.Fade('popup_gallery', {afterFinish: function(){ generateBackGround(false); }});
				return false;
			}
			div.appendChild(a);
		}
			
		document.documentElement.scrollTop = 0;
		
		if(!$("gallery-content")) {
			var divC = document.createElement("div");
			divC.setAttribute("id", "gallery-content");
			divC.className = "clearfix";
			div.appendChild(divC);
		}
		
		//requisita arquivo com o formulário
		var url = "/content/" + alias + ".mmp?template=gallery";
		var pars = "rnd=" + Math.random()*4;
		var loadingCss = $F("loadingCss");

		$("gallery-content").innerHTML += "<p id='loading_message'><img src='/images/others/loading.gif' title='carregando' />  aguarde, carregando...</p>";
		var myAjax = new Ajax.Updater( 
			{}, 
			url, 
			{ 
				method: 'get',
				parameters: pars, 
				onSuccess: function(request) {
					$("gallery-content").removeChild($("loading_message")); //remove mensagem de aguarde...
					$('gallery-content').innerHTML = request.responseText;
					new Effect.Appear('popup_gallery');
					
				}, 
				onFailure: function(request) {
					$("gallery-content").removeChild($("loading_message")); //remove mensagem de aguarde...
					if(request.responseText.indexOf("<body>")>0)
						$('gallery-content').innerHTML += request.responseText.substring(request.responseText.indexOf("<body>") + 6, request.responseText.indexOf("</body>"));
					else
						$('gallery-content').innerHTML += request.responseText;
					new Effect.BlindDown('popup_gallery');
				},
				evalScripts:true
			}
		);
	
}



function changeGallery() {
	generateBackGround(true);
	div = $("popup_gallery");
	
	//insere botão de fechar, caso não exista
	if(!$("popup_close")) {
		var a = document.createElement("a");
		a.setAttribute("id", "popup_close");
		a.setAttribute("title", "fechar janela");
		a.setAttribute("href", "#");
		
		//botão de fechar
		a.onclick = function() {
			new Effect.Fade('popup_gallery', {afterFinish: function(){ generateBackGround(false); }});
			return false;
		}
		div.appendChild(a);
	}
		
	document.documentElement.scrollTop = 0;
	
	if(!$("gallery-content")) {
		var divC = document.createElement("div");
		divC.setAttribute("id", "gallery-content");
		divC.className = "clearfix";
		div.appendChild(divC);
	}
	
	//requisita arquivo com o formulário
	var url = "/includes/htms/galleries.htm";
	var loadingCss = $F("loadingCss");
	var pars = "rnd=" + Math.random()*4;
	$("gallery-content").innerHTML += "<p id='loading_message'><img src='/images/color/others/loading.gif' title='carregando' />  aguarde, carregando...</p>";
	var myAjax = new Ajax.Updater( 
		{}, 
		url, 
		{ 
			method: 'get',
			parameters: pars, 
			onSuccess: function(request) {
				$("gallery-content").removeChild($("loading_message")); //remove mensagem de aguarde...
				$('gallery-content').innerHTML = request.responseText;
				new Effect.Appear('popup_gallery');
				
			}, 
			onFailure: function(request) {
				$("gallery-content").removeChild($("loading_message")); //remove mensagem de aguarde...
				if(request.responseText.indexOf("<body>")>0)
					$('gallery-content').innerHTML += request.responseText.substring(request.responseText.indexOf("<body>") + 6, request.responseText.indexOf("</body>"));
				else
					$('gallery-content').innerHTML += request.responseText;
				new Effect.BlindDown('popup_gallery');
			},
			evalScripts:true
		}
	);
}

function selectGallery(type) {
	//seta o tipo de galeria
	$("galleryType").value = type;
	//fecha popup e abre nova galeria...
	new Effect.Fade('popup_gallery', {afterFinish: function(){ generateBackGround(false); coreService.setPropertyToUserFolder($F("loggedUserId"), "gallery", type); contentGallery($F("contentAlias")); }});
	
}


function changePicture(url, description, width, height, index) {
	/*
	//tenta pegar próximo thumbnail
	var nextThumb = index + 1;
	if($("thumb_" + nextThumb)) {
		$("navForward").style.visibility = "visible";
		$("navForward").href = $("thumb_" + nextThumb).href;
	} else
		$("navForward").style.visibility = "hidden";
	
	//tenta pegar thumbnail anterior
	var prevThumb = index - 1;
	if($("thumb_" + prevThumb)) {
		$("navBackward").style.visibility = "visible";
		$("navBackward").href = $("thumb_" + prevThumb).href;
	} else
		$("navBackward").style.visibility = "hidden";
	*/
	$("photo_description").innerHTML = description;
	var img = $("imageGallery");
	img.src = url;
	img.alt = description;
	
	//redimensiona grandes imagens 
	if(width > height){
		if(width > 560){
			img.width = "560";
		} else{
			img.removeAttribute('width');
		}
		img.removeAttribute('height');
	} else{
		if(height > 560){
			img.height= "560";
		} else{
			img.removeAttribute('height');
		}
		img.removeAttribute('width');
	}
}


var posInic = 0;
var passo = 0;

function ticker() {	
	var tickers = $("thumbMask");
	var thumbs = $("thumbs");
	
	//if(thumbs.clientHeight > tickers.clientHeight) {
		
		var posicao = tickers.style.marginTop.substring(1, tickers.style.marginTop.length - 2);
			posicao = parseInt(posicao);
		if(isNaN(posicao))
			posicao = 0;	
					
		var topMargin = thumbs.style.marginTop.substring(1, thumbs.style.marginTop.length - 2);
		var diferenca = parseInt(thumbs.clientHeight - topMargin);
			
		if(topMargin==0 && passo == -3){
			passo = 0;
		}
		else if(diferenca < tickers.clientHeight && passo == 3) {
			passo = 0;
		}
		posInic = posInic - passo;
		thumbs.style.marginTop = posInic + "px";
		
		
		
		//if((posInic*(-1))>tickers.clientWidth){
			//posInic = tickers.clientWidth;
		//}
		setTimeout("ticker()", 20);
	//}
}



