function get_album(user) {
		var url = 'plugins/dload_album.cmd.php';
		var params = 'user='+user;
		
		showHigh(url, params, 'dloadAlbum');
}

function not_album() {
	var url = 'plugins/dload_album.cmd.php';
	var params = '';
	
	
	showHigh(url, params, 'dloadAlbum');
}

function sendmail(name, email, msg) {
		var url = 'site/email.php';
		var params = 'name=' + name.value + '&email0=' + email.value + '&message=' + msg.value;
			
		showHigh(url, params, 'sendEmail');	
}

function save_email(email) {
		var url = 'plugins/save_email.php';
		var params = 'email1=' + email.value;
			
		showHigh(url, params, 'saveEmail');	
}

function updateinfo(pass, email, sex) {
		var url = 'plugins/update_info.cmd.php';
		var params = 'pass=' + name.value + '&email=' + email.value + '&sex=' + sex.value;
			
		showHigh(url, params, 'updUserInfo');	
}

function dload( album, music ) {
		var url = 'plugins/dload.php';
		var params = 'file=' + music + '&album=' + album;
					
	    $(document.body).startWaiting('bigBlackWaiting');
	    
		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {
				pageTracker._trackPageview('/dloadMusic');
		  		$(document.body).stopWaiting();  
		  		window.location = transport.responseText; 		       
		   
		  },
		  onFailure: function(transport) {
		  	$(document.body).stopWaiting();  
		  		alert(transport.responseText); 
		  }
		});

}

function changeMain( div, sec, num ) 
{
	changeNormal(sec +"="+ num , div);
}
function changeNormal(parameters, div, sec) {
		var url = 'site/normal.cmd.php';
		var params = parameters;
					
		
		//alert( params + div + sec );
	    $(document.body).startWaiting('bigBlackWaiting');
	    
		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {
			pageTracker._trackPageview('/chgNormal');
		  	window.setTimeout( function() { 
		  		//alert(transport.responseText);			    
    		    $(div + '_div').update(transport.responseText);	
    		    $(document.body).stopWaiting();	    		    
    		    new Effect.Appear($(div + '_div'), { queue: {position:'end', scope: 'menuxscope', limit:2} }); // #1;
		    }, 1200) ;    
		   
		  },
		  onFailure: function(transport) {
		      //alert(transport.responseText);
		  }
		});

}

function change(parameters, div, sec) {
		var url = 'site/' + sec + '.cmd.php';
		var params = parameters;
					
		
		//alert( params + div + sec );
	    //$(div + '_div').startWaiting('bigBlackWaiting', 270, 225);
	    $(document.body).startWaiting('bigBlackWaiting');
		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {
		  	window.setTimeout( function() { 
				pageTracker._trackPageview('/chg');
		  		$(document.body).stopWaiting();			    
    		    $(div + '_div').update(transport.responseText);	    		    
    		    new Effect.Appear($(div + '_div'), { queue: {position:'end', scope: 'menuxscope', limit:2} }); // #1;
		    }, 1200) ;    
		   
		  },
		  onFailure: function(transport) {
		  }
		});

}

function changeCmd(parameters, div, sec) {
		var url = 'plugins/' + sec + '.cmd.php';
		var params = parameters;
					
	    $(div + '_div').startWaiting('bigBlackWaiting');
	    new Effect.Fade($(div + '_div'), { queue: {position:'front', scope: 'menuxscope', limit:2} }); // #1
		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {	
			pageTracker._trackPageview('/chgCmd');
		  	$(div + '_div').stopWaiting(); 		  	
		  	window.setTimeout( function() { 			    
    		    $(div + '_div').update(transport.responseText);	
    		    new Effect.Appear($(div + '_div'), { queue: {position:'end', scope: 'menuxscope', limit:2} }); // #1;
		    }, 1200) ;    
		   
		  },
		  onFailure: function(transport) {
		  }
		});

}

function changePage(par, div, sec) {		
		var params = 'sel_page=' + par;
					
	    change( params, div, sec);
}


function changeMus(par, div, sec) {		
		var params = 'mus=' + par;
					
	    change( params, div, sec);
}



