//document.title="91社区_bbs.91.com_(阳光·生活·娱乐)";


//-------------------------------------------------------------------------------------------------------下拉菜单相关代码
 var h;
 var w;
 var l;
 var t;
 var topMar = 1;
 var leftMar = -2;
 var space = 1;
 var isvisible;
 var MENU_SHADOW_COLOR='white';//定义下拉菜单阴影色
 var global = window.document;
 global.fo_currentMenu = null;
 global.fo_shadows = new Array;

 function hiddenAllSelect()
{
	var obj=document.all.tags("SELECT");
	for(var i=0;i<obj.length;i++)
		{
		 obj.item(i).style.visibility="hidden";
		}
}

function showAllSelect()
{
	var obj=document.all.tags("SELECT");
	for(var i=0;i<obj.length;i++)
		{
		 obj.item(i).style.visibility="";
		}
}

function HideMenu() 
{
 var mX;
 var mY;
 var vDiv;
 var mDiv;
	if (isvisible == true)
{
		vDiv = document.all("menuDiv");
		mX = window.event.clientX + document.body.scrollLeft;
		mY = window.event.clientY + document.body.scrollTop;
		if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight)){
			vDiv.style.visibility = "hidden";
			isvisible = false;
			showAllSelect();
		}
}
}

function ShowMenu(fuwucenter,tWidth,tHeight) {
	var vMnuCodeMenu = document.all(fuwucenter).innerHTML;
	var vMnuCode;
	hiddenAllSelect();
	vSrc = window.event.srcElement;
	vMnuCode = "<table id='submenu' cellspacing=1 cellpadding=3 style='width:"+tWidth+"' class=tableborder1 onmouseout='HideMenu()'><tr height=23><td nowrap align=left class=tablebody1>";

	if ( tHeight != 0 )
	{
		if ( tHeight > 400 )
		{
			vMnuCode += "<div style='width:" + tWidth + "px; height:400px; table-layout:fixed;WORD-BREAK: break-all;overflow:auto;'>";
			vMnuCode += vMnuCodeMenu;
			vMnuCode += "</div>";
		}
		else
		{
			vMnuCode += vMnuCodeMenu;
		}
	}
	else
	{
		vMnuCode += vMnuCodeMenu;
	}
	vMnuCode += "</td></tr></table>";

	h = vSrc.offsetHeight;
	w = vSrc.offsetWidth;
	l = vSrc.offsetLeft + leftMar+4;
	t = vSrc.offsetTop + topMar + h + space-2;
	vParent = vSrc.offsetParent;
	while (vParent.tagName.toUpperCase() != "BODY")
	{
		l += vParent.offsetLeft;
		t += vParent.offsetTop;
		vParent = vParent.offsetParent;
	}

	menuDiv.innerHTML = vMnuCode;
	menuDiv.style.top = t;
	menuDiv.style.left = l;
	menuDiv.style.visibility = "visible";
	isvisible = true;
	try
	{
		makeRectangularDropShadow(submenu, MENU_SHADOW_COLOR, 4);
	}
	catch(e){}
}

function makeRectangularDropShadow(el, color, size)
{
	var i;
	for (i=size; i>0; i--)
	{
		try
		{
			var rect = document.createElement('div');
			var rs = rect.style
			rs.position = 'absolute';
			rs.left = (el.style.posLeft + i) + 'px';
			rs.top = (el.style.posTop + i) + 'px';
			rs.width = el.offsetWidth + 'px';
			rs.height = el.offsetHeight + 'px';
			rs.zIndex = el.style.zIndex - i;
			rs.backgroundColor = color;
			var opacity = 1 - i / (i + 1);
			rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
			el.insertAdjacentElement('afterEnd', rect);
			global.fo_shadows[global.fo_shadows.length] = rect;
		}
		catch(e){}
	}
}
//-------------------------------------------------------------------------------------------------------下拉菜单相关代码


