$(function(){ 
	$('#page').css('margin-left','-'+($('#page').width()/2)+'px');
	$('body').css('height',($('#page').height()+$('#top').height()+140)+'px');
	var url=String(window.location).substring(0,String(window.location).indexOf('.com/a/')+7);
	if ($('#flashMessage').length > 0){
		$("#flashMessage").slideToggle("slow");
		setTimeout('$("#flashMessage").slideToggle("slow");',3000);	
	}
	if ($('#authMessage').length > 0){
		$("#authMessage").slideToggle("slow");
		setTimeout('$("#authMessage").slideToggle("slow");',3000);	
	}
	try{
		$('#page').corner();
	}catch (err){}
	$('.cornerit').corner();
	
	$('#help').click(function(event){
		event.preventDefault();
		if ($('#ayuda').length == 0){
			$('<div id="ayuda"></div>').insertBefore('#page');
			$('#ayuda').addClass('containerPlus draggable resizable {buttons:\'m,c,i\', icon:\'help.png\', skin:\'white\', width:\'605\',iconized:\'false\', dock:\'help\',rememberMe:true, title:\'Centro de ayuda\'}');
			var _lau = $('body').width()/2 - 303;
			$('#ayuda').css({'top':'100px','left':_lau+'px'});
			$('#ayuda').html('<div class="no"><div class="ne"><div class="n">Ayuda</div></div><div class="o"><div class="e"><div class="c"><div class="mbcontainercontent">Cargando...</div></div></div></div><div><div class="so"><div class="se"><div class="s"> </div></div></div></div></div>');
			
			$(".containerPlus").buildContainers({
				containment:"document",
				elementsPath: url+"img/elements/",
				effectDuration:200,
				onLoad:function(o){
					//alert(o.attr("id"));
				},
				onClose:function(o){
					o.mb_removeCookie("closed");
					o.remove();
				}
			});
			var href=$(this).attr('href');
			
			$('#ayuda .mbcontainercontent').load(href+'/index/ajax', function(){
				$('#ayuda').mb_resizeTo(273, 605);
				$.getScript(url+"js/help.js", null);
			});
		}
	});
	$('#chatWebmaster').click(function(){
		if ($('#chatSupport').length==0){
			$('body').append('<div id="chatSupport"><!-- Beginning of meebo me widget code. Want to talk with visitors on your page? Go to http://www.meebome.com/ and get your widget! --> <object width="190" height="275" ><param name="movie" value="http://widget.meebo.com/mm.swf?uNKMvoioIr"/><embed src="http://widget.meebo.com/mm.swf?uNKMvoioIr" type="application/x-shockwave-flash" width="190" height="275"></embed></object></div>');
		}else{
			if ($('#chatSupport').is(':visible')){
				$('#chatSupport').hide();
			}else $('#chatSupport').show();
		}
	});
});