function closeNews(boxprefix, id, header) {
    
    var title = document.getElementById( "event" + id );
	if ( title ) {
	    title.className = "alt";

	    closeEffect( boxprefix, id );
	    
	    closeView( "B_reply_link_", id );
	        
	    link = document.getElementById("A_reply_link_" + id);
	    if ( link ) { 
	       link.style.display = 'block';
	       link.focus();
	    }
	    
	    var title = document.getElementById( "event" + id );
	    title.className = "alt";	    
	    
	    title.onclick = function() {
	        openNews( boxprefix, id, header );
	    }
	    
	    title.onmouseover = function() {
	       senddbl( "Exibir", header );    
	    }
	}
  
}

function openNews(boxprefix, id, header) {
    
    var title = document.getElementById( "event" + id );
	if ( title ) {
	    title.className = "hdr";

	    openEffect( boxprefix, id );
	        
	    closeView( "A_reply_link_", id );   
	    
	    var link = document.getElementById("B_reply_link_" + id);
	    if ( link ) { 
    	    link.style.display = 'block';
    	    link.focus();
	    }
	    
	    title.onclick = function() {
	        closeNews( boxprefix, id, header );
	    }
	    
	    title.onmouseover = function() {
	       senddbl( "Esconder", header );    
	    }
	    
	    
	}
}

function closeNews2(boxprefix, id, header) {
    var title = document.getElementById( boxprefix );
    
	if ( title ) {
	    title.className = "alt";

	    closeEffect( boxprefix, id );
	    
	    closeView( "B_reply_link_", id );
	        
	    link = document.getElementById("A_reply_link_" + id);
	    if ( link ) { 
	       link.style.display = 'block';
	       link.focus();
	    }
	    
	    title.className = "alt";	    
	    
	    title.onclick = function() {
	    	
	        openNews2( boxprefix, id, header );
	    }
	    
	    title.onmouseover = function() {
	       senddbl( "Exibir", header );    
	    }
	}
  
}

function openNews2(boxprefix, id, header) {
   
    var title = document.getElementById( boxprefix  );
    
	if ( title ) {
	    title.className = "hdr";

	    openEffect( boxprefix, id );
	        
	    closeView( "A_reply_link_", id );   
	    
	    var link = document.getElementById("B_reply_link_" + id);
	    if ( link ) { 
    	    link.style.display = 'block';
    	    link.focus();
	    }
	    
	    title.onclick = function() {
	        closeNews2( boxprefix, id, header );
	    }
	    
	    title.onmouseover = function() {
	       senddbl( "Esconder", header );    
	    }
	    
	    
	}
}

function showMsg(msg) {
		var url = 'plugins/show_msg.cmd.php';
		var params = 'msg=' + msg;
				
	    showHigh( url, params, 'showMsg' );
}

function showMapa(endereco) {
		var url = 'plugins/show_gmap.cmd.php';
		var params = 'address=' + endereco;
				
	    showHigh( url, params, 'showGmap');
}

function showAgenda(dia, mes, ano) {
		var url = 'plugins/show_agenda.cmd.php';
		var params = 'eventD=' + dia + '&eventM=' + mes + '&eventY=' + ano;
					
	    showHigh( url, params, 'showAgenda' );
}

function showHigh(url, params, trackId) {
		$(document.body).startWaiting('bigBlackWaiting');	
		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {	
				pageTracker._trackPageview('/'+trackId);
    		    $(document.body).showAbout(transport.responseText);		   
		  },
		  onFailure: function(transport) {		  	
		    alert(transport.status);
		    $(document.body).stopWaiting();	
		  }
		});

}

function showVideo(album,video) {
		var url = 'plugins/show_video.cmd.php';
		var params = 'album=' + album + '&video=' + video;

		showHigh( url, params, 'showVideo' );
}

function showVideoCode(code, name) {
		var url = 'plugins/show_video_code.cmd.php';
		var params = 'code=' + code + '&video=' + name;

		showHigh( url, params, 'showVideoCode' );
}

function showImg(img) {
		var url = 'plugins/show_img.cmd.php';
		var params = 'img=' + img;

		showHigh( url, params, 'showImg' );
}