//# 公用方法：无返回值的弹出模式窗口
function usp_openwin(sss,w_height,w_width) //
{
	var temp1;
	var strVersion;
	strVersion = navigator.appVersion;
	if(strVersion.indexOf("MSIE 5")!=0 && strVersion.indexOf("MSIE 5")!=-1)
		temp1 = window.showModalDialog(sss,"Dialog Arguments Value","dialogHeight: " + w_height + "px; dialogWidth: " + w_width + "px; center: Yes; help: No; resizable: No; status: no;");
	else{
		temp1 = window.showModalDialog(sss,"Dialog Arguments Value","dialogHeight: " + w_height + "px; dialogWidth: " + w_width + "px; center: Yes; help: No; resizable: No; status: no;");
	}
}

//发贴和回贴的验证表单函数
function CheckForm()
{
	var str;
	
	//标题
	if(document.all("TextBox_Subject"))
	{
		str = document.all("TextBox_Subject").value;
		if(str.length == 0)
		{
			alert("请输入帖子标题！");
			document.all("TextBox_Subject").focus();
			return false;
		}
		if(str.length > 50)
		{
			alert("帖子标题过长(超过50字)！");
			document.all("TextBox_Subject").focus();
			return false;
		}
	}

	
	//帖子内容
	if(document.all("TextBox_context_Message"))
	{
		str = document.all("TextBox_context_Message").value;
		if(str.length == 0)
		{
			alert("请输入帖子内容！");
			document.all("TextBox_context_Message").focus();
			return false;
		}
		if(str.length > 15000)
		{
			alert("您的文章字数(超过15000字)，请调整后再发布！");
			document.all("TextBox_context_Message").focus();
			return false;
		}
	}
	
	//验证码
	if(document.all("TextBox_context_TextBox_pwds")){
		var str1;
		str1 = document.all("TextBox_context_TextBox_pwds").value;
		if(str1.length == 0)
		{
			alert("请输入验证码！");
			document.all("TextBox_context_TextBox_pwds").focus();
			return false;
		}
	}
}

function openwin(wname)
{
	var	f="height="+new String(screen.availHeight/2)+",top=0,left=0,width="+new String(screen.availWidth/2)+",resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no";
	window.open("",wname,f,false);
}


//函数名：fucCheckNUM 
//功能介绍：检查是否为数字 
//参数说明：要检查的数字 
//返回值：1为是数字，0为不是数字 
function fucCheckNUM(NUM) 
{ 
	var i,j,strTemp; 
	strTemp="0123456789."; 
	if ( NUM.length== 0) 
	return 0 
	for (i=0;i<NUM.length;i++) 
	{ 
	j=strTemp.indexOf(NUM.charAt(i)); 
	if (j==-1) 
	{ 
	//说明有字符不是数字 
	return 0; 
	} 
	} 
	//说明是数字 
	return 1; 
} 

//检验图片的选择
function file1_onpropertychange() {
var str;

if(document.images["img1_file"]) {
 
    str=frmUpload.FileName0.value; 
    if (str == "") return false;
    if( str.substr(str.length-3,3) == "jpg" || str.substr(str.length-3,3) == "gif" || 
        str.substr(str.length-3,3) == "JPG" || str.substr(str.length-3,3) == "GIF" )
        
        { 
          document.images["img1_file"].src=str;
		   
        }
    //else 
      //  {
        //  alert("不是图形文件！");
		  //document.images["img1_file"].src=str;
		  //frmUpload.FileName0.value = ""; //如果加上会出现死循环操作，即不断弹出提示
		  //alert(frmUpload.FileName0.value);
          //return false;
        //}  
               

  }
}

//# 应用在弹出窗口中：选择信息后传递数据同时关闭窗口
function SaveToDataBase(getok)
{
	window.returnValue = getok
	window.close();
}

//# 全选复选框
function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
}
  
//# 判断是否选择复选框
function CheckAll_yesno(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
		var e = form.elements[i];
		if (e.checked)
		{
			return true;
		}
    }
  return false;
}


//# 应用在表格的行中的变色效果
 function movecolor(orow)
 {
	var bk="#EEE3CB"
	orow.bgColor=bk
 }

//# 应用在表格的行中的变色效果
 function outcolor(orow)
 {
	var bk="white"
	orow.bgColor=bk
 }

