﻿var ajax = {
        storeVal: {
            "fun" : ""
        },
        simple: function(url,method,data,fun)
        {
            if(url == null || url == "")
            {
                url = String(location);
            }
            method = (method == null || method == "") ? "post" : method;
            var html = "";
            
            if(!document.getElementById("ajaxform"))
            {
                html += "<form action='"+url+"' target='ajaxFrame' method='"+method+"' id='ajaxform'>";
                html += "</form>";
                html += "<iframe name='ajaxFrame' src='javascript:void 0;' height='0' width='0' frameborder='0' scrolling=auto></iframe>";
            }
            else
            {
                document.getElementById("ajaxform").action = url;
                document.getElementById("ajaxform").method = method;
                document.getElementById("ajaxform").innerHTML = data;
            }
            
            var obj = document.createElement("div");
	        if(!document.getElementById("ajax_Div"))
	        {
	            obj.setAttribute("id","ajax_Div");
	            obj.style.display = "none";
	            obj.innerHTML = html;
	            document.body.appendChild(obj);
	        }
	        
	        if(data != null && data != "")
	        {
	            document.getElementById("ajaxform").innerHTML = data;
	        }
	        
	        if(typeof(fun) == "function")
	        {
	            this.storeVal.fun = fun;
	        }
	        else
	        {
	            this.storeVal.fun = "";
	        }
	        
	        document.forms["ajaxform"].submit();
        },
        callBack: function(data)
        {
            //ajax回调处理            
            var fun = this.storeVal.fun;
            
            if(fun != null && fun != "")
            {
                fun(data);
            }
        }
    }
    
function changeLan()
{
    var url = "index.aspx?type=setlan&id="+document.getElementById("selLanguages").value;
    ajax.simple(url,"","",success);
}

function success()
{
    window.location.href = "/index.aspx";
}