function showLyrics(music) {
		var url = 'plugins/show_lyrics.cmd.php';
		var params = 'music=' + music;

		showHigh( url, params, 'showLyrics' );
}

function closeAbout() {
	 $(document.body).stopWaiting();	
}

function showAbout(num_id) {
		var url = 'plugins/show_about.cmd.php';
		var params = 'num_id=' + num_id;
					
		showHigh( url, params, 'showAbout' );
}

function openAlbum() {
		var url = 'plugins/show_mp3.cmd.php';
		var params = 'album=' + $('album').options[$('album').selectedIndex].value;
		var div = $('mp3_list_div');	
		//closeView( 'mp3_list_', 'div' );
		//div.startWaiting('bigBlackWaiting', 15, 430);
		//Effect.SlideUp( div, {queue: 'front'} );
		new Effect.Fade(div, { queue: {position:'front', scope: 'menuxscope', limit:2} }); // #1
				
		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {		  	
		    //$('mp3_list_div').stopWaiting();
		    //closeView( 'mp3_list_', 'div' );
			pageTracker._trackPageview('/openAlbum');
		    window.setTimeout( function() { 
		        div.update(transport.responseText);
		        new Effect.Appear('mp3_list_div', { queue: {position:'end', scope: 'menuxscope', limit:2} }); // #1;
		    }, 1000) ;
		    		 
		    //new Effect.Appear(div, {duration: 2, queue: {position: 'end', scope: 'menuxscope', limit:2} });  // #3   
		    //new Effect.Highlight(div, {queue: {position:'end', scope: 'menuxscope', limit:2} }); // #2
		    //Effect.SlideDown( div, {queue: 'end'} );
		    		   
		  },
		  onFailure: function(transport) {		  			    
		    //div.stopWaiting();
		    div.update(transport.responseText);
		    openEffect( 'mp3_list_', 'div' );	
		  }
		});

}

function openMusic2(p2, p4, p5 ) {

		var url = 'site/getMusic.php';
		var params = 'musica=' + p5 + '&num=' + p4;
		var div = p2 + p4;
		$(document.body).startWaiting('bigBlackWaiting');

		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {
		    var notice = $(div);
			pageTracker._trackPageview('/openMusic2');
		    $(document.body).stopWaiting();
		    notice.update(transport.responseText);
		    openNews( p2, p4, p5 );		    
		   
		  },
		  onFailure: function(transport) {
		    var notice = $(div);
		    $(document.body).stopWaiting();
		    notice.update('Shiitt happens');
		    openNews( p2, p4, p5 );
		  }
		});

}

function closeMusic2( p2, p4, p5 ) {
		closeNews( p2, p4, p5 );
}

function openEventDefault(div) {

		var url = 'site/getPublicEvents.php';
		
		var div = div;
		$(document.body).startWaiting('bigBlackWaiting');

		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) {
			pageTracker._trackPageview('/openPublicEvents');
		    var notice = $(div);
		    $(document.body).stopWaiting();
		    notice.update(transport.responseText);
		    openEffect( notice, '' );		    
		   
		  },
		  onFailure: function(transport) {
		    var notice = $(div);
		    $(document.body).stopWaiting();
		    notice.update('Shiitt happens');
		    openEffect( notice, '' );
		  }
		});

}


function openEvent2(p2, p3, p4, p5 ) {

		var url = 'site/getEvent.php';
		var params = 'file=' + p3 + '&num=' + p4;
		var div = p2 + p4;
		$(document.body).startWaiting('bigBlackWaiting');

		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  parameters: params,
		  onSuccess: function(transport) {
			pageTracker._trackPageview('/openEvent2');
		    var notice = $(div);
		    $(document.body).stopWaiting();
		    notice.update(transport.responseText);
		    openNews( p2, p4, p5 );		    
		   
		  },
		  onFailure: function(transport) {
		    var notice = $(div);
		    $(document.body).stopWaiting();
		    notice.update('Shiitt happens');
		    openNews( p2, p4, p5 );
		  }
		});

}

function closeEvent2(p1, p2, p3, p4, p5 ) {
		closeNews( p2, p4, p5 );
}

