﻿$(document).ready(function(){
	$("#menu > ul > li > ul > li:first-child").addClass("fisrt");
	$("#menu > ul > li > ul > li:last-child").addClass("last");
	$("#menu > ul > li:last-child").addClass("last");
	
	$("#menu .slide").hover(function () {
		$("div", this).stop(true,true).slideDown('fast');
	},function () {
		$("div", this).stop(true,true).slideUp('fast');
	});

	$("#show").addClass("cur");
	$("#show").prev().css("background", "none");	


	$("#menu > ul > li").hover(function () {
		$("#menu > ul > li").removeAttr("style");
		$("#menu > ul > li").removeClass("cur");
		$(this).addClass("cur");
		$(this).prev().css("background", "none");
	}, function() {
		$("#menu .slide div").css({display: "none"});
		$(this).removeClass("cur");
		$(this).prev().removeAttr("style");
		$("#show").addClass("cur");
		$("#show").prev().css("background", "none");			
	});	
	

	var run = null;

	$(".aBox").hover(function () {
		var span = $("span", this);

		run = setInterval(function () {
			span.stop().slideDown();
			clearInterval(run);
		}, 500);		
		
	}, function () {
		clearInterval(run);
		$("span", this).stop().slideUp();
	});

	var animate = $("#animate li");	
	var tumSmall = $("#tumbnailsSmall li");	
	var tum = $("#tumbnails li");	
	
	if(animate.size() < 4)
	{
		animate.parent().parent().parent().find("> a").css({opacity: 0.5, cursor: "default"});
	}
	
	if(tumSmall.size() < 3)
	{
		tumSmall.parent().parent().parent().find("> a").css({opacity: 0.5, cursor: "default"});
	}
	
	if(tum.size() < 5)
	{
		tum.parent().parent().parent().find("> a").css({opacity: 0.5, cursor: "default"});
	}
});

function popImg(id)
{
	$("body").append('<div id="loading"></div>');

	var objImagePreloader = new Image();

	objImagePreloader.onload = function() {

		var w = objImagePreloader.width/2;
		var h = objImagePreloader.height/2;			
	
		$("#popImg .center span span").html('<img src="'+id+'" />');
		$("#popImg").css({marginTop: -h, marginLeft: -w});	

		$("#loading").remove();
		$("#popImg").fadeIn(100);
		
		objImagePreloader.onload=function(){};
	};
	objImagePreloader.src = id;

	
}

function iClose()
{
	$("#popImg").fadeOut(100);
}

