﻿$(function() {
    var image = $('.image:first').attr("rel");
    $("#image_inner").html('<img    height="412px" width="680px" src="' + image + '" />');
    $(".image").click(function() {
        clearInterval(stop_interval);
        $("#image_inner").stop();
        var image = $(this).attr("rel");
        $("#image_inner").animate({ opacity: "0.0" }, 300, function() {
            $("#image_inner").html('<img    height="412px" width="680px" src="' + image + '" />');
        });
        $("#image_inner").animate({ opacity: "1.0" }, 300);

        $(".image").removeClass('active last-active');
        $(this).addClass('active');
        
        return false;
    });
    $(".image").click(function() {
        return false;
    });
});

function slideSwitch() {
    var $active = $('.gallery_images a.active');
    if ($active.length == 0) $active = $('.gallery_images a:last');
    var $next = $active.next().length ? $active.next()
        : $('.gallery_images a:first');
    $active.addClass('last-active');
    $next.addClass('active');
    $active.removeClass('active last-active');
    var image = $next.attr("rel");
    $("#image_inner").addClass('active').animate({ opacity: "0.0" }, 1000, function() {
    $("#image_inner").html('<img    height="412px" width="680px"  src="' + image + '" />');
        $active.removeClass('active last-active');
    });
    $("#image_inner").animate({ opacity: "1.0" }, 1000);
}

$(function() {
    //preload images
    $(".gallery_images a").each(
		function(intIndex) {
		    jQuery("<img>").attr("src", $(this).attr("rel"));
		}
	);

    var $first = $('.gallery_images a:first');
    $first.addClass('active');
    stop_interval = setInterval("slideSwitch()", 4000);

    

    $("#slide_left").click(function() {
        clearInterval(stop_interval);
        var $active = $('.gallery_images a.active');
        if ($active.length == 0) $active = $('.gallery_images a:last');
        var $next = $active.next().length ? $active.next()
            : $('.gallery_images a:first');
        $active.addClass('last-active');
        $next.addClass('active');
        $active.removeClass('active last-active');
        var image = $next.attr("rel");
        $("#image_inner").addClass('active').animate({ opacity: "0.0" }, 1000, function() {
            $("#image_inner").html('<img   height="412px" width="680px"  src="' + image + '" />');
            $active.removeClass('active last-active');
        });
        $("#image_inner").animate({ opacity: "1.0" }, 1000);
        return false;
    });

    $("#slide_right").click(function() {
        clearInterval(stop_interval);
        var $active = $('.gallery_images a.active');
        if ($active.length == 0) $active = $('.gallery_images a:first');
        var $next = $active.prev().length ? $active.prev()
            : $('.gallery_images a:last');
        $active.addClass('last-active');
        $next.addClass('active');
        $active.removeClass('active last-active');
        var image = $next.attr("rel");
        
        $("#image_inner").addClass('active').animate({ opacity: "0.0" }, 1000, function() {
            $("#image_inner").html('<img   height="412px" width="680px"  src="' + image + '" />');
            $active.removeClass('active last-active');
        });
        $("#image_inner").animate({ opacity: "1.0" }, 1000);
        return false;
    });

});

$(document).ready(function() {
	$("#header_menu ul ").addClass('dropdown');
	
});

function displayHTML(printContent) {
var inf = printContent;
win = window.open("print.htm", 'popup', 'toolbar = no, status = no');
win.document.write(inf);
win.document.close();
} 