function openEvent(p1, p2, p3 ) {

		var url = 'site/getEvent.php';
		var params = 'file=' + p2 + '&num=' + p3;
		var div = 'result' + p3;
		//alert(div);
		/*
		var ajax = new Ajax.Updater(
			{success: reportError},
			url,
			{method: 'get', parameters: params, onFailure: reportError});
			*/
		var ajax = new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) {
			pageTracker._trackPageview('/openEvent');
		    var notice = $(div);
		    notice.update(transport.responseText);
		    notice.setStyle({display: 'block'});
		    
		   
		  },
		  onFailure: function(transport) {
		    var notice = $(div);
		    notice.update('Shiitt happens');
		   
		  }
		});

}

function checkZip() {

		var url = 'site/getEvent.php';
		var params = 'zip=';
		var ajax = new Ajax.Updater(
			{success: 'result'},
			url,
			{method: 'get', parameters: params, onFailure: reportError});

}

function reportError(request) {
	$F('result') = "Error";
}

function displayWindow(url) {
	var Win = window.open(url,"displayWindow",'width=420,height=350,resizable=0,scrollbars=no,menubar=no,status=yes');
}

function stripeTables() {
	if (document.getElementsByTagName) {
		var tables = document.getElementsByTagName("table");
		for (var i=0; i<tables.length; i++) {
			var rows = tables[i].getElementsByTagName("tr");
			for (var j=1; j<rows.length; j=j+2) {
				rows[j].className = "alt";
			}
		}
	}
}

function openVideoList(obj, boxprefix, id, tag) {	
	var a = Event.getHtmlVideos( id, tag, {
	  callback:function(str) { 
	     document.getElementById( boxprefix + id ).innerHTML=str;
	     	      quickReplyOpen(obj, boxprefix, id );
	
	  		 		  		
	  	}
	});
}
		


function startTime()
{
	var today=new Date();
	var dia=checkTime(today.getDate());
	var mes=checkTime(today.getMonth() + 1);
	var ano=1900 + today.getYear();
	var h=today.getHours();
	var m=today.getMinutes();
	var s=today.getSeconds();
	// add a zero in front of numbers<10
	m=checkTime(m);
	s=checkTime(s);
	document.getElementById('hora_div').innerHTML=dia+"/"+mes+"/"+ano+ " " + h+":"+m+":"+s;
	t=setTimeout('startTime()',500);
}

function checkTime(i)
{
if (i<10) 
  {i="0" + i};
  return i;
}

function sendmsg( msg ){
document.getElementById('status').innerHTML=msg;
}

function sendalert( msg ){
 sendmsg("<font color=red>" + msg + "</font>");
 document.getElementById('statusFocus').focus();
}

function senddbl( hdr, msg ){
 sendmsg("<font color=#ff9600>" + hdr + ":</font> " + msg );
}
function closeVid(vidId) {
      if (vidPaneID.style.display=='block') {
         vidPaneID.style.display='none';
         vidPaneID.innerHTML=''; 
      } 
}

function playVideoOut(vidId) {
      if (vidPaneID.style.display=='block') {
         vidPaneID.style.display='none';
         vidPaneID.innerHTML=''; 
      } 
      
         vidPaneID.style.display='block';
         vidPaneID.innerHTML='<A id=videoClose HREF="javascript:closeVid()">fechar</A>';
         var vidstring ='<center><embed enableJavascript="false" allowScriptAccess="never"';
         vidstring+=' allownetworking="internal" type="application/x-shockwave-flash"';
         vidstring+='  src="http://www.youtube.com/v/'+vidId+'&autoplay=1" ';
         vidstring+=' wmode="transparent" height="354" width=430"></center>';
         vidPaneID.innerHTML+=vidstring;
         
         videoClose.focus();
      
   }

