﻿// JScript 文件

function SplitString(str,count)
{
    var l = str.length;
    var s;    
    if(l>count)
    {
        s = str.replace("<br>","").substring(0,count);
    }
    else
    {
        s = str; 
    }
    return s;
}

function FormatTime(strTime)
{
    return strTime.split(' ')[0]
}

function FormatPrice(strPrice, w)
{
   if(strPrice=="-100.00" || strPrice == "0" || strPrice=="价格面议")
    {
        return "价格面议";
    }
    else
    {
        if(w)
        {
            if(strPrice>5000 && strPrice<10000)
                return strPrice+"元";
            return strPrice+"万元";
         }
        return strPrice+"元";
    }
}
function FormatRent(p,typeid2,sdType)
{
	if(p==-100.00 || p == 0 || p.toString().indexOf("面议") > -1) 
        return "价格面议";
    else if(typeid2 == 1004)
    	return p.replace(".00","") + "/天";
    else if(typeid2 == 1007)
    {
    	if(sdType == "出售")
    		return p.replace(".00","") + "/平米";
    	else
    		return p.toString().replace(".00","") + "/平米/天";
    }
    else if(/^2253|2254|2255|2256|2257|2258$/.test(typeid2))
    {
        if(sdType == "出售")
    		return p.replace(".00","");
    	else
    		return p.toString().replace(".00","") + "月";
    }
    else
    	return p.replace(".00","") + "/月";
}
function FormatArea(strArea,ext)
{
    if(strArea=="-101.00" || strArea == "0" || strArea=="价格面议")
    {
        return "不限";
    }
    return  strArea + " ㎡";
} 

function FormatColor(str)
{
    if(str=="个人")
    {
        return "<font color='green'>["+str+"]</font>"
    }
    else
    {
    
     if(str=="网站推荐经纪")
    {
        return "<a href=\"http://static.hand2hand.cn/help/yanzheng/\" target='_blank'><img src='http://img.hand2hand.cn/ico_jian.gif' /></a>"
    }
    else
    {
         return "<font color='red'>["+str+"]</font>"
         }
    }
}

//51day,52m
function FormatRent1007(p,demand,mode)
{
	if(p==-100.00 || p==-100 || p==0 || p.toString().indexOf("面议") > -1) 
    	return "价格面议";
    var rs = p.toString().replace(".00","") + "元";  
	
	if(demand == "出租")
	{
		if(mode == "元_月")
			rs = rs + "/月"
		else
			rs = rs + "/平米/天";
	}
	else
		rs = rs + "/平米";
	return rs.replace("元元","元");
}

function FormatRent1497(p,typeid2)
{
	if(p=="-100.00" || p == "-100"|| p == "0" || p.indexOf("面议") > -1) 
        return "面议";
    else if(typeid2 == 1004)
    	return p.replace(".00","") + "/天";
    else
        return p.replace(".00","") + "元/月";	
} 


function FormatColorOnly(str,istop)
{   
if(istop =="1101")
{
     if(str=="网站推荐经纪")
    {
        return "<a href=\"http://static.hand2hand.cn/help/yanzheng/\" target='_blank'><img src='http://img.hand2hand.cn/ico_jian.gif' /></a>"
    }
   else
    {
        return "";
    }
    }
    else
    {
        if(str=="个人")
    {
        return "<font color='green'>["+str+"]</font>"
    }
    else
    {
    
     if(str=="网站推荐经纪")
    {
        return "<a href=\"http://static.hand2hand.cn/help/yanzheng/\" target='_blank'><img src='http://img.hand2hand.cn/ico_jian.gif' /></a>"
    }
    else
    {
         return "<font color='red'>["+str+"]</font>"
         }
    }
    
    }
    
}
function FormatColorJob(str)
{

    if(str=="网站推荐经纪")
    {
        return "<a href=\"http://static.hand2hand.cn/help/yanzheng/\" target='_blank'><img src='http://img.hand2hand.cn/ico_jian.gif' /></a>"
    }
    else
    {
        return "";
    }
}


