var Ajax_msg="获取失败";
var webdir="./";


//调用用户短信管理
function get_msg()
{
	$('#msg_num').html("");
	$('#msg_num').load("ajax.asp?a=get_msg_num&b="+Math.random()+""); 
}
//用户当前位置提交给服务器统计在线
function get_wz(wz)
{
	if (wz!='')
	{	$('#msg_num').load("ajax.asp?a=get_wz&wz="+wz+"&b="+Math.random()+"");}
}

//检测注册用户名问题
function get_checkReg(username,t1){
	$('#'+t1).html("正在检测用户名……");
	$.ajax({
	type: "get",
	cache:false,
	url: webdir+"ajax.asp?a=checkreg&un="+username+"&b="+Math.random()+"",
	timeout: 20000,
	error: function(){$('#'+t1).html(Ajax_msg);},
	success: function(t0){$('#'+t1).html(t0);}
	});
}
//后台调用官方网站最新头条
function Get_Notice(t0){
	
}

function getBoxHtml(data)
{
	var t2="<dl>";
	for(var e in data) 
	{ 
		t2+="<dt>"+data[e]+"</dt>";
	}
	t2+="</dl>";
	return t2;
}
function getBoxlink(url,title){
return '<div><a href="'+url+'" target="_blank">'+title+'</a></div>';
}
//调用匿名发帖的ip归属地区
function showIpData(ip,spanid,t1){
	$.ajax({
	type: "get",
	cache:false,
	url: webdir+"ajax.asp?a=ipname&ip="+ip+"&t1="+t1+"",
	timeout: 20000,
	error: function(){$('#'+spanid).html(Ajax_msg);},
	success: function(t0){$('#'+spanid).html(t0);}
	});
}
//调用帖子的附件归属
function get_guishu(filename,t1){
	$('#'+t1).html("gsdfsdfds");
	$.ajax({
	type: "get",
	cache:false,
	url: webdir+"ajax.asp?a=guishu&fn="+filename+"&b="+Math.random()+"",
	timeout: 20000,
	error: function(){$('#'+t1).html(Ajax_msg);},
	success: function(t0){$('#'+t1).html(t0);}
	});
}
//调用发帖权限管理
function get_bqx(boardid,t1){
	$('#'+t1).html("正在获取……");
	$.ajax({
	type: "get",
	cache:false,
	url: webdir+"ajax.asp?a=bqx&bid="+boardid+"&b="+Math.random()+"",
	timeout: 20000,
	error: function(){$('#'+t1).html(Ajax_msg);},
	success: function(t0){$('#'+t1).html(t0);}
	});
}

function SetValue(ctrl,val)
{
	try
	{
		document.getElementById(ctrl).innerHTML = val;
	}
	catch(e)
	{
	}
}


function Get_Cookie(name) {     
   var start = document.cookie.indexOf(name+"=");    
   var len = start+name.length+1;    
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;    
   if (start == -1) return null;    
   var end = document.cookie.indexOf(";",len);    
   if (end == -1) end = document.cookie.length;    
   return unescape(document.cookie.substring(len,end));      
}     
     
function Set_Cookie(name,value,expires) {     
    expires = expires * 60*60*24*1000;    
    var today = new Date();    
    var expires_date = new Date( today.getTime() + (expires) );    
    var cookieString = name + "=" +escape(value) +    
       ( (expires) ? ";expires=" + expires_date.toGMTString() : "") +";path=/";    
    document.cookie = cookieString;    
}   

function postCheck(formct){
	if (formct.BoardId.value=='' ){
		alert('分类不能为空.');
		formct.BoardId.focus();
		return false; 
	}
	if (formct.title.value=='' ){
		alert('标题不能为空,请填写.');
		formct.title.focus();
		return false; 
	}
	if (editor.getSource()=='' ){
		alert('内容不能为空,请填写.');
		return false; 
	}
	if (formct.zd_code.value=='' ){
		alert('验证码不能为空,请填写.');
		formct.zd_code.focus();
		return false; 
	}
	formct.Submit.disabled=true;
	return true;
}

function reCheck(formct){
	if (editor.getSource()=='' ){
		alert('回复内容不能为空,请填写.');
		return false; 
	}
	if (formct.zd_code.value=='' ){
		alert('验证码不能为空,请填写.');
		formct.zd_code.focus();
		return false; 
	}
	formct.Submit.disabled=true;
	return true;
}


//快捷的删除确认程序
function delete_confirm(e) {
 if (event.srcElement.outerText=="删除")
  event.returnValue=confirm("您确认执行该操作么？不可恢复!");
 }
document.onclick=delete_confirm;

//定义一个运行代码的函数，
function runCode(o)
{
    ie = (document.all)? true:false
    if (ie)
    {
        var code=o.innerText;//即要运行的代码。
        var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
        newwin.opener = null // 防止代码对论谈页面修改
        newwin.document.write(code);  //向这个打开的窗口中写入代码code，这样就实现了运行代码功能。
        newwin.document.close();
    }
}
//ff下ctrl+Enter提交贴子
function ctlent (eventobject) { 
   var evt = window.event ? window.event : eventobject; 
   if (evt.ctrlKey && evt.keyCode == 13) {  
      document.getElementById('save').submit(); 
   } 
} 
//发贴内容缓存
function CopyText(obj) {
	ie = (document.all)? true:false
	if (ie){
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		rng.scrollIntoView();
		rng.select();
		rng.execCommand("Copy");
		rng.collapse(false);
	}
}