function changeVideo(name, id, title, len, count) {
      vidPaneID = document.getElementById("video"+name);
      if (vidPaneID.style.display=='block') {
         vidPaneID.style.display='none';
         vidPaneID.innerHTML=''; 
      } 
      
         vidPaneID.style.display='block';
         vidPaneID.innerHTML='';
         var vidstring ='<center><embed enableJavascript="false" allowScriptAccess="never"';
         vidstring+=' allownetworking="internal" type="application/x-shockwave-flash"';
         vidstring+='  src="http://www.youtube.com/v/'+id+'&autoplay=1&rel=0" ';
         vidstring+=' wmode="transparent" height="288" width=350"></center>';
         vidstring+='<br>';
		   vidstring+='<font color=#ff9600>T&iacute;tulo:</font> '    + title      + '<br>';
		   vidstring+='<font color=#ff9600>Dura&ccedil;&atilde;o:</font> '   + len        + '<br>'; 
		   //vidstring+='<font color=#ff9600>Views:</font> '   + count        + '<br>'; 
         vidPaneID.innerHTML+=vidstring;
         
         //videoClose.focus();
      
   }


   function moveHandler(e){
      if (e == null) { e = window.event } 
      if (e.button<=1&&dragOK){
         savedTarget.style.left=e.clientX-dragXoffset+'px';
         savedTarget.style.top=e.clientY-dragYoffset+'px';
         return false;
      }
   }

   function cleanup(e) {
      document.onmousemove=null;
      document.onmouseup=null;
      savedTarget.style.cursor=orgCursor;
      dragOK=false;
   }

   function dragHandler(e){
      var htype='-moz-grabbing';
      if (e == null) { e = window.event; htype='move';} 
      var target = e.target != null ? e.target : e.srcElement;
      orgCursor=target.style.cursor;
      if (target.className=="vidFrame") {
         savedTarget=target;       
         target.style.cursor=htype;
         dragOK=true;
         dragXoffset=e.clientX-parseInt(vidPaneID.style.left);
         dragYoffset=e.clientY-parseInt(vidPaneID.style.top);
         document.onmousemove=moveHandler;
         document.onmouseup=cleanup;
         return false;
      }
   }
	 
	 document.onmousedown=dragHandler;


var type = "MO";

var savedTarget=null; // The target layer (effectively vidPane)
   var orgCursor=null;   // The original Cursor (mouse) Style so we can restore it
   var dragOK=false;     // True if we're allowed to move the element under mouse
   var dragXoffset=0;    // How much we've moved the element on the horozontal
   var dragYoffset=0;    // How much we've moved the element on the verticle
   
   
function init() {
 startTime() ;
  if (navigator.userAgent.indexOf("Opera")!=-1
   && document.getElementById) {
      type="OP";
  }

  if (document.all) {
  		type="IE";
  	}

  if (document.layers) {
  		type="NN";
  	}
  	
	if (!document.all && document.getElementById) {
		type="MO"; 
	}
	
	
   //vidPaneID = document.getElementById('vidPane'); // Our movable layer
   //vidPaneID.style.top='75px';                     // Starting location horozontal
   //vidPaneID.style.left='75px';                    // Starting location verticle
 
 }
 
 function changeContent(id, str) {
  if (type=="IE") {
    ///var elem = document.createElement("div");
    //document.appendChild( elem );
    //elem.innerHTML += str;
    //alert( elem.innerHTML );
    //document.all[id].innerHTML += null;
    
    //elem.id = id;
  }
  if (type=="NN") {
    document.layers[id].document.open();
    document.layers[id].document.write(str);
    document.layers[id].document.close();
  }
  if (type=="MO" || type=="OP") {
    document.getElementById(id).innerHTML = str;
  }
}
 
  function changeColor(obj, color) {      
	   // obj.style.cursor =cursor:hand;
	    obj.style.backgroundColor = color;
  }
  
  function playVideo(vidstring, divID) {
      vidPaneID = document.getElementById(divID);
      //if (vidPaneID.style.display=='block') {
         vidPaneID.style.display='none';
         vidPaneID.innerHTML=''; 
      //} 
      
         vidPaneID.style.display='block';
         //vidPaneID.innerHTML='';
         /*
         var vidstring ='<center><embed enableJavascript="false" allowScriptAccess="never"';
         vidstring+=' allownetworking="internal" type="application/x-shockwave-flash"';
         vidstring+='  src="http://www.youtube.com/v/'+vidId+'&autoplay=1" ';
         vidstring+=' wmode="transparent" height="350" width=425"></center>';
         */
         vidPaneID.innerHTML+=vidstring;
         
         //videoClose.focus();
      
   }
  
  function changeVideozz(name, id, title, len){    
		
		var videoHTML = "<object width=350 height=288>" +
		"<param name=movie value=http://www.youtube.com/v/" + id + "></param>" +
		"<param name=wmode value=transparent></param>" +
		"<embed src=http://www.youtube.com/v/" + id + "&autoplay=1 type=application/x-shockwave-flash wmode=transparent width=350 height=288></embed>" +
		"</object>" +
		"<br>" +
		"<font color=#ff9600>T&iacute;tulo:</font> "    + title      + "<br>" +
		"<font color=#ff9600>Dura&ccedil;&atilde;o:</font> "   + len        + "<br>"; 
//		"<A HREF=javascript:playVid('" + id + "')>abrir</A>";
		
    if (type=="IE") {
       //playVideo( videoHTML, "video"+name );
       playVid( id, "video"+name );
       //vidPaneID.focus()
    }
    else {
       
	    changeContent( "video"+name, videoHTML );
		
		 document.getElementById("video"+name+"lnk").focus();
	}

  }
    function closeAllViews2() {
   var view =    document.getElementById("view_" + 0 );
   for ( var i=0; view != null; i++ ) {
        closeEffect( "view_", i );
		view =    document.getElementById("view_" + i );
   }

}

