$(document).ready( function () {
	$("ul").addClass("hidden");
	time=new Date().getTime();
	
	$("div.mi, div.in").hover( function () {
		$(this).stop().animate({ width: "80%" }, "fast").css("border-style", "solid", "height", "290px");
		$(this).siblings("div").stop().animate({width: "19%"}, "fast");
		$(this).siblings("h1").css("background-color", "#D41889");
		$(this).children("div").children("ul.hidden").removeClass("hidden").addClass("showing");
		//time=new Date().getTime();
		//console.log("in time : " +time);
	}, function () {
		//outTime=new Date().getTime();
		//console.log("diff : " + (outTime-time));
		//if(outTime-time > 500){
			//console.log("outTime : "+outTime);
			$("ul.showing").removeClass("showing").addClass("hidden");
			$(this).css("border-style", "hidden");
		//};
	});
	
	$("div.mi3, div.in3, div.oh3").hover( function () {
		$(this).stop().animate({ width: "70%" }, "fast").css("border-style", "solid", "height", "290px");
		$(this).siblings("div").stop().animate({width: "14%"}, "fast");
		$(this).siblings("h1").css("background-color", "#D41889");
		$(this).children("div").children("ul.hidden").removeClass("hidden").addClass("showing");
		//time=new Date().getTime();
		//console.log(time);
	}, function () {
		//outTime=new Date().getTime();
		//console.log(outTime);
		//if(outTime-time > 200){
			$("ul.showing").removeClass("showing").addClass("hidden");
			$(this).css("border-style", "hidden");
		//};
	});
	
	$("div.product").mouseleave(function (){
		$(this).resetSliders($(this).children("div:eq(0)").attr("class"));
	});
	
	$("div.subProduct").hover( function (){
		$(this).children("h1.shortText").removeClass("shortText").addClass("overShortText");
	}, function (){
		$(this).children("h1.overShortText").removeClass("overShortText").addClass("shortText");
	});
	
	$("div.mi, div.in, div.subProduct").click( function () {
		window.location = $(this).attr("url");
		if(this.className == "subProduct") {
			$(this).children("h1.overShortText").removeClass("overShortText").addClass("shortText");
		} else {
			$(this).parent().resetSliders(this.className);	
		}
		return false;
	});
	
	$("li").hover( function (){
		$(this).animate({opacity:1}, "fast").css("background-color", "#D41889");
	}, function (){
		$(this).stop().animate({opacity: 0.8}, "fast").css("background-color", "#00a8d2");
	});
	
	$("ul li").click( function () {
		window.location = $(this).find("a").attr("href"); 
		$(this).stop().animate({opacity: 0.8}, "fast").css("background-color", "#00a8d2");
		$(this).parent().parent().parent().parent().resetSliders(this.className);
		return false;
	});
	
	$.fn.resetSliders = function (thisClass) {
		if(thisClass == "mi"){
			$(this).children("div").stop().animate({width: "49%"}, "fast").css("border-style", "hidden");
		} else {
			$(this).children("div").stop().animate({width: "32%" }, "fast").css("border-style", "hidden");
		};
		$(this).children("h1").css("background-color", "#00a8d2");
	}
});
