
$(document).ready(function() {

	//Append the tooltip template and its value to document.body!	
	$(document.body).append('<div id="tooltip" style="display:none;"><div class="tipHeader"></div><div class="tipBody" id="tipBody"></div><div class="tipFooter"></div></div>');
	
	$(".tip").mousemove(function(e) {
			$('#tooltip').css('top', e.pageY + 10 );
			$('#tooltip').css('left', e.pageX + 20 );
			});
		$(".tip").hover(
			function (e) {
				var tip_text = $(this).attr("rel");
				$(this).data('timeout', setTimeout(
					function () {
						$("#tipBody").html(tip_text);
						$('#tooltip').fadeIn('fast');
						}, 500));},
					function () {
						clearTimeout($(this).data('timeout'));
						$('#tooltip').fadeOut('fast');
						});
						
	//rotation speed and timer
	var speed = 10000;
	var run = setInterval('rotate()', speed);	
	
	//grab the width and calculate left value
	var item_width = $('#slides li').outerWidth(); 
	var left_value = item_width * (-1); 
        
    //move the last item before first item, just in case user click prev button
	$('#slides li:first').before($('#slides li:last'));
	
	//set the default item to the correct position 
	$('#slides ul').css({'left' : left_value});

    //if user clicked on prev button
	$('#prev').click(function() {

		//get the right position            
		var left_indent = parseInt($('#slides ul').css('left')) + item_width;

		//slide the item            
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200,function(){    

            //move the last item and put it as first item            	
			$('#slides li:first').before($('#slides li:last'));           

			//set the default item to correct position
			$('#slides ul').css({'left' : left_value});
		
		});

		//cancel the link behavior            
		return false;
            
	});

 
    //if user clicked on next button
	$('#next').click(function() {
		
		//get the right position
		var left_indent = parseInt($('#slides ul').css('left')) - item_width;
		
		//slide the item
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200, function () {
            
            //move the first item and put it as last item
			$('#slides li:last').after($('#slides li:first'));                 	
			
			//set the default item to correct position
			$('#slides ul').css({'left' : left_value});
		
		});
		         
		//cancel the link behavior
		return false;
		
	});        
	
	//if mouse hover, pause the auto rotation, otherwise rotate it
	$('#slides').hover(
		
		function() {
			clearInterval(run);
		}, 
		function() {
			run = setInterval('rotate()', speed);	
		}
	); 
 
  //top navigation area
 	$("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag
	
	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the a tag
		$(this).find("span").show().html(linkText); //Add the text in the span tag
	}); 
	
	$("#topnav li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({ 
			marginTop: "-40" //Find the span tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0" //Move the span back to its original state (0px)
		}, 250);
	});

 //site menu
	  $('#huge-1').hugeMenu({
   rowItems: '3',
   speed: 'fast',
   effect: 'show',
   direction: 'right'
   });
        
});

//a simple function to click next link
//a timer will call this function, and the rotation will begin :)  
function rotate() {
	$('#next').click();
}

function open_blogconnect()	{
		
			Shadowbox.open({
        content:    "/PT/docs/shadowbox_blog_connect.php",
        player:     "iframe",
        title:      "Conectar seu Blog",
        height:     455,
        width:      520
    });
		
}

function open_newsletter()	{
		
			Shadowbox.open({
        content:    "/PT/docs/shadowbox_newsletter.php",
        player:     "iframe",
        title:      "Gerenciador de Newsletter",
        height:     480,
        width:      510
    });
		
}

function open_registerpage()	{
		
			Shadowbox.open({
        content:    "/PT/docs/_register_001.php",
        player:     "iframe",
        title:      "Cadastre-se 100% gratis",
        height:     520,
        width:      650
    });
		
}

function open_barra()	{
		
			Shadowbox.open({
        content:    "/phpbb/shadowbox_forumbar.php?status=2",
        player:     "iframe",
        title:      "Configure sua barra de ícones",
        height:     180,
        width:      400
    });
		
}

function open_login()	{
		
			Shadowbox.open({
        content:    "/PT/docs/shadowbox_data_new.php",
        player:     "iframe",
        title:      "Seus dados de Login",
        height:     180,
        width:      500
    });
		
}

function open_dataspersonal()	{
		
			Shadowbox.open({
        content:    "/PT/docs/shadowbox_efam_new.php",
        player:     "iframe",
        title:      "Seus dados Pessoais",
        height:     650,
        width:      500
    });
		
}

function open_login_simple()	{
		
			Shadowbox.open({
        content:    "/phpbb/login_simple.php",
        player:     "iframe",
        title:      "Entrar no E-familynet",
        height:     551,
        width:      700
    });
		
}

