﻿$(function(){
	 var index = 0;
	 $("#btn span").mouseover(function(){
		index  =  $("#btn span").index(this);
		showImg(index);
	});	
	 //滑入 停止动画，滑出开始动画.
	 $('#imgnav').hover(function(){
			  if(MyTime){
				 clearInterval(MyTime);
			  }
	 },function(){
			  MyTime = setInterval(function(){
			    showImg(index)
				index++;
				if(index==5){index=0;}
			  } , 4000);
	 });
	 //自动开始
	 var MyTime = setInterval(function(){
		showImg(index)
		index++;
		if(index==5){index=0;}
	 } , 4000);
})
//关键函数：通过控制i ，来显示不通的幻灯片
function showImg(i){
		$("#img img")
			.eq(i).stop(true,true).fadeIn(800)
			.parent().siblings().find("img").hide();
		$("#msg li")
			.eq(i).stop(true,true).fadeIn(800)
			.siblings().hide();
		 $("#btn span")
			.eq(i).addClass("hov")
			.siblings().removeClass("hov");
}
//判断 登陆 新邮件

function chk_login(n){
			
	$.ajax({
    url: "/chk_usrandmail.ashx",
    cache: false,
    type: "get",    
	data: "flag="+n,
    success: function(msg) {
    //alert(msg);
	if(msg!="0"){
		if(n==1){
        $("#lflag").html(msg);
		}else{
		$("#maila").text(msg);				
			}
	   
	   
	   }
    },


    error: function(msg, textStatus, errorThrown) {

      
    }


});
			
			
			
			}
//钢铁读取			
function LoadSteel(){
	$("#stext").show();
	$.ajax({
        url: "/get_SteelData.ashx",
        cache: false,
        type: "post",
        //data: "key=" + $("#top_key").val(),
        success: function(msg) {
 
            $("#GSteel").html(msg);
			$("#stext").hide();
        },
 
 
        error: function(msg, textStatus, errorThrown) {
 
           
        }
 
 
    });

	
	}


//登录转向

function checkform(){
   var p = $.query.get('p');
   
	$.ajax({
    url: "in_login.aspx",
    cache: false,
    type: "post",    
	data: $("#form_reg").serialize(),
    success: function(msg) {
    //alert(msg);
	if(msg=="1"){
		//账号未激活
		$("#errmsg").html("您的账号未激活或者被锁定，请联系管理员或者激活账户");
		}else if(msg=="2"){
			//密码错误
			$("#errmsg").html("密码填写错误，请检查");
			}else if(msg=="3"){
				$("#errmsg").html("必须填写用户名密码");
				}else{
					
					//location.href=document.referrer;
					//alert(document.referrer);
				if(p==""){
                                  location.href=document.referrer;
                           }else{
                                  location.href=p;
                                             }	


			}
    },


    error: function(msg, textStatus, errorThrown) {

      
    }


});
			
			
			
			}




function checkform1(){
	
	$.ajax({
    url: "in_login.aspx",
    cache: false,
    type: "post",    
	data: $("#form_reg").serialize(),
    success: function(msg) {
    //alert(msg);
	if(msg=="1"){
		//账号未激活
		alert("您的账号未激活或者被锁定，请联系管理员或者激活账户");
		}else if(msg=="2"){
			//密码错误
			alert("密码填写错误，请检查");
			}else if(msg=="3"){
				alert("必须填写用户名密码");
				}else{
					
					location.href=window.location.href;
					//alert(document.referrer);
					}
    },


    error: function(msg, textStatus, errorThrown) {

      
    }


});
					
			}


function checkform2(){
	
	$.ajax({
    url: "/usr/in_login.aspx",
    cache: false,
    type: "post",    
	data: $("#form_reg").serialize(),
    success: function(msg) {
    //alert(msg);
	if(msg=="1"){
		//账号未激活
		alert("您的账号未激活或者被锁定，请联系管理员或者激活账户");
		}else if(msg=="2"){
			//密码错误
			alert("密码填写错误，请检查");
			}else if(msg=="3"){
				alert("必须填写用户名密码");
				}else{
					
					location.href=window.location.href.replace("#end","");
					//alert(document.referrer);
					}
    },


    error: function(msg, textStatus, errorThrown) {

      
    }


});							
			}



function sendmail(){
$("#btn_fb").attr("disabled","disabled")
$.ajax({
        url: "/send_message.aspx",
        cache: false,
        type: "post",
        data: "e=ok&Receiver_Name=" + $("#Receiver_Name").val()+"&Mail_Title="+$("#Mail_Title").val()+"&Mail_Context="+$("#Mail_Context").val(),
        success: function(msg) {
           $('.boxy-content').html("<div style=\"height:30px; padding:8px;\">"+msg+"</div><div class=\"mailbottom btline\"><input type=\"button\" onclick=\"Boxy.get(this).hide()\" name=\"cancel\" value=\"确 定\" class=\"inputmail1\"></div>");
           //Boxy.get(this).setContent("提交成功");
		   
        },
 
 
        error: function(msg, textStatus, errorThrown) {
 
           
        }
 
 
    });
	};
	
	
	

function open_top(t_obj)
{
	var id=t_obj;
	var s=id.split("_");
	close_all(s[0]);
	$("#"+t_obj).hide();
	$("#"+s[0]+"_"+s[1]+"_open").show();
	
}
function close_all(name)
{
	for(var i=1;i<=num;i++)
	{
		$("#"+name+"_"+i+"_open").hide();
		$("#"+name+"_"+i+"_close").show();
		
	}
}


function DrawImage(ImgD,maxheight)
{  
   var image=new Image(); 
   image.src=ImgD.src; 
   if(image.height>maxheight)
   {    
     ImgD.height=maxheight;      
   } 
}


function slideLine(ul, delay, speed, lh) {
	var slideBox = (typeof ul == 'string')?document.getElementById(ul):ul;
	var delay = delay||1000, speed=speed||20, lh = lh||20;
	var tid = null, pause = false;
	var start = function() {
		tid=setInterval(slide, speed);
	}
	var slide = function() {
		if (pause) return;
		slideBox.scrollTop += 2;	
		if (slideBox.scrollTop % lh == 0) {
			clearInterval(tid);
			slideBox.appendChild(slideBox.getElementsByTagName('li')[0]);
			slideBox.scrollTop = 0;
			setTimeout(start, delay);
		}
	}
	slideBox.onmouseover=function(){pause=true;}
	slideBox.onmouseout=function(){pause=false;}
	setTimeout(start, delay);
  }


