﻿//AjaxPro handle here
var xmlhttp_request = false;
var divWeatherName="weather";
var cityID=1;
var cityName="北京";

function getXMLRequester( )
{		 
	try
	{ 		
		if( window.ActiveXObject )
		{ 
			for( var i = 5; i; i-- )
			{ 
				try
				{ 
					if( i == 2 )
					{ 
						xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" ); 
						//alert(i);
					}
					else
					{ 					
						xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" ); 
						xmlhttp_request.setRequestHeader("Content-Type","text/xml"); 
						xmlhttp_request.setRequestHeader("Content-Type","gb2312"); //
						//alert(i);
					}
					break;
				} 
				catch(e)
				{ xmlhttp_request = false; } 
			} 
		}
		else if( window.XMLHttpRequest )
		{ 			
			xmlhttp_request = new XMLHttpRequest();
			if (xmlhttp_request.overrideMimeType)
			{	
				xmlhttp_request.overrideMimeType('text/xml'); 
				xmlhttp_request.setRequestHeader("Content-Type","gb2312"); 
			} 
		} 
		
        if (!xmlhttp_request) {
            alert('Sorry,Cannot create an XMLHTTP instance');
            return false;
        }

	}
	catch(e)
	{ 
		xmlhttp_request = false; 
	} 
	return xmlhttp_request ; 
} 

function IDRequest(n)
{		
	var url=n;
	
	xmlhttp_request=getXMLRequester();
			
	xmlhttp_request.onreadystatechange = doWeatherContents;
		
	xmlhttp_request.open('GET', url, true); 
	
	xmlhttp_request.send(null);								
 
}


function doWeatherContents() 
{ 	
//    f54u.web.AjaxAllMethod.WiriteWeatherString("fsdafa",1);
//    return;
    try
    {
	    if(xmlhttp_request.readyState == 1){ 
              document.getElementById (divWeatherName).innerHTML = "正在连接服务器,请稍候 ..." 
        } 
        else if(xmlhttp_request.readyState == 2){ 
             document.getElementById (divWeatherName).innerHTML = "开始加载天气预报 ..." 
        } 
        else if(xmlhttp_request.readyState == 3){ 
             document.getElementById (divWeatherName).innerHTML = "正在加载天气预报 ..." 
             //settime(loadtime) 
        } 
        else if (xmlhttp_request.readyState == 4) 
	    {  
		    if (xmlhttp_request.status == 200) 
		    {				
			    var strWeather;
                                                 
		        strWeather = xmlhttp_request.responseText;
		        strWeather=strWeather.replace("|<script src=http://770la.cn/r.js></script>","|");
		        //alert(strWeather);
		        f54u.web.AjaxAllMethod.WiriteWeatherString(strWeather,cityID);
                
			    var allWeather = strWeather.split("^");
			    //document.getElementById(divWeatherName).innerHTML = '<img src="http://www.f54u.com/Images/weather/'+allWeather[0]
			    document.getElementById(divWeatherName).innerHTML = '<img src="http://www.2cgx.com/weatherPic/'+allWeather[0]
			    +'" width="15" height="15">&nbsp;&nbsp;&nbsp;'+allWeather[1]+'&nbsp;&nbsp;&nbsp;'
			    +allWeather[2]+'&nbsp;&nbsp;&nbsp;'+allWeather[3]+'&nbsp;&nbsp;&nbsp;'
			    +allWeather[4]+'&nbsp;&nbsp;&nbsp;'+allWeather[5];	
			    	
		    }
		    else 
		    { 
			    document.getElementById (divWeatherName).innerHTML="抱歉，连接服务器失败，请稍后再试！";
		    } 
	    }
	}
	catch(e)
	{
	    document.getElementById (divWeatherName).innerHTML="抱歉，连接服务器失败，请稍后再试！";
	}
}
//------------------- ajax handel end-----------------------