function open_closeaccount()	{
		
			Shadowbox.open({
        content:    "/PT/docs/shadowbox_efam_phpbb_delete_user.php",
        player:     "iframe",
        title:      "Cancelar sua conta no E-familynet!",
        height:     425,
        width:      550
    });
		
}

function open_birthday()	{
		
			Shadowbox.open({
        content:    "/phpbb/birthday_popup.php",
        player:     "iframe",
        title:      "Feliz Aniversário",
        height:     500,
        width:      600
    });
		
}

function denuncia(username) {

    Shadowbox.open({
        content:    "/PT/docs/denuncia.php?username=" + username,
        player:     "iframe",
        title:      "Denunciar este usuário",
        height:     400,
        width:      500
    });

};

function denuncia_post(post) {

    Shadowbox.open({
        content:    "/PT/docs/denuncia_post.php?post=" + post,
        player:     "iframe",
        title:      "Denunciar esta mensagem",
        height:     400,
        width:      500
    });

};

function fav_forum(post) {

    Shadowbox.open({
        content:    "/PT/docs/fav_forum.php?forumid=" + post,
        player:     "iframe",
        title:      "Incluir este fórum em meu Atalho de Fóruns",
        height:     400,
        width:      500
    });

};

function open_buddy(post) {

    Shadowbox.open({
        content:    "/phpbb/" + post,
        player:     "iframe",
        title:      "Faça deste usuário seu amigo.",
        height:     225,
        width:      350
    });

};

function open_disallow(post) {

    Shadowbox.open({
        content:    "/phpbb/" + post,
        player:     "iframe",
        title:      "Desabilitar este usuário.",
        height:     210,
        width:      350
    });

};

function open_ignore(post) {

    Shadowbox.open({
        content:    "/phpbb/" + post,
        player:     "iframe",
        title:      "Ignorar este usuário.",
        height:     210,
        width:      350
    });

};

function friendrequest(post) {

    Shadowbox.open({
        content:    "" + post,
        player:     "iframe",
        title:      "Solicitação para a lista de amigos",
        height:     240,
        width:      360
    });

};

function renommee(postid)
{
	
	Shadowbox.open({
        content:    "http://www.e-familynet.com/phpbb/renommee.php?p=" + postid,
        player:     "iframe",
        title:      "Avaliar esse Tópico",
        height:     300,
        width:      420
    });
	
	return false;
}

function renommee_del(delid)
{
	
		Shadowbox.open({
        content:    "http://www.e-familynet.com/phpbb/renommee_loeschen.php?id=" + delid,
        player:     "iframe",
        title:      "Deletar esta avaliação",
        height:     300,
        width:      420
    });
	
	return false;
}

function open_image(imageurl)	{
		
			Shadowbox.open({
        content:    "/phpbb/album_mod/upload/" + imageurl,
        player:     "image",
        title:      "Álbum de fotos E-familynet",
        height:     300,
        width:      420
    });

	return false;	
}
 
function popup(name,einstellungen)
{
window.open('',name,einstellungen);
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function Navigate(FormObj){if(FormObj.options[FormObj.selectedIndex].value!=""){clusterExit=0;self.location.href=FormObj.options[FormObj.selectedIndex].value;}}

function surfto(form){var myindex=form.select1.selectedIndex
if(form.select1.options[myindex].value!="0"){location=form.select1.options[myindex].value;}}

function setCheckedValue(radioObj,newValue){if(!radioObj)
return;var radioLength=radioObj.length;if(radioLength==undefined){radioObj.checked=(radioObj.value==newValue.toString());return;}
for(var i=0;i<radioLength;i++){radioObj[i].checked=false;if(radioObj[i].value==newValue.toString()){radioObj[i].checked=true;}}}

function bookmarksite(title,url){if(window.sidebar)
window.sidebar.addPanel(title,url,"");else if(window.opera&&window.print){var elem=document.createElement('a');elem.setAttribute('href',url);elem.setAttribute('title',title);elem.setAttribute('rel','sidebar');elem.click();}
else if(document.all)
window.external.AddFavorite(url,title);}

		// When the DOM is ready, initialize the scripts.
		jQuery(function( $ ){
 
			// Get a reference to the container.
			var container = $( "#bottom_container" );
 
 
			// Bind the link to toggle the slide.
			$('[name|="registerbox"]').click(
				function( event ){
					// Prevent the default event.
					event.preventDefault();
					
					// Toggle the slide based on its current
					// visibility.
					if (container.is( ":visible" )){
 
						// Hide - slide up.
						container.slideUp( 500 );
 
					} else {
 
						// Show - slide down.
						container.slideDown( 500 );
 
					}
				}
			);
 
		});
