var aryDateLeft = [0,0,0,0];
var intSid = -1;
$(window).load(
	function()
	{
		var intLeft = parseInt($("#timer").find("input:eq(0)").val());
		aryDateLeft[0] = Math.floor(intLeft / (24 * 3600)) ;
		intLeft = intLeft - aryDateLeft[0] * 24 * 3600;
		aryDateLeft[1] = Math.floor( intLeft / (3600));
		intLeft = intLeft - aryDateLeft[1]  * 3600;
		aryDateLeft[2] = Math.floor( intLeft / (60));
		intLeft = intLeft - aryDateLeft[2]  * 60;
		aryDateLeft[3] = intLeft  ;
		
		$("#timer").find(".cssDay:eq(0)").find("div").html(aryDateLeft[0]);
		strA = aryDateLeft[1]+"";
		$("#timer").find(".cssHr:eq(0)").find("td:eq(0)").html(strA.length == 1 ? "0" : strA.substring(0,1));
		$("#timer").find(".cssHr:eq(0)").find("td:eq(1)").html(strA.length == 1 ? strA.substring(0,1) : strA.substring(2,1));
		strA = aryDateLeft[2]+"";
		$("#timer").find(".cssMin:eq(0)").find("td:eq(0)").html(strA.length == 1 ? "0" : strA.substring(0,1));
		$("#timer").find(".cssMin:eq(0)").find("td:eq(1)").html(strA.length == 1 ? strA.substring(0,1) : strA.substring(2,1));
		strA = aryDateLeft[3]+"";
		$("#timer").find(".cssSec:eq(0)").find("td:eq(0)").html(strA.length == 1 ? "0" : strA.substring(0,1));
		$("#timer").find(".cssSec:eq(0)").find("td:eq(1)").html(strA.length == 1 ? strA.substring(0,1) : strA.substring(2,1));
		
		//_typeface_js.initialize();
		//alert(_typeface_js.initialize());
		intSid = setInterval("jsCountDownNow()" , 1000 );
	}
);

function jsCountDownNow()
{
	aryDateLeft[3] = aryDateLeft[3] - 1;
	if (aryDateLeft[3] < 0)
	{
		aryDateLeft[2] = aryDateLeft[2] - 1;
		aryDateLeft[3] = 59;
		
		if (aryDateLeft[2] < 0 )
		{
			aryDateLeft[2] = 59 ;
			aryDateLeft[1] = aryDateLeft[1] - 1;
			
			if (aryDateLeft[1] < 0 )
			{
				aryDateLeft[1] = 23;
				aryDateLeft[0] = aryDateLeft[0] - 1;
				
				if (aryDateLeft[0] < 0  )
				{
					aryDateLeft[0] = 0;
					clearInterval(intSid);
				}
			}
		}
	}
	
	//.find("div")
	$("#timer").find(".cssDay:eq(0)").find("div:eq(0)").html(aryDateLeft[0]); //.html('<div class=" typeface-js" style="width:60px;color:#ffffff;font-size:55px;font-family:Arial;font-style:italic;">'+aryDateLeft[0]+"</div>");
	strA = aryDateLeft[1]+"";
	$("#timer").find(".cssHr:eq(0)").find("td:eq(0)").html(strA.length == 1 ? "0" : strA.substring(0,1));
	$("#timer").find(".cssHr:eq(0)").find("td:eq(1)").html(strA.length == 1 ? strA.substring(0,1) : strA.substring(2,1));
	strA = aryDateLeft[2]+"";
	$("#timer").find(".cssMin:eq(0)").find("td:eq(0)").html(strA.length == 1 ? "0" : strA.substring(0,1));
	$("#timer").find(".cssMin:eq(0)").find("td:eq(1)").html(strA.length == 1 ? strA.substring(0,1) : strA.substring(2,1));
	strA = aryDateLeft[3]+"";
	$("#timer").find(".cssSec:eq(0)").find("td:eq(0)").html(strA.length == 1 ? "0" : strA.substring(0,1));
	$("#timer").find(".cssSec:eq(0)").find("td:eq(1)").html(strA.length == 1 ? strA.substring(0,1) : strA.substring(2,1));
	//_typeface_js.initialize(); 
}

