// JavaScript Document

function getHTTPObject() {
		var xmlhttp;
		/*@cc_on
		@if (@_jscript_version >= 5)
		try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e) {
		try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch (E) {
		xmlhttp = false;
		}
		}
		@else xmlhttp = false;
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			try { xmlhttp = new XMLHttpRequest();
			} catch (e) {
				xmlhttp = false;
			}
		}
		return xmlhttp;
}

function getVideo(video) 
{
	document.getElementById('video_destaque').innerHTML = "<img src='imagens/loading.gif' alt='loading' /><br>Carregando...";
	var req = new getHTTPObject();
	req.open('GET', 'includes/getvideo.php?op=byid&id='+video, false);
	req.setRequestHeader('Content-type',
			'application/x-www-form-urlencoded;charset=utf-8;');
	req.send(null);
	
	if(req.status == 200)
	{
		document.getElementById('video_destaque').innerHTML = req.responseText;	
	}
}

function getbycod(cod,titulo) 
{
	document.getElementById('video_destaque2').innerHTML = "<img src='imagens/loading.gif' alt='loading' /><br>Carregando...";
	var req = new getHTTPObject();
	req.open('GET', 'includes/getvideo.php?op=bycode&titulo='+titulo+'&cod='+cod, false);
	req.setRequestHeader('Content-type',
			'application/x-www-form-urlencoded;charset=utf-8;');
	req.send(null);
	
	if(req.status == 200)
	{
		document.getElementById('video_destaque2').innerHTML = req.responseText;	
	}
}

function atualizaLegenda( foto ) {
	
	var legenda = document.getElementById('gal'+foto).value;
	document.getElementById('gal'+foto).value = 'Atualizando...';
	
	var req = new getHTTPObject();
	req.open('POST', 'modules/Galeria/ajaxac.php?op=atLegenda', false);
	req.setRequestHeader('Content-type',
			'application/x-www-form-urlencoded;charset=utf-8;');
	req.send('foto=' + foto + '&legenda=' + legenda + '&XMLHttpRequest=test');
	
	if(req.status == 200)
	{
		document.getElementById('gal'+foto).value = req.responseText;	
	}
}
