/*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";
}
}


function sc5(){
document.getElementById("Javascript.Div5").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("Javascript.Div5").offsetHeight)+"px";
document.getElementById("Javascript.Div5").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div5").offsetWidth)+"px";
}

function scrollup(o,d,c){
       if(d==c){
              var t=o.firstChild.cloneNode(true);
              o.removeChild(o.firstChild);
              o.appendChild(t);
              t.style.marginTop=o.firstChild.style.marginTop='0px';
       }
       else{
              var s=3,c=c+s,l=(c>=d?c-d:0);
              o.firstChild.style.marginTop=-c+l+'px';
              window.setTimeout(function(){scrollup(o,d,c-l)},100);
       }
}
