www.gusucode.com > 中网景企业网站管理系统 2008源码程序 > common/com_en.js

    // JavaScript Document
function change(a,b)
{
	if(eval(a).style.display=='')
	{
		eval(a).style.display='none';
		eval(b).className='menu1';
	}
	else
	{
		eval(a).style.display='';
		eval(b).className='menu2';
	}
}

function openwin(url,w,h)
{
  top.window.open(url,"","top=100,left=100,width="+w+",height="+h+",toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,status=0");
  return false;
}


//search form
function searchkey() {
validity=true;

 if (!check_empty(document.form_search.keyword.value))
{ validity=false;
 alert('Please input keyowrd');
document.form_search.keyword.focus();
 return validity; } 
}

function cfdel(){
 if(!confirm("Are you sure?"))
 return false;
}

function IsDigit()
{  return ((event.keyCode >= 48) && (event.keyCode <= 57));} 

//调整图片宽高
function adjustImage(target_img)
{
	var newX, newY;
	var newHeight, newWidth;
	var newImg;

	var maxWidth = 495;
	var maxHeight = 380;

	newImg = new Image();
	newImg.src = target_img.src;
	imgw = newImg.width;
	imgh = newImg.height;

	if (imgw > maxWidth || imgh > maxHeight) {
		if(imgw > imgh) {
			if(imgw > maxWidth)
				newWidth = maxWidth;
			else
				newWidth = imgw;
			newHeight = Math.round((imgh*newWidth)/imgw);
		} else {
			if(imgh > maxHeight)
				newHeight = maxHeight;
			else
				newHeight = imgh;
			newWidth = Math.round((imgw*newHeight)/imgh);
		}
	} else {
		newWidth = imgw;
		newHeight = imgh;
	}

	newX = maxWidth/2 - newWidth/2;
	newY = maxHeight/2 - newHeight/2;

	target_img.onload = null;
	target_img.src = newImg.src;
	target_img.width = newWidth;
	target_img.height = newHeight;
}

//DW预载、交换图片
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.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 check_empty(text) {
return (text.length > 0); // returns false if empty
}

function check_email(address) {
if ((address == "")
|| (address.indexOf ('@') == -1)
|| (address.indexOf ('.') == -1))
return false;
return true;
}


/*guestbook*/
function checkguestbook() {
validity=true;

if (document.gbform.contactname.value.length<2)
{ validity=false;
 alert('Please input your name!');
document.gbform.contactname.focus();
 return validity; }
/*
if (!check_email(document.gbform.email.value))
{ validity=false;
 alert('Please input your E-mail!');
 document.gbform.email.focus();
 return validity; }
*/
if (document.gbform.title.value.length<2)
{ validity=false;
 alert('Please input title!');
document.gbform.title.focus();
 return validity; }


if (document.gbform.ly.value.length<4)
{ validity=false;
 alert('Please input content!');
document.gbform.ly.focus();
 return validity; }

if (validity==true)
{return(confirm("Confirm?"));}
return validity;
}
/*guestbook end*/

/*hr*/
function chkhrform() {
validity=true;

if (document.hrform.PersonName.value.length<2)
{ validity=false;
 alert('Please input your name!');
document.hrform.PersonName.focus();
 return validity; }

if (document.hrform.Birthday.value.length<8)
{ validity=false;
 alert('Please input your Birthday!');
document.hrform.Birthday.focus();
 return validity; }

if (!check_email(document.hrform.email.value))
{ validity=false;
 alert('Please input your E-mail !');
 document.hrform.email.focus();
 return validity; }

if (document.hrform.Tel.value.length<8)
{ validity=false;
 alert('Please input your Telephone number!');
document.hrform.Tel.focus();
 return validity; }

if (document.hrform.Resumes.value.length<4)
{ validity=false;
 alert('Please input your Resumes!');
document.hrform.Resumes.focus();
 return validity; }

if (document.hrform.Ability.value.length<4)
{ validity=false;
 alert('Please input your ability!');
document.hrform.Ability.focus();
 return validity; }

if (validity==true)
{return(confirm("Confirm?"));}
return validity;
}


/*chkeck regusername*/
function CheckUserName() {
	var username = document.regform.username.value;
	if (username.length == 0 || username == " " || username.length > 20) {
		alert("Please input user name!"); return false;
	}
	
	popupWindow = window.open("checkid.asp?username="+username,"check", "width=300, height=150,resizable=no,status=no,titlebar=no,location=no,scrollbars=yes");

	if(popupWindow)
	    popupWindow.focus();
}


