﻿$(function(){
        $('#img_search').hover(
            function(){
                $(this).css({cursor:"pointer"});
            },
            function(){
                $(this).css({cursor:"default"});
            }
        );
        $('#txtkey').bind('mousedown',function(){
            if($('#txtkey').val()=='关键字'){
                   $(this).val('');
            }
            else{
                $(this).select();
            }
        });
        $('#txtkey,#txt_search').bind('blur',function(){
            if($('#txtkey').val()==''){
                   $('#txtkey').val('关键字');
            }
            if($('#txt_search').val()==''){
                   $('#txt_search').val('关键字');
            }
        });
        $('#img_search').click(
            function(){
                if($('#txtkey').val()!='' && $('#txtkey').val()!='关键字'){
                    if($('#txtkey').val().length<=20){
                        window.location.href=domain+'search.aspx?key='+encodeURIComponent($('#txtkey').val())+"&page=1";
                    }else{
                        alert('关键字过长，无法完成您的请求');
                    }
                }else{
                    $('#txtkey').focus();
                }
            }
        );
        $('#btn_search').click(
            function(){
                if($('#txt_search').val()!='' && $('#txt_search').val()!='关键字'){
                    if($('#txt_search').val().length<=20){
                        window.location.href=domain+'search.aspx?key='+encodeURIComponent($('#txt_search').val())+"&page=1";
                    }else{
                        alert('关键字过长，无法完成您的请求');
                    }
                }else{
                    $('#txt_search').focus();
                }
            }
        );
        $('#txtkey').keydown(function(){
            if(window.event.keyCode==13){
                if($('#txtkey').val()!='' && $('#txtkey').val()!='关键字'){
                        if($('#txtkey').val().length<=20){
                            window.location.href=domain+'search.aspx?key='+encodeURIComponent($('#txtkey').val())+"&page=1";
                        }else{
                            alert('关键字过长，无法完成您的请求');
                        }
                    }else{
                        $('#txtkey').focus();
                        return;
                }
            }else return;
        });
        $.ajax(
            {
                type:'GET',
                url:domain+"count/count.ashx",
                cache:false,
                success:function(e){
                    if(e.indexOf("-")>0)
                    {
                        var ee='今日访问量：'+e.split('-')[0]+'&nbsp;昨日访问量：'+e.split('-')[1]+'&nbsp;总访问量：'+e.split('-')[2];
                        $('#sitecount').html(ee);
                        if(e.split('-')[3]==1)
                        {
                            if(window.location.href==domain || window.location.href.indexOf('index.aspx')>0)
                            {
                                //window.open(domain+'account.aspx',300,400);
                            }
                        }
                    }
                }
            }
        );
    });


