function XmlHttpPost(url)
{
	var xmlHttp = new xmlHTTP();
	xmlHttp.Open("GET",url,true);
	xmlHttp.onreadystatechange = function ()
			{
				if(xmlHttp.ReadyState == 4)
				{
					var isOnline =  xmlHttp.responseText.split(';');
					for(i=0;i<isOnline.length;i++)
					{	
						var bftbImg = isOnline[i] == "false"? "http://pro.bfjieju.com/images/detail/MI2.gif" : "http://pro.bfjieju.com/images/detail/MI.gif";

						var layerData = "<img alt='百方通宝IM' src="+bftbImg+" width=42 height=33 border=0 style='cursor:hand' onclick=javascript:chatbyIM('"+id+"') />";	
						if(imgLyer != null)
							document.getElementById(imgLyer).innerHTML = document.getElementById(imgLyer+"_").innerHTML = layerData;
					}
				}
				else
				{
					document.getElementById(imgLyer).innerHTML = document.getElementById(imgLyer+"_").innerHTML="<img src=http://www.bfjieju.com/byfIM/images/default.gif alt=正在获取在线状态>";
				}
			}
	xmlHttp.Send(null);
}

var id = "";
var imgLyer = "";

function imImage(id,imgLayer)
{	 
	this.imgLyer = imgLayer;
	this.id = id;
	XmlHttpPost("/IsOnline.aspx?id=" + id + "&" + Math.random() );
}

function getComData(userName,type,v)
{	
	var xmlHttp = new xmlHTTP();
	var url = "/detailData.aspx?v="+v+"&type="+ type +"&userName=" + userName + "&" + Math.random();
	xmlHttp.Open("GET",url,true);
	xmlHttp.onreadystatechange = function()
			{	
				if(xmlHttp.ReadyState == 4)
				{	
					var comData = document.getElementById("comData");	
					var datas = xmlHttp.responseXML.getElementsByTagName("xml");
					if(v=="1")
						document.getElementById("vipYear").innerHTML = datas[0].getElementsByTagName("vtime")[0].getAttribute('time');
					if( datas[0].getAttribute('result') == "ok" )
					{		
						var id , pic , time , title , url;
						var data = "<table width=90% height=263 border=0 align=center cellpadding=0 cellspacing=0>"
								+"<tr><td width=3 background=http://pro.bfjieju.com/images/detail/bj_left.gif></td>"
								+"<td valign=top><table width=100% height=6 border=0 align=center cellpadding=0 cellspacing=0>"
								+"<tr><td background=http://pro.bfjieju.com/images/detail/bb_pic4_2.gif></td></tr></table>"
								+"<table width=100% height=212 border=0 cellpadding=0 cellspacing=0> <tr>"
								+"<td align=center valign=top background=http://pro.bfjieju.com/images/detail/bb_pic5.gif>"
								+"<table width=100% height=26 border=0 cellpadding=0 cellspacing=0><tr>"
								+"<td width=28 align=center><img src=http://pro.bfjieju.com/images/detail/jt.gif width=11 height=10 /></td>"
								+"<td width=800 align=left>掌柜推荐</td></tr></table><table width=100% height=186 border=0>"
								+"<tr><td align=center><table width=100% border=0 cellpadding=0 cellspacing=0><tr>";
					/*	var data = "<table width=90% height=263 border=0 align=center cellpadding=0 cellspacing=0>"
							+"<tr><td width=3 background=http://pro.bfjieju.com/images/detail/bj_left.gif></td>"
							+"<td valign=top><table width=100% height=6 border=0 align=center cellpadding=0 cellspacing=0>"
							+"<tr><td background=http://pro.bfjieju.com/images/detail/bb_pic4_2.gif></td></tr></table>"
							+"<table width=100% height=212 border=0 cellpadding=0 cellspacing=0><tr>"
							+"<td align=center valign=middle background=http://pro.bfjieju.com/images/detail/bb_pic5.gif><table width=100% height=26 border=0 cellpadding=0 cellspacing=0>"
							+"<tr><td width=28 align=center><img src=http://pro.bfjieju.com/images/detail/jt.gif width=11 height=10/></td>"
							+"<td width=800 align=left>掌柜精品推荐</td></tr></table><table width=100% border=0 cellspacing=0 cellpadding=0><tr>";
					*/	for( var i =0 ; i < datas[0].getElementsByTagName('row').length ; i ++)
						{	
							id=datas[0].childNodes[i].childNodes[0].childNodes[0].nodeValue;
							pic=datas[0].childNodes[i].childNodes[1].childNodes[0].nodeValue;
							time=datas[0].childNodes[i].childNodes[2].childNodes[0].nodeValue;
							title=datas[0].childNodes[i].childNodes[3].childNodes[0].nodeValue; 
						
							url = getURL(id,time,type);  
											
							data += "<td width=173 align=center><a href="+url+" target=_blank><img src="+getPic(id,pic)+" width=100 height=100 border=0 /></a><br /><br />"
					    		+"<a href="+url+" target=_blank class=blue_12>"+title+"</a><br />";	
					    }		
					    
						data += "</tr></table></td></tr></table></td></tr></table>"		
							+"<table width=100% height=45 border=0 cellpadding=0 cellspacing=0><tr>"
							+"<td align=center valign=middle background=http://pro.bfjieju.com/images/detail/gj_01.gif><table width=100% border=0 cellpadding=0 cellspacing=0>"
							+"<tr><td width=490 align=right>挑选更多&gt;&gt;</td><td align=left>"
							+"<a href=http://b2b.bfjieju.com/company/"+userName+"/samplelist.shtml target=_blank><img src=http://pro.bfjieju.com/images/detail/spcp.gif width=113 height=25 border=0 /></a></td>"
							+"</tr></table></td></tr></table></td>"
							+"<td width=3 background=http://pro.bfjieju.com/images/detail/bj_right.gif></td></tr></table>";
				/*		data += "</tr></table></td></tr></table><table width=100% height=45 border=0 cellpadding=0 cellspacing=0><tr>"
							+"<td align=center valign=middle background=http://pro.bfjieju.com/images/detail/gj_01.gif><table width=100% border=0 cellpadding=0 cellspacing=0>"
							+"<tr><td width=490 align=right>挑选更多的产品&gt;&gt;</td><td align=left>"
							+"&nbsp;&nbsp;<a href=http://b2b.bfjieju.com/company/"+userName+"/samplelist.shtml target=_blank><img src=http://pro.bfjieju.com/images/detail/spcp.gif width=113 height=25 border=0 /></a></td>"
							+"</tr></table></td></tr></table></td><td width=3 background=http://pro.bfjieju.com/images/detail/bj_right.gif></td></tr></table>";
				*/
						document.getElementById("comData").innerHTML = data;
					}						
				} 
			};	
	xmlHttp.Send(null);
}

