﻿// JScript 文件
    function $(id) {
	                                                       return document.getElementById(id);
                                                         }
function  subcontent()
{
       if(document.getElementById('TxtContent').value.length > 90)
       {
            document.getElementById('TxtContent').value =document.getElementById('TxtContent').value.substring(0,90);
       }
}
  function response(url){
	var xmlObj = null;
	if(window.XMLHttpRequest)
	{
		xmlObj = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		return;
	}
	xmlObj.onreadystatechange = function ()
	{
		if(xmlObj.readyState == "4")
		{		    
		  processXML(xmlObj.responseText);
		}
	} 
	xmlObj.open("post",url,true);
	xmlObj.send("");
}

function lm(userid,content,infoid)
{
  	url = "/LeaveMessage.aspx?userid=" +userid + "&content=" +content + "&infoid=" + infoid + "&type=mes";
	response(url);
}

function processXML(text)
{	
    document.getElementById("TxtContent").value = '';
    document.getElementById('LeaveMessagediv').innerHTML =text;
   if(ok) 
    document.getElementById("postSUC").style.display = '';
} 
 function addfavorite(InfoID)
 {
    if(/^\d+$/.test(InfoID))
    {
      url = "/Ajax.aspx?InfoID=" +InfoID + "&action=Collect";
      ResponseFavorite(url);
    }
    else
    {
        if (document.all)
         {
           window.external.addFavorite(location.href,'手递手网-'+InfoID);
         }
         else if (window.sidebar)
         {
           window.sidebar.addPanel('手递手网-'+InfoID, location.href,"");
         }
    }
 }
   function ResponseFavorite(url){
	var xmlObj = null;
	if(window.XMLHttpRequest)
	{
		xmlObj = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		return;
	}
	xmlObj.onreadystatechange = function ()
	{
		if(xmlObj.readyState == "4")
		{		    
		  processXMLFavorite(xmlObj.responseText);
		}
	} 
	xmlObj.open("post",url,true);
	xmlObj.send("");
}
function processXMLFavorite(text)
{	
      var url = window.location;
      if(text == "True")
      {
        document.getElementById('MyCollect').innerHTML ='信息已收藏';   
      }
       if(text == "notLogin")
      {
         var back = '请先<a href =\'http://my.hand2hand.cn/users/login.vhtml?reurl=' + url + '\'>登陆</a>';
         document.getElementById('MyCollect').innerHTML =   back;
      } 
       if(text == "HadHave")
      {
       document.getElementById('MyCollect').innerHTML ='信息已收藏';   
      }     
} 
