﻿// JScript 文件

function fridayPopWinInit(){

 if(document.getElementById("mainContentID")==null){	
 
    var beforeDiv = '<div id="fridayPopWindows" class="fridayWindows">'

    +'<div class="fash_dltop"></div>'
    +'<div class="fash_dlbg">'
    +'<div class="fash_dlbott">'
//    +'<div class="fash_dlclose"><a href="#"><img src="/images/close.gif" onclick="hidePopWin();"/></a></div>'
    +'<div id="mainContentID">内容</div>'

    +'</div>'
    +'</div><div class="fash_dlbot"></div>'

    +'</div>'

    +'<div id="lockBackground" class="blockWindows"></div>'
    $("body").prepend (beforeDiv);
        

	ResizeBlockBackground();
	hidePopWin();
	window.onresize=ResizeBlockBackground;
	
	}
}	
	

function hidePopWin(){
	$("#fridayPopWindows").hide();
	$("#lockBackground").hide();
}

function showPopWin(){
	$("#fridayPopWindows").show();
	$("#lockBackground").show();
}

function openLoginWindow(targetUrl,w_idth,h_eight){
    if (targetUrl.indexOf("?")==-1)
		{targetUrl=targetUrl+"?jsrnd="+Math.random();}
	else
		{targetUrl=targetUrl+"&jsrnd="+Math.random();}
	showPopWin();
	var tableHeight=h_eight-34;
	$('#fridayPopWindows').css({left:'40%',top:'10%',width:w_idth,height:h_eight})
	$("#mainContentID").html("<table border=0  width=100% height="+tableHeight+"><tr><td class='guildTitle' align=center valign=center>正在打开页面，请稍候...</td></tr></table>");
    $.ajax({url: targetUrl,
        success:function(msg){
            $("#mainContentID").html(msg);
        } 
    });
}

function showString(Str){
	$("#loginID").html(Str);
	hidePopWin();
}

function ResizeBlockBackground(){
	var isIE=document.all?true:false;
	if (isIE)
	{
		var tempWidth=document.body.scrollWidth;
		var tempHight=document.body.scrollHeight>document.body.clientHeight?document.body.scrollHeight:document.body.clientHeight;
	}else{
		var tempWidth=document.documentElement.scrollWidth>document.documentElement.clientWidth?document.documentElement.scrollWidth:document.documentElement.clientWidth;
		var tempHight=document.documentElement.scrollHeight>document.documentElement.clientHeight?document.documentElement.scrollHeight:document.documentElement.clientHeight;
	}
	$('#lockBackground').css({width:tempWidth+"px",height:tempHight+"px"});
//	$('#lockBackground').css({background:#71a831,filter:alpha(opacity=100),-moz-opacity:0});
}



//登录
function postLogin(formName,targetUrl){

    var postStr="";
	
	if (getObj('tb_name').value==""){
		alert ("请输入用户名！");
		getObj('tb_name').focus();
		return false;
	}
	postStr += "&name=" + getObj('tb_name').value;
	
	if (getObj('tb_pswd').value==""){
		alert ("请输入密码！");
		getObj('tb_pswd').focus();
		return false;
	}
	postStr += "&pswd=" + getObj('tb_pswd').value;
	    
	$.ajax({ url: targetUrl,
		type:"post",
		dataType:"html",
		data: postStr,
		beforeSend:showPopWin,
		success:function(msg){
		    if(msg == 'no')
		    {
		        $("#error_info").html("用户名密码不正确").attr("style","color:red;");
		        return false;
		    }
		    else
		    {
		        window.location.href='/member/manage.aspx';
		    }
		    
			//$("#loginID").html(msg);
		}
	});
}



//登录Index
function postLoginIndex(formName,targetUrl){

    var postStr="";
	
	if (getObj('tb_name').value==""){
		alert ("请输入用户名！");
		getObj('tb_name').focus();
		return false;
	}
	postStr += "&name=" + getObj('tb_name').value;
	
	if (getObj('tb_pswd').value==""){
		alert ("请输入密码！");
		getObj('tb_pswd').focus();
		return false;
	}
	postStr += "&pswd=" + getObj('tb_pswd').value;
	    
	$.ajax({ url: targetUrl,
		type:"post",
		dataType:"html",
		data: postStr,
		success:function(msg){
		    if(msg == 'no')
		    {
		        $("#error_info").html("用户名密码不正确").attr("style","color:red;");
		        return false;
		    }
		    else
		    {
		        var dataName = "&name=" + getObj('tb_name').value;
		        $.ajax({ url: '/member/memberNickName.ashx',
		        type:"post",
		        dataType:"html",
		        data: dataName,
		        success:function(nick){
		           
                    document.getElementById('indexFlash').sendToActionScript(nick);
                    window.location.href='/member/manage.aspx';
		        }
	        });
		    }
		    
		}
	});
}

//打开新窗口Index
function openLoginWindowIndex(){
    var targetUrl = '/member/loginIndex.html';
    var w_idth = '639';
    var h_eight= '348';
    
    if (targetUrl.indexOf("?")==-1)
		{targetUrl=targetUrl+"?jsrnd="+Math.random();}
	else
		{targetUrl=targetUrl+"&jsrnd="+Math.random();}
	showPopWin();
	var tableHeight=h_eight-34;
	$('#fridayPopWindows').css({left:'40%',top:'10%',width:w_idth,height:h_eight})
	$("#mainContentID").html("<table border=0  width=100% height="+tableHeight+"><tr><td class='guildTitle' align=center valign=center>正在打开页面，请稍候...</td></tr></table>");
    $.ajax({url: targetUrl,
        success:function(msg){
            $("#mainContentID").html(msg);
        } 
    });
}

//退出登录
function postLogOut(formName,targetUrl){   
	$.ajax({ url: targetUrl,
		type:"post",
		dataType:"html",
		data: "",
		success:function(msg){
			//$("#loginID").html(msg);
			if(msg == 'yes')
			{
			    window.location='/index.html';
			}
		}
	});
}


//退出登录Index
function postLogOutIndex(){   
	$.ajax({ url:  '/member/memberLogout.ashx',
		type:"post",
		dataType:"html",
		data: "",
		success:function(msg){
			//$("#loginID").html(msg);
			if(msg == 'yes')
			{
			    window.location='/index.html';
			}
		}
	});
}


//登录验证
function validateState(aaa){
    	$.ajax({ url:  '/member/memberLogStateFlash.aspx',
		type:"post",
		dataType:"html",
		data: "",
		success:function(msg){
			//$("#loginID").html(msg);
			aaa = msg;
			return aaa;
			alert(msg);
            //alert(msg);
		}
		
	});
    
    
}



//取得元件
function getObj(itemId)
{
    var itemObj=document.getElementById(itemId);
    
    return itemObj;
}


//校验邮箱
function chkemail(a) 
{ 
    var i=a.length; 
    var temp = a.indexOf('@'); 
    var tempd = a.indexOf('.'); 
    if( (temp > 1) &&((i-temp) > 3)&& ((i-tempd)>0))
    { 
        return  true ; 
    } 
    return false ; 
} 


//校验数字
function isNumber(name) //数值检测
{ 
    if(name.length == 0)
        return false;
    for(i = 0; i < name.length; i++) 
    { 
        if(name.charAt(i) < "0" || name.charAt(i) > "9")
            return false;
    }
    return true;
}