// JavaScript Document
$(document).ready(function(){
	
	/* Navigation */
	$("#nav ul ul").each(function(i){ $(this).hide().css('top', '34px'); });
	$("#nav ul li:last-child").addClass('last');
	$("#nav ul li").hover(
		function(){
			$(this).addClass('activesub');
			$('ul', this).show(); 
			//$('ul', this).stop(true, true).slideDown('fast');
		},
		function(){
			$(this).removeClass('activesub');
			$('ul', this).hide();
			//$('ul', this).stop(true, true).slideUp('fast');
		}
	);
	
	/* thumbs rollover */
	
	if($("#thumbs").length > 0 ){
		/*
		$('.thumbs .thumb').hover(
			function(){ //mouseover   
				$(this).animate({backgroundColor: "#009CE4"}, 500);   
			},
			function(){  
				$(this).animate({backgroundColor: "#ffffff"}, 300);   
			}
		);
		*/
		$("div#flist a").fancybox({
			'overlayShow':	true
		});
	}
	
	
	/* login to mybuffalo */ 
	if($('#mblogin').length > 0 ){
		$('#mblogin').ajaxForm(function(response){							
			if(response.indexOf('error') == -1){
				window.location=response;
			}else{
				$('#fb_ins').html(response);
				$('#fb').show();	
				$('#submit').show();
			}
			
			return false; 
		});
	}
	
	/* reg to mybuffalo */ 
	if($('#mbreg').length > 0 ){
		$('#mbreg').ajaxForm(function(response){							
			if(response.indexOf('error') == -1){
				$('#fb_ins').html(response);
				$('#fb').show();	
				$('#submit').show();
			}else{
				$('#fb_ins').html(response);
				$('#fb').show();	
				$('#submit').show();
			}
			
			return false; 
		});
	}
	
	
	/* userup to mybuffalo */ 
	if($('#mbuser').length > 0 ){
		$('#mbuser').ajaxForm(function(response){							
			$('#fb_ins').html(response);
			$('#fb').show();	
			$('#submit').show();
			return false; 
		});
	}
	
	
	
	
	

	


}); //ends doc.ready


function show_mb_register(url){
	$.ajax({
	   url: url+'/'+Math.floor(Math.random()*11111),
	   success: function(msg){
			$('#mb_login_div').html(msg);
	   }
	 });
	return false;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=650,height=600');");
}