function getPic(id,pic)
{
	if(pic != "noPic" )
		return "http://trade.bfjieju.com/BreviaryPhoto/"+id+pic;
	else
		return "http://trade.bfjieju.com/images/nopp.gif";
}
function getURL(id,time,value)
{	
	return "http://trade.bfjieju.com/"+setTypeValue(value)+"/detail/"+setTime(time)+id+".shtml";
}
function setTime(time)
{
	var arryTime = time.substring(0,time.indexOf(" ")).split('-');
	var month = arryTime[1];
	var day = arryTime[2];
	if(month.length == 1)
		month = "0" + month	
	if(day.length == 1)
		day = "0" + day;		
	return arryTime[0]+"/"+month+"/"+day+"/";
}
function setTypeValue(value)
{
	var typeValue = "provide";
	value=value+"1"
	switch(value)
	{
		case "21" :
			typeValue = "buyer";
			break;
		case "31" :
			typeValue = "Surrogate";
			break;
		case "41":
			typeValue = "Cooperate";
			break;
	}
	return typeValue;
}
 function getFlashPic(pic)
 {	
	if(pic.toLowerCase().indexOf(".jpg") > 0 || pic.toLowerCase().indexOf(".gif") > 0 )
		pic = "http://trade.bfjieju.com/BreviaryPhoto/" + pic ;
	else
		pic = "http://trade.bfjieju.com/images/nopp.gif";
	document.getElementById("picFlash").innerHTML = "<object width=178 height=178 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0>"
		+"<param name=allowScriptAccess value=sameDomain />"
		+"<param name=movie value=http://pro.bfjieju.com/template/ShowPics.swf />"
		+"<param name=FlashVars value=pics="+pic+">"
		+"<param name=quality value=high />"
		+"<param name=bgcolor value=#ffffff />"
		+"<<embed src=ShowPics.swf FlashVars=pics="+pic+" quality=high bgcolor=#ffffff width=100% height=100% align=middle allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer />>"
		+"</object>";
 }
 