 function addBookmark(url,title) {
if (window.sidebar) { 
   window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
   window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
   return true;
}
}

function setHomepage()
{
if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(window.location.href);

   }
   else if (window.sidebar)
   {
   if(window.netscape)
   {
        try
    { 
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
          } 
        catch (e) 
        { 
     alert( "The operation was refused browser if you want to enable this feature, please enter in the address column of about: config, and then the item for the true value of signed.applets.codebase_principal_support" ); 
        }
   } 
   var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
   prefs.setCharPref('browser.startup.homepage',window.location.href);
}
}

 function pleaselogin() 
{alert('please login');
 document.location.replace('login.aspx'); 
} 

function playSound(src){
var _s = document.getElementById('snd');
if(src!='' && typeof src!=undefined){
_s.src = src;
}
}


 function SendMessage(info) 
{ window.open(info,"","width=680,height=490,left=120,top=50,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
} 

 function SendMessage2(info) 
{
	
	var div_bgObj=document.getElementById("div_bgObj");
	var div_msgObj=document.getElementById("div_msgObj");
	document.body.removeChild(div_bgObj); 
	document.body.removeChild(div_msgObj); 
		  document.getElementById('chat_msg').innerHTML='';
window.open(info,"","width=680,height=490,left=120,top=50,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
} 

function Search() 
{  var ProductID=document.getElementById("txtProductID").value; 

	XMLHttp.sendReq('GET', 'AjaxSearchProductID.aspx?id='+ProductID, '', Search_CallBack);
	
} 



function Search_CallBack(obj)
{ var msg=obj.responseText;
   if(msg=='no') alert('The product does not exist'); 
   if(msg=='error') alert('Please input a correct ID No');
    if(msg.substr(0,16)=='productview.aspx'){  document.getElementById("txtProductID").value='';
	document.location.replace(msg); 
	}
	}
	
   
function openbag(id) 
{ window.open("productinfo.aspx?ID="+id,"","width=650,height=630,left=220,top=50,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
} 

function opennew(url) 
{ window.open(url,"","width=650,height=630,left=220,top=50,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
} 


  function JHshNumberText()
  {    if(window.event.keyCode==13) Search();
   if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
   {
    window.event.keyCode = 0 ;
   }

  }
  
  	  
  function update()
  { // alert('111');
	   XMLHttp.sendReq('GET', 'chat/AjaxUpdateOnlineTime.aspx', '', Update_CallBack);
  }
	
	  
	  function Update_CallBack(obj)
	  { var msg=obj.responseText;
	    if(msg!='')
		 if(document.getElementById('chat_msg').innerHTML!=1)  
		  {document.getElementById('chat_msg').innerHTML=1;
		   if(msg=='type-invite'){alertWin('invite chat',document.getElementById('Invite_text').innerHTML,300,100);}
		     if(msg=='type-msg'){alertWin('new message',document.getElementById('msg_text').innerHTML,300,100);}
		   }
		 }
		  
		  function star()
		  {  //alert('111');
			 setInterval("update();",5000); 
			  }






function alertWin(title, msg, w, h){ 
	var titleheight = "22px"; // 提示窗口标题高度 
	var bordercolor = "#666699"; // 提示窗口的边框颜色 
	var titlecolor = "#FFFFFF"; // 提示窗口的标题颜色 
	var titlebgcolor = "#666699"; // 提示窗口的标题背景色
	var bgcolor = "#FFFFFF"; // 提示内容的背景色
	
	var iWidth = document.documentElement.clientWidth; 
	var iHeight = document.documentElement.clientHeight; 
	var bgObj = document.createElement("div"); 
	bgObj.id="div_bgObj";
	bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
	document.body.appendChild(bgObj); 
	
	var msgObj=document.createElement("div");
		msgObj.id="div_msgObj";
	msgObj.style.cssText = "position:absolute;font:11px 'Arial';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	document.body.appendChild(msgObj);
	
	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;";
	table.cellSpacing = 0;
	var tr = table.insertRow(-1);
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "width:100%;height:"+titleheight+"px;text-align:left;padding:3px;margin:0px;font:bold 13px 'Arial';color:"+titlecolor+";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
	titleBar.style.paddingLeft = "10px";
	titleBar.innerHTML = title;
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	
	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor;
	closeBtn.innerHTML = "<span style='font-size:15pt; color:"+titlecolor+";'> </span>";
	closeBtn.onclick = function(){ 
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 
	} 
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "font:10pt 'Arial';";
	msgBox.colSpan  = 2;
	msgBox.innerHTML = msg;
	
    // 获得事件Event对象，用于兼容IE和FireFox
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
} 