www.gusucode.com > CC校友录贴吧 CCBar源码程序asp编程 > js/forum_func.js

    // the flag of web finished
var EndFlag = 1;

function MM_findObj(n,d)
{
	var p,i,x;
	if(!d)d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById)x=document.getElementById(n);return(x);
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MSHL()
{
	var i,p,v,obj,args=MSHL.arguments;
	for(i=0;i<(args.length-2);i+=3)if((obj=MM_findObj(args[i]))!=null){v=args[i+2];
	if(obj.style){obj=obj.style;v=(v=='show')?'visible':(v='hide')?'hidden':v;}
			 obj.visibility=v;}
}


var h;
var w;
var l;
var t;
var topMar = 1;
var leftMar = -2;
var space = 1;
var isvisible = false;
var MENU_SHADOW_COLOR='#999999';//定义下拉菜单阴影色
var global = window.document
global.fo_currentMenu = null
global.fo_shadows = new Array

function HideClew() 
{
	var mX;
 	var mY;
 	var vDiv;
 	var mDiv;
	var strMnuCode;
	if (isvisible == true)
	{
		vDiv = document.all("divClew");
		vDiv.style.visibility = "hidden";

		strMnuCode = "<table id='tableClew' cellspacing=0 cellpadding=0 style='width:0'  onmouseout='HideClew()'><tr height=0><td></td></tr></table>";

		divClew.innerHTML = strMnuCode;
		divClew.style.top = t;
		divClew.style.left = l;
		divClew.style.visibility = "visible";
		makeRectangularDropShadow(tableClew, MENU_SHADOW_COLOR, 4)

		isvisible = false;

	}
}

function ShowClew(vMnuCode) 
{
	strTbClass = "CSS_TB1"
	strTdClass = "CSS_TD_CENTER1"
	vSrc = window.event.srcElement;
	vMnuCode = "<table id='tableClew' cellspacing=1 cellpadding=3 class="+strTbClass+" onmouseout='HideClew()'><tr height=23 ><td nowrap align=left class="+strTdClass+">" + 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;
	}

	divClew.innerHTML = vMnuCode;
	divClew.style.top = t;
	divClew.style.left = l;
	divClew.style.visibility = "visible";
	isvisible = true;
    makeRectangularDropShadow(tableClew, MENU_SHADOW_COLOR, 4)
}

function makeRectangularDropShadow(el, color, size)
{
	var i;
	for (i=size; i>0; i--)
	{
		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;
	}
}

// 问候语提示
function ShowHello() {
	var welcomestring;
	var d = new Date();	
	h = d.getHours();
	if(h<6)
		welcomestring="凌晨好";
	else if (h<9)
		welcomestring="早上好";
	else if (h<12)
		welcomestring="上午好";
	else if (h<14)
		welcomestring="中午好";
	else if (h<17)
		welcomestring="下午好";
	else if (h<19)
		welcomestring="傍晚好";
	else if (h<22)
		welcomestring="晚上好";
	else
		welcomestring="夜里好";
	document.write(welcomestring);
}

function CheckFormLogin() 
{
	if (document.frmLogin.iptUserName.value == "" )
		{ 
		 alert(':-)  对不起!请您填入用户名。'); 
		 document.frmLogin.iptUserName.focus()
		 return false;
		}
	if (document.frmLogin.iptPassword.value == "" )
		{ 
		 alert(':-)  对不起!请您填入用户密码。'); 
		 document.frmLogin.iptPassword.focus()
		 return false;
		}
	if (document.frmLogin.iptPassword.value.length < 5 )
		{ 
		 alert(':-)  对不起!,您输的密码小于6位。密码应为6-14位'); 
		 document.frmLogin.iptPassword.focus()
		 return false;
		}
	return true;
}