function FormatImg(state)
{
    switch(state)
    {
        case "1001":
        return "";
        break;
        
        case "1002":
        return "<a href=\"http://static.hand2hand.cn/help/yanzheng/\" target='_blank'><img src='http://img.hand2hand.cn/ico_color.gif' /></a>";
        break;

        case "1101":
        return "<a href=\"http://static.hand2hand.cn/help/yanzheng/\" target='_blank'><img src='http://img.hand2hand.cn/ico_top.gif' /></a>";
        break;
        
        default:
        return "";
    }
}
function FormatInfoSTATURE(a)
{
    if(a == '9 厘米')
       return "未知"; 
    return a;
}
function FormatInfoAGE(a)
{
    if( a == "0 岁")
        return "年龄未知"; 
    return a; 
}
function FormatPhoto(img)
{
    if(img=="")
    {
        return "";
    }
    else
    {
         return  "<a href=\"http://static.hand2hand.cn/help/yanzheng/\" target='_blank'><img src='http://img.hand2hand.cn/ico_image.gif' /></a>";
    }
}
function SetQQ(num)
{
	
	var back = '';
	if(num != '' && num != '不限')
	{
	  back=  "<a href=\"tencent://message/?uin=" + num +"&Site=quna.com&Menu=yes\"><img src=\"http://img.hand2hand.cn/info/info_qq.jpg\"  style=\"border:0;margin-top:5px;\" alt=\"QQ临时通话\" /></a>";
	}
	else
	{
	     back=  "<img src=\"http://img.hand2hand.cn/info1229/qqnone.gif\"  style=\"border:0; margin-top:5px;\" alt=\"无QQ\" />";
	}
	return back;

}
function FormatInfoImg(img,href)
{
	if(img != "")
	{
		var url=img;
		if(img.indexOf('|')>0)
			url = img.split('|')[0];
	    if(url.indexOf('ttp') > 0)
			{
		return "<td width='10%'><a href='/I"+href+".html' target='_blank'><img width=50px height=50px src='"+url+"' border=0 /></a></td>";
		}
		else
		{
		    	return "<td width='10%'><a href='/I"+href+".html' target='_blank'><img width=50px height=50px src='http://img01.hand2hand.cn/UserPostInfo"+url+"' border=0 /></a></td>";
		}
	}
	return "";
}
function FormatInfoImg100120(img,href)
{
	if(img != "")
	{
		var url=img;
		if(img.indexOf('|')>0)
			url = img.split('|')[0];
	    if(url.indexOf('ttp') > 0)
			{
		return "<td width='10%'><a href='/I"+href+".html' target='_blank'><img width=60px height=72px src='"+url+"' border=0 /></a></td>";
		}
		else
		{
		    	return "<td width='10%'><a href='/I"+href+".html' target='_blank'><img width=60px height=72px src='http://img01.hand2hand.cn/UserPostInfo"+url+"' border=0 /></a></td>";
		}
	}
	return "";
}
function FormatInfoImgLives(img,href)
{
	if(img != "")
	{
		var url=img;
		if(img.indexOf('|')>0)
			url = img.split('|')[0];
	    if(url.indexOf('ttp') > 0)
			{
		return "<td width='10%'><a href='"+href+"' target='_blank'><img width=89px height=70px src='"+url+"' border=0 /></a></td>";
		}
		else
		{
		    	return "<td width='10%'><a href='"+href+"' target='_blank'><img width=89px height=70px src='http://img01.hand2hand.cn/UserPostInfo"+url+"' border=0 /></a></td>";
		}
	}
	return "";
}
function FormatInfoImgAuto(img,href,width,height)
{
	if(img != "" && img != "不限")
	{
        var url=img;
		if(img.indexOf('|')>0)
			url = img.split('|')[0];
	   
		return "<a href='"+href+"' target='_blank'><img width="+ width+"px  src='"+url+"' border=0  /></a>";
	}
	return "";
}
function FormatInfoImgAuto3(img,href,width,height)
{
	if(img != "" && img != "不限")
	{
        var url=img;
		if(img.indexOf('|')>0)
			url = img.split('|')[0];
	   
		return "<a href='"+href+"' target='_blank'><img width="+ width+"px height="+height  +"px src='"+url+"' border=0  /></a>";
	}
	return "<img width="+ width+"px height="+height  +"px src='http://img.hand2hand.cn/nophoto.gif' border=0  />";
}
function FormatInfoImgAuto2(img,href,width,height)
{
	if(img != "" && img != "不限")
	{
		var url=img;
		if(img.indexOf('|')>0)
			url = img.split('|')[0];
                if(url.indexOf('ttp') > 0)
			{
		return "<td style='border:1px solid #CCCCCC;padding:2px;'><a href='/I"+href+".html' target='_blank'><img width="+ width+"px  height="+height  +"px  src='"+url+"'  /></a></td>";
                }
		else
		{
		    	return "<td style='border:1px solid #CCCCCC;padding:2px;'><a href='/I"+href+".html' target='_blank'><img width="+ width+"px height="+height  +"px src='http://img01.hand2hand.cn/UserPostInfo"+url+"'  /></a></td>";
		}
	   
			}
	return "";
}
function FormatInfoImgAuto4(img,href,width,height)
{
	if(img != "" && img != "不限")
	{
		var url=img;
		if(img.indexOf('|')>0)
			url = img.split('|')[0];
                if(url.indexOf('ttp') > 0)
			{
		return "<td style='border:1px solid #CCCCCC;padding:2px;'><a href='"+href+"' target='_blank'><img width="+ width+"px  height="+height  +"px  src='"+url+"'  /></a></td>";
                }
		else
		{
		    	return "<td style='border:1px solid #CCCCCC;padding:2px;'><a href='"+href+"' target='_blank'><img width="+ width+"px height="+height  +"px src='http://img01.hand2hand.cn/UserPostInfo"+url+"'  /></a></td>";
		}
	   
			}
	return "";
}
function FormatContent(content)
{
    if(content.lengh>60)
    {
        return content.substring(0,60);
    }
    else
    {
        return content;
    }
}

