///////////////////////////////////
// SITE SERIDÓ FEST (www.seridofest.com.br)
// TEXT JAVASCRIP - BY LEYDSON
///////////////////////////////////

var textCenterAjaxLoad = '<p>&nbsp;</p><p>&nbsp;</p><p class=\"text-blank-11\"><img src=\"img/ajax-loader3.gif\" width=\"43\" height=\"11\"><br><br>Carregando conte&uacute;do...</p><p>&nbsp;</p>';
var textErroAjax = '<img src="img/5px.gif" width="5" height="5"><br><table width="440" border="0" cellpadding="0" cellspacing="2" bgcolor="#000000" style="border:#FFFFFF 1px solid;">'+
'<tr>'+
       ' <td height="30" colspan="2" background="img/bg_menu30x10.gif"><img src="img/titCenterErro.gif" width="210" height="30"></td>'+
      '</tr>'+
      '<tr>'+
       ' <td width="120" height="200" align="center" valign="middle"><img src="img/ico_info55x55.gif" width="55" height="55" alt="" /></td>'+
        '<td width="312" height="200" valign="middle"><p class="text-red-12-bolder">Opa! N&atilde;o foi poss&iacute;vel executar a  sua solicita&ccedil;&atilde;o:</p>'+
          '<p class="text-blank-11">Ocorreu um erro ao efetuar a conex&atilde;o com o nosso site.<br>Talvez o problema tenha ocorrido devido voc&ecirc; n&atilde;o est&aacute;  conectado a Internet.<br>Verifique suas configura&ccedil;&otilde;es de conex&atilde;o e tente novamente.</p></td>'+
 ' </tr>'+
'</table>';
var textErroAjaxBasic = '<span class="text-black-11"><br>As Informações não estão disponíveis.<br>Verifique sua conexão com a Internet.</span><br>';
var stopAllAct = 0;
var myAjax = null;
var responseAjax = null;
var textmsgstatus =null;
var statusLoadingStop = null;
var tempLoading = null;

function showMsgStatus(textmsgstatus){
if(textmsgstatus == '1'){
textmsgstatus ="Carregando...";
}
if(textmsgstatus == '2'){
textmsgstatus ="Falha!";
}
if(textmsgstatus == '3'){
textmsgstatus ="Enviando...";
}
if(textmsgstatus == '4'){
textmsgstatus ="Recebendo...";
}
if(textmsgstatus == '5'){
textmsgstatus ="Tentando...";
}
if(textmsgstatus == '6'){
textmsgstatus ="Concluído!";
}
if(textmsgstatus == '7'){
textmsgstatus ="Conectando...";
}
if(textmsgstatus == '8'){
textmsgstatus ="Atualizando...";
}
if(textmsgstatus == '9'){
textmsgstatus ="Buscando...";
}
if(textmsgstatus == '10'){
textmsgstatus ="Erro!...";
}
document.getElementById('loading2').innerHTML = textmsgstatus;
}

function loading_start(textmsgstatus) {
showMsgStatus(textmsgstatus);
window.clearTimeout(statusLoadingStop);
window.clearTimeout(tempLoading);
document.getElementById("loading").style.display="block";
statusLoadingStop = window.setTimeout("showMsgStatus('5');", 15000);
}

function loading_stop() {
document.getElementById("loading").style.display="none";
}

function loading_stoptime(textmsgstatus) {
showMsgStatus(textmsgstatus);
window.clearTimeout(statusLoadingStop);
window.clearTimeout(tempLoading);
tempLoading = window.setTimeout("loading_stop();", 3000);
}

function ajaxDestroy(){
	myAjax = null;
	responseAjax = null;
	locationupdate = null;
	//var stopAllAct = 1;
	return nd();
}

function Ajax(){
if(window.XMLHttpRequest){
myAjax = new XMLHttpRequest();
}else if(window.ActiveXObject){
myAjax = new ActiveXObject("Microsoft.XMLHTTP");
}else{
myAjax = 'none';
}
return myAjax;
}


function pageRequest(page, target, msgstatus, tempbg){

var myAjax = Math.random(0, 50);
var nocache = Math.random(50, 100);
var url = Math.random(100, 150);
myAjax = Ajax();
//var locationupdate = Math.random();

url = 'center.php?page=' + page + '&target='+ target + '&userRequest=ajax&nocache=' + nocache;
myAjax.open('GET', url, true);

myAjax.onreadystatechange = function() {
if(myAjax.readyState == 1) {
	if(msgstatus != null){
	loading_start(msgstatus);
	}
}
if(tempbg == 1){
	document.getElementById(target).innerHTML = textCenterAjaxLoad;
}

if (myAjax.readyState == 4) {
	
	var text = myAjax.responseText;
	if(text != responseAjax){
	document.getElementById(target).innerHTML = text;
	responseAjax = text;
	}
	
if (myAjax.status == 200) {
	if(target == 'pagecenter'){
	if(msgstatus != null){
	loading_stoptime('6');
	}
	window.scrollTo(0,1);
	//window.location='#top';
	document.title='.: SERIDÓ FEST >> Os melhores eventos estão aqui.';
	}
	ajaxDestroy();
}else{
	if(msgstatus != null && target == 'pagecenter'){
	document.getElementById(target).innerHTML = textErroAjax;
	if(msgstatus != null){
	loading_stoptime('2');
	}
	}else{
	document.getElementById(target).innerHTML = textErroAjaxBasic + '<a href"javascript:pageRequest('+page+', '+target+', '+msgstatus+');" class="text-yellow-11"> Repetir </a>';
	}
	ajaxDestroy();
}
}
	
}
myAjax.send(null);

//loadFunctions();
}