function getValueSelected(d,m,y){
      fb.start({ href: 'agenda/evento.php?dia='+d+'&month='+m+'&year='+y, rev: 'width:680 height:550 scrolling:no' });
}

function getValueSelected_blog(d,m,y){
      fb.start({ href: '../agenda/evento.php?dia='+d+'&month='+m+'&year='+y, rev: 'width:680 height:550 scrolling:no' });
}

function videos(n){
      fb.start({ href: '../links/videos.php?id='+n, rev: 'width:500 height:400 scrolling:no theme:red' });
}


function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Seu navegador não suporta ajax. Sugerimos um update!");
				return false;
			}
		}
	}

	ajaxRequest.onreadystatechange = function () {
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			fb.start({ href: '../includes/ok.html', rev: 'width:500 height:250 scrolling:no' });

			document.contato.nome.value = '';
			document.contato.email.value = '';
			document.contato.ddd.value = '';
			document.contato.tel.value = '';
			document.contato.msg.value = '';

			trocaimg('botao','../images/submit_btn.gif');
			document.getElementById("botao").disabled = false;
			document.contato.email.style.backgroundColor='#f2fdec';

		} else {

			document.getElementById("ajaxDiv").innerHTML="<img src='../images/ajax-loader.gif' width='24' height='24' padding-right:2px;' border='0' /> <font style='font-size:11px;color:#ccc;font-family:arial;'>Enviando...</font>";

		}
	}

	if(BrowserDetect.browser == 'Explorer'){

		val1 = UTF8.decode (UTF8.encode(document.contato.nome.value));
		val2 = UTF8.decode (UTF8.encode(document.contato.email.value));
		val3 = UTF8.decode (UTF8.encode(document.contato.ddd.value));
		val4 = UTF8.decode (UTF8.encode(document.contato.tel.value));
		val5 = UTF8.decode (UTF8.encode(document.contato.msg.value));

	} else {

		val1 = document.contato.nome.value;
		val2 = document.contato.email.value;
		val3 = document.contato.ddd.value;
		val4 = document.contato.tel.value;
		val5 = document.contato.msg.value;

	}

	if(BrowserDetect.browser == 'Explorer'){

		ajaxRequest.open("GET", "../contato/form_process_utf.php?data="+val1+"&data2="+val2+"&data3="+val3+"&data4="+val4+"&data5="+val5, true);

	} else {

		ajaxRequest.open("GET", "../contato/form_process.php?data="+val1+"&data2="+val2+"&data3="+val3+"&data4="+val4+"&data5="+val5, true);

	}
	ajaxRequest.send(null);
}

