var is_login = 0;//登录状态
//document.domain="mop.com";									
function is_logon()
{
	var allcookie = document.cookie.split('; ');
	for(var i=0;i<allcookie.length;i++)
	{
		var cookiename = allcookie[i].split('=')[0];
		if(cookiename=='mop_logon')
		{
			return true;
		}
	}
	return false;
}
function setLogonStatus()
{
	if(is_logon())
	{
	  is_login = 1;
	}
}

function setPageStyle()
{
	if(is_login)
	{
		jQuery("#unlogin").hide();
	}else
	{
		jQuery("#login").hide();
	}
}

//包子图
function showimg_k()
{
	//把包子选择加上，说明选了包子
	hadChooseImg =true;
	
	var face2_1 = jQuery("#face2_1").val();
	var face2_2 = jQuery("#face2_2").val();
	var face2_3 = jQuery("#face2_3").val();
	var face = face2_1+face2_2+face2_3+".gif";
	var show_file = '<span style="cursor:hand" onclick="inserThisImg();"><img src="http://img.mop.com/images/face/'+face+'" align="absmiddle"  title="点击插入"/></span>';
	jQuery("#show").html(show_file);
}
function inserThisImg()
{
	var face2_1 = jQuery("#face2_1").val();
	var face2_2 = jQuery("#face2_2").val();
	var face2_3 = jQuery("#face2_3").val();
	var face = face2_1+face2_2+face2_3+".gif";
	var str = '<img src="http://img.mop.com/images/face/'+face+'"/>';
	insertHTML(str)
}

function insertHTML(appStr) 
{
	var replyBody = jQuery("#reply_body").val();
	replyBody = replyBody +appStr;
	jQuery("#reply_body").val(replyBody);
	jQuery("#reply_body").focus();
}

var isPosting = false;
function doReplyV2()
{
	if(isPosting)
	{
		alert("您已经发送了请求，请稍等...");
		return;
	}
	var replyBody = jQuery("#reply_body").val();
	var txtusername2 = jQuery("#txtusername2").val();
	var txtpassword2 = jQuery("#txtpassword2").val();
	if(replyBody == '')
	{
		alert("回复内容不能为空");
		return;
	}
	if(is_login == 0)
	{
		if(txtusername2  == '' || txtpassword2 == '')
		{
			alert("请输入用户名，与密码。");
			return;
		}
	}
	
	//赋值
	
	jQuery("#body").val(jQuery("#reply_body").val());
	jQuery("#uname").val(jQuery("#txtusername2").val());
	jQuery("#upwd").val(jQuery("#txtpassword2").val());
	jQuery("#sid").val(jQuery("#sid1").val());
	jQuery("#replyfrom").submit();
}
					
//复制
function copyToClipBoard(theUrl) 
{  
	var txt = jQuery("#copyDiv").html()+"\n";
	txt += theUrl;
	if(window.clipboardData) 
	{   
		 window.clipboardData.clearData();
		  
		 window.clipboardData.setData("Text", txt);   
	} else if(navigator.userAgent.indexOf("Opera") != -1) {   
		  window.location = txt;   
	} else if (window.netscape) 
	{   
		  try 
		  {   
			   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
		  } catch (e) 
		  {   
			   alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");   
		  }   
		  var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);   
		  if (!clip)   
			   return;   
		  var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);   
		  if (!trans)   
			   return;   
		  trans.addDataFlavor('text/unicode');   
		  var str = new Object();   
		  var len = new Object();   
		  var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);   
		  var copytext = txt;   
		  str.data = copytext;   
		  trans.setTransferData("text/unicode",str,copytext.length*2);   
		  var clipid = Components.interfaces.nsIClipboard;   
		  if (!clip)   
			   return false;   
		  clip.setData(trans,null,clipid.kGlobalClipboard);   
	} 
	alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");
 }

function bodyAutoHeightV2()
{
	var ch =  pageHeight();
	var height1 = ch-52;
	
	jQuery("#DOM_LContent").height(height1+"px");
	jQuery("#content_right").height((height1+0)+"px");
	
	var cw= pageWidth();
	var width1 = cw -514;
	jQuery("#content_right").width((width1)+"px");
}
	
// 计算当前窗口的宽度 //
function pageWidth()
{
	return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
 
// 计算当前窗口的高度 //
function pageHeight()
{
	return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

function setPromotionCookie()
{
	//var exp = new Date(); 
	//exp.setTime(exp.getTime() + 24*60*60*1000);
	//document.cookie = "dzh_propose" + "=151447;expires=" + exp.toGMTString(); 
	setCookie("dzh_propose",151447);
}

function setCookie(name,value)  
{  
	var Days = 1;  
	var exp = new Date();   
	exp.setTime(exp.getTime() + Days*24*60*60*1000);  
	document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=" + "/" + ";domain=" + "mop.com"
	//document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}  
					
