// JavaScript Document
/*******************************************************
Funo de clculo da viewport
centralizao de objetos na tela
*******************************************************/
function screensize(i){
var viewportwidth;
var viewportheight;
if (typeof window.innerWidth != 'undefined'){
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
}else if(typeof document.documentElement != 'undefined'&& typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight
}else{
viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
viewportheight = document.getElementsByTagName('body')[0].clientHeight
}
switch(i){
case 'w': return viewportwidth; break;
case 'h': return viewportheight; break;
}
}
/*******************************************************
contador de caracteres restantes
*******************************************************/
function chars(id,count,maxchar){
var field = document.getElementById(id);
var count = document.getElementById(count);
var maxChars = maxchar;

if (field.value.length > maxChars){
field.value = field.value.substring(0, maxChars);
}else{
count.value = " " + (maxChars - field.value.length);
}
}
function el(i){
return document.getElementById(i);
}
function sjax(source){
var xmlHttp;
var resposta = -1;
try{
xmlHttp=new XMLHttpRequest();
}catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
alert("Seu navegador no tem suporte a SJAX!");
return false;
}
}
}

var uid = 10 + Math.floor(Math.random() * 985486);

var td = new Date();

var data = td.getDate();
var hora = td.getTime();

if( source.indexOf("?") != -1 ){
source += "&uidajax=" + uid + "&dataajax=" + data + "&horaajax=" + hora;
}else{
source += "?uidajax=" + uid + "&dataajax=" + data + "&horaajax=" + hora;
}

xmlHttp.open("GET",source,false);
xmlHttp.send(null);
if(xmlHttp.status==200){
resposta = xmlHttp.responseText;
}else{
resposta = 0;
}
xmlHttp = null;
return resposta;
}
function ajax(source){
var xmlHttp;
var resposta = -1;
try{
xmlHttp=new XMLHttpRequest();
}catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
alert("Seu navegador no tem suporte a AJAX!");
return false;
}
}
}

var uid = 10 + Math.floor(Math.random() * 985486);

if( source.indexOf("?") != -1 ){
source += "&uid=" + uid;
}else{
source += "?uid=" + uid;
}

xmlHttp.open("GET",source,true);
xmlHttp.send(null);

xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState==4){
if(xmlHttp.status == 200){
resposta = xmlHttp.responseText;
}else{
resposta = 0;
}
}
}
xmlHttp = null;
return resposta;
}

function ajax_blogecolunas_atualizar(){
var resposta = sjax('/capa/incs/blogecolunas.inc?codigo=');
if(resposta!=0){
alert('* Demanda atualizada com sucesso','error');
}else{
alert("Erro AJAX");
}
}
function play(img, video){
img.style.display = 'none';
document.getElementById(video).style.display = 'block';
	try{
		MPlay1.Play();
	}catch(err){
		MPlay1.sendEvent('PLAY');
	}
}


