function getProgramacao(){
	$.ajax({  
		type: "GET",  
		url: "xml/programacao.xml",  
		dataType: "xml",  
		success: function(xml) {  
			$(".box_programacao_aovivo").empty();
			arrProg = [];
			$(xml).find("item").each(function(i){
				arrProg[i] = $(this).text();
			});
			$(".box_programacao_aovivo")
				.append("<h3><span>Agora:</span> "+arrProg[0]+"</h3>")
				.append("<h3><span>Em seguida:</span> "+arrProg[1]+"</h3>");
		}  
	});
}

// copyHeight
function copyHeight(obj){
	hMax = $(obj).eq(0).height();
	for (i=0; i<$(obj).length; i++){
		if(hMax < $(obj).eq(i).height()){
			hMax = $(obj).eq(i).height();
		}
	}
	$(obj).height(hMax);
}

// carrossel flickr
function carrosselFlickr(obj, quantF){
	var initF = 0;
	var minF = 1;
	var itensCarrossel = $(obj + " li");
	for(var f = 0; f < itensCarrossel.length; f++){
		if(f < quantF) itensCarrossel[f].style.display = 'inline';
	}
	$('.nav_galeria_nextF').click(function(){
		if(quantF != itensCarrossel.length && minF <=itensCarrossel.length){
			$(itensCarrossel).eq(initF++).hide();
			$(itensCarrossel).eq(quantF++).show();
		}
		return false;
	});
	$('.nav_galeria_prevF').click(function(){
		if(initF != 0){
			$(itensCarrossel).eq(--quantF).hide();
			$(itensCarrossel).eq(--initF).show();
		}
		return false;
	});
	$(obj + " li a").click(function(){
		if(obj == "#imagesFlickr"){
			$(".box_img").empty();
			// inicializa imagens
			var str = $(this).attr("title");
			arrDescription = [];
			arrDescription = str.split("|")
			var img0 = new Image();
			$(img0).load(function () {
				if($(img0).load){
					$(".flickr h4").empty().text(arrDescription[0]);
					$(".flickr p").empty().text(arrDescription[1]);
					$(".flickr small").empty().append("De <a href='http://www.flickr.com/photos/"+arrDescription[2]+"'>"+arrDescription[2]+"</a><br />"+arrDescription[3]);
					$(".box_img").append(img0);
				}
			}).error(function(){}).attr("src", $(this).attr("href"));
		}
		return false;
	});
 }
 
// carrossel youtube
function carrosselYoutube(obj, quantY){
	var initY = 0;
	var minY = 1;
	var itensYoutube = $(obj + " li");
	for(var y = 0; y < itensYoutube.length; y++){
		if(y < quantY) itensYoutube[y].style.display = 'inline';
	}
	$('.nav_galeria_nextY').click(function(){
		if(quantY != itensYoutube.length && minY <=itensYoutube.length){
			$(itensYoutube).eq(initY++).hide();
			$(itensYoutube).eq(quantY++).show();
		}
		return false;
	});
	$('.nav_galeria_prevY').click(function(){
		if(initY != 0){
			$(itensYoutube).eq(--quantY).hide();
			$(itensYoutube).eq(--initY).show();
		}
		return false;
	});	
	$(obj + " li a").click(function(){
		if(obj == "#imagesYouTube"){
			$(".box_player").empty();			var video = "<object height=\"205\" width=\"235\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,12,36\" id=\"VoxelPlayer\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"><param value=\"http://videos.oi.com.br/VoxelPlayer/PlayerOi_Embed.swf\" name=\"movie\"/><param value=\"always\" name=\"allowscriptaccess\"/><param value=\"lang=PT-BR&amp;configsLocation=http://videos.oi.com.br/VoxelPlayer/EmbedConfig/&amp;video_id="+$(this).attr("href")+"\" name=\"flashvars\"/><param value=\"opaque\" name=\"wmode\"/><embed height=\"205\" width=\"235\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" wmode=\"opaque\" allowscriptaccess=\"always\" name=\"VoxelPlayer\" flashvars=\"lang=PT-BR&amp;configsLocation=http://videos.oi.com.br/VoxelPlayer/EmbedConfig/&amp;video_id="+$(this).attr("href")+"\" src=\"http://videos.oi.com.br/VoxelPlayer/PlayerOi_Embed.swf\"/></object>";			//			var video = "<object width=\"235\" height=\"155\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+$(this).attr("href")+"&hl=pt-br&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/"+$(this).attr("href")+"&hl=pt-br&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"235\" height=\"155\"></embed></object>"
			var str = $(this).attr("title");
			arrDescription = [];
			arrDescription = str.split("|")
			$(".youtube h4").empty().text(arrDescription[0]);
			$(".youtube p").empty().text(arrDescription[1]);
			$(".youtube small").empty().append("De <a href='http://www.youtube.com/"+arrDescription[2]+"'>"+arrDescription[2]+"</a><br />"+arrDescription[3]);
			$(".box_player").append(video);
		}
		return false;
	});
 }

//contador de caracteres
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else 
		countfield.value = maxlimit - field.value.length;
}	