function DspyImages(imgs)
{
	var arrImgs = imgs.split('|');	
	var k = 0;
	var dvImgs = ""; 
	for(var i=0;i<arrImgs.length;i++){
		if(k%2 == 0){
		        dvImgs =  dvImgs + "<hr style='visibility: hidden; width:600px;'>";
				dvImgs += "<div class='box' style='margin-left:30px;'>";
		}
		else{
				dvImgs += "<div class='abox'>";
		}
		var img = WriteIMG(arrImgs[i]);				
		if(img != ""){ 
			k ++;
			dvImgs += img + "</div>";
		}
	}
	if(dvImgs != "")
	{
	    dvImgs = dvImgs + "<br><div style='height:10px;'>";
	}
	$("dvFBox").innerHTML = dvImgs;
}

function WriteIMG(img)
{
    if(img != undefined && img.indexOf('.') > -1)
    { 
        var html = "<a href='#href#' target='_blank' style='vertical-align:middle;'><img  style='width:240px; height:180px;' onerror='this.removeNode(true);' src='#sImg#' border=1/></a>";
        
        //orginal img
        //var smallImg = img.replace(/b(\.[a-z]{2,4}$)/i,"$1");
		if((/^http/i).test(img))
		{ 
			html = html.replace(/#sImg#/i,img);
		   	return html.replace(/#href#/ig,img);
		}
		else
		{
			html = html.replace(/#sImg#/i,"http://img01.hand2hand.cn/UserPostInfo" + img);
			return html.replace(/#href#/ig,"http://img01.hand2hand.cn/UserPostInfo" + img);
	    }	
    }
    return "";  
}

function ImgOnload(obj)
{
	var DWIDTH = 240;
	var DHEIGHT = 180;
	var disWidth  = obj.width-DWIDTH;
	var disHeight = obj.height-DHEIGHT; 
	
	if(disWidth/obj.width > disHeight/obj.height)
	{
		obj.width = DWIDTH;
	}
	else
	{
		obj.height = DHEIGHT;
	}
}
function ImgGoNext(idx)
{
	var arrayImg = images.split('|');   
	
	if(arrayImg.length == 0 || arrayImg[0].indexOf('.') == -1) 
	{ 
		$('dvFBox').style.display='none';
		$('dvBtns').style.display='none';
		return;
	}
		
	if(arrayImg[idx]!=undefined)
	{
		$('dvImg01').innerHTML = WriteIMG(arrayImg[idx++]);
		$('dvImg02').innerHTML = WriteIMG(arrayImg[idx]);
	}
	else
	{
		if(pIndex < 0) pIndex = 0;
		if(pIndex >= arrayImg.length) pIndex = arrayImg.length -1;
	} 
}

function ImgPrev()
{
	ImgGoNext(--pIndex);
}

function ImgNext()
{
	ImgGoNext(++pIndex);
}

function  BehindMsn()
{
    return "";
}

var IR = " &nbsp;提示：若电话号码、QQ号码出现在标题、内容中极有可能为非法中介或虚假信息，谨防上当受骗。";
var IR_HOUSE = " 提示：<div style=\"padding-left:5px;color:red\">1：以任何形式，要求先缴纳任何数目钱款的行为都可能涉嫌欺诈。请尽量选择当面交易并提防欺诈。<br>";
IR_HOUSE += "2：若电话号码、QQ号码出现在标题、内容中极有可能为非法中介或虚假信息，谨防上当受骗。</div></div><tr style=\"width:100%; height:12px;\"><td></td></tr>";
	
							
function GetIntro(id)
{
	var houseId = "1001,1004,1002,1005,1003,1006";
	
	if(houseId.indexOf(id.toString()) > -1)
		return IR_HOUSE;
	
	return IR_HOUSE;
}
function SubWay(value,type)
{
    var tr = "";//<tr><td class='info_comm'>公交线路："//</td></tr>"
    if(value != "," && value != "，")
    {
        tr += "<tr><td class='info_comm'>"+ type + "线路：" + value +  "</td></tr>"
    }
    return tr;
    
}
function HouseExcepTion(value)
{
    var tr = "";
    if(value != "不限" )
    {
        tr += "<tr><td class='info_comm'>房间说明：" + value +  "</td></tr>"
    }
    return tr;
    
}
function yanimg()
{
    return  document.write("</a><a  href='http://static.hand2hand.cn/help/yanzheng/' target='_blank'><img src=\"http://img.hand2hand.cn/ico_card.gif\" alt=\" 验\">");
}

function openwin(id) { 
       var   vartop=(screen.height-300)/2;   
        var   varleft=(screen.width-400)/2; 
window.open ("http://job.hand2hand.cn/TransmissionMail.aspx?id=" + id + "", "newwindow", "top = " + vartop + ", left = " +varleft + ", height=300, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") ;

} 
function SetUserIMG(img)
{
	
	var back = '';
	if(img != '' && img != '不限')
	{
	  back=  "<img src=\""+ img +"\"  style=\"border:0;width:85px; height:85px;\"  />";
	}
	else
	{
	   back=  "<div style='border:1px solid #dcdcdc; width:87px;'><img src=\"http://img.hand2hand.cn/my/noavatar.gif\"  style=\"border:0;width:85px; height:85px;\"  /></div>"; 
	}
	
	return back;

}

function SetTypeID3(type)
{
    var back = ""
    if(type != '' && type != '不限' && type != "{TYPE3NAME}")
    {
       back =  "<tr><td ><span class=\"InfoTil\">详细类别：</span></td><td>"+ type +"</td></tr> "
    }
    return back;
}
function SetTypeID3Other(type)
{
    var back = ""
    if(type != '' && type != '不限' && type != "{TYPE3NAME}")
    {
       back =  "<tr><td style='width:120px;'><span class=\"InfoTil\">详细类别：</span>"+ type +"</td></tr> "
    }
    return back;
}
function SetJuBao(InfoID)
{
    var back = ""
    if(InfoID != '' && InfoID != '不限')
    {
    
      back =   "<a  href =\"#\" onclick=\"openBg(1);openSelect(1)\"  style=\"color:red; text-decoration: underline; \">请填写详细原因</a>";
    }
    return back;
}