function search_in_site() {
    var url = "";
    var keyword = document.all("keyword").value;
	var searchInSiteType = document.all("searchInSiteType").value;
	if (searchInSiteType == "WAREHOUSE")
		url = "../../product/web/product_list.aspx?keyword=" + keyword;
	else if (searchInSiteType == "NEWS")
		url = "../../news/web/news_list.aspx?keyword=" + keyword;
	else {
	   search_other_in_page();
	}
	
	if (url != "")
		document.location.href = url;
}

// 增加下载统计
function tbwh_add_download(warehouseID) { 	 
  if (warehouseID == null || warehouseID == undefined || warehouseID == "" || warehouseID == "0") {
	 return;
  }
  else {
  　var xmlIn = '<ReqAgents><ReqAgent Method="TbwhReqAgent.AddTbwhDownload" ResultNode="Result"><Params>';
	xmlIn = xmlIn + '<WarehouseID>' + warehouseID + '</WarehouseID>';
	xmlIn = xmlIn + '</Params></ReqAgent></ReqAgents>';	
	var result = SendReqAgent(xmlIn);
	//alertReqAgent(result,"heheh!");
  }
}

// 增加下载统计。toolbar_add_download也增加到warehouse中
function toolbar_add_download(toolbarID) {   
  if (toolbarID == null || toolbarID == undefined || toolbarID == "" || toolbarID == "0") {
	 return;
  }
  else {
  　var xmlIn = '<ReqAgents><ReqAgent Method="TbwhReqAgent.AddToolbarDownload" ResultNode="Result"><Params>';
	xmlIn = xmlIn + '<ToolbarID>' + toolbarID + '</ToolbarID>';
	xmlIn = xmlIn + '</Params></ReqAgent></ReqAgents>';	
	var result = SendReqAgent(xmlIn);
	//alert(result);
	//alertReqAgent(result,"heheh!");
  }
}

// qq联系
function qq_contact(qqno) {
	if (qqno == null || qqno == undefined)
		qqno = "630521691";
	window.open("http://wpa.qq.com/msgrd?V=1&Uin=" + qqno + "&Site=http://www.ieshow.net&Menu=yes");
}

// msn联系
function msn_contact(address) {
   if (address == null || address == undefined)
		address = "msn@ieshow.net";
   try
   {
      MsgrObj.codetype="application/x-oleobject";
      MsgrObj.classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28";
   }
   catch(e)
   {
      alert("请您在MSN中手动添加" + address);
      return;
   } 

   if(MsgrObj.MyStatus == 1)
   {
      alert('您的MSN没有登陆，请先登陆');
   }
   else if(MsgrObj.MyStatus == 2 || MsgrObj.MyStatus == 10 || MsgrObj.MyStatus == 14 || MsgrObj.MyStatus == 34 || MsgrObj.MyStatus == 50 || MsgrObj.MyStatus == 66 || MsgrObj.MyStatus == 6)
   {
      MsgrObj.InstantMessage(address);
   }
   else if (MsgrObj.MyStatus == 512 || MsgrObj.MyStatus == 768)
   {
      alert('您的MSN正在登陆，请稍等...');
   }
   else 
   {
      alert("请您在MSN中手动添加" + address);
   }
}


//cross platform function for getting the scroll width of the page
function getScrollWidth()
{
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
           
   return w ? w : 0;
} 

//cross platform function for getting the scroll height of the page
function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}

function HideComponentBySpanID(spnID)
{
	
	// if the spnID display is 'none' it will be null and we dont need to do any work here
	if (document.all[spnID] != null)
	{
		
		var eventX = window.event.x+getScrollWidth();
		var eventY = window.event.y+getScrollHeight();
	
		var pos = GetElementPosition(spnID);
		
		pos.top+=2;//the mouseout even fires too soon and we aren't really out yet so add some padding
		pos.left+=2;//the mouseout even fires too soon and we aren't really out yet so add some padding
	
		var right = pos.left + document.all[spnID].offsetWidth;
		var bottom = pos.top + document.all[spnID].offsetHeight;
		
		
		// If the mouse is out of the actions (the span) we hide it
		if (!(( eventX > pos.left && eventX < right ) && ( eventY > pos.top && eventY < bottom )))
		{				
			document.all[spnID].style.display	= "none";
			//document.getElementById("tdDelete").onclick = "";
		}
	}	
}


function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
	return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
	return "";
	}
	else{
	return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
	return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(0,iTemp +1);
	break;
	}
	iTemp = iTemp-1;

	} //End While
	return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(iTemp,v_length);
	break;
	}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function



function GetElementBySubID(objParent, id)
{	
	var retVal = null;
	
	for (var i=0; i<objParent.all.length; i++)
	{
		if (objParent.all[i].id.indexOf(id) >= 0)
		{
			retVal = objParent.all[i];
			break;
		}
	}
	return retVal;
}

function GetElementPosition(elemID) 
{    
	var counter = 0;
	
	var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) 
    {
	
		offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
        counter ++;
    }
   
    return {left:offsetLeft, top:offsetTop};
}

/*-- 进度条 --*/
function ShowMakerProgress()
{
	try
	{   
		whichbar=1;
		var i;					
		var uploadGif	= document.all("UploadProgress");
			
		uploadGif.style.display = "";			
		uploadGif.style.display		= "inline";				
		setTimeout("doPrg()", 250);		
	}
	catch(er)
	{		
	}	
}

/*-- 进度条 --*/
function ShowUploadProgressWithID(id)
{
	if (typeof id == 'undefined')	
		var id=-1;
	try
	{
		var isOK = true;//Page_ClientValidate();
		//isOK = Page_ClientValidate();
	
		var btnSave = document.all("btnNext");	
		var btnBack = document.all("btnPreviod");
		if (btnSave	==	null)
		{			
			btnSave =	document.all("btnFinish");
			btnBack	=	document.all("btnPreviod");
			if (btnSave	!=	null)
			{			
				btnBack.style.display ="none";
			}
		}
		
		var i;
		if (isOK)
		{			
			var uploadGif	= document.all("UploadProgress");	
			var pos			= GetElementPosition(event.srcElement.id);
			
			uploadGif.style.display = "";
			btnSave.style.display ="none";
			if (btnBack != null && btnBack != undefined)	
				btnBack.style.display ="none";
			
			if (id.indexOf("btnNext") != -1)
			{
				uploadGif.style.left		= pos.left - 100;
			}
			else
			{
				uploadGif.style.left		= pos.left - 150;
			}
			alert(pos.top);
			uploadGif.style.top			= pos.top - 20;
			uploadGif.style.display		= "inline";			
			
			setTimeout("doPrg()", 250);
		}
	}
	catch(er)
	{		
	}	
}

var whichbar=1;
function doPrg()
{		
	if(whichbar >= 0 && whichbar < 15 ) {
		var imgid = "prog" + whichbar;
		if (document.all["prog1"].length > 1)
		{		
			return;
		}
		if (whichbar == 1)
		{
			document.all["prog14" ].style.display = 'none';
			document.all["prog1"].style.display = 'inline';
		}
		else
		{
			document.all[imgid].style.display = 'inline'
			document.all["prog" +(whichbar -1 )].style.display = 'none'
		}		
		setTimeout("doPrg()", 250)
		whichbar ++;		
	}
	else if (whichbar != -1)
	{
	  	whichbar =1
	  	for (var i =1 ; i < 15 ; i++ ){
	  		document.all["prog"+i].style.display = 'none'
	  	}
	  	setTimeout("doPrg()", 250)
	}	
}

function StopProgress() {
	whichbar = -1;
}