function openAllViews2() {
   var view =    document.getElementById("view_" + 0 );
   for ( var i=0; view != null; i++ ) {
        openEffect( "view_", i );
		view =    document.getElementById("view_" + i );
   }
}

  function closeAllViews() {
   var view =    document.getElementById("view_" + 0 );
   for ( var i=0; view != null; i++ ) {
        quickReplyClose( null, "view_", i );
		view =    document.getElementById("view_" + i );
   }

}

function openAllViews() {
   var view =    document.getElementById("view_" + 0 );
   for ( var i=0; view != null; i++ ) {
        quickReplyOpen( null, "view_", i );
		view =    document.getElementById("view_" + i );
   }
}
  
  /**
   * Called to close all quick reply boxes. Enables all reply buttons.
   */
  function quickReplyCloseAll(texts_prefix, buttons_prefix){
      
      var max = 14;   

    for (var i = 0; i <= max; i++) {
      var text = document.getElementById(texts_prefix + i);
      if(text == null)
        break;
        
      text.style.display = "none";
      var link = document.getElementById("A_" + buttons_prefix + i);
      if(link == null)
        break;      

      link.style.cursor="pointer";
      link.style.textDecoration="underline"; 

      link.style.display = 'block';
    
      link = document.getElementById("B_" + buttons_prefix + i);
      link.style.display = 'none';
    }
    
    // toggles the reply result message.
    var message = document.getElementById("quickReplyResult");
    if (message) {
      message.style.display = "none";
    }
  }
  
  function openView( boxprefix, id, close, effect ) {
	if ( document.getElementById(boxprefix + close) ) {
       if ( document.getElementById(boxprefix + close).display != "none" ) {
          if ( effect == 1 ) {
             closeEffect( boxprefix, close );
          }
          else {
	          closeView( boxprefix, close );
	      }
       }
    }   
       if ( effect == 1 ) {
             openEffect( boxprefix, id );
          }
          else {
	          // changes the requested box state
	          var box = document.getElementById(boxprefix + id); 
	          if ( box ) {
	               box.style.display = 'block';
          	    }   
	          
	      }
  		
 
	    var boxFocus = document.getElementById( id + "Focus" ); 

	    if ( boxFocus ) {
	       boxFocus.focus();
	    }
  }
  
  function closeView( boxprefix, id, effect ) {
    	if ( effect == 1 ) {
             closeEffect( boxprefix, id );
          }
          else {
          	var link = document.getElementById( boxprefix + id);
          	    if ( link ) {
	               link.style.display = 'none';
          	    }
	      }
    	
  }
  
  function closeEffect( box, id ) {
  		var link = document.getElementById(box+id);
		if ( link ) {
			new Effect.Fade(link);    	
		}
  }
  
  function openEffect( box, id ) {
  		var link = document.getElementById(box+id);
		if ( link ) {
			new Effect.Appear(link,{to:.96 });   // @gms: 	
		}
  }
  
  
  /**
   * Called to open a particular Quick Reply box. Disables the respective button.
   */
  function quickReplyOpen(obj, boxprefix, id) {

    // closes all
    // quickReplyCloseAll(boxprefix, "reply_link_");
    
    var title = document.getElementById( "event" + id );
	if ( title ) {
	    title.className = "hdr";

	    openEffect( boxprefix, id );
	        
	    closeView( "A_reply_link_", id );   
	    
	    var link = document.getElementById("B_reply_link_" + id);
	    if ( link ) {
    	    link.style.display = 'block';
    	    link.focus();
	    }

	    // and disables the quick reply link
	    // alert(obj.style.color);
	    // obj.style.color="#666666";
	    // obj.style.cursor="default";
	    // obj.style.textDecoration="none";  
	    // obj.focus(); 
			}
  }
  
  function quickReplyClose(obj, boxprefix, id) {

    // closes all
    // quickReplyCloseAll(boxprefix, "reply_link_");
    
    var title = document.getElementById( "event" + id );
	if ( title ) {
	    title.className = "alt";

	    closeEffect( boxprefix, id );
	    
	    closeView( "B_reply_link_", id );
	        
	    link = document.getElementById("A_reply_link_" + id);
	    if ( link ) {
	       link.style.display = 'block';
	       link.focus();
	    }
	    
	    var title = document.getElementById( "event" + id );
	    title.className = "alt";
	    
	    
	}
  
  }