function CheckAll(form1)  {
  for (var i=0;i<form1.elements.length;i++)    {
    var e = form1.elements[i];
    if (e.name != 'chkall')       e.checked = form1.chkall.checked; 
   }
  }

function socheck(formct){
	if (formct.Keys.value=='' ){
		alert('关键词不能为空！.');
		formct.Keys.focus();
		return false; 
	}
	formct.Submit.disabled=true;
	return true;
}

/*hideText*/
function hideText(e, conLen, str1, str2)
{
	textBox = document.getElementById(e);
	if ("" == conText)
	{
		conText = textBox.innerHTML;
	}
	if(navigator.appName.indexOf("Explorer") > -1)
	{
		if (textBox.innerText.length < conLen)
		{
			return;
		}
		textBox.innerHTML = textBox.innerText.substr(0, conLen);    
	}
	else
	{
		if (textBox.textContent.length < conLen)
		{
			return;
		}
		textBox.innerHTML = textBox.textContent .substr(0, conLen);
	}
	textBox.innerHTML += '...&nbsp;&nbsp;<a href="javascript:;" onclick="showText(\'' + e + '\',\'' + conLen + '\', \'' + str1 + '\', \'' + str2 + '\');return false" target="_self">' + str1 + '</a>';
}

function showText(e, conLen, str1, str2)
{
	textBox = document.getElementById(e);;
	textBox.innerHTML = conText + '&nbsp;&nbsp;<a href="javascript:;" onclick="hideText(\'' + e + '\', \'' + conLen + '\', \'' + str1 + '\', \'' + str2 + '\');return false" target="_self">' + str2 + '</a>';
}

/*--上传图片--*/
function checkImgType(filename){
	var right_type=new Array(".gif",".jpg",".jpeg",".png");
	filename=filename.toLowerCase();
	var postfixLen=filename.length;
	var result=false;
	for (var i=0;i<right_type.length;i++){
		var ext = filename.substring(postfixLen-right_type[i].length,postfixLen);
		if(ext==right_type[i]){ 
			result=true;
			break;
		}
	}
	return result;
}

function imgcheckSize(img,min_w,min_h) {
	if(!img) return false;
	if(img.width>=min_w&&img.height>=min_h){
		return true;
	}else {
		return false;
	}
}

function checkupload () {
	var from = document.uploadfrom;
	var filepath = from.File.value;
	if(!filepath){
		alert('请选择上传的图片。');
		return false;
	}
	if(filepath.lastIndexOf("\\")>0){
		var filename= filepath.substring(filepath.lastIndexOf("\\")+1,filepath.length);
  }
	if(filename){
		if(!checkImgType(filename)){
			alert('您上传的格式不正确，允许上传的格式有jpeg、jpg、gif、png.');
			return false;
		}
	}
	var r = from.getElementsByTagName('input');
	if(r){
		var checked=false;
		for (var i=0; i<r.length; i++)
			if (r[i].type=='radio'&&r[i].name=='photo_type'&&r[i].checked)
				checked = true;
		if(!checked){
			alert('请选择图片类型。');
			return false;
		}
	}else{
		alert('表单不完整，请重新刷新本页。');
		return false;
	}
	if(from.photo_name.value.length==0){
		alert('请填写图片标题。');
		return false;
	}else if(from.photo_name.value.length>20){
		alert('图片标题字数不能超过20个。');
		from.photo_name.focus();
		return false;
	}
	from.submitbutton.disabled = true;
	return true;
}
//信息添加检查！
function checkaddinfo(theform)
{
   if (theform.news_title.value == '' )
   {
      alert("信息标题一定要填写！！");
      theform.news_title.focus();
      return false;
   }
  return true
 }
//信息添加检查！
function checkOne(theform)
{
   if (theform.content.value == '' )
   {
      alert("信息内容一定要填写！！");
      theform.content.focus();
      return false;
   }
  return true
 }


//登记商铺提交检查
function checkaddshop(theform)
{
   if (theform.shop_name.value == '' )
   {
      alert("商铺名称一定要填写！！");
      theform.shop_name.focus();
      return false;
   }
   if(theform.shop_telephone.value == "")
   {
   		alert("联系方式应该不能少呢");
		theform.shop_telephone.focus();
		return false ;
   }
   if(theform.shop_content.value == "")
   {
   		alert("商铺介绍适当说两句吧");
		theform.shop_content.focus();
		return false ;
   }
   return true;     
 }

//点评提交检查
function checkreview(theform)
{
   if (theform.r_shopid.value == '0' )
   {
      alert("参数错误！");
      theform.r_shopid.focus();
      return false;
   }
   if(theform.r_sort1.value == "" || theform.r_sort2.value == "" || theform.r_sort3.value == "" || theform.r_sort4.value == "")
   {
   		alert("四个点评分值都要填写!");
		theform.r_sort1.focus();
		return false ;
   }
   if(theform.r_avrprice.value == "")
   {
   		alert("请填写人均消费!");
		theform.r_avrprice.focus();
		return false ;
   }
   if(theform.content.value == "")
   {
   		alert("请填写点评内容!");
		theform.content.focus();
		return false ;
   }
   return true;     
 }

 //公用选项卡js
function setTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"current":"";
con.style.display=i==cursel?"block":"none";
}
}