//# 验证是否输入的是否是数值
function checkint() 
{
	if  ( ( event.keyCode >= 37 && event.keyCode <= 40 ) || ( event.keyCode >= 96 && event.keyCode <= 105 ) || ( event.keyCode >= 48 && event.keyCode <= 57 ) || ( event.keyCode==190 ) || ( event.keyCode==110 ) || ( event.keyCode==8 ) || ( event.keyCode==46 ) )  {
		event.keyCode=0;
	}else{
		if ( event.keyCode!=13 ) alert("请输入数值！");
		event.keyCode=9;
	}
}

//# 调用弹出窗口进行选择函数
function Searchshiwu(btnname,obj) 
{
	var sss;
	sss="con_inttype.asp?obj=" + obj
	mypub(sss,btnname);
}

//# 调用弹出窗口，该函数和上述一函数共同完成选择窗口
function mypub(sss,obj) //
{
	var temp1;
	var strVersion;
	strVersion = navigator.appVersion;
	if(strVersion.indexOf("MSIE 5")!=0 && strVersion.indexOf("MSIE 5")!=-1)
		temp1 = window.showModalDialog(sss,"Dialog Arguments Value","dialogHeight: 300px; dialogWidth: 450px; center: Yes; help: No; resizable: No; status: no;");
	else{
		temp1 = window.showModalDialog(sss,"Dialog Arguments Value","dialogHeight: 300px; dialogWidth: 450px; center: Yes; help: No; resizable: no; status: no;");
	}
	if ( temp1 != null ){
		document.all[obj].value=temp1;}
}




function outcheck(check_value){
	if(check_value != ""){
		alert(check_value)
		return false; 
	}
	return true;
}

function checkvalue(obj, low, up, mode, lable){
/*
Mode = 1 检测是否为空   2是否是数字  4是否整数
8是否是为数字、字母和_.-
16 自定义字符检测
32 长度检测
64 数字大小检测
*/
    var temp,type;
    var length, i, base, str;
    
    str=getformvalue(obj);
    if(str==null){
		lenght=0;
		str="";
	}	
	else{	
		length = str.length
	}	
    temp=""
    if( mode % 2 >= 1 ){
        if( str == "" ){
            temp = temp + "“" + lable + "”" + "不能为空！" + "\n";
        }
    }
    
    if( mode % 4 >= 2 ){
        base = "0123456789."
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1  ){
				temp = temp + "“" + lable + "”" + "必需是数字！" + "\n";
				break;
            }    
    }
    
    if( mode % 8 >= 4 ){
        base = "0123456789"
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1  ){
                temp = temp + "“" + lable + "”" + "必需是整数！" + "\n";
                break;
            }    
    }
    
    if( mode % 16 >= 8 ){
        base = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_-."
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1  ){
                temp = temp + "“" + lable + "”" + "包含非法字符！它只能是字母、数字和“- _ .”。" + "\n";
                break;
            }
    }
    
    if( mode % 32 >= 16 ){
        base = low.replace("[a-z]", "abcdefghijklmnopqrstuvwxyz")
        base = base.replace("[a-z]", "abcdefghijklmnopqrstuvwxyz")
        base = base.replace( "[0-9]", "0123456789")
        for(i = 0;i<=length-1;i++)
            if( base.indexOf(str.substring(i, i+1)) == -1 ){
                temp = temp + "“" + lable + "”" + "包含非法字符！它只能是" + up + "。" + "\n";
                break;
            }
    }
    
    if( mode % 64 >= 32 ){
        if( ! (length >= low && length <= up) ){
               temp = temp + "“" + lable + "”" + "的长度必需在" + low + "到" + up + "之间！" + "\n";
        }
    }
    
     if( mode % 128 >= 64 ){
        if( ! (parseInt(str) >= parseInt(low) && parseInt(str) <= parseInt(up)) ){
               temp = temp + "“" + lable + "”" + "必需在" + low + "到" + up + "之间！" + "\n";
        }

    }
    if(temp!=""){
    	alert(temp);
    	type=(getformtype(obj));
    	if(type!="radio" && type!="checkbox"){
    		obj.focus();
    	}
	return false; 
   }
   return true;
    
}

