//公有变量
var tempFoc=1;
var procId;
var index =false;
$().ready(function(){
		//初始化
		if (index){ playNext()};
		//getcopyright();
	});

function showMenu(num) {
	if (num == tempFoc){
		return null;
	}else{
		tempFoc = num;
		$(".menu_list").css("display","none");
		$("#menu_" + num).css("display","block");
	}
}
function playNext(){
	procId =  setInterval("showNextImg()",3000);
}
function showImg(obj){
	//
	playIt(obj);
	clearInterval(procId);
	
}
function playIt(obj){
	//
	$(".flash_list_focus").removeClass("flash_list_focus").addClass("flash_list_item"); 
	obj.className = "flash_list_focus";
	var i = $(".flash_list_focus").attr("cid");
	$("#flash_img_url").attr("href",linkArray[parseInt(i)]); 
	$("#flash_img_show").attr("src",picArray[parseInt(i)]);
	
}

function showNextImg(){
	var i = $(".flash_list_focus").attr("cid");
	if (i==1) {
		playIt($(".flash_list_item")[1]);	
	}else{
		playIt($(".flash_list_item")[0]);		
	}
}

function getbyid(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	}else if (document.all) {
		return document.all[id];
	}else if (document.layers) {
		return document.layers[id];
	}else {
		return null;
	}
}
//===========================================
//函数名：user_log
//参数：log_na,log_pwd
//Create by leo at20080805
//last updated @20081030
//===========================================
function user_log(a){
	var usr_na;
	var usr_pwd;

	usr_na=getbyid("log_user_na").value;
	usr_pwd=getbyid("log_user_pwd").value;
	
	if ((usr_na=="") || (usr_pwd=="")){
		getbyid("log_state").innerHTML="用户名或密码不能为空！";
		getbyid("log_state").style.color="red";
	}else{
		//	Ajax调用，判读用户名和密码的正确性
		
		var str = "key=" + usr_na + "&key1=" + usr_pwd;
		$.post('/login/checklogin.asp',str,function(s){

			if (s=="err"){
				
				getbyid("log_state").innerHTML="用户名或密码错误！";
				getbyid("log_state").style.color="red";
				return false;
				
			}else if (s=="del"){
				
				getbyid("log_state").innerHTML="该用户已删除！";
				getbyid("log_state").style.color="red";
				return false;
				
			}else{
				if (a==1){
					var comeurl;
					if (getbyid("comeurl")) comeurl=getbyid("comeurl").value;
					if (comeurl==null || comeurl=="") comeurl="/";
					window.location.href=comeurl;
				}else{
					var temparry=new Array;
					temparry=eval(s);
					$(".logoform").css("display","none");
					getbyid("log_una").innerHTML=temparry[0].Name;
					//getbyid("log_umail").innerHTML=temparry[0].Email;
					getbyid("log_utime").innerHTML=temparry[0].LastLogTime;
					getbyid("log_uip").innerHTML=temparry[0].LastLogIp;
					//getbyid("log_ujf").innerHTML=temparry[0].integral;
					getbyid("loged_area").style.display="";
					//getbyid("head_nav").innerHTML="你好，<a href=\"/my\"><span id=\"log_una1\"></span></a>&nbsp;|&nbsp;<a href=\"/my\">个人中心</a>&nbsp;|&nbsp;<a href=\"/my?proc=logout\">退出</a>&nbsp;|&nbsp;<span class=\"ico_3\"><a href=\"/help\">帮助</a></span>";
					//getbyid("log_una1").innerHTML=temparry[0].Name;
				}
				return false;
			}							  
		}
		);	
	}
}



function sendPwdForLost(){
	var obj,val;
	val=getbyid("usrna").value;
	obj=getbyid("usrna_display");
	var regs = new Ajax('checks', 'HTML');
	var str = "key=" + val;
	var statue;
	regs.post('passReset.asp',str,function(s){
		if (s==1){
			obj.className="lost_input_pass";
			obj.innerHTML="处理完毕！重设密码的链接已经发送到你的邮箱中，请注意查收并及时修改密码！";
			statue=false;
		}else{
			obj.className="lost_input_err";
			obj.innerHTML="发生不知名错误，你的请求没有完成，请刷新后重新尝试";
			obj.innerHTML=s;
			statue=true;
		}							  
	}
	);
}

//重设密码，判断密码是否合法
function passReset(x){
	var state=true;
	var obj = getbyid("showinfo");
	var val = getbyid("pwd").value;
	obj.style.display="none";
	if (!isPwd()) state=false;
	if (!isRePwd()) state=false;
	if (state!=false){
		var regs = new Ajax('checks', 'HTML');
		var str = "key=" + val + "&key1=" + x;
		var statue;
		regs.post('resetPass.asp',str,function(s){
			if (s==1){
				obj.style.display="block";
				obj.className="lost_input_pass";
				obj.innerHTML='处理完毕！密码已修改，请返回后重新登陆！ <a href="/">返回上海环保产业协会网首页</a>';
			}else if(s==3){
				obj.style.display="block";
				obj.className="lost_input_err";
				obj.innerHTML="你修改过密码了，或者该链接已失效！";
			}else{
				obj.style.display="block";
				obj.className="lost_input_err";
				obj.innerHTML="发生不知名错误，你的请求没有完成，请刷新后重新尝试";
			}							  
		}
	);
		return true;
	}else{
		obj.style.display="block";
		obj.className="lost_input_err";
		obj.innerHTML="出错，请检查所有必填选项！";
		return false;
	}
}


function drawImage(ImgD,widthStr,heightStr){ 
	var image=new Image(); 
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){ 
		if(image.width/image.height>= 1){ 
			if(image.width>widthStr){
   				ImgD.width=widthStr; 
   				ImgD.height=(image.height*widthStr)/image.width; 
  			}else{ 
  			 	ImgD.width=image.width;
   				ImgD.height=image.height; 
  			}
		}else{ 
  			if(image.height>heightStr){
   				ImgD.height=heightStr; 
   				ImgD.width=(image.width*heightStr)/image.height; 
  			}else{ 
   				ImgD.width=image.width;
   				ImgD.height=image.height; 
  			} 
		} 
	}
}
