$(function() {
	var hasfocus = false;
	var isbig = false;
	var theDelay = null;

	var focusfunc = function() {
		$("#search-panel-hd,#search-panel-hd input").stop();
		$("#search-panel-hd .top .left,#search-panel-hd .top .right,#search-panel-hd .bottom .left,#search-panel-hd .bottom .right").css('background-image','url(images/hd-search-bg-b.gif)');
		$('#search-panel-hd .top .center,#search-panel-hd .bottom .center').css('background-image','url(images/hd-search-bg-tb.gif)');
		$('#search-panel-hd .center .left,#search-panel-hd .center .right').css('background-image','url(images/hd-search-bg-lr.gif)');
		$("#search-panel-hd").animate({top:'18px'},'normal');
		$("#search-panel-hd .center .center").animate({padding:'5px'},'normal');
		$("#search-panel-hd .text").animate({height:'26px',width:'268px',paddingLeft:'1px',fontSize:'19px',backgroundPosition:'-100px'},'normal',
			function() {
				isbig=true;
			} );
		$("#search-panel-hd .button").animate({height:'30px',width:"60px"},'normal',function(){$("#search-panel-hd .button").css('border-width','0px');});
		return true;
	}
	
	var blurfunc = function() {
		isbig=false;
		$("#search-panel-hd,#search-panel-hd input").stop();		
		$("#search-panel-hd .center .center").animate({padding:'0px'},'normal');
		$("#search-panel-hd").animate({top:'30px'},'normal');
		$("#search-panel-hd .text").animate({height:'16px',width:'198px',paddingLeft:'20px',fontSize:'13px',backgroundPosition:'0px'},'normal',
			function()	{
				$("#search-panel-hd .top .left,#search-panel-hd .top .right,#search-panel-hd .bottom .left,#search-panel-hd .bottom .right").css('background-image','url(images/hd-search-bg.gif)');
				$('#search-panel-hd .top .center,#search-panel-hd .bottom .center').css('background-image','none');
				$('#search-panel-hd .center .left,#search-panel-hd .center .right').css('background-image','none');
			});
		$("#search-panel-hd .button").animate({height:'20px',width:"50px"},'normal');
		$("#search-panel-hd .button").css('border-width','1px');
		return true;
	}
	
	var checkfunc = function() {
		if (theDelay) {
			clearTimeout(theDelay);
			theDelay = null;
		}
		if (hasfocus!=isbig) {
			if (hasfocus) {
				focusfunc();
			} else {
				theDelay = setTimeout(blurfunc,300);
			}
		}
	}


	$("#search-panel-hd *").focus(
		function() {
			hasfocus = true;
			checkfunc();
		}
	);
	$("#search-panel-hd *").blur(
		function() {
			hasfocus = false;
			checkfunc();
		}
	);
	
	$("#verify_img").mouseover(
			function(){
				$(this).css("cursor", "pointer")
			}
	).click(
			function(){
				$(this).attr("src", "_check_num.php?t="+Math.random());
			}
	);
	
	$("#download-dll-btn").click(function(){
		var check_num = $("#check_num").val();
		if(check_num.length < 1){
			alert("Please Input the check_num");
			$("#check_num").focus();
			return false;
		}
		$("#download_form").submit();
		return false;
	});
});