function getformtype(obj){
	var type;
	type=obj.type;
	if(typeof(type)=="undefined"){

		type=obj[0].type;
	}
	return type;		
}
function getformvalue(input){
//取表单域的值
	var type,temp;
	temp="";
	
	type=getformtype(input);	

	switch(type){
		case "radio":	//单选框
			n=input.length-1;

			if(isNaN(n)==true){
				if(input.checked == true){
					temp = input.value;
				}else{
					temp = "";
				}	
			}else{
				for(i=0;i<=n;i++){
					if(input[i].checked == true){
						return(input[i].value);
					}
				}
				break;
			}
			case "checkbox":	//复选框
			n=input.length-1;
			if(isNaN(n)==true){
				if(input.checked == true){
					temp = input.value;
				}else{
					temp = "";
				}	
			}else{
				for(i=0;i<=n;i++){
					if(input[i].checked == true){
						if(temp!=""){
							temp += ",";
						}
						temp += input[i].value;

					}	
				}
			}
			return(temp);
			break;
			
		case "select-one" :	//单选列表框
			n=input.length-1;	
			for(i=0;i<=n;i++){
				if(input.options[i].selected == true){
					temp = input.options[i].value;
					break;
				}			
			}
			return(temp);
			break;				
		case "select-multiple":	//多选列表框
			n=input.length-1;	
			for(i=0;i<=n;i++){
				if(input.options[i].selected == true){
					if(temp!=""){
						temp+=",";
					}					
					temp+=input.options[i].value;
				}			
			}
			return(temp);
			break;			
		default:				//其它
			return(input.value);
			break;
	
	}
	
	return(input.value);

}

function ischecked(group,value){
	var i,n;
	n=group.length-1;
	for(i=0;i<=n;i++){
		if(value==group[i]){
			return true;			
		}
	}
	return false;
}


function SetSelectedAndChecked(input,value){
//设置表单域的选择
	var type,temp,i,n;
	var split_value = new Array();
	temp="";
	
	type=input.type;
	
	if(typeof(type)=="undefined"){
		type=input[0].type;
	}
	

	switch(type){
		case "radio":	//单选框
			n=input.length-1;

			if(isNaN(n)==true){
				if(input.value = value){
					input.checked = true;
				}else{
					input.checked = false;
				}	
			}else{
				for(i=0;i<=n;i++){
					if(input[i].value == value){
						input[i].checked = true;
					}else{
						input[i].checked = false;					
					}
				}
			}
			break;

		case "checkbox":	//复选框
			n=input.length-1;
			split_value=value.split(", ");
			if(isNaN(n)==true){
				if(ischecked(split_value,input.value)){
					input.checked = true;
				}else{
					input.checked = false;
				}	
			}else{
				for(i=0;i<=n;i++){
					if(ischecked(split_value,input[i].value)){
						input[i].checked = true;
					}else{
						input[i].checked = false;					
					}					
				}
				
			}
			break;
			
		case "select-one" :	//单选列表框
			n=input.options.length-1;	
			for(i=0;i<=n;i++){
				if(input.options[i].value == value){
					input.options[i].selected = true;
				}else{
					input.options[i].selected = false;				
				}
						
			}
			break;				
		case "select-multiple":	//多选列表框
			n=input.options.length-1;	
			split_value=value.split(",");
			for(i=0;i<=n;i++){
				if(ischecked(split_value,input.options[i].value)){
						input.options[i].selected = true;
				}else{
						input.options[i].selected = false;				
				}			
			}
			break;			
		default:				//其它
			return false;
			break;
	
	}
	
	return true;

}

//电子邮箱格式校验
function checkemail(stremail)
{
	var str=stremail
	var filter=/^.+@.+\..{2,3}$/
	if (filter.test(str))
		testresults=true
	else
	{
		testresults=false
	}
	return (testresults)
}

//判断是否是英文
function CheckIfEnglish(String)
{ 
   var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
   var i;
   var c;
   for( i = 0; i < String.length; i ++ )
   {
     c = String.charAt( i );
	   if (Letters.indexOf( c ) < 0)
	     return false;
   }
     return true;
}

//************利用正则表达式判断内容中的是否有空格回车******************
function checkIsNull(str)
{
	var newstr;
	var re = /\s/gi;
	newstr=str.replace(re, "");
	if(str.length!=newstr.length)
	return(1);
	else
	return(0);
}