/* <![CDATA[ */

var jq = jQuery;

		var player = null;
		function playerReady(thePlayer) {
			player = window.document[thePlayer.id];
			addListeners();
		}

		function createPlayer2(theFile) {
					var flashvars = {
							playerid: theFile
					}
					var params = {
					  allowscriptaccess: 'always',
					  allowfullscreen: 'false',
					  wmode: 'transparent'
					}
					var attributes = {
							id:"imgRadioCCB",  
							name:"imgRadioCCB"
					}
					swfobject.embedSWF("http://congregacao.net/wp-content/themes/TheCorporation/player/audioplay.swf", "imgRadioCCB", "30", "30", "9.0.0", false, flashvars, params, attributes);
		}
		function loadRadioCCB2() {
			if( jq.cookie("radioOnline") ) {
				var theFile = jq.cookie("radioOnline");
				jq.cookie("radioOnline", theFile, { path: '/', expires: 28 });
				createPlayer2(theFile);
			}
		}

		function loadFile(theFile) { 
			currentItem = -1; 
			previousItem = -1; 
			player.sendEvent('LOAD', 'http://64.56.64.78:'+theFile+'/;stream.nsv&type=mp3'); 
		};
		function createPlayer(theFile) {
					var flashvars = {
							file: 'http://64.56.64.78:'+theFile+'/;stream.nsv&type=mp3',
							autostart: 'true', 
							skin: 'http://congregacao.net/wp-content/themes/TheCorporation/includes/stylish.swf', 
							volume: 50
					}
					var params = {
					  allowscriptaccess: 'always',
					  allowfullscreen: 'true',
					  wmode: 'opaque'
					}
					var attributes = {
							id:"divRadioCCB",  
							name:"divRadioCCB"
					}
					swfobject.embedSWF("http://congregacao.net/wp-content/themes/TheCorporation/includes/player.4.3.swf", "divRadioCCB", "215", "30", "9.0.0", false, flashvars, params, attributes);
		}
		function loadRadioCCB() {
			if( jq.cookie("radioOnline") ) {
				var theFile = jq.cookie("radioOnline");
				createPlayer(theFile); 
				jq("#iconRadioCCB").show();
				jq("#ic11028").removeClass("ic11028"); jq("#ic13780").removeClass("ic13780"); jq("#ic13684").removeClass("ic13684");
				jq("#ic"+theFile).addClass("ic"+theFile);
				jq.cookie("radioOnline", theFile, { path: '/', expires: 28 });
			} else {
				jq("#iconRadioCCB").show();
			} 
		}

	jq(document).ready( function() {
	
		loadRadioCCB();
		humanMsg.setup();
		
		jq('#signup_username').alphanumeric({nocaps:true}); 
		jq(".comment-reply-login, .bp-login a").click(function () { 
			var url = jq(this).attr("href");
			jq.prettyPhoto.open(url+"?iparent=true&iframe=true",'','');
			return false;
		});

		jq(".bibletag").click(function () { 
			var url = jq(this).attr("href");
			jq.prettyPhoto.open(url,'','');
			return false;
		});

		jq('div.meta_activity').click( function(event) {
			var target = jq(event.target);
			/* Favoriting activity stream items */

			if ( target.attr('class') == 'fav' || target.attr('class') == 'unfav' ) {
				var type = target.attr('class')
				var parent = target.parent().parent().parent();
				var parent_id = target.attr('rel');
				target.addClass('loading');
				jq.post( ajaxurl, {
					action: 'activity_mark_' + type,
					'cookie': encodeURIComponent(document.cookie),
					'id': parent_id
				},
				function(response) {
					target.removeClass('loading');
					target.fadeOut( 100, function() {
						jq(this).html(response);
						jq(this).fadeIn(100);
					});
					if ( 'fav' == type ) {
						if ( !jq('div.item-list-tabs li#activity-favorites').length )
							jq('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' (<span>0</span>)</a></li>');
						target.removeClass('fav');
						target.addClass('unfav');
						jq('div.item-list-tabs ul li#activity-favorites span').html( Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) + 1 );
					} else {
						target.removeClass('unfav');
						target.addClass('fav');
						jq('div.item-list-tabs ul li#activity-favorites span').html( Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) - 1 );
						if ( !Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) ) {
							if ( jq('div.item-list-tabs ul li#activity-favorites').hasClass('selected') )
								bp_activity_request( null, null );
							jq('div.item-list-tabs ul li#activity-favorites').remove();
						}
					}
				});
				return false;
			}
		});
		jq(".posthinario a").toggle(
		  function () {
			jq(this).append('<div class="posthino" id="imghinario"><img src="'+this.rel+'"></div>');
		  },
		  function () {
			jq(this).find('.posthino').remove();
		  }
		);

		jq("#activity-stream li").each(function(){
				jq(this).find("div.activity-meta").hide();
			jq(this).mouseenter(function() {
				jq(this).find("div.activity-meta").show();
			  }).mouseleave(function() {
				jq(this).find("div.activity-meta").hide();
			  });
		});

		jq(".activity-comments li").each(function(){
			jq(this).find("div.acomment-options").hide();
			jq(this).mouseenter(function() {
				jq(this).find("div.acomment-options").show();
			}).mouseleave(function() {
				jq(this).find("div.acomment-options").hide();
			});
		});

		jq("[title='date']").each(function(){
			jq(this).datepicker({
				dateFormat: 'dd/mm/yy',
				clearText: 'Limpar', clearStatus: '',
				closeText: 'Fechar', closeStatus: '',
				prevText: '&#x3c;Anterior', prevStatus: '',
				prevBigText: '&#x3c;&#x3c;', prevBigStatus: '',
				nextText: 'Pr&oacute;ximo&#x3e;', nextStatus: '',
				nextBigText: '&#x3e;&#x3e;', nextBigStatus: '',
				currentText: 'Hoje', currentStatus: '',
				monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho',
				'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
				monthStatus: '', yearStatus: '',
				weekHeader: 'Sm', weekStatus: '',
				dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sabado'],
				dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
				dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
				dayStatus: 'DD', dateStatus: 'D, M d',
				dateFormat: 'dd/mm/yy', firstDay: 0,
				initStatus: '', isRTL: false,
				showMonthAfterYear: false, yearSuffix: '',
				showButtonPanel: true
			});

			// Datepicker

			jq(this).datepicker({
				inline: true,
				showOn: 'button',
				buttonImage: 'images/calendar.gif',
				buttonImageOnly: true
			});
		});
});

	var params = {
	  allowscriptaccess: 'always',
	  allowfullscreen: 'true',
	  wmode: 'opaque'
	};

	var attributes = {};

	function replace_player(idmedia, url, player, install) {
		swfobject.embedSWF(
			player, 
			idmedia, 
			'600', 
			'24', 
			'9.0.0',
			install, 
			{file: url, lightcolor: '3388BB', autostart: 'true'}, 
			params, 
			attributes
		);
	}

	function countLines(strtocount, cols) {
	  var hard_lines = 1;
	  var last = 0;
	  while ( true ) {
	    last = strtocount.indexOf("\n", last+1);
	    hard_lines ++;
	    if ( last == -1 ) break;
	  }
	  var soft_lines = Math.round(strtocount.length / (cols-1));
	  var hard = eval("hard_lines  " + unescape("%3e") + "soft_lines;");
	  if ( hard ) soft_lines = hard_lines;
	  return soft_lines;
	}

	function cleanForm() {
	  for(var no=0;no<document.forms.length;no++){
	    var the_form = document.forms[no];
	    for( var x in the_form ) {
	      if ( ! the_form[x] ) continue;
	      if( typeof the_form[x].rows != "number" ) continue;
	      if(!the_form[x].onkeyup) {the_form[x].onkeyup=function()
	      {this.rows = countLines(this.value,this.cols)+1;};the_form[x].rows =
	      countLines(the_form[x].value,the_form[x].cols) +1;}
	    }
	  }
	}

	function addLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
	    window.onload = func;
	  } else {
	    window.onload = function() {
	      if (oldonload) {
	        oldonload();
	      }
	      func();
	    }
	  }
	}

	addLoadEvent(function() {
		cleanForm();
	});
	
/* ]]> */