function ajaxFunction_fas(){
	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Seu navegador não suporta ajax. Sugerimos um update!");
				return false;
			}
		}
	}

	ajaxRequest.onreadystatechange = function () {
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			fb.start({ href: '../includes/ok.html', rev: 'width:500 height:250 scrolling:no' });

			document.fas.nome.value = '';
			document.fas.email.value = '';
			document.fas.ddd.value = '';
			document.fas.tel.value = '';
			document.fas.dddcel.value = '';
			document.fas.cel.value = '';
			document.fas.dia.value = '';
			document.fas.mes.value = '';
			document.fas.ano.value = '';
			document.fas.msg.value = '';

			//document.fas.conheceu.checked = false;
			document.fas.conheceu.value = '';
			//document.fas.conheceu_outros.value = '';
			document.fas.tipo1.checked = false;
			document.fas.tipo2.checked = false;
			document.fas.tipo3.checked = false;
			document.fas.tipo4.checked = false;
			document.fas.tipo_outros.value = '';

			//document.fas.artista.value = '';
			document.fas.sugestao.value = '';
			//document.fas.mailing.value = '';

			trocaimg('botao','../images/submit_btn.gif');
			document.getElementById("botao").disabled = false;
			document.fas.email.style.backgroundColor='#f2fdec';

		} else {

			document.getElementById("ajaxDiv").innerHTML="<img src='../images/ajax-loader.gif' width='24' height='24' padding-right:2px;' border='0' /> <font style='font-size:11px;color:#ccc;font-family:arial;'>Enviando...</font>";

		}
	}



	/*--- checkbox ---*/
	/*var radField = document.fas.conheceu;
	var radLength = document.fas.conheceu.length;
	for (var i=0; i<radLength; i++) {
           if (radField[i].checked) {
              var chkContact = radField[i].value;
              continue;
           }
    }*/
	if(BrowserDetect.browser == 'Explorer'){

		val1 = UTF8.decode (UTF8.encode(document.fas.nome.value));
		val2 = UTF8.decode (UTF8.encode(document.fas.email.value));
		val3 = UTF8.decode (UTF8.encode(document.fas.ddd.value));
		val4 = UTF8.decode (UTF8.encode(document.fas.tel.value));
		val5 = UTF8.decode (UTF8.encode(document.fas.dddcel.value));
		val6 = UTF8.decode (UTF8.encode(document.fas.cel.value));
		val7 = UTF8.decode (UTF8.encode(document.fas.dia.value));
		val8 = UTF8.decode (UTF8.encode(document.fas.mes.value));
		val9 = UTF8.decode (UTF8.encode(document.fas.ano.value));
		val10 = UTF8.decode (UTF8.encode(document.fas.msg.value));
		//val11 = chkContact;
		val11 = UTF8.decode (UTF8.encode(document.fas.conheceu.value));
		//val12 = document.fas.conheceu_outros.value;
		val14 = UTF8.decode (UTF8.encode(document.fas.tipo_outros.value));
		//val15 = document.fas.artista.value;
		val16 = UTF8.decode (UTF8.encode(document.fas.sugestao.value));


	} else {

		val1 = document.fas.nome.value;
		val2 = document.fas.email.value;
		val3 = document.fas.ddd.value;
		val4 = document.fas.tel.value;
		val5 = document.fas.dddcel.value;
		val6 = document.fas.cel.value;
		val7 = document.fas.dia.value;
		val8 = document.fas.mes.value;
		val9 = document.fas.ano.value;
		val10 = document.fas.msg.value;
		//val11 = chkContact;
		val11 = document.fas.conheceu.value;
		//val12 = document.fas.conheceu_outros.value;
		val14 = document.fas.tipo_outros.value;
		//val15 = document.fas.artista.value;
		val16 = document.fas.sugestao.value;


	}

	val13 = document.fas.tipo1.checked;
	val13b = document.fas.tipo2.checked;
	val13c = document.fas.tipo3.checked;
	val13d = document.fas.tipo4.checked;
	val17 = document.fas.mailing.value;

	if(BrowserDetect.browser == 'Explorer'){

		ajaxRequest.open("GET", "../fas/form_process.php?data="+val1+"&data2="+val2+"&data3="+val3+"&data4="+val4+"&data5="+val5+"&data6="+val6+"&data7="+val7+"&data8="+val8+"&data9="+val9+"&data10="+val10+"&data11="+val11+"&data13="+val13+"&data13b="+val13b+"&data13c="+val13c+"&data13d="+val13d+"&data14="+val14+"&data16="+val16+"&data17="+val17, true);

	} else if(BrowserDetect.browser == 'Firefox' || BrowserDetect.browser == 'Chrome' || BrowserDetect.browser == 'Safari') {

		ajaxRequest.open("GET", "../fas/form_process_utf.php?data="+val1+"&data2="+val2+"&data3="+val3+"&data4="+val4+"&data5="+val5+"&data6="+val6+"&data7="+val7+"&data8="+val8+"&data9="+val9+"&data10="+val10+"&data11="+val11+"&data13="+val13+"&data13b="+val13b+"&data13c="+val13c+"&data13d="+val13d+"&data14="+val14+"&data16="+val16+"&data17="+val17, true);

	}
	ajaxRequest.send(null);
}

function trocaimg(imgName,src){
	document.images[imgName].src=''+src;
}