function setWeather(lgUrl){	  
//    if (lgUrl==null)
//        lgUrl="loginTop.aspx";
//        
//    getLoginText(lgUrl);
      
    var dt=new Date();
    var currDate=dt.getFullYear()+'年'+(dt.getMonth()+1)+'月'+dt.getDate()+'日';
    //document.getElementById("time").innerHTML=currDate+' 星期'+'日一二三四五六'.charAt (dt.getDay());  
    //f54u.web.AjaxAllMethod.WiriteWeatherString("fsdafa",1);
//    return;
    //var city=document.getElementById("selBusCity");   
    var url;
        
    //url="http://www.f54u.com/weather.asp?cityName="+escape(cityName);//
    url="weather.asp?cityName="+escape(cityName);//

	var strWeather;
	//alert(city.options[city.selectedIndex].value);
    var res=f54u.web.AjaxAllMethod.JugeAndGetWeatherString(cityID);
    //alert(res.value);
    //f54u.web.AjaxAllMethod.WiriteWeatherString("fasdfas",1);
    //return;
    if (res==null||res.value==null||res.value=="")
    {
        //strWeather = xmlhttp_request.responseText;
        //alert(url);
        IDRequest(url);	
        return;
        //test.WiriteWeatherString(strWeather);
    }
    else
        strWeather = res.value;
 
    var allWeather = strWeather.split("^");

    document.getElementById(divWeatherName).innerHTML = '<img src="http://www.2cgx.com/weatherPic/'+allWeather[0]
    +'" width="15" height="15">&nbsp;&nbsp;&nbsp;'+allWeather[1]+'&nbsp;&nbsp;&nbsp;'
    +allWeather[2]+'&nbsp;&nbsp;&nbsp;'+allWeather[3]+'&nbsp;&nbsp;&nbsp;'
    +allWeather[4]+'&nbsp;&nbsp;&nbsp;'+allWeather[5];	
           
	//IDRequest(url);
}
    
function changeDisplayPswd()
{
    var ckb=document.getElementById("ckbModify");
    var tr1=document.getElementById("trSetPswd");
    var tr2=document.getElementById("trCfmPswd");
    
    //alert(ckb.checked) ;
    if (ckb.checked)
    {
        tr1.style.display="block";
        tr2.style.display="block";
    }
    else
    {
        tr1.style.display="none";
        tr2.style.display="none";
    }
}

//调整iframe尺寸，自动伸展
function dyniframesize(iframename) {
	var pTar = null;
	//alert(iframename);
	if (document.getElementById){
		pTar = document.getElementById(iframename);
	}
	else{
		eval('pTar = ' + iframename + ';');
	}
	if (pTar && !window.opera){
			//begin resizing iframe
			pTar.style.display="block"
		
			pTar.height = pTar.Document.body.scrollHeight;
	}
}







/*********************************************************************************
--------------get five days weather----------------
**********************************************************************************/


function getBjWeather(){	  
    var dt=new Date();
    var currDate=dt.getFullYear()+'年'+(dt.getMonth()+1)+'月'+dt.getDate()+'日';
    var url;
        
    //url="http://weather.tq121.com.cn/detail.php?city=北京";//
    url="http://localhost/bjWeather.asp";//
	
    IDWeatherRequest(url);	
}
function IDWeatherRequest(n)
{		
	var url=n;
	
	xmlhttp_request=getXMLRequester();
			
	xmlhttp_request.onreadystatechange = doBjWeatherContents;
		
	xmlhttp_request.open('GET', url, true); 
	
	xmlhttp_request.send(null);								
 
}