/*regfrom*/
function registerform() {
validity=true;

if ((document.regform.username.value.length<2) || (document.regform.username.value.length>20))
{ validity=false;
 alert('Please input user name!');
document.regform.username.focus();
 return validity; }

if (document.regform.password.value.length<6)
{ validity=false; 
alert('Please input password!');
document.regform.password.focus();
return validity;}

if (document.regform.password2.value.length<6)
{ validity=false; 
alert('Please input confirm password!');
document.regform.password2.focus();
return validity;}

if (document.regform.password.value!=document.regform.password2.value)
 {validity=false;
  alert('Please reinput password !');
  document.regform.password.focus();
  return validity; }

if (document.regform.pwd_question.value.length<1)
{ validity=false; 
alert('Please input question!');
document.regform.pwd_question.focus();
return validity;}

if (document.regform.pwd_answer.value.length<1)
{ validity=false; 
alert('Please input answer!');
document.regform.pwd_answer.focus();
return validity;}

if (document.regform.birthday.value.length<1)
{ validity=false; 
alert('Please input your birthday!');
document.regform.birthday.focus();
return validity;}

if (!check_email(document.regform.email.value))
{ validity=false;
 alert('Please input your E-mail !');
 document.regform.email.focus();
 return validity; }

if (document.regform.yzma.value=='')
{
 alert("Please input check code!");
 document.regform.yzma.focus();
 return false;
}

if (validity==true)
{return(confirm("Confirm?"));}

return validity;
}

/*login from*/
function userloginform() {
validity=true;

if (document.loginform.username.value=='')
{ validity=false;
 alert('Please input user name!');
document.loginform.username.focus();
 return validity; }

if (document.loginform.password.value=='')
{ validity=false; 
alert('Please input password!');
document.loginform.password.focus();
return validity;}
}

/*login from*/
function usermodiform() {
validity=true;

if (document.modiform.birthday.value.length<1)
{ validity=false; 
alert('Please input your birthday!');
document.modiform.birthday.focus();
return validity;}

if (!check_email(document.modiform.email.value))
{ validity=false;
 alert('Please input your E-mail!');
 document.modiform.email.focus();
 return validity; }

if (validity==true)
{return(confirm("confirm?"));}
return validity;
}

/*modi password form*/
function modipwdform() {
validity=true;

if (document.mpwdform.password.value.length<6)
{ validity=false; 
alert('Please input password!');
document.mpwdform.password.focus();
return validity;}

if (document.mpwdform.password2.value.length<6)
{ validity=false; 
alert('Please input confirm password !');
document.mpwdform.password2.focus();
return validity;}

if (document.mpwdform.password.value!=document.mpwdform.password2.value)
 {validity=false;
  alert('Please reinput password !');
  document.mpwdform.password.focus();
  return validity; }
 }

/*Login user guestbook*/
function usergbform() {
validity=true;

if (document.gbform.title.value.length<2)
{ validity=false;
 alert('Please input title !');
document.gbform.title.focus();
 return validity; }
 
if (document.gbform.content.value.length<4)
{ validity=false;
 alert('Please input content!');
document.gbform.content.focus();
 return validity; }

return validity;
}

/**/
function forgetpwd1() {
validity=true;

 if (!check_empty(document.fgform1.chkusername.value) || (document.fgform1.chkusername.value=="username"))
{ validity=false;
 alert('Please input username!');
document.fgform1.chkusername.focus();
 return validity; } 
}

function forgetpwd2() {
validity=true;
if (!check_empty(document.fgform2.chkpwdanswer.value))
{ validity=false;
 alert('Please input answer!');
document.fgform2.chkpwdanswer.focus();
 return validity; } 
}

function forgetpwd3() {
validity=true;
if (document.fgform3.password.value.length<6)
{ validity=false; 
alert('Please input password!');
document.fgform3.password.focus();
return validity;}
if (document.fgform3.password2.value.length<6)
{ validity=false; 
alert('Please input confirm password!');
document.fgform3.password2.focus();
return validity;}
if (document.fgform3.password.value!=document.fgform3.password2.value)
 {validity=false;
  alert('Please reinput the password !');
  document.fgform3.password.focus();
  return validity; }
}


/**/
function chkcmt(){
validity=true;
if (document.formcmt.content.value=='')
{ validity=false;
alert('Please input content');
document.formcmt.content.focus();
 return validity; }
if (document.formcmt.yzma.value=='')
{ validity=false;
alert('Please input the check code');
document.formcmt.yzma.focus();
 return validity; }
}

/*checkout*/
function checkout() {
validity=true;

if (!check_empty(document.chkoutform.username.value))
{ validity=false;
 alert('Please input your name');
document.chkoutform.username.focus();
 return validity; }
 
if (!check_empty(document.chkoutform.tel.value))
{ validity=false; 
alert('Please input your telephone number');
document.chkoutform.tel.focus();
return validity;}

if (!check_empty(document.chkoutform.address.value))
{ validity=false; 
alert('Please input your address');
document.chkoutform.address.focus();
return validity;}
/*
if (!check_email(document.chkoutform.email.value))
{ validity=false;
 alert('Please input your E-mail!');
 document.chkoutform.email.focus();
 return validity; }

if (!document.chkoutform.baojiafangshi.checked)
{ validity=false; 
alert('Please select quote');
return validity;}
*/
if (validity==true)
{return(confirm("Are you sure?"));}
return validity;
}