function funZoomIn()
{
	var objMask = $("<div class='cssMask' id='olMask'></div>");
	var objOLContent = $("<div class='cssOlContent' id='olContent'></div>");
	
	if ($("#olContent").length == 0 )
	{
		objMask.css('position' , 'absolute');
		objMask.css('top' , '0');
		objMask.css('left' , '0');
		objMask.css('z-index' , '2000');
		objMask.css('width' , $(window).width());
		objMask.css('height' , intOverallH);
		objMask.css("background" , "#000000");
		objMask.css("opacity" , "0.65");
		objMask.hide();
		
		
		objOLContent.hide();
		
		$("body").append(objMask);
		$("body").append(objOLContent);
	}
	else
	{
		objMask = $("#olMask");
		objOLContent = $("#olContent");
	}
	
	objMask.fadeIn("normal");
}

function funZoomOut()
{
	$("#olMask").fadeOut("normal" , function() { $("#olMask").remove() } );
	$("#olContent").fadeOut("normal" , function() { $("#olContent").remove() } );
}

function initNavMenu()
{
	$("#nav_bar").find(".cssMover").css("opacity" , 0);
	$("#nav_bar").find(".cssMover").css("height" , $("#nav_bar").find(".cssCore").height() + 30 );
	//alert($("#nav_bar").find(".cssCore:eq(0)").html() );
	//$("#nav_bar").find(".cssCore").css( "top" , 1 * ($("#nav_bar").find("ul").height() + 10) );
	$("#nav_bar").find(".cssMover").find("img:eq(0)").css("margin-left" , -237);
	
	$("#nav_bar").find(".cssCore").find("div").each(
			function()
			{
				//alert($(this).find("img").height());
				$(this).css("overflow" , "hidden");
				$(this).css("width" , "230");
				$(this).css("height" , $(this).find("img:eq(1)").height());
				
				$(this).find("img:eq(1)").css("position" , "relative");
				$(this).find("img:eq(1)").css("z-index" , 5);
				$(this).find("img:eq(1)").css("top" , -1 * $(this).find("img:eq(0)").height() );//+ ( $(this).find("img:eq(1)").height() - $(this).find("img:eq(0)").height()  ) / 2  );
				intH = $(this).find("img:eq(0)").height();
				$(this).find("img:eq(0)").css("width" , 0);
				$(this).find("img:eq(0)").css("height" , intH);
				
				$(this).find("img:eq(2)").css("position" , "relative");
				$(this).find("img:eq(2)").css("z-index" , 3);
				$(this).find("img:eq(2)").css("top" , -2 * $(this).find("img:eq(0)").height() );//+ ( $(this).find("img:eq(1)").height() - $(this).find("img:eq(0)").height()  ) / 2  );
				$(this).find("img:eq(2)").hide();
				//$(this).find("img:eq(2)").css("left" , 3);
				
				$(this).mouseenter(
					function()
					{
						$(this).stop();
						//alert("?");
						$(this).find("img:eq(0)").css("opacity" , 1);
						$(this).find("img:eq(0)").css("width" , 1);
						
						intH = $(this).find("img:eq(0)").height();
						$(this).find("img:eq(0)").animate(
							{
								width : 230,
								height: intH
							}
						);
						
					}
				);
				$(this).mouseleave(
					function()
					{
						$(this).stop();
						$(this).find("img:eq(0)").animate(
							{
									opacity : 0
							}
						);
							
					}
				);
			}
		);
	/*
	$("#nav_bar").find(".cssCore").find("div").each(
		function()
		{
			//alert($(this).find("img").height());
			$(this).css("height" , $(this).find("img").height());
			$(this).mouseover(
				function()
				{
					intT = ($(this).offset().top - $("#nav_bar").find(".cssCore").offset().top ) + 10;
					$("#nav_bar").find(".cssMover").css("opacity" , 1);
					
					$("#nav_bar").find(".cssMover").find("img:eq(0)").stop();
					$("#nav_bar").find(".cssMover").find("img:eq(0)").animate(
						{
							marginLeft : 0,
							marginTop : intT
						}
					);
					
				}
			);
		}
	);
	*/
}
