﻿document.write('<input id="SKey" type="text" class="Search_frame" style="width: 400px;float: left;" value="输入需要搜索的关键字" onfocus="CheckKey();" onKeyDown="KeyEvent(event);" /><div id="test1"></div>');
function GoSearch() 
{ 
    var Name = document.getElementById('SKey').value;
    if(Name =="输入需要搜索的关键字"||Name=="")
	alert("请先输入搜索关键字");
    else
    {
        var searchType = '';
        var subSearchType = '';
        if(arguments.length==0)
        {
            searchType = GetArgsFromHref(location.href,"S");
            subSearchType= GetArgsFromHref(location.href,"SS");
        }
        else if(arguments.length==1)
        {
            searchType = arguments[0];
            subSearchType = GetArgsFromHref(location.href,"SS");
        }
        else
        {
            searchType = arguments[0];
            subSearchType = arguments[1];
        }
        location.href = "http://s.sky-fire.com/?Key="+escape(Name)+"&S="+searchType+"&SS="+subSearchType;
    }
}
//新的动画搜索
function NewVodSearch()
{
    var Name = document.getElementById('SKey').value;
    if(Name =="输入需要搜索的关键字"||Name=="")
	alert("请先输入搜索关键字");
    else
    {
        location.href = "search.asp?searchword="+escape(Name);
    }
}
function redirect(param,value)
{
    var key = GetArgsFromHref(window.location.href,param);
    //alert(key);
    var link;
    if(key!="") //参数不为空
    {
        var reg = new RegExp(param+"=(\\d+|[a-zA-Z*]|-1)","i");
        link = window.location.href.replace(reg,param+"="+value);
    }
    else
    {
        if(window.location.href.split("?")[0]==window.location.href) //URL未带任何参数
        {
            link = window.location.href+"?"+param+"="+value;
        }
        else link = window.location.href+"&"+param+"="+value;   
    }
    window.location.href = link.replace(/PageIndex=(\d+)/gi,"");
}
function KeyEvent(event)
{
    if (event.keyCode == 13)
    {
	if(typeof(dropDownList)!='undefined') 
	        GoSearch(0,dropDownList.GetSelectedItemIndex());
	else GoSearch();
    }
}
function CheckKey()
{
    if(document.getElementById('SKey').value=='输入需要搜索的关键字')
        document.getElementById('SKey').value='';
}
function GetArgsFromHref(sHref, sArgName) 
{ 
    var args = sHref.split("?"); 
    var retval = ""; 

    if(args[0] == sHref) /*参数为空*/ 
    { 
        return retval; /*无需做任何处理*/ 
    } 
    var str = args[1]; 
    args = str.split("&"); 
    for(var i = 0; i < args.length; i ++) 
    { 
        str = args[i]; 
        var arg = str.split("="); 
        if(arg.length <= 1) continue; 
        if(arg[0] == sArgName) retval = arg[1]; 
    } 
    return retval; 
}