sf = function(form_id){
  var vf = $('#'+form_id);
  $.ajax({url: vf.attr('action'), type: vf.attr('method'), data: vf.serialize(), dataType: 'json', 
	success: function(r){ 
	if(!r.success)
	  $('#msg').html(r.msg);
	if(r.redirect)
	  window.location.href  = r.redirect;
}}
);
}

ssm = function(){
	$('.menu ul li').mouseover(function(){
		
	});
}

ts = function(s){
	var i = 1;
	$.each($(s+' .team_member'), function(k, e){
		$(e).attr('e', i);	
		if(i > 3)
			$(e).hide();		
		i++;
	});
	for(j = 1; j <= Math.ceil(i/3); j++)
		$(s).children(':last-child').prepend('<a id="botonGaleria" href="javascript:;" onclick="st(\''+s+'\', '+j+'); return false">'+j+'</a>');

}

st = function(s, t){
	$.each($(s+' .team_member'), function(k, e){
		if(Math.ceil((k+1)/3) == t)
			$(e).show();
		else
			$(e).hide();
	});
}

tm = function(m){
	$(m+" > div:not(:first)").hide(); 
	$(m+" ul li:first").addClass("active"); 

	$(m+" li a").click(function() {
		$(m+" li.active").removeClass("active");
		$(m+ ' > div:visible').hide(); 

		$(this).parents('li:first').addClass("active");
		$(m+' div#'+$(this).attr("id")).fadeIn(); //Fade in the active ID content
		return false;
	});
}

utt = function(){
	$('div.twitter-theader span').html($('#twitters div:visible').attr('title'));
}
fd = function(s, l){
  var m = [];
  if(l == 'en'){
    m = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
  }else{
    m = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'];
  }
  
  $(s).each(function(){
      var h = $(this).html();
      if(h.search(/\d{4}-\d{2}-\d{2}/) == 0){
	h = h.replace(/ [\d:]*/, '');
	h = h.split("-");
	$(this).html(m[h[1]-1]+' '+(h[2]*1)+', '+h[0]);

      }else if(h.search(/\w{3}, \d{2} \w{3} \d{4}/) == 0){
	h = h.replace(/\w{3}, (\d{2}) (\w{3}) (\d{4}).*/, '$2 $1, $3');
	$(this).html(h);
      }
    });
	
}

av = function(){
	$('div.footer').css({'position': 'relative'});
	var m = $(window).height() - $(document).height() + 61;
	if(m > 0)
		$('div.footer').css({'position': 'fixed', 'botom': '0px'});
}

iefixes = function(){
	if($.browser.msie){
		$('div.header').css('magin', 0);
		var colors	= ['#99AA1F', '#666818', '#87A282', '#547164', '#74C0AD', '#649386'];
		var i		= 0;
		var st		= { tl: { radius: 20 }, tr: { radius: 20 }, bl: { radius: 20 }, br: { radius: 0 }, antiAlias: true, autoPad: true, validTags: ["div"]};

		$('div.submenu1 > ul li').each(function(){$(this).css('background-color', colors[i%6]);i++;});
		i			= 0;
		$('div.submenu2 > ul li').each(function(){$(this).css('background-color', colors[i%6]);i++;});
		$('div.submenu1 > ul li, div.submenu2 > ul li').corner("top left 10px");
		$('div.main-header div.title').wrap('<div class="ib"></div>');
		$('div.main-header div.title div.ib').corner('sc:#87A282 top left 10px');
		$('div.nav-buttons a').corner('top left 5px');
		
	}
}

sh = function(l){
	var u = window.location.href;
	var t = $(document).attr('title');
	
	$('div.share a').each(function(k,v){
		var h = $(v).attr('href');
		h = h.replace('\{TITLE\}', t);
		h = h.replace('\{LINK\}', u); 
		$(v).attr('href', h);
	});
}

bk = function(){
  $("a.bookmark").click(function(){
      var bookmarkUrl = window.location.href;
      var bookmarkTitle = $(document).attr('title');
      
      if ($.browser.mozilla) // For Mozilla Firefox Bookmark
	{
	  window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
	}
      else if($.browser.msie || $.browser.webkit) // For IE Favorite
	{
	  window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
	}
      else if($.browser.opera ) // For Opera Browsers
	{
	  $("a.bookmark").attr("href",bookmarkUrl);
	  $("a.bookmark").attr("title",bookmarkTitle);
	  $("a.bookmark").attr("rel","sidebar");
	  $("a.bookmark").click();
	}
      else // for other browsers which does not support
	{
	  alert('Please hold CTRL+D and click the link to bookmark it in your browser.');
	}
      return false;
    });
}

