//<![CDATA[

document.write("<scr"+"ipt type='text/javascript' src='bannerImages.as'></scr"+"ipt>");
document.write("<scr"+"ipt type='text/javascript' src='sIFR/sifr.js'></scr"+"ipt>");

var hasFlash = function(){

    var nRequiredVersion = 6;   
    
    if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1){
        document.write('<script language="VBScript"\> \n');
        document.write('on error resume next \n');
        document.write('hasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + nRequiredVersion + '))) \n');  
        document.write('<'+'/script\> \n');
        /*  If executed, the VBScript above checks for Flash and sets the hasFlash variable. 
            If VBScript is not supported it's value will still be undefined, so we'll run it though another test
            This will make sure even Opera identified as IE will be tested */
        if(window.hasFlash != null){
            return window.hasFlash;
        };
    };
    
    if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        var flashDescription = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
        var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
        return flashVersion >= nRequiredVersion;
    };
    
    return false;
}();

function swfObject (swf,fv,w,h){
    var swfCODE;
    swfCODE  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/  shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'">';
    swfCODE += '    <param name="movie" value="'+swf+'" />';
    swfCODE += '    <param name="flashvars" value="'+fv+'" />';
    swfCODE += '    <embed src="'+swf+'" flashvars="'+fv+'" width="'+w+'" height="'+h+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
    swfCODE += '<'+'/object>';
    return swfCODE;
}      

function random(n){
    var ranNum= Math.round(Math.random()*(n-1));
    return ranNum;
}
function WriteLayer(text,id){
    if(document.getElementById){
       x = document.getElementById(id);
       x.innerHTML = text;
       //   if(window.navigator.appName == 'Netscape')
       //  window.sizeToContent();  
    }else if(document.all){
       x = document.all[id];
       x.innerHTML = text;
    }else if(document.layers){
       x = document.layers[id];
       x.document.open();
       x.document.write(text);
       x.document.close();
    }
}
function checkFlash(area){    
    if(hasFlash){
        fv='q='+document.getElementById('filter').value +"&area="+area;
        var swf= swfObject ('top.swf',fv,475,170);
        WriteLayer(swf,'servicos');        
    }else{
        var rand =  random(images.length);
        var chosen = images[rand];        //alert(rand);
        document.getElementById('servicos').style.backgroundImage="url(img/top/"+chosen+")";
        //document.getElementById('servicos').style.display="block";    
        //document.getElementById('servicosFlash').style.display="none";
    }
}    

function openWin(path,winW,winH) {
    var iMyWidth;
    var iMyHeight;
    iMyWidth = (window.screen.width/2) - ((winW/2)+ 10); 
    iMyHeight = (window.screen.height/2) - ((winH/2) + 50); 
    var win2 = window.open(path,"","status,toolbar=0,height="+winH+",width="+winW+",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
    win2.opener=window;
    win2.focus();
}
function openChat(){
    var path = '?pageId=chatInsMember';
    var winW=610;
    var winH=420;
    var iMyWidth;
    var iMyHeight;
    iMyWidth = (window.screen.width/2) - ((winW/2)+ 10); 
    iMyHeight = (window.screen.height/2) - ((winH/2) + 50); 
    var win2 = window.open(path,"ChatWin","titlebar=0, status=0,toolbar=0,height="+winH+",width="+winW+",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
    win2.opener=window;
    win2.focus();
}

function mostrar (id, prefix){
    if( last!=id){
        x = document.getElementById(id);
        x.className=prefix+'_show';
    
        y = document.getElementById(last);
        y.className=prefix+'_hide';
        last=id;
    }
}
function isValidEmailAddress(addr) {
    var re;
    re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
    if (re.test(addr) == true)
       return true;
    else
      return false;
}

function validaFormContato(){
    var f = document.contato;
    if(f.nome.value==""){
        alert('Preencha seu nome.');
        f.nome.focus();
        return false;
    } 
    if(!isValidEmailAddress(f.email.value)){
        alert('Verifique seu email.');
        f.email.focus();
        return false;
    }
    if(f.atuacao.value==""){
        alert('Escolha sua área de atuação.');
        f.atuacao.focus();
        return false;
    }
    if(f.mensagem.value==""){
        alert('Preencha a mensagem.');
        f.mensagem.focus();
        return false;
    }
    return true;
}

function validaFormCadastro(){
    var f = document.cadastro;
    if(f.name.value==""){
        alert('Preencha seu nome.');
        f.name.focus();
        return false;
    } 
    if(!isValidEmailAddress(f.login.value)){
        alert('Verifique seu email.');
        f.login.focus();
        return false;
    }
    if(f.password.value==""){
        alert('Escolha sua senha.');
        f.password.focus();
        return false;
    }
    if(f.passwordConf.value!=f.password.value){
        alert('A confirmação de senha não confere.');
        f.passwordConf.focus();
        return false;
    }
    if(f.performanceArea.value==""){
        alert('Escolha sua área de atuação.');
        f.performanceArea.focus();
        return false;
    }
    if(f.organization.value==""){
        alert('Preencha sua organização.');
        f.organization.focus();
        return false;
    }
    return true;
}

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  }
}
function abre(link){   
    openWin(link,600,500);
    return false;
}
function aMod_externalLink(){    
    var as,i,islink,content;
    content=document.getElementById('content');
    as=content.getElementsByTagName('a');
    for(i=0;i<as.length;i++){
        // take the link's href
        islink=as[i].href; 
        // and check if it contains the current location 
        var host = new String(window.location.hostname);
        rExp = /www./gi;
        domain = host.replace(rExp, "");

        if(islink.indexOf(domain)==-1 && islink.indexOf('javascript:')==-1){
            if(!as[i].getAttribute('title')) as[i].setAttribute('title',islink);
            if(!as[i].getAttribute('class')) as[i].setAttribute('class','linkExterno');
            as[i].setAttribute("target","_blank");             
        } 
    }
}
function convertLinks(){//desligado
	var as = document.getElementsByTagName('a');
	for(i=0;i<as.length;i++){
		var a = as[i];	
		if(a.className=='openWin'){
            if (addEventListener){
                a.setAttribute('onclick',"openWin('"+a.href+"',600,500);return false;");
            } else{
                a.onclick = openWin(a.getAttribute('href'),600,500);
                
            }
		}	
	}		
	
}
addEvent(window, 'load', aMod_externalLink, 0);


//]]>
