var isIE=(navigator.appName.indexOf("Microsoft")!=-1);
var isMoz=(navigator.appName.indexOf("Netscape")!=-1);
if(isMoz){
	Event.prototype.__defineGetter__("srcElement",function(){var node=this.target;while(node.nodeType!=1){node=node.parentNode}return node})
	Event.prototype.__defineGetter__("x",function(){return this.clientX+2})
	Event.prototype.__defineGetter__("y",function(){return this.clientY+2})
}
String.prototype.inc=function(k1){return this.indexOf(k1)>-1?true:false}
String.prototype.lenB=function(){return this.replace(/\*/g," ").replace(/[^\x00-\xff]/g,"**").length}
function oo(obj){return document.getElementById(obj)}

function sAlert(str){
var msgw,msgh,bordercolor;
msgw=300;//提示窗口的宽度
msgh=100;//提示窗口的高度
titleheight=25 //提示窗口标题高度
bordercolor="#407c32";//提示窗口的边框颜色
titlecolor="#407c32";//提示窗口的标题颜色

var sWidth,sHeight;
sWidth=screen.width;
sHeight=screen.height;

sWidth1=(document.body.scrollWidth-msgw)/2
sHeight1=(document.body.clientHeight/2+document.body.scrollTop-msgh/2)

var bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.style.background="#ffffff";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=document.body.scrollWidth + "px";
bgObj.style.height=document.body.clientHeight + "px";
bgObj.style.zIndex = "1000";
document.body.appendChild(bgObj);

var msgObj=document.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "50%";

//msgObj.style.left = sWidth1 + "px";
//msgObj.style.top = sHeight1 + "px";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw + "px";
msgObj.style.height =msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight ="25px";
msgObj.style.zIndex = "10001";

var title=document.createElement("h4");
title.setAttribute("id","msgTitle");
title.setAttribute("align","right");
title.style.margin="0";
title.style.padding="3px";
title.style.background=bordercolor;
title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
title.style.opacity="0.75";
title.style.border="1px solid " + bordercolor;
title.style.height="18px";
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
title.style.color="white";
title.style.cursor="pointer";
title.innerHTML="关闭";
title.onclick=function(){
document.body.removeChild(bgObj);
document.getElementById("msgDiv").removeChild(title);
document.body.removeChild(msgObj);
}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(title);
var txt=document.createElement("p");
txt.style.margin="1em 0"
txt.setAttribute("id","msgTxt");
txt.innerHTML=str;
document.getElementById("msgDiv").appendChild(txt);
}

function ajax_friend(str)
{
	var uiUrl = '/app/public_ajax/friend.php';
	var method = "POST";
	var vars = "accepter_id="+str+"&rdm=" + new Date().getTime();

	var cb = function(xhq) {
			sAlert(xhq.responseText);
	}

	var xhconn = new XHConn();
	xhconn.connectAsync(uiUrl, method, vars, cb);

}

function ajax_garner(str)
{
	str = str.split("|");
	var uiUrl = '/app/public_ajax/garner.php';
	var method = "POST";

	var vars = "app="+str[0]+"&subject_id="+str[1]+"&subject_name="+str[2]+"&subject_img="+str[3]+"&rdm=" + new Date().getTime();

	var cb = function(xhq) {
			sAlert(xhq.responseText);
	}

	var xhconn = new XHConn();
	xhconn.connectAsync(uiUrl, method, vars, cb);

}

function show_div_msg(str)
{

	if (str == '')
	{	
		str = "div_msg"
	}

	oo(str).style.left=(document.body.scrollWidth-300)/2+"px"
	oo(str).style.top=(document.body.clientHeight/2+document.body.scrollTop-300/2)+"px"

	oo(str).style.display=""
}



function hide_div_msg(str) {
	if (str == '')
	{	
		str = "div_msg"
	}
    oo(str).style.display = "none";    	
}

function ajax_msg(str)
{
	hide_div_msg(str);
	var uiUrl = '/app/public_ajax/msg.php';
	var method = "POST";
	var msg_content = oo('msg_content').value;
	var accepter_id = oo('accepter_id').value;

	var vars = "content="+msg_content+"&accepter_id="+accepter_id+"&rdm=" + new Date().getTime();

	var cb = function(xhq) {
			sAlert(xhq.responseText);
	}

	var xhconn = new XHConn();
	xhconn.connectAsync(uiUrl, method, vars, cb);
	oo('msg_content').value="";
}


function div_change(num,num1,className1,className2,cn)
{
	for (i=0; i<=num1 ; i++ )
	{
		obj=document.getElementById(cn+i);
		obj2=document.getElementById(cn +"c_"+ i);
		if (obj&&obj2){
			if(i==num){
				document.getElementById(cn + i).className=className1;
				//alert(i);
				//alert(num);
				document.getElementById(cn +"c_"+ i).style.display="";
			}else{
				document.getElementById(cn +"c_"+ i).style.display="none";
				document.getElementById(cn + i).className=className2;
				//alert(i);
			}
		}
		
	}
}

function div_tj(num,num1,className1,className2)
{
	document.search.app.value=num; 
	for (i=0; i<num1 ; i++ )
	{
		if (document.getElementById("div_menuss_"+i))
		{
			if(i==num){
				document.getElementById("div_menuss_" + i).className=className1;
			}else{
				document.getElementById("div_menuss_" + i).className=className2;
			}
			//alert();
		}else{
			alert("您的浏览器出错！");
		}
	}
	//alert("摊位css:"+document.getElementById("div_menu_0").className+"\n商品css:"+document.getElementById("div_menu_1").className+"\n采购css:"+document.getElementById("div_menu_2").className+"\n");
}