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

    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;}
}


// 问候语提示
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;
}

//加为收藏 0--好友 1--帖子 2--相片
function OpwCollection(r,id,name)
{
	window.open('../dialog/dialog_collection_form.asp?iptType=' + r + "&OID=" + id + "&iptName=" + name,'','width=450,height=37,scrollbars=auto,status=no');
}


//设定留言板的心情图标
function SetSmileFace() 
{
	window.open('board_smile_face.asp','','width=250,height=450,scrollbars=auto,status=yes');
}


//改变留言板的心情图标
function ChangeSmileFace()
{
	var strTemp;
	ValidationPassed = true;
	strTemp = document.frmAddBoard.iptSmileFace.value;
	document.imgSmileFace.src = './smileface/' + strTemp + '.gif';
	return ValidationPassed
}


//设定用户卡通图标
function SetCartoonFace() 
{
	window.open('user_cartoon_face.asp','','width=500,height=450 scrollbars=auto,status=yes');
}


//全选动作
function CheckAll(form,object)
{
	for(var i = 0 ; i < form.elements.length ; i++)
	{
		var E = form.elements[i];
		if((E.name  != object.name) && (E.type == "checkbox"))
		{
				E.checked = object.checked;
		}
	}
}


//翻页
function PageTurn(url,value)
{
	window.location.href=url + "intPageNow=" + value;
}


//校验是否选择checkbox
function CheckSelChkBox(form,hint)
{
	var reflag;
	reflag = confirm(hint);
	if (!reflag) return false;
	var b = 0;
	for(a = 0;a < form.elements.length;a++)
	{
		if(form.elements[a].checked == true)
		{
			b = 1;
		}
	}    
	if(!b)
	{
		alert("对不起,你未选择任何操作项!");
		return false;
	}
	form.submit();
}

function fPopUpCalendarDlg(ctrlobj)
{
	showx = event.screenX - event.offsetX - 4 - 10 ; // + deltaX;
	showy = event.screenY - event.offsetY -168; // + deltaY;
	newWINwidth = 210 + 4 + 18;

	retval = window.showModalDialog("../inc/inc_calendar.asp", "", "dialogWidth:170px; dialogHeight:190px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; "  );
	if( retval != null ){
		ctrlobj.value = retval;
	}else{
		//alert("canceled");
	}
}

//ubb tag
document.write('<script language="JavaScript" src="../js/ubbcode.js"><\/script>');

document.write('<script language="JavaScript" src="../js/forum_func.js"><\/script>');