$(document).ready(function() {
//all hover and click logic for buttons

function pulsate() {
	$(".top_text").
    animate({opacity: 0.1}, 5000, 'linear').
    animate({opacity: 0.5}, 5000, 'linear', pulsate);
  }
  pulsate();
	
	$(".fg-button:not(.ui-state-disabled)")
		.hover(
			function(){ 
				$(this).addClass("ui-state-hover"); 
			},
			function(){ 
				$(this).removeClass("ui-state-hover"); 
			}
		)
		.mousedown(function(){
				$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
				if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
				else { $(this).addClass("ui-state-active"); }	
		})
		.mouseup(function(){
			if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
				$(this).removeClass("ui-state-active");
			}
		});
		
		
		
		
		$(".shadoww").dropShadow({left: -1, top: 1, blur: 2, opacity: 0.9, color: "black"});

				$("a[rel=view_G]").fancybox({
				'scrolling'		: 'no',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.6,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
				$("a[rel=view_G2]").fancybox({
				'scrolling'		: 'no',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.6,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
	
	$("#login_button").fancybox({
		'type'			: 'inline',
		'content'		: '#login_form',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.6,
		'padding'		: 0,
		'scrolling'		: 'no',
		'titleShow'		: false,
		'onClosed'		: function() {
			$("#login_error").hide();
		}
	});
	
	$('.tipp').tipsy({fade: true});
	
	
	$("#login_form").bind("submit", function() {

	if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) {
	    $("#login_error").show();
	    $.fancybox.resize();
	    return false;
	}

	$.fancybox.showActivity();

var post = $("#login").serialize();    

$.post("login.php", post, function(data) { 
    $.fancybox(data);
	setTimeout("document.location.href='index.php'",2500);
});

/*
	$.ajax({
		type		: "POST",
		url		: "login.php",
		
		//data		: $(this).serializeArray(),
data : data,
		success: function(data) {
			
			$.fancybox(data);
			//setTimeout("document.location.href='index.php'",2500);
		}
	});
*/

	return false;
});
	
	
	
	$(".btn-slide").click(function(){
		$("#panel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	
	$('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        random: 1,
        delay:  8000
	});
	
});



function loadit($what) 	{
document.location.href=($what);
}


function slid($wh)	{
/*	$("html").animate({ scrollTop: $wh }, 1500);*/

	
		  $('html').animate({
			scrollTop: $wh
		  }, {
			duration: 1800, 
			specialEasing: {
			  width: 'linear',
			  height: 'easeOutBounce'
			}, 
			complete: function() {
			  //alert("A");
			}
		  });
	


	}
