// start - vista frame site custom js
// start - cookies
function get_cookie ( cookie_name ) {
 var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
 if ( results )
  return ( unescape ( results[2] ) );
 else
  return null;
}

function checkCookie(id) {
 var mode = get_cookie ( 'mode' );
 if (mode == null) {
  document.cookie = 'mode=1';
  document.getElementById(id).style.visibility = 'visible';
 } else if (mode == '1') {
  document.getElementById(id).style.visibility = 'visible';
 } else {
  document.getElementById(id).style.visibility = 'hidden';
  document.cookie = 'mode=0';
 }
}

// end - cookies

// start - open close divs

function troca(id) {
 if ( document.getElementById(id).style.visibility == 'hidden' ) {
  document.getElementById(id).style.visibility = 'visible';
  document.cookie = 'mode=1';
 } else {
  document.getElementById(id).style.visibility = 'hidden';
  document.cookie = 'mode=0';
 }
}

function startdiv(id) {
 document.getElementById(id).style.visibility = 'hidden';	
}

function closediv(id) {
 document.getElementById(id).style.visibility = 'hidden';
 document.getElementById('vista004c').value = '0';
 var vista004a = document.getElementById('vista004a');
 var vista004b = document.getElementById('vista004b');
 var vazio = "&nbsp;";
 vista004a.innerHTML = vazio;
 vista004b.innerHTML = vazio;
}

// end - open close divs

// start - ajax report

function ajaxreport(id) {
 if ( document.getElementById(id).style.visibility == 'hidden') {

  document.getElementById('vista004c').value = '1';
  var vista004a = document.getElementById('vista004a');
  var vista004b = document.getElementById('vista004b');
  var vazio = "&nbsp;";
  vista004a.innerHTML = vazio;
  vista004b.innerHTML = vazio;
  document.getElementById(id).style.visibility = 'visible';
  var ajaxRequest;
  if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   ajaxRequest=new XMLHttpRequest();
  } else if (window.ActiveXObject) { // code for IE6, IE5
   ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");
  } else {
   alert("Your browser does not support XMLHTTP!");
  }
  ajaxRequest.onreadystatechange=function() {
   if(ajaxRequest.readyState==4) {
    var vista004a = document.getElementById('vista004a');
    vista004a.innerHTML = ajaxRequest.responseText;
   }
  }
  ajaxRequest.open("POST", "vista/report_form.php", true);
  ajaxRequest.send(null);

 } else if ( document.getElementById('vista004c').value == '1' ) {

  document.getElementById(id).style.visibility = 'hidden';
  document.getElementById('vista004c').value = '0';

 } else {

  document.getElementById('vista004c').value = '1';
  document.getElementById(id).style.visibility = 'visible';
  var vista004a = document.getElementById('vista004a');
  var vista004b = document.getElementById('vista004b');
  var vazio = "&nbsp;";
  vista004a.innerHTML = vazio;
  vista004b.innerHTML = vazio;
  document.getElementById(id).style.visibility = 'visible';
  var ajaxRequest;
  if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
  ajaxRequest=new XMLHttpRequest();
  } else if (window.ActiveXObject) { // code for IE6, IE5
  ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");
  } else {
   alert("Your browser does not support XMLHTTP!");
  }
  ajaxRequest.onreadystatechange=function() {
   if(ajaxRequest.readyState==4) {
    var vista004a = document.getElementById('vista004a');
    vista004a.innerHTML = ajaxRequest.responseText;
   }
  }
  ajaxRequest.open("POST", "vista/report_form.php", true);
  ajaxRequest.send(null); 

 }
}

// end - ajax report

// start - send report

function sendreport() {
 var ajaxRequest3;
 if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
  ajaxRequest3=new XMLHttpRequest();
 } else if (window.ActiveXObject) { // code for IE6, IE5
  ajaxRequest3=new ActiveXObject("Microsoft.XMLHTTP");
 } else {
  alert("Your browser does not support XMLHTTP!");
 }
 ajaxRequest3.onreadystatechange=function() {
  if(ajaxRequest3.readyState==4) {
   var vista004b = document.getElementById('vista004b');
   vista004b.innerHTML = ajaxRequest3.responseText;
  }
 }
 var r_name = document.getElementById('r_name').value;
 var r_mail = document.getElementById('r_mail').value;
 var r_type = document.getElementById('r_type').value;
 var r_msg = document.getElementById('r_msg').value;
 var security_code = document.getElementById('security_code').value;
 var queryString = "&r_name=" + r_name + "&r_mail=" + r_mail + "&r_type=" + r_type + "&r_msg=" + r_msg + "&security_code=" + security_code;
 ajaxRequest3.open("POST", "vista/report_send.php", true);
 // Send the proper header information along with the request
 ajaxRequest3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 ajaxRequest3.setRequestHeader("Content-length", queryString.length);
 ajaxRequest3.setRequestHeader("Connection", "close");
 ajaxRequest3.send(queryString); 

}

// end - send report

// start - clear report

function clearreport() {
 var vista004a = document.getElementById('vista004a');
 var vazio = "&nbsp;";
 vista004a.innerHTML = vazio;
}

// end - clear report

// start - send report error

function sendreporterror() {
 alert("Codigo errado. Por favor, digite o codigo novamente ou gere outro codigo.");
}

// end - send report error

// start - ajax vip

function ajaxvip(id) {
 if ( document.getElementById(id).style.visibility == 'hidden') {

  document.getElementById('vista004c').value = '2';
  var vista004a = document.getElementById('vista004a');
  var vista004b = document.getElementById('vista004b');
  var vazio = "&nbsp;";
  vista004a.innerHTML = vazio;
  vista004b.innerHTML = vazio;	
  document.getElementById(id).style.visibility = 'visible';
  var ajaxRequest;
  if (window.XMLHttpRequest) {  // code for IE7+, Firefox, Chrome, Opera, Safari
   ajaxRequest=new XMLHttpRequest();
  } else if (window.ActiveXObject) {  // code for IE6, IE5
   ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");
  } else {
   alert("Your browser does not support XMLHTTP!");
  }
  ajaxRequest.onreadystatechange=function() {
   if(ajaxRequest.readyState==4) {
    var vista004a = document.getElementById('vista004a');
    vista004a.innerHTML = ajaxRequest.responseText;
   }
  }
  ajaxRequest.open("POST", "vista/vip_data.php", true);
  ajaxRequest.send(null); 

 } else if ( document.getElementById('vista004c').value == '2' ) {

  document.getElementById(id).style.visibility = 'hidden';
  document.getElementById('vista004c').value = '0';

 } else {

  document.getElementById('vista004c').value = '2';
  var vista004a = document.getElementById('vista004a');
  var vista004b = document.getElementById('vista004b');
  var vazio = "&nbsp;";
  vista004a.innerHTML = vazio;
  vista004b.innerHTML = vazio;	
  document.getElementById(id).style.visibility = 'visible';
  var ajaxRequest;
  if (window.XMLHttpRequest) {  // code for IE7+, Firefox, Chrome, Opera, Safari
   ajaxRequest=new XMLHttpRequest();
  } else if (window.ActiveXObject) {  // code for IE6, IE5
   ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");
  } else {
   alert("Your browser does not support XMLHTTP!");
  }
  ajaxRequest.onreadystatechange=function() {
   if(ajaxRequest.readyState==4) {
    var vista004a = document.getElementById('vista004a');
    vista004a.innerHTML = ajaxRequest.responseText;
   }
  }
  ajaxRequest.open("POST", "vista/vip_data.php", true);
  ajaxRequest.send(null);

 }
}

// end - ajax vip

// end - vista frame site custom js
