function openApp(URL, _scroll) {

	  	var _top    = parseInt((screen.width/2) - (1024/2));
	  	var _left   = parseInt((screen.height/2) - (768/2)); 
	  	var _width  = parseInt(screen.width);
	  	var _height = parseInt(screen.height);
      /*
      if(_scroll == 0 || _scroll == '')
        var _scroll = (screen.height > 800)? 0 : 'yes';
        */
      
      var _scroll = 'yes'; 
	  
		  window.open(URL, 'DreamBooks', 'toolbar=0, scrollbars=' + _scroll + ', location=1, statusbar=0, menubar=0, resizable=yes, width='+_width+', height='+_height);

	//  window.open(URL);
	  
	 }
	 
function validaEmail(form){
  
  if(form.T1.value=='')
  {
    alert('Por favor, insira o email!');
    return false;
  } else {
    return ValidarEmail(form.T1.value,'Email inválido: ');
  }
  
  return false;
}


function validateLogin(form){
  
  if(form.email.value=='' || form.password.value=='')
  {
    alert('Por favor, insira os dados de login!');
    return false;
  } else {
    return true;
  }
  
  return false;
}

function showimg(srcimg,idlink){

  var el = document.getElementById('img_central');
  var el2 = document.getElementById(idlink);
  
  var xclose = document.getElementsByTagName("a");
  
  for (var i=0; i<xclose.length; i++) {
    if (xclose[i].className == "links_imgs_peqsel"){
      xclose[i].className = "links_imgs_peq";
    }
    
  }
  
  el2.className='links_imgs_peqsel';
  el.src = srcimg;
  
}
function popup(URL) {

		day = new Date();
		id = day.getTime();		
	  
	  	var _top =  parseInt((screen.width/2) - (700/2));
	  	var _left = parseInt((screen.height/2) - (500/2)); 		  		
		
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1020,height=730,left = " + _top + ",top = " + _left + "');");
	}
	
function showfaq(id,id2) {

  var el = document.getElementById(id);
  var el2 = document.getElementById(id2);
  
  var xclose = document.getElementsByTagName("div");
  
  for (var i=0; i<xclose.length; i++) {
    if (xclose[i].className == "faq_div"){
      xclose[i].style.display = "none";
    }
    
    if (xclose[i].className == "pergunta" && xclose[i].style.display=="none"){
      xclose[i].style.display = "block";
    }
    
  }
  
  el2.style.display = "none";
  
  el.style.display = "block";
  //init_dw_Scroll2(id);
  
 // wndo.scrollToId_el_lyr1();
}

function init_dw_Scroll2(id) {
    var wndo = new dw_scrollObj('wn', 'lyr1', 't1');
    wndo.setUpScrollControls('scrollbar', true, 'v');
    //scrollToId_id_lyr1();
}

function init_dw_Scroll() {
    var wndo = new dw_scrollObj('wn', 'lyr1', 't1');
    wndo.setUpScrollControls('scrollbar', true, 'v');
}

function init_dw_Scrollhorizontal() {
    var wndo = new dw_scrollObj('wnv', 'lyr1', 't1');
    
    wndo.setUpScrollControls('scrollLinks2', true, 'h');
    
    wndo.setUpScrollControls('scrollLinks1', true, 'h');
}

function setload(){
  if ( document.getElementById && document.getElementsByTagName ) {
      addLoadEvent(init_dw_Scroll);
  }
}

function setloadhorizontal(){
  if ( document.getElementById && document.getElementsByTagName ) {
      addLoadEvent(init_dw_Scrollhorizontal);
  }
}
function getXmlHttpRequest() {
  		if (window.XMLHttpRequest) {
  			return new XMLHttpRequest();
  		} else if (window.ActiveXObject) {
  			return new ActiveXObject("Microsoft.XMLHTTP");
  		}
 	}
 	
function createQuery(form)
{
    var elements = form.elements;
    var pairs = new Array();

    for (var i = 0; i < elements.length; i++) {

        if ((name = elements[i].name) && (value = elements[i].value))
            pairs.push(name + "=" + encodeURIComponent(value));
        if ((name = elements[i].name) && (value = elements[i].checked))
            pairs.push(name + "=" + encodeURIComponent(value));
    }

    return pairs.join("&");
}



function detectaBrowser() {
    if (navigator.appName.toLowerCase().indexOf('microsoft internet explorer') > -1)
    return('ie');
    else
    if (navigator.appName.toLowerCase().indexOf('netscape') > -1)
    return('firefox');
    }

function show_div(elem){

document.getElementById(elem).style.display="block";
verifica_novamente();
}

function hide_div(elem){

document.getElementById(elem).style.display="none";
verifica_novamente();
}

function popOpen(popup)
{
    //document.getElementById(popup).style.display='block';
    var height;
    var width;
    if(document.all)
    {
        height=document.body.offsetHeight;
        width=document.body.offsetWidth;
        divHeight=document.getElementById(popup).offsetHeight;
        divWidth=document.getElementById(popup).offsetWidth;
    }
    else
    {
        if(document.getElementById)
        {
            height=window.innerHeight;
            width=window.innerWidth;
            divHeight=document.getElementById(popup).offsetHeight;
            divWidth=document.getElementById(popup).offsetWidth;
        }
    }
    
    getViewportScrollY = function() {
      var scrollY = 0;
      if( document.documentElement && document.documentElement.scrollTop ) {
        scrollY = document.documentElement.scrollTop;
      }
      else if( document.body && document.body.scrollTop ) {
        scrollY = document.body.scrollTop;
      }
      else if( window.pageYOffset ) {
        scrollY = window.pageYOffset;
      }
      else if( window.scrollY ) {
        scrollY = window.scrollY;
      }
      return scrollY;
    };
    var newTop=getViewportScrollY()+(height/2)-(divHeight/2);
    var newLeft=(width/2)-(divWidth/2);
    document.getElementById(popup).style.top=newTop;
    document.getElementById(popup).style.left=newLeft;
}
