﻿
/*****************************************************/
/*          Mensagens roolup  de notificação         */
/*****************************************************/
/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var delay = 2500; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)

var fcontent=new Array();
begintag = '<div style="font: normal 14px Arial; padding: 5px; text-align:center;height:20px;vertical-align:middle;">'; //set opening tag, such as font declarations
fcontent[0] = '<div style="color:Red"><b>Ganhe uma consulta gratuita !!!</b></div>';
fcontent[1]='<div style="font: normal 10px Arial; padding: 5px;">Faça seu cadastro e ganhe uma consulta para que você possa testar o serviço!</div>';
closetag='</div>';

var fwidth='15px'; //set scroller width
var fheight='10px'; //set scroller height

var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////
var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;



//function to change content
function changecontent(){

  if (index>=fcontent.length)
    index=0
  if (DOM2){

    document.getElementById("tbScrool").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
    document.getElementById("tbScrool").innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.tbScrool.innerHTML=begintag+fcontent[index]+closetag;
  index++
}


function linkcolorchange(step){
  var obj=document.getElementById("tbScrool").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
    document.getElementById("tbScrool").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{
    clearTimeout(fadecounter);
    document.getElementById("tbScrool").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    setTimeout("changecontent()", delay);
	
  }   
}

function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff > 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

//Scrool de de mensagem 
if (window.addEventListener)
    window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
    window.attachEvent("onload", changecontent)
else if (document.getElementById)
    window.onload=changecontent



/*****************************************************/
/*          Popup de alertas                         */
/*****************************************************/
 var maskHeight = getWidth();
var maskWidth = getHeight();


//Get the window height and width
var winH = maskHeight;
var winW = maskWidth;
var objIdImg = document.getElementById('idTbToolTip');
var objIdTxt = document.getElementById('idPopSms');




function getWidth() {
    return window.innerWidth && window.innerWidth > 0 ? window.innerWidth : /* Non IE */
         document.documentElement.clientWidth && document.documentElement.clientWidth > 0 ? document.documentElement.clientWidth : /* IE 6+ */
        document.body.clientWidth && document.body.clientWidth > 0 ? document.body.clientWidth : -1; /* IE 4 */
}

function getHeight() {
    return window.innerHeight && window.innerHeight > 0 ? window.innerHeight : /* Non IE */
        document.documentElement.clientHeight && document.documentElement.clientHeight > 0 ? document.documentElement.clientHeight : /* IE 6+ */
        document.body.clientHeight && document.body.clientHeight > 0 ? document.body.clientHeight : -1; /* IE 4 */
}

function resize() {

    var winH = getHeight();
    var winW = getWidth();

    if (objIdImg == null || objIdTxt == null)
        return;

    objIdImg.style.position = "absolute";
    objIdImg.style.left = (winW / 2 - 70) + 'px'; //- parseInt(objId.style..width)/2 ;
    objIdImg.style.top = (winH / 2 - 70) + 'px';

    objIdTxt.style.position = "absolute";
    objIdTxt.style.left = (winW / 2 - 18) + 'px';
    objIdTxt.style.top = (winH / 2 - 20) + 'px';
    
    //var obj = document.getElementById('idModal');
    //obj.className = 'modalBackground' ;
    document.body.className = 'modalBackground' ;
     //document.body.className = 'modalBackground';
     //document.body.style.zIndex = 10001;
     objIdTxt.style.zIndex = 10001;
        
         /*this.style. .modalBackground {
            background-color:Gray;
            filter:alpha(opacity=70);
            opacity:0.7;
        }*/

}

function fecharPopUp() {
    objIdImg.style.display = 'none';
    objIdTxt.style.display = 'none';
}

//Pop up de alertas 

window.onresize = resize;
window.onload = resize;

if (objIdImg != null)
    objIdImg.style.display = '';

if (objIdTxt != null)
    objIdTxt.style.display = '';