function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   sendalert("Email inv?lido.");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   sendalert("Email inv?lido.");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    sendalert("Email inv?lido.");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    sendalert("Email inv?lido.");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    sendalert("Email inv?lido.");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    sendalert("Email inv?lido.");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    sendalert("Email inv?lido.");
		    return false;
		 }

 		 return true			;		
	}

function ValidateEmail( emailID ){
		
	if ((emailID.value==null)||(emailID.value=="")){
		sendalert("Preencha com seu email.");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
	   sendalert("Preencha com um email v?lido.");
		emailID.value="";
		emailID.focus();
		return false;
	}
	return true;
 }
 
 function ValidateMsg( msgID ){
 	if ((msgID.value==null)||(msgID.value=="")){
		sendalert("Digite uma mensagem...");
		//msgID.focus();
		return false;
	}	
	return true;
 }
 
 function ValidateName( nameID ){	
	if ((nameID.value==null)||(nameID.value=="")){
		sendalert("Preencha com o seu nome.");
		//nameID.focus();
		return false;
	}
	return true;
 }
 
 function validateSendEmail() {
 
    if ( ValidateName( document.frmSendEmail.name ) &&
         ValidateEmail( document.frmSendEmail.email0 ) &&
         ValidateMsg( document.frmSendEmail.message ) ) {
         	sendmail(document.frmSendEmail.name,document.frmSendEmail.email0,document.frmSendEmail.message);
         return false;
    }
    return false;
 }
 
 function ValidateCheckList( checkbox_form ) {
 
	// set var checkbox_choices to zero	
	var checkbox_choices = 0;	
	
	// Loop from zero to the one minus the number of checkbox button selections
	for (var counter =0; counter < checkbox_form.checkbox.length ; counter++)
	{	
		// If a checkbox has been selected it will return true
		// (If not it will return false)
		if ( checkbox_form.checkbox[counter].checked )
		{ 
			checkbox_choices = checkbox_choices + 1; 	
		}
	}
	if ( checkbox_choices > 0 ) {
	   return true;
	}	
	sendalert("Escolha pelo menos um da lista.");
	//checkbox_form.elements[0].focus();
	return false;	
		
 }
 
  function validateSendListEmail() {
 
    if ( ValidateCheckList( document.frmSendListEmail ) &&         
         ValidateMsg( document.frmSendListEmail.message ) ) {
         return true;
    }
    return false;
 }
 
 function validateSignIn() {
    if ( ValidateEmail( document.frmSign.email1 ) ) {
    	save_email(document.frmSign.email1);
    }
    return false;
 }