function submitDisable(){
	var submitted = false;
	if(!submitted){
		submitted = true;
		trocaimg('botao','../images/submit_btn2.gif');
		document.getElementById("botao").disabled = true;
		//document.contato.submit();
	 }
	 return true;
}

function valida_form(){

	var msg = '';
	var mail = document.contato.email.value;
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

	if(!document.contato.nome.value){msg+='Insira o seu Nome\n';}
	if(!document.contato.email.value) msg += 'Insira o seu E-mail\n';
	if(!document.contato.ddd.value){msg+='Insira o DDD do Telefone\n';}
	if(!document.contato.tel.value){msg+='Insira o Telefone\n';}
	if(!document.contato.msg.value){msg+='Escreva a Mensagem\n';}
	if(document.contato.email.value){
		if(!er.test(mail)) msg += 'Digite um e-mail válido \n';
		document.contato.email.style.backgroundColor='#aaef85';
		document.contato.email.focus();

	}

	if(msg != ''){
		alert(msg +"\n\rClique 'OK' para continuar");
		return false;
	} else {
		submitDisable();
		ajaxFunction();
	}
}


function valida_form_fas(){

	var msg = '';
	var mail = document.fas.email.value;
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

	if(!document.fas.nome.value){msg+='Insira o seu Nome\n';}
	if(!document.fas.email.value) msg += 'Insira o seu E-mail\n';
	if(!document.fas.ddd.value){msg+='Insira o DDD do Telefone\n';}
	if(!document.fas.tel.value){msg+='Insira o Telefone\n';}
	if(!document.fas.dia.value){msg+='Insira o dia do Nascimento\n';}
	if(!document.fas.mes.value){msg+='Insira o mês do Nascimento\n';}
	if(!document.fas.msg.value){msg+='Escreva a Mensagem\n';}
	if(document.fas.email.value){
		if(!er.test(mail)) msg += 'Digite um e-mail válido \n';
		document.fas.email.style.backgroundColor='#aaef85';
		document.fas.email.focus();

	}

	if(msg != ''){
		alert(msg +"\n\rClique 'OK' para continuar");
		return false;
	} else {
		submitDisable();
		ajaxFunction_fas();
	}
}

function colorBack(){
	document.contato.email.style.backgroundColor='#f2fdec';
}

function colorBack2(){
	document.fas.email.style.backgroundColor='#f2fdec';
}

function isNumberKey(evt){
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57)){
         alert('Atenção: somente números neste campo');
			return false;
         } else {
	        return true;
        }
}

function mostrar(n){
	document.getElementById(n).style.display = (document.getElementById(n).style.display=='none' ? '' : 'none');
}

function esconde(s){
	document.getElementById(s).style.display = 'none';
}




var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

if(BrowserDetect.browser == 'Firefox'){

	if(BrowserDetect.version <= 2){
		parent.location.href="../red/error.html?firefox";
	}

} else if(BrowserDetect.browser == 'Explorer'){

	if(BrowserDetect.version <= 6){
		parent.location.href="../red/error.html?explorer";
	}

} else if(BrowserDetect.browser == 'Chrome'){

	if(BrowserDetect.version <= 2){
		parent.location.href="../red/error.html?chrome";
	}

} else if(BrowserDetect.browser == 'Safari'){

	if(BrowserDetect.version <= 3){
		parent.location.href="../red/error.html?safari";
	}
}
//document.write('<p class="accent" style="color:white;">You\'re using ' + BrowserDetect.browser + ' ' + BrowserDetect.version + ' on ' + BrowserDetect.OS + '!</p>');

//-----------Encodeamento---------------//

UTF8 = {
	encode: function(s){
		for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
			s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
		);
		return s.join("");
	},
	decode: function(s){
		for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
			((a = s[i][c](0)) & 0x80) &&
			(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
			o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
		);
		return s.join("");
	}
};
//-----------Encodeamento---------------//

UTF8 = {
	encode: function(s){
		for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
			s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
		);
		return s.join("");
	},
	decode: function(s){
		for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
			((a = s[i][c](0)) & 0x80) &&
			(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
			o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
		);
		return s.join("");
	}
};