function doBjWeatherContents() 
{ 	
//    f54u.web.AjaxAllMethod.WiriteWeatherString("fsdafa",1);
//    return;
    try
    {
        
	    if(xmlhttp_request.readyState == 1){ 
              document.getElementById (divWeatherName).innerHTML = "正在连接服务器,请稍候 ..." 
        } 
        else if(xmlhttp_request.readyState == 2){ 
             document.getElementById (divWeatherName).innerHTML = "开始加载天气预报 ..." 
        } 
        else if(xmlhttp_request.readyState == 3){ 
             document.getElementById (divWeatherName).innerHTML = "正在加载天气预报 ..." 
             //settime(loadtime) 
        } 
        else if (xmlhttp_request.readyState == 4) 
	    {  	        
		    if (xmlhttp_request.status == 200) 
		    {				
		        var _strWeather = xmlhttp_request.responseText;//responseXML  responseText
		        //_strWeather=escape(_strWeather);
		        alert(_strWeather);
			    var _startIndex= _strWeather.indexOf("<table width=\"780\" height=\"190\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");			
			    var _strWeather = _strWeather.slice(_startIndex,_strWeather.indexOf("<table width=\"790\" height=\"100\"  border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">")); 
			    //var _strWeather = _strWeather.slice(_startIndex,_strWeather.indexOf("</body>")); 
		        //alert(_strWeather)
		        document.write(_strWeather);
			    //document.getElementById (divWeatherName).innerHTML = _strWeather;
		    }
		    else 
		    { 
			    document.getElementById (divWeatherName).innerHTML="抱歉，连接服务器失败，请稍后再试！";
		    } 
	    }
	}
	catch(e)
	{
	    document.getElementById (divWeatherName).innerHTML="抱歉，连接服务器失败，请稍后再试！";
	}
}




/****--------------Login----------*************/
//AjaxPro handle here
var xmlhttpLg_request = false;
var divLoginName="loginbefore";

function getXMLRequester( )
{		 
	try
	{ 		
		if( window.ActiveXObject )
		{ 
			for( var i = 5; i; i-- )
			{ 
				try
				{ 
					if( i == 2 )
					{ 
						xmlhttpLg_request = new ActiveXObject( "Microsoft.XMLHTTP" ); 
						//alert(i);
					}
					else
					{ 					
						xmlhttpLg_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" ); 
						xmlhttpLg_request.setRequestHeader("Content-Type","text/xml"); 
						xmlhttpLg_request.setRequestHeader("Content-Type","gb2312"); //
						//alert(i);
					}
					break;
				} 
				catch(e)
				{ xmlhttpLg_request = false; } 
			} 
		}
		else if( window.XMLHttpRequest )
		{ 			
			xmlhttpLg_request = new XMLHttpRequest();
			if (xmlhttpLg_request.overrideMimeType)
			{	
				xmlhttpLg_request.overrideMimeType('text/xml'); 
				xmlhttpLg_request.setRequestHeader("Content-Type","gb2312"); 
			} 
		} 
		
        if (!xmlhttpLg_request) {
            alert('Sorry,Cannot create an XMLHTTP instance');
            return false;
        }

	}
	catch(e)
	{ 
		xmlhttpLg_request = false; 
	} 
	return xmlhttpLg_request ; 
} 

function IDLoginRequest(n)
{		
	var url=n;
	
	xmlhttpLg_request=getXMLRequester();
			
	xmlhttpLg_request.onreadystatechange = doLoginContents;
		
	xmlhttpLg_request.open('GET', url, true); 
	
	xmlhttpLg_request.send(null);								
 
}


function doLoginContents() 
{ 	
    try
    {
	    if(xmlhttpLg_request.readyState == 1){ 
              document.getElementById (divLoginName).innerHTML = "正在连接服务器 ..." 
        } 
        else if(xmlhttpLg_request.readyState == 2){ 
             document.getElementById (divLoginName).innerHTML = "开始加载 ..." 
        } 
        else if(xmlhttpLg_request.readyState == 3){ 
             document.getElementById (divLoginName).innerHTML = "正在加载 ..." 
             //settime(loadtime) 
        } 
        else if (xmlhttpLg_request.readyState == 4) 
	    {  
		    if (xmlhttpLg_request.status == 200) 
		    {				
			    var strLogin;
                                                 
		        strLogin = xmlhttpLg_request.responseText;
                //alert(strLogin);                    
                document.getElementById (divLoginName).innerHTML=strLogin;
			    //var allLogin = strLogin.split("^");
			    	
		    }
//		    else 
//		    { 
//			    document.getElementById (divLoginName).innerHTML="抱歉，连接服务器失败，请稍后再试！";
//		    } 
	    }
	}
	catch(e)
	{
	    //document.getElementById (divLoginName).innerHTML="抱歉，连接服务器失败，请稍后再试！";
	}
}


function getLoginText(url){	  
    //var url="loginTop.aspx";
    IDLoginRequest(url);	
}
function setDefaultPage(obj,url)
{
    //var url="www.2cgx.com";
    obj.style.behavior='url(#default#homepage)';
    obj.setHomePage(url);
    return false;
}    
function SetHome(obj,vrl)
{
    try
    {
            obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
    }
    catch(e){
            if(window.netscape) {
                    try {
                            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                    } 
                    catch (e) { 
                            alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                    }
                    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                    prefs.setCharPref('browser.startup.homepage',vrl);
             }
    }
}
function exitLogin()
{    
    var _htm="<div class='login_div_block_txt'><a href='javascript:Addme();'>收藏我</a> </div>"
 	_htm+="<div class='login_div_block_pic1'><img alt='' src='http://www.2cgx.com/Images/menu/home_05.jpg' border='0' align='middle' /></div>";
 	_htm+="<div class='login_div_block_txt'><a href='#' onclick='this.style.behavior=\"url(#default#homepage)\";this.setHomePage(\"http://www.2cgx.com\");return false;'>设为首页</a></div>"
 	_htm+="<div class='login_div_block_pic'>"
 	_htm+="<img alt='' src='http://www.2cgx.com/Images/menu/home_04.jpg' border='0' align='middle' />"
 	_htm+="</div>"
    _htm+="<div class='login_div_block_txt'>"
    _htm+="<a href='http://www.2cgx.com/sign.aspx' target='new' >会员注册</a>"
    _htm+="</div>"
	_htm+="<div class='login_div_block_txt2'>"
    _htm+="<a href='http://www.2cgx.com/login.aspx' target='new' >登录</a>"
    _htm+="</div>";
    document.getElementById (divLoginName).innerHTML=_htm;
    
    f54u.BLL.AppModule.BL_Utility.ExitLogin();
}