/**
 * 缩定页面特效
 */

    function isObject(obj){
        if (obj != null && typeof(obj) != "undefined")
            return true;
        else
            return false;
    }
    
    function focusFirstElement(formName){
        var form = document.forms[formName];
        if (!isObject(form) || form.tagName != "FORM")
            return;
            
        var elements = form.elements;
        for (var i = 0; i < elements.length; i++) {
            if (elements[i].type == 'text' && !elements[i].disabled) {
                elements[i].focus();
                break;
            }
        }
    }
    
    function fillNumbericOptions(start, end, val){
        var str = "";
        for (var i=start; i<=end; i++){
            str += "<option value='" + i + "'" ;
            if (i == val)
                str += " selected";
            str += " >" + i + "</option>";
        }

        document.write (str);
    }
    
    function fillOptions(data, val){
        var str = "";
        for (var i=0; i<data.length; i++){
            
            str += "<option value='" + data[i][0] + "'" ;
            if (data[i][0] == val)
                str += " selected";
            str += " >" + data[i][1] + "</option>";
            
        }
        
        document.write (str);
    }
    
    function fillQuestionOptions(val){
       fillOptions(hintQuestionList, val);
    }
    
    function fillIDTypeOptions(val){
       fillOptions(IDCardTypeList, val);
    }
    
    function fillSecureOptions(val){
        
       fillOptions(updateSecureList, val);
    }
    
    function getHintQuestion(val){
        if (val == "")
            return val;
            
        for (var i=0; i<hintQuestionList.length; i++){
            if (hintQuestionList[i][0] != "" && hintQuestionList[i][0] == val)
                return hintQuestionList[i][1];
        }
    }
    
    function getUpdateSecure(val){
        if (val == "")
            return val;
            
        for (var i=0; i<updateSecureList.length; i++){
            if (updateSecureList[i][0] != "" && updateSecureList[i][0] == val)
                return updateSecureList[i][1];
        }
    }
    
    function getIDCardType(val){
        if (val == "")
            return val;
            
        for (var i=0; i<IDCardTypeList.length; i++){
            if (IDCardTypeList[i][0] != "" && IDCardTypeList[i][0] == val)
                return IDCardTypeList[i][1];
        }
    }
    
    function getCountry(val){
        if (val == "")
            return val;
        
        for (var i=0; i<countryList.length; i++){
            if (countryList[i][0] != "" && countryList[i][0] == val)
                return countryList[i][1];
        }
    }
    
    function hideSelectForm(){
        var opts = document.getElementsByTagName("SELECT");
        if (opts == null || typeof(opts) == "undefined")
            return ;
            
        for (var i=0; i<opts.length; i++){
            opts[i].style.visibility = "hidden";
        }
    }
    
    function showSelectForm(){
        var opts = document.getElementsByTagName("SELECT");
        if (opts == null || typeof(opts) == "undefined")
            return ;
            
        for (var i=0; i<opts.length; i++){
            
            opts[i].style.visibility = "visible";
        }
    }
    
    function createBgDiv(id){
        if (!isObject(id))
            id = "backgroundDiv";
           
        offHeight = window.screen.height;
        var div = document.createElement("DIV");
        div.id = id;
        div.style.left = 0;
        div.style.top = 0;
        div.style.width=document.body.scrollWidth;
        div.style.height = document.body.scrollHeight;
        div.style.position = "absolute";
        div.style.display = "";
        div.style.zIndex = "999";
        div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
        div.style.backgroundColor="#777";
        document.body.appendChild(div);
        hideSelectForm();
        
        fadeBg(10, id);
        
        return div;
    }

        //自动在页面生成层
   function createHtmlDiv(id){
			
			var id1 = document.getElementById("logoutInfoDiv");
			var id2 = document.getElementById("logoutInfoDiv1");
        if (id1==null || id2==null){

				var div1 = document.createElement("DIV");
				var div2 = document.createElement("iframe");

				//设置1
				div1.id="logoutInfoDiv";
				div1.style.display="none";
				//设置1
				//div2.src="javascript:false";
				div2.src="";
				div2.id="logoutInfoDiv1";
				div2.style.display="none";

				document.body.appendChild(div1);
				document.body.appendChild(div2);
				return (div1+div2);
		}

        return "";
    }

    function fadeBg(index, str){
		try{
			var obj = document.getElementById(str);
			obj.style.filter = "alpha(Opacity=" + index + ")";
			
			if (index < 40)
				window.setTimeout("fadeBg(" + (index+10) + ", '" + str + "')", 10);
        }catch(e){}
    }
                            function showConfirmMsg1(){
                                if (!isObject(document.getElementById("logoutDiv")))
                                        createBgDiv("logoutDiv");
                                      
                                if (!isObject(document.getElementById("HtmlDiv")))
                                        createHtmlDiv("HtmlDiv");

                                    var infoDiv = document.getElementById("logoutInfoDiv");
									var infoDiv1 = document.getElementById("logoutInfoDiv1");

                                    infoDiv.innerHTML = generateConfirmLogoutMsg();

                                    with(infoDiv.style){
                                        zIndex = 1000; 
                                        position = "absolute"; 
                                        width = "300px";
                                        top = (document.body.offsetHeight-300)/2 + document.body.scrollTop; 
                                        left = (document.body.offsetWidth-300)/2;
                                        //border = "1px #4372A5 solid"; 
                                        padding = "10px"; 
                                        //backgroundColor = "#ffffff"; 
                                        //filter = "Alpha(Opacity=50)";
                                        display = "block";
                                    }

                                    with(infoDiv1.style){
										left = 0;
										top = 0;
										width=document.body.scrollWidth;
										height = document.body.scrollHeight;
										position = "absolute";
										display = "";
										zIndex = "999";
										filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)";
										backgroundColor="#777";
                                        display = "block";
                                    }
                                    
                            }
                            
                            function cancelLogout(){
								try{
									var aa = document.getElementById("logoutDiv");
									var infoDiv = document.getElementById("logoutInfoDiv");
									var infoDiv1 = document.getElementById("logoutInfoDiv1");
										infoDiv.style.display = "none";
										infoDiv1.style.display = "none";
									if (isObject(aa))
										document.body.removeChild(aa);     
                                }catch(e){}
                                showSelectForm();
                           }

                            function generateConfirmLogoutMsg(){	
								var msg = "";
								msg += '<table border="0" align="center" cellpadding="3" cellspacing="2" bgcolor="#999999">';
								msg += '<tr>';
								msg += '<td background="http://61.128.193.13/cqnews/images/waiting.gif" width="233" height="225">';
								msg += '</td>';
								msg += '</tr>'
								msg += '</table>';


                                return msg;
                             }

