
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function switchImg(dir) {
    var $active = $('#slideshow SPAN.active');

    if ( $active.length == 0 ) $active = $('#slideshow SPAN:last');

    // use this to pull the images in the order they appear in the markup
    var $next;
		
		if (dir == 1) {
			$next =  $active.prev().length ? $active.prev()
        : $('#slideshow SPAN:last');
		}
		else {
			$next =  $active.next().length ? $active.next()
        : $('#slideshow SPAN:first');			
		}
				

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.hide().removeClass('active');
    $next.show().addClass('active');
		$("#subtext").html($next.attr("alt"));
		
		/*
		$active.addClass('last-active')
		.animate({opacity: 0.0}, 1000, function() {
		});
		//var w = ($next.width() > 745?745:$next.width());
		//$("#imgs").css("width", w + "px");
		//$("#block-slideshow").css("width", (w + 60) + "px");
		
    $next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
				$active.removeClass('active last-active');
				$("#subtext").html($next.attr("alt"));
		});
		*/
}
$(document).ready(function() {
	$("#arr_1").click(function() {
		$(this).attr("href", "javascript:void(0);");
		switchImg(1);
	});
	$("#arr_2").click(function() {
		$(this).attr("href", "javascript:void(0);");
		switchImg(2);
	});
	
	$("#arr_2_1").click(function() {
		$(this).attr("href", "javascript:void(0);");
		switchImg(1);
	});
	$("#arr_2_2").click(function() {
		$(this).attr("href", "javascript:void(0);");
		switchImg(2);
	});
	
	
	// for honepage iamge
	$("#img_home").css({opacity: 0.0})
		.animate({opacity: 1.0}, 1000, function() {
	});
		
	$("#nav_1, #nav_2").mouseover(function() {
		$("#sub" + $(this).attr("id")).show();							 
	});
	$("#nav_1, #nav_2").mouseout(function() {
		$("#sub" + $(this).attr("id")).hide();	
	});
	
	
	// for honepage iamge
	$(".join").unbind('click').bind('click', function() {
		$("#subscribe").show();
		$("#subscribe_email").focus();
	});

	$('#btn_subscribe').unbind('click').bind('click', function() {
		$(this).attr('href', 'javascript:void(0)');
		$.get("ajax/subscribe.php?email=" + $('#subscribe_email').val(), function(data) {
			$('#subscribe').html(data);
			return false;
		});
	});
	
	//$('#slideshowHolder').jqFancyTransitions({ width: 1024, height: 469, effect: 'curtain', direction: 'left' });
	
	$('#slideshowHolder').cycle({
		fx: 'scrollRight',
		timeout: 5000
	})
	
});
