String.prototype.trim=function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function isNumber(obj)
{if(isNaN(obj.value)){alert('只能输入数字！');obj.value=''}}
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}

//------------------------------------------------------------------------------------------
var Request = new Object();
Request.reqList = [];
function getAjax()
{
    var ajax=false; 
    try 
    { 
     ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
    } 
    catch (e)
     { 
      try 
      { 
      ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
      } 
     catch (E)
      { 
      ajax = false; 
      } 
    }
    if (!ajax && typeof XMLHttpRequest!='undefined') 
    { 
     ajax = new XMLHttpRequest(); 
    } 
    return ajax;
}
Request.send = function(url, method, callback, data, urlencoded, callback2)
 { 
    var req=getAjax();  
    req.onreadystatechange = function() 
    {
    if (req.readyState == 4) 
    {
			if (req.status < 400) 
			{
			if(callback)
				callback(req,data);
			} 
			// 当请求返回错误
			else 
			{
				alert("当加载数据时发生错误 :\n" + req.status+ "/" + req.statusText);
				if (callback2) 
				callback2(req,data);
			}
			afterLoading();
			try {
				delete req;
				req = null;
			} catch (e) {}
		}
	}
	if (method=="POST")
	 {
		req.open("POST", url, true);
		if (urlencoded) 
		    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');		
		req.send(data);
		Request.reqList.push(req);
	}
	 else 
	{
		req.open("GET", url, true);
		req.send(null);
		Request.reqList.push(req);
	}
	loading();	
	return req;
}
Request.clearReqList = function() 
{
	var ln = Request.reqList.length;
	for (var i=0; i<ln; i++) {
		var req = Request.reqList[i];
		if (req) 
		{
		try 
		{
			delete req;
		} catch(e) {}
		}
	}
	Request.reqList = [];
}
Request.sendPOST = function(url, data, callback, clear, callback2) 
{
	if (clear)
		Request.clearReqList();
	Request.send(url, "POST", callback, data, true, callback2);
}
Request.sendGET = function(url, callback, args, clear, callback2) 
{
	if (clear)
		Request.clearReqList();
	return Request.send(url, "GET", callback, args, false, callback2);
}
function loading()
{
var div = $("loadingflag");
if(div)
div.style.display ="";
setTimeout(afterLoading,5000);
}
function afterLoading()
{
var div = $("loadingflag");
if(div)
div.style.display ="none";
}
 
//menu
var timer
function s_out(){
	var posSel=$("head1Sel").style.display;
	if(posSel=="block"){
		timer = setTimeout("drop_hide('head1')", 1000);
	}
}
function s_over(){
	try{window.clearTimeout(timer);}catch(e){}
}
function s_show(st1,href1){
	$("s_cateID").value=st1;
    $("head1Sel").style.display="none";
    $("head1Slected").innerHTML=href1.innerHTML;
    $("keyword").focus();
	try{window.clearTimeout(timer);}catch(e){}
	return false;
}
function s_click()
{if($('head1Sel').style.display=='none'){$('head1Sel').style.display='block';}else {$('head1Sel').style.display='none';};return false;}

//站点头部搜索
function fEvent(sType,oInput){
  switch (sType){
   case "focus" :
    oInput.isfocus = true;
   case "mouseover" :
    oInput.style.borderColor = '#9ecc00';
    break;
   case "blur" :
    oInput.isfocus = false;
   case "mouseout" :
    if(!oInput.isfocus){
     oInput.style.borderColor='#84a1bd';
    }
    break;
  }
 }
