﻿             function serverLogin(v)//登录
             {                
                 if(getcookie("yoguinickname") != "")
                 {
                    cookievalue = "1-"+getcookie("yoguinickname");
                    login(cookievalue);
                    return;
                 }
                 type = v;
                 var userName = document.getElementById("ServerUserName").value;
                 var passWord = document.getElementById("ServerPassWord").value;
                 var requestUrl = systemPage+"/Templates/Configuration/Login.aspx?Method=login&userName="+userName+"&passWord="+passWord;
                 var myAjax = new Ajax( requestUrl, {
                                                       method: "get",
                                                       async:true,
								                       onComplete: login
									                }
						               );
	             myAjax.request();  
	         };
	         
	         function serverLoginOut()//退出登录
	         {
	             type = 0;
                 var requestUrl = systemPage+"/Templates/Configuration/Login.aspx?Method=loginout";
                 var myAjax = new Ajax( requestUrl, {
                                                       method: "get",
                                                       async:true,
								                       onComplete: login
									                }
						               );
	             myAjax.request();  
	         };
	          
             function login(requestText)
             {
                result = requestText.split('-');//alert(requestText);
                if(result[0] == '1')//登陆成功
                {
                    document.cookie = "yoguinickname="+result[1];//设置cookie
                    html = "欢迎您&nbsp;&nbsp;： <font color='#E01348'>"+result[1]+"</font> | <a href='javascript:void(0);' onclick='serverLoginOut();'>退出</a> | <a href='"+systemPage+"/UserPage/Default.aspx'>个人管理</a>";
                    document.getElementById("login").innerHTML = html;
                    return;
                }
                else///登陆失败
                {
                    if(type == "0")//退出
                    {
                        //清空客户端的cookie
                        var date=new Date();//获取当前时间
                        date.setTime(date.getTime()-10000);//将date设置为过去的时间
                        document.cookie="yoguinickname="+result[1]+"; expire="+date.toGMTString()+ ";path=/;domain="+systemPage+"";//将userId这个cookie删除
                     
                        html = "用户名：<input class='add_input' id='ServerUserName' type='text' style='width: 100px;' />密码：<input class='add_input' id='ServerPassWord' type='password' style='width: 100px;' /><a href='javascript:void(0);' onclick='serverLogin(1);'>登录</a>";
                        document.getElementById("login").innerHTML = html;
                    }
                    if(type == "1")
                    {
                        html = "登录失败！请检查用户名或密码是否正确！";
                        alert(html);
                    }
                }
             };
             
             //获取cookie键/值
             function getcookie(cookiename)
             {
                var cookievalue = "";
                //获取cookie字符串
                var strCookie=document.cookie;
                //将多cookie切割为多个名/值对
                var arrCookie=strCookie.split(";");
                //遍历cookie数组，处理每个cookie对
                for(var i=0;i<arrCookie.length;i++){
                       var arr=arrCookie[i].split("=");
                       //找到名称为userId的cookie，并返回它的值
                       if( cookiename == arr[0]){
                              cookievalue = arr[1] == 'undefined'?"":arr[1];
                              break;
                       }
                }
                return cookievalue;
             }
             
             window.onload = function(){ //页面加载完毕就调用这个方法
		        //serverLogin(0);
	         };
	         
	         //搜索
	         function server_search()
	         {
	            var search_type = document.getElementById("search_type").value;
	            var search_keywords = document.getElementById("search_keywords").value;
	            var url = systemPage+"/Search/Search.aspx?Type=" + search_type + "&MagazineName=" + encodeURI(search_keywords);
	            window.open(url);
	         };

             function gotoRegion()
             {
                  window.location = systemPage+"/Register.aspx?ReturnUrl="+encodeURIComponent(window.location);
             }; 
            function SearchClick(button)
            {
                if (event.keyCode == 13) 
                {        
                   event.keyCode=9; 
                   event.returnValue = false;
                   document.all[button].click();
                } 

            };        
            
            function setHeight(){
             if ((screen.width == 1024) && (screen.height == 768))
             {
               var tmpH = getPageSize()-document.getElementById('header').scrollHeight-173;
               if(tmpH<530){
                 tmpH = 530;
               }
                try
                 {
                   if(window.ie7){
                        if(document.getElementById('content01')){
                       document.getElementById('div_split').style.height = tmpH+"px";
                       if(document.getElementById('div_split')){
                       document.getElementById('navigation').style.height=tmpH+"px";
                       }
                      }  
                      if(document.getElementById('content02')){
                        var tmpHeight = document.getElementById('div_cont').scrollHeight;
                        if(tmpHeight>555){
                          if(document.getElementById('div_split')){
                           document.getElementById('div_split').style.height = tmpHeight+"px";
                          }                        
                        }                        
                      }                   
                     }
                     
                   if( window.ie6){
                        if(document.getElementById('content01')){
                       document.getElementById('div_split').style.height = tmpH+"px";
                       if(document.getElementById('div_split')){
                       document.getElementById('navigation').style.height=tmpH+"px";
                       }
                      }  
                      if(document.getElementById('content02')){
                        var tmpHeight = document.getElementById('div_cont').scrollHeight;
                        if(tmpHeight>565){
                          if(document.getElementById('div_split')){
                           document.getElementById('div_split').style.height = tmpHeight+"px";
                          }                        
                        }                        
                      }                
                     }
                   if( window.gecko){
                      tmpH = document.body.clientHeight-document.getElementById('header').scrollHeight-165;
                      tmpH = tmpH<494?494:tmpH;
                        if(document.getElementById('content01')){
                       document.getElementById('div_split').style.height = tmpH+"px";
                       if(document.getElementById('div_split')){
                       document.getElementById('navigation').style.height=tmpH+"px";
                       }
                      }   
                      if(document.getElementById('content02')){
                        var tmpHeight = document.getElementById('div_cont').scrollHeight;
                        if(tmpHeight>555){
                          if(document.getElementById('div_split')){
                           document.getElementById('div_split').style.height = tmpHeight+"px";
                          }                        
                        }                        
                      }                                        
                     }
                 }
                 catch(e)
                 {
                 
                 }                 
             }
                        
             
             if ((screen.width == 1280) && (screen.height == 1024))
             {
             var tmpH = getPageSize()-document.getElementById('header').scrollHeight-173;
             
                try
                 {
                   if(window.ie7){
                        if(document.getElementById('content01')){
                       document.getElementById('div_split').style.height = tmpH+"px";
                       if(document.getElementById('div_split')){
                       document.getElementById('navigation').style.height=tmpH+"px";
                       }
                      }  
                      if(document.getElementById('content02')){
                        var tmpHeight = getPageSize()-document.getElementById('header').scrollHeight-73;
                        if(document.getElementById('div_split')){
                           document.getElementById('div_split').style.height = tmpHeight+"px";                      
                        }                        
                      }                  
                     }
                     
                   if( window.ie6){
                        if(document.getElementById('content01')){
                       document.getElementById('div_split').style.height = tmpH+"px";
                       if(document.getElementById('div_split')){
                       document.getElementById('navigation').style.height=tmpH+"px";
                       }
                      }  
                      if(document.getElementById('content02')){
                        var tmpHeight = getPageSize()-document.getElementById('header').scrollHeight-73;
                        if(document.getElementById('div_split')){
                           document.getElementById('div_split').style.height = tmpHeight+"px";                      
                        }                        
                      }                
                     }
                   if( window.gecko){
                      tmpH = document.body.clientHeight-document.getElementById('header').scrollHeight-165;
                      
                        if(document.getElementById('content01')){
                       document.getElementById('div_split').style.height = tmpH+"px";
                       if(document.getElementById('div_split')){
                       document.getElementById('navigation').style.height=tmpH+"px";
                       }
                      }   
                      if(document.getElementById('content02')){
                        var tmpHeight = document.getElementById('div_cont').scrollHeight;
                        if(tmpHeight>555){
                           document.getElementById('div_split').style.height = tmpHeight+6+"px";                       
                        }                      
                      }                                        
                     }
                 }
                 catch(e)
                 {
                 
                 }    
             };                
            }     
 	     
 	     if($('lavaLamp')){
		    FancyExample = new SlideList($E('ul', 'lavaLamp'), OneColumn, {transition: Fx.Transitions.backOut, duration: 700, onClick: function(ev, item) { ev.stop(); }}); 
		 }; 
		    
         if($('a_Region')){
          $('a_Region').addEvent('click', function(){
              gotoRegion();
              return false;
          });		
         };               
        
         if (window.navigator.userAgent.indexOf("MSIE")>=1)
        {
            //如果浏览器为IE
            document.getElementById("box").className="box";
            }else{
            if (window.navigator.userAgent.indexOf("Firefox")>=1)
            {
            //如果浏览器为Firefox
            document.getElementById("box").className="box1";
            }else{
            //如果浏览器为其他
            document.getElementById("box").className="box";
            }
        };   



          
      (function(){  
        $('ifrm_login').src=systemPage+"/Templates/Configuration/ILogin.aspx"; }).delay(500); 
      (function(){  
        $('webCount').src = htmlSR+"/webContent.htm"; }).delay(900); 

      setHeight();
      
      
  function getPageSize() 
{
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY)
    {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } 
    else if (document.body.scrollHeight > document.body.offsetHeight) 
    {
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } 
    else 
    {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) 
    {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } 
    else if (document.documentElement && document.documentElement.clientHeight) 
    {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } 
    else if (document.body) 
    {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight) 
    {
        pageHeight = windowHeight;
    } 
    else 
    {
        pageHeight = yScroll;
    }
   
    return pageHeight;
}

