/*function openUtils(){
	var x=gclass('open-buttons');
	for ( var i = 0; i < x.length; i++ )
	{
		var campo=x[i];
       		
		var tipo=campo.rel;		
		
		var idnot=document.getElementById('ajaxid').innerHTML;
		var tabnot=document.getElementById('ajaxmod').innerHTML;
		
		campo.onclick = function () {ajax('/ajax/ajax-utils.php','ajax-show-utils','tipo,id,tab',tipo+','+idnot+','+tabnot);return false}
        		
	}


}*/

/*function hideShowForm(){
	var x=gclass('hideAndShow');
	for ( var i = 0; i < x.length; i++ )
	{
		var campo=x[i];
		
		var startval=campo.value;
		
		campo.onfocus =  function () {if (this.value==startval) {this.value="";} };
		campo.onblur = function () {if (this.value=="") {this.value=startval;}};
	}
}*/


function externalLinks(){
	
    var hostname=window.location.hostname.toLowerCase();
    
    var Xterlinks = document.getElementsByTagName('A');
    
	for (var i=0;i<Xterlinks.length;i++)
	{ 
		var eachLink = Xterlinks[i];
		var regexp_isYourdomain=hostname;
		var regexp_ishttp=/(http(.)*:\/\/)/;
		//Check if the link is valid and is external link
		if( (eachLink.href != null) && (eachLink.href.match(regexp_isYourdomain) == null) && eachLink.href.match(regexp_ishttp)!=null )
	  	{
	  	    var linkhref=eachLink.href;
            
            /// retira o http:// pois o mod_rewrite nao codifica bem
            //oldhref=oldhref.replace("http://","");
          
            
  			eachLink.target ="_blank";//make the target for this external link
            eachLink.onclick= function () {pageTracker._trackPageview('/redirect/'+linkhref+'') }
            eachLink.rel="external";
            
	  	}
	}
}

//function ShowHideInput(){   
//    var valor= new Array;
//    	var x=gclass('hideOnFocus');
//	for ( var i = 0; i < x.length; i++ )
//	{
//      //  if (x[i].type=='password'){
////            x[i].type='text';
////            x[i].rel='password';
////        }
//        
//        x[i].onfocus=function (){clearText(this); /*if (this.rel=='password') {this.type='password'}*/};       
//        x[i].onblur=function () {clearText(this); /*if (this.rel=='password' && (this.value==this.defaultValue || this.value=='')) {this.type='text'}*/};    
//        
//        // IE NAO FUNCIONA PASSWORD!!!    
//	}
//}
//
//function clearText(field){
//    if (!field.title){
//        field.setAttribute('title',field.defaultValue);
//    }
//    
//    if (field.title == field.value) {field.value = '';
//   
//    }
//    else if (field.value == '') {field.value = field.title;
//
//       }
//}




/*function tabNav(){
    var childNav=gclass('tabNavigator');
    for ( var j = 0; j < childNav.length; j++ ) {
           if (childNav[j].style && hasClass(childNav[j],'tabselected')){
                var open=j;                
            }
            childNav[j].onclick=function () { opentab(this); return false}
        
    }
    
     var child=gclass('tabContent');
    for ( var j = 0; j < child.length; j++ ) {
      
        if (child[j].style){            
            if (j!=open){
        child[j].style.display='none';
        }
         else {
        child[j].style.display='block';
        }
        }
       
       
    }
}

function opentab(elem){
    /// remove a classe de todas
    var childNav=gclass('tabNavigator');
    for ( var j = 0; j < childNav.length; j++ ) {
            if (childNav[j].style && hasClass(childNav[j],'tabselected') && elem!=childNav[j]){
                removeClass(childNav[j],'tabselected');
            } 
            //childNav[j].onclick=function () { opentab(this); return false}
}
    
    addClass(elem,'tabselected');
    tabNav();
       
}*/


function redirectSelects(){
    	var x=gclass('redirectValue');
	for ( var i = 0; i < x.length; i++ ){
	   x[i].onchange=function() {if (this.value!='') {location.href=this.value;}};
	}
}

addLoadEvent(redirectSelects);
//addLoadEvent(tabNav);
//addLoadEvent(ShowHideInput);
addLoadEvent(externalLinks);
/*addLoadEvent(openUtils);
addLoadEvent(hideShowForm);*/
