var p_title="";//预告标注html
var t_title="";//招标标注html
var b_title="";//中标标注html
if(nowtype=="tender"){
	setBzHtml(2,bzlist)	
}else if(nowtype=="bid"){
	setBzHtml(3,bzlist)
}else{
	setBzHtml(1,bzlist)
}

var bzcontent="";//选中内容
$(function () {
	$('#spcontent').mouseup(function (e) {
		bzcontent="";
		var x = 10;
		var y = -80;
		if (document.selection) {
			bzcontent = document.selection.createRange().text;
		}else if (window.getSelection()) {
			bzcontent = window.getSelection();
		}
		bzcontent=TransferString("'"+bzcontent+"'")
		if (bzcontent!= "") {
			if(nowtype=="bid"){
				$('body').append(b_title);
			}else if(nowtype=="tender"){
				$('body').append(t_title);
			}else{
				$('body').append(p_title);
			}
			$('#bztitle').css({
				'top': (e.pageY + y) + 'px',
				'left': (e.pageX + x) + 'px',
				'position': 'absolute'
			}).show('fast');
		}
	}).mousedown(function () {
		$('#bztitle').remove();
	});
})


//
function setbzinput(id){
	$("#"+id).val(bzcontent);
	$("#bztitle").remove();
}
//拼装标注界面
function setBzHtml(type,obj){
	var tmp="";
	for(var key in obj){
		if(key%2==0){
			tmp+="<p class='pbiaozhu'><a id='"+obj[key].Key+"' class='abiaozhu' onclick=setbzinput(this.id) style='padding:5px'>"+obj[key].Name+"</a>&nbsp;"
		}else{
			tmp+="<a id='"+obj[key].Key+"' class='abiaozhu' onclick=setbzinput(this.id) style='padding:5px'>"+obj[key].Name+"</a></p>"
		}
	}
	if(type==2){
		t_title="<div id='bztitle' style='background-color:#D5D5D5;'>"+
		"<div><p class='ptitle'>招标信息标注</p>"+tmp+"</div></div>";
	}else if(type==1){
		p_title="<div id='bztitle' style='background-color:#D5D5D5;'>"+
		"<div><p class='ptitle'>预告信息标注</p>"+tmp+"</div></div>";
	}else{
		b_title="<div id='bztitle' style='background-color:#D5D5D5;'>"+
		"<div><p class='ptitle'>中标信息标注</p>"+tmp+"</div></div>";
	}
}

