	//Global functions
	function randomNumber(qtd){
		return Math.floor(Math.random()*(qtd))
	}

	function createMenu(){
		jQuery('#menu li').each(function(i){
			if((jQuery('#menu li').size() - 1) != i ){ 	
				jQuery(this).append('|'); 
			}
		});
		jQuery('#menufooter').html(jQuery('#menu').html()); 
	}
	
	function randomBgBody(){
		jQuery('body').css('background','#000000 url(../wp-content/themes/default/images/bg_'+randomNumber(0)+'.jpg) no-repeat scroll center 0');
	}
	
	function home(){
		if (jQuery('#emailGuest').size() > 0){
			jQuery('#contentHome').ifixpng();
			jQuery('#header h1 a').attr('title','Você está na home').css('cursor','default').click(function(e){e.stopPropagation();e.preventDefault();});
			
			var validaEmail = new RegExp(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/);			
			
			jQuery("#alertshow button").click(function(e){
				var email =  jQuery("#emailGuest").val();
				var labelHtml = jQuery('#alertshow dd:first').html();
				var inputHtml = jQuery('#alertshow dd:last').html();
				if (!validaEmail.test(email)){
					jQuery('#emailGuest').focus();
					jQuery('#alertshow dd:last input').css('background','red');
					jQuery('#alertshow dt').html('E-mail inválido, tente novamente');
				}else{
					jQuery('#alertshow dl dt').html('Aguarde, enviando ...');
					jQuery('#alertshow dd').html('');
					jQuery.ajax({
						type: 'POST',
						url: '../wp-content/themes/shipshape/sendmail.php',
						data: 'email='+email+'&type=alert',
						success: function(msg){
							if (msg == 'ok'){
								jQuery('#alertshow dl dt').html('Enviado com sucesso !<br/>Aguarde nosso alerta');
							}else{
								jQuery('#alertshow dt').html('E-mail inválido, tente novamente');
								jQuery('#alertshow dd:first').html(labelHtml);
								jQuery('#alertshow dd:last').html(inputHtml);
								jQuery('#alertshow dd:last input').css('background','red');
								jQuery('#emailGuest').focus();
							}
						},
						error:function(){
							jQuery('#alertshow dt').html('Falha na conexão, tente novamente');
							jQuery('#alertshow dd:first').html(labelHtml);
							jQuery('#alertshow dd:last').html(inputHtml);
						}
					});
				}
			});
		}
		
		jQuery('#contentHomeTop').append(jQuery('#twitter-1 ul'));
		jQuery('#contentHomeTop ul li span').prepend(' - ');
		
		//jQuery('#play').append('<object height="265" width="320"><param value="http://www.youtube.com/v/upYaJQ7bt6I&amp;hl=pt-br&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" name="movie"/><param value="true" name="allowFullScreen"/><param value="always" name="allowscriptaccess"/><param value="transparent" name="wmode"/><embed height="265" width="320" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://www.youtube.com/v/upYaJQ7bt6I&amp;hl=pt-br&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" /></object>');
		
	}
	
	function aBanda(){
		if (jQuery('body #post-20').size() > 0){
			jQuery('div.contentRight dl a').click(function(e){
				e.stopPropagation();
				e.preventDefault();
				var divId = (jQuery(this).attr('id'));
				
				jQuery('div.contentRight dl a').each(function(){
					if (jQuery(this).attr('id') != divId ){
						jQuery('#'+jQuery(this).attr('id')+' img').fadeTo(300, 0.3);
					}else{
						jQuery('#'+jQuery(this).attr('id')+' img').fadeTo(300, 1);
					}
				});

				jQuery('.equipDesc').hide();
				jQuery('#'+divId+'Equip').show();
			});
			jQuery('#bruno').click();
			
		}
	}
	
	function mural(){
		if (jQuery('body h1:contains(Mural)').size() > 0){
			jQuery('#post-57 .contentRight .css_post_embedded dl').ifixpng();
			
			jQuery('#mailPost').keyup(function(){
				jQuery('#gravatar').val(jQuery('#mailPost').val())
			});
			
		}
	}

	function setList(){
		if (jQuery('body h1:contains(Músicas)').size() > 0){
			jQuery('div.contentLeft ul li a').each(function(e){
				var linkId = jQuery(this).attr('href');
				var linkText =jQuery(this).text();

				if (linkId.length > 1){
					jQuery(this).attr('title','Clique para visualizar a letra de '+jQuery(this).text().replace('ShipShape - ',''));
					jQuery(this).click(function(a){
						a.preventDefault();
						tb_show(linkText,'#TB_inline?height=400&width=400&inlineId='+linkId.replace('#',''),false);
					});
				}else{
					jQuery(this).parent().text(linkText);
				}

			});
			
		}
	}

	function fotos(){
		if (jQuery('body h1:contains(Fotos)').size() > 0){
			jQuery('.contentLeft .album a img, .contentLeft .album h4 a').each(function(a){
				jQuery(this).click(function(e){
					e.stopPropagation();
					e.preventDefault();
					jQuery('.contentRight').remove();
					jQuery('.contentRight').ifixpng();
					jQuery('.content').append('<div class="contentRight"><h1>Carregando, aguarde ...</h1></div>');
					
					var title = jQuery(this).attr('alt');
					var urlAlbum = jQuery(this).parent().attr('href')+'&flavor=ajax';
					if (typeof title == 'undefined'){
						title = jQuery(this).attr('title');
						urlAlbum = jQuery(this).attr('href')+'&flavor=ajax';
					}		
					jQuery.ajax({
						type: 'GET',
						url: urlAlbum,
						dataType: 'html',
						success: function(msg){
							jQuery('.contentRight').remove();
							jQuery('.content').append('<div id="temp" style="display:none;">'+msg+'</div>');
							var content = jQuery('#temp .album').html();
							jQuery('#temp').remove();
							jQuery('.content').append('<div class="contentRight"><h1>'+title+'</h1>'+content+'</div>');
							jQuery('.contentRight').ifixpng();
							tb_init('a.thickbox');
							
						},
						error: function(){
							jQuery('.contentRight').remove();
							jQuery('.contentRight').ifixpng();
							jQuery('.content').append('<div class="contentRight"><h1>Erro ao carregar, tente novamente</h1></div>');
						}
					});
				});
			});
			
		}
	}	

	function init(){
		//Bugfix png for IE6
		jQuery('img[src$=.png],body,#leftbar,.bgBarPng,.contentLeft,.contentRight').ifixpng();
		
		createMenu();
		//randomBgBody();
		home();
		aBanda();
		setList();
		mural();
		fotos()
	}
	
	jQuery(document).ready(function() {
		init();
	});



                                