﻿function windowOpen(url)
{
    window.open(url,'','width=990px,height=600px,toolbar=no,location=no,directories=yes,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no')    
}
function windowOpenwithSize(url)
{
     var width  = 900;
     var height = 600;
     var left   = (screen.width  - width)/2;
     var top    = (screen.height - height)/2;
     var params = 'width='+width+', height='+height;
     params += ', top='+top+', left='+left;
     params += ', directories=no';
     params += ', location=no';
     params += ', menubar=no';
     params += ', resizable=no';
     params += ', scrollbars=yes';
     params += ', status=no';
     params += ', toolbar=no';
     newwin=window.open(url,'windowname5', params);
     if (window.focus) {newwin.focus()}     
}  
 

function wordWrap(){
///******
//* wordWrap to firefox for big words
//* Creative Commons license * Version: 1.0 - 26/04/2006
//* Autor: Micox - Náiron J.C.G - micoxjcg@yahoo.com.br - http://elmicoxcodes.blogspot.com
//* Uso: call the function on onload of body element.
//* put the class "word-wrap" on elements to wordwrap
//*******/
//    var larg_total,larg_carac,quant_quebra,pos_quebra;
//    var elementos,quem, caracs, texto, display_orig;
//    
//    elementos = document.getElementsByTagName("p")
//    
//    for(var i=0; i<elementos.length;i++){
//        if(elementos[i].className=="word-wrap"){
//            quem = elementos[i];
//            
//            quem.innerHTML = String(quem.innerHTML).replace(/ /g,"Ø")
//            texto = String(quem.innerHTML)
//            
//            quem.innerHTML = " "
//            
//            display_orig = quem.style.display;
//            quem.style.display="block";
//            larg_oficial = quem.offsetWidth;
//            //alert("oficial: " + larg_oficial)
//            //alert("display " + quem.style.display)
//            if(!document.all) quem.style.display="table";
//            //alert("display " + quem.style.display)
//            quem.innerHTML = texto;
//            larg_total = quem.offsetWidth;
//            //alert("total: " + larg_total)
//            
//            pos_quebra = 0;
//            caracs = texto.length;
//            texto = texto.replace(/Ø/g," ")
//            larg_carac = larg_total / caracs
//            if(larg_total>larg_oficial){
//                quant_quebra = parseInt(larg_oficial/larg_carac)
//                quant_quebra = quant_quebra - (parseInt(quant_quebra/6)) //quanto menor o num, maior a garantia;
//                quem.innerHTML = ""
//                while(pos_quebra<=caracs){
//                    quem.innerHTML = quem.innerHTML + texto.substring(pos_quebra,pos_quebra + quant_quebra) + " "
//                    pos_quebra = pos_quebra + quant_quebra;
//                }
//            }else{
//                quem.innerHTML = texto;
//            }//end if do larg_total>larg_oficial
//            quem.style.display = display_orig;
//        }//end if do word wrap
//    }//end for loop dos elementos
}
function Count(text, longText) {
    var maxlength = new Number(longText); // Change number to your max length.
    if (text.value.length > maxlength) { text.value = text.value.substring(0, maxlength); }
}
function checkTextAreaMaxLength(textBox, e, length) {
    var mLen = textBox["MaxLength"];
    if (null == mLen) mLen = length;

    var maxLength = parseInt(mLen);
    if (!checkSpecialKeys(e)) {
        if (textBox.value.length > maxLength - 1) {
            if (window.event) e.returnValue = false;
            else e.preventDefault();
        } 
    } 
}
function checkSpecialKeys(e) {
    if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40) return false;
    else return true;
}