// 自适应显示图片
function DrawImage(ImgD,intLargeImgWidth,intLargeImgHeight,intAltFlag)
{
	var image = new Image();
	image.src = ImgD.src;

	if (image.width > 0 && image.height > 0)
	{
		flag = true;
		if (image.width/image.height >= intLargeImgWidth/intLargeImgHeight)
		{
			if (image.width > intLargeImgWidth)
			{  
				ImgD.width = intLargeImgWidth;
				ImgD.height = (image.height * intLargeImgWidth)/image.width;
			} 
			else
			{
				ImgD.width = image.width;  
				ImgD.height = image.height;
			}

			if (intAlfFlag = 0 )
			{
				ImgD.alt = "实际大小:" + image.width + "×" + image.height + ",点击查看原始图";
			}
		}
		else
		{
			if (image.height > intLargeImgHeight)
			{  
				ImgD.height = intLargeImgHeight;
				ImgD.width = (image.width * intLargeImgHeight)/image.height;     
			}
			else
			{
				ImgD.width = image.width;  
				ImgD.height = image.height;
			}
			
			if (intAltFlag = 0 )
			{
				ImgD.alt = "实际大小:" + image.width + "×" + image.height+ ",点击查看原始图";
			}
		}
	}
   /*else{
    ImgD.src="";
    ImgD.alt=""
    }*/
} 

// 自适应显示图片
function DrawImage2(ImgD,intLargeImgWidth)
{
	var image = new Image();
	image.src = ImgD.src;

	if (image.width > intLargeImgWidth)
	{  
			ImgD.width = intLargeImgWidth;
	}

	ImgD.alt = "实际大小:" + image.width + "×" + image.height + ",点击查看原始图";

}


function CheckFormLogin() 
{
	if (document.frmLogin.iptUserName.value.length < 2 || document.frmLogin.iptUserName.value.length > 10 )
	{ 
		 alert(':-)  对不起!请您填入用户名(2-10字)'); 
		 document.frmLogin.iptUserName.focus();	 
		 return false;
	}

	if (document.frmLogin.iptPassword.value.length < 6 || document.frmLogin.iptPassword.value.length > 20 )
	{ 
		 alert(':-)  对不起!请您填入用户密码(6-20字)'); 
		 document.frmLogin.iptPassword.focus();	 
		 return false;
	}
	return true;
}

function CheckGoForm()
{
	if (!IsNumeric(document.frmGo.intPageNow.value))
	{
		 alert(':-)  对不起!请您填入正确的页码'); 
		 document.frmGo.intPageNow.focus();	 
		 return false;
	}

	return true;
}
function IsNumeric(p) 
{ 
	if (p == "") 
		return false;
	
	var l = p.length; 
	var count = 0; 
	for (var i = 0; i < l; i++) 
	{ 
		var digit = p.charAt(i); 
		if (digit == "." ) 
		{ 
			++count; 
			if (count > 1) return false; 
		} 
		else if (digit < "0" || digit > "9") 
		return false; 
	}
	
	return true;
	
} 

// 表单提交后submit按钮变为不可用
function submitonce(theform)
{
	if (document.all||document.getElementById)
	{
		for (i=0;i<theform.length;i++)
		{
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
		}
	}
}

// 改变背景颜色
function BgChange(field,strClassName)
{
	field.className = strClassName;
}

// 回复背景颜色
function BgReset(field,strClassName)
{
	field.className = strClassName;
}

function CheckFormAddTopics(strFormName) 
{
	if (strFormName.iptTitle.value.length < 1 || strFormName.iptTitle.value.length > 100 )
	{ 
		 alert(':-)  对不起!请您填入帖子主题(1-20字)'); 
		 strFormName.iptTitle.focus();	 
		 return false;
	}

	if (strFormName.txtContent.value.length < 5 || strFormName.txtContent.value.length > 10000 )
	{ 
		 alert(':-)  对不起!请您填入帖子内容(5-10000字)'); 
		 strFormName.txtContent.focus();	 
		 return false;
	}

	//submitonce(strFormName);

	return true;
}

function CheckFormAddReply(strFormName)
{
	if (strFormName.iptReTitle.value.length < 1 || strFormName.iptReTitle.value.length > 100 )
	{ 
		 alert(':-)  对不起!请您填入回复主题(1-20字)'); 
		 strFormName.iptReTitle.focus();	 
		 return false;
	}

	if (strFormName.txtContent.value.length < 5 || strFormName.txtContent.value.length > 10000 )
	{ 
		 alert(':-)  对不起!请您填入回复内容(5-10000字)'); 
		 strFormName.txtContent.focus();	 
		 return false;
	}
	//submitonce(strFormName);
	return true;
}