﻿function lngUser(obj){
    if($.trim($("#username").val())==""){
        alert("请输入用户名");
        $("#username")[0].focus();
        return;
    }
    if($.trim($("#password").val())==0){
        alert("请输入密码");
        $("#password")[0].focus();
        return;
    }
    
    obj.disabled="disabled";

    $.ajax({type:"POST",url:"/ajax/MemberLng.ashx",data:"u="+$("#username").val()+"&p="+$("#password").val()+"&t="+$("#mType option:selected").val(),success:function(msg){
        obj.disabled="";
        if(msg.indexOf("对不起")==0){
            alert(msg);
        }
        else{
            $(".userTable").html(msg);
        }
    }});
}
function orderLngUser(url){
    if($.trim($("#L_Username").val())==""){
        alert("请输入用户名");
        $("#L_Username")[0].focus();
        return;
    }
    if($.trim($("#L_Password").val())==0){
        alert("请输入密码");
        $("#L_Password")[0].focus();
        return;
    }

    $.ajax({type:"POST",url:"/ajax/MemberLng.ashx",data:"u="+$("#L_Username").val()+"&p="+$("#L_Password").val()+"&t="+$("input:[class='radio']:checked").val(),success:function(msg){
        if(msg.indexOf("对不起")==0){
            alert(msg);
        }
        else{
            $(".userTable").html(msg);
            closeLng();
            
            $("form").attr("action", url);
            $("form").submit();
        }
    }});
}
function outUser(){
    $.ajax({type:"POST",url:"/ajax/MemberOut.ashx",success:function(msg){
        $(".userTable").html(msg);
    }});
}

function getWeather() {
    $.ajax({
        type: "POST",
        url: "/WebServer/GetWeather.ashx",
        data: "url",
        dataType: "html",
        success: function(retv) {
            $(".travelinfo").append("<p>&nbsp;"+retv+"</p>");
        }
    });
}
$(function() {
    if (location.pathname.toLowerCase() == "/" || location.pathname.toLowerCase() == "/default.aspx" || location.pathname.toLowerCase() == "/index.html") {
        getWeather();
    }
})
//弹出层
function opendiv(m,w,h){
$("#"+m).fadeIn("slow"); 
$("#"+m).show();setPos(m,w,h);
}

function setPos(p,w,h){
var cur=getPosition();
leftadd = (cur.width-w)/2;
topadd = (cur.height-h)/2;
document.getElementById(p).style.left=leftadd+cur.left+"px";
document.getElementById(p).style.top=h+"px";
window.onscroll = function (){
var Position = getPosition();
document.getElementById(p).style.top = (Position.top + topadd) +"px";
document.getElementById(p).style.left = (Position.left + leftadd) +"px";
};
}

function getPosition() {
var top = document.documentElement.scrollTop;
var left = document.documentElement.scrollLeft;
var height = document.documentElement.clientHeight;
var width = document.documentElement.clientWidth;
return {top:top,left:left,height:height,width:width};
} 