// JavaScript Document
//window.onload = getMsg;
window.onresize = resizeDiv;
//window.onerror = function(){}
//短信提示使用(asilas添加)
var bodyST,bodySL,divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,objTimer_AlphaMin,i= 0;
function getbodyST()
{
	//bodyST body scrollTop
	if(window.pageYOffset)
	{
		bodyST=window.pageYOffset;
	}
	else if(document.documentElement&&document.documentElement.scrollTop)
	{
		bodyST=document.documentElement.scrollTop;
	}
	else if(document.body)
	{
		bodyST=document.body.scrollTop;
	}
}
function getbodySL()
{
	var w=window, d=document, dd=d.documentElement;
	//bodySL body scrollLeft
	if(w.pageXOffset) 
	{
		bodySL=w.pageXOffset;
	}
    else if(dd&&dd.scrollLeft)
	{
		bodySL=dd.scrollLeft;
	}
    else if(d.body) 
	{
		bodySL=d.body.scrollLeft;
	}
}
function getdocHeight()
{
	if(window.innerHeight)
	{
		docHeight=window.innerHeight;
	}	
	else if(document.documentElement&&document.documentElement.clientHeight)
	{
		docHeight=document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		docHeight=document.body.clientHeight;
	}
}
function getdocWidth()
{
	var w=window, d=document, dd=d.documentElement;
	 if(dd&&dd.clientWidth)
	{
		docWidth=dd.clientWidth;
	}
    else if(w.innerWidth) 
	{
		docWidth=w.innerWidth;
	}
    else if(d.body)
	{
		docWidth=d.body.clientWidth;
	}
}
function getMsg(MailCount,ContentHeadTowText,ContentMainTwoText)
{

ContentHeadTowText="网站公告";
	//在弹出新邮件消息框时,要初始化变量i=0;
	//alert("go");
	i=0;
	document.getElementById('eMeng').filters.alpha.opacity=100;
	try
	{
		
		divTop = parseInt(document.getElementById("eMeng").style.top,10);
		divLeft = parseInt(document.getElementById("eMeng").style.left,10);
		divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
		divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
		
		/*
		var bodyST, bodyCH, bodyCW, bodySL;
		if(window.pageYOffset)
		{bodyST=window.pageYOffset;}
		else if(document.documentElement&&document.documentElement.scrollTop){bodyST=document.documentElement.scrollTop;}
		else if(document.body){bodyST=document.body.scrollTop;}
		if(window.innerHeight){bodyCH=window.innerHeight;}
		else if(document.documentElement&&document.documentElement.clientHeight){bodyCH=document.documentElement.clientHeight;}
		else if(document.body){bodyCH=document.body.clientHeight;}
		var w=window, d=document, dd=d.documentElement;
		if(dd&&dd.clientWidth) bodyCW=dd.clientWidth;
		else if(w.innerWidth) bodyCW=w.innerWidth;
		else if(d.body) bodyCW=d.body.clientWidth;
		if(w.pageXOffset) bodySL=w.pageXOffset;
		else if(dd&&dd.scrollLeft) bodySL=dd.scrollLeft;
		else if(d.body) bodySL=d.body.scrollLeft;
		*/
	
		//bodyST body scrollTop
		getbodyST();
		
		//bodySL body scrollLeft
		getbodySL();
	
	
		getdocWidth();
		getdocHeight();
		//docWidth = document.body.clientWidth;
		//docHeight = document.body.clientHeight;
		
	   
		
	
		
	
	
		document.getElementById("eMeng").style.top = parseInt(bodyST,10) + docHeight + 10;// divHeight
		document.getElementById("eMeng").style.left = parseInt(bodySL,10) + docWidth - divWidth;
		document.getElementById("eMeng").style.display="block";
		var tips=readCookie("tips");
		
		if(tips==""||tips==undefined)
		{
			tips="0";
		}
		if(tips=="0")
		{
			maxDiv(); //最大化
		}
		else
		{
			minDiv();//最小化
		}
	}
	catch(e){

		}
	
	//写值
	//第二个框架头文字
	if(ContentHeadTowText!=null)
	{
		document.getElementById("li_other").innerHTML=ContentHeadTowText;
	}
	var str_corp="";  //在每封提示下面加上一段话
	/*
	var city=readCookie("city");
	if(city!=""||city!=undefined)
	{
		if(city.indexOf("湖北")!=-1)
		{
			str_corp+="<p><a href='http://www.dflr.net/party/' target='_blank'><font color='red'>[武汉]世茂锦绣长江精英白领姻缘会</font></a></p>";
			str_corp+="<p><a href='http://www.dflr.net/article/htm_article/200902/20090213102476020.shtml' target='_blank'>楚天金报：千万富翁的曲折寻偶路</a></p>";
		}
	}
	*/
	//str_corp+="<p><a href='http://www.dflr.net/party/' target='_blank'><font color='red'>[武汉]东方丽人19号邀您户外踏春</font></a></p>";
	//str_corp+="<p><a href='http://www.dflr.net/party/' target='_blank'><font color='green'>[武汉]复地 东湖国际尊尚白领姻缘会</font></a></p>";
	//str_corp+="<p><a href='http://www.dflr.net/article/htm_article/200902/20090213102476020.shtml' target='_blank'>楚天金报：千万富翁的曲折寻偶路</a></p>";
	//str_corp+="<p><a href='http://www.dflr.net/article/htm_article/200901/20090121105047530.shtml'  target='_blank'>请警惕酒托、饭托借约会骗取消费</a></p>";
	
	
	
	
	//第二个框架，其它

	if(ContentMainTwoText=="")
	{
		getMyOther();
		//document.getElementById("contentMainTwo").innerHTML="<p class='ContentMainTwoNoValue'></p>";
		document.getElementById("contentMainTwo").innerHTML=str_corp;
		
	}
	else
	{
		getMyOther();
		document.getElementById("contentMainTwo").innerHTML=ContentMainTwoText+str_corp;
	}
	//第一个框架，邮件

	if(MailCount==0)
	{
		document.getElementById("contentMainOne").innerHTML="您当前没有新邮件!"+str_corp;
	}
	else
	{
		getMyMail();
		document.getElementById("contentMainOne").innerHTML="<a href='http://www.027love.com/userpro/msg-inbox.shtml' target='_blank'><font color='red'>您当前有"+MailCount+"封新邮件!</font></a>"+str_corp;
	}
	

	//$("span_MailCount").innerHTML=MailCount;
	//sort=1,是abx;sort=2,是rm;
	/*
	if(IsSecondPage) //如果是二级页面
	{
		$("div_lookMalText").innerHTML="<a href='javascript:goToLookMsg(\"http://www.dflr.net/userpro/msg.shtml?"+Sort+"\");'><font color=#FF0000>点击查看邮件</font></a>";
		//$("div_lookMalText").innerHTML="<a href='javascript:location=\"../userpro/msg.shtml?"+Sort+"\"'><font color=#FF0000>点击查看邮件</font></a>";
	}
	else
	{
		//$("div_lookMalText").innerHTML="<a href='javascript:location=\"userpro/msg.shtml?"+Sort+"\"'><font color=#FF0000>点击查看邮件</font></a>";
		$("div_lookMalText").innerHTML="<a href='javascript:goToLookMsg(\"http://www.dflr.net/userpro/msg.shtml?"+Sort+"\");'><font color=#FF0000>点击查看邮件</font></a>";
	}
	*/
	
}

//点击框架菜单
function getMyMail()
{
	if(document.getElementById("li_thetipsop").className=="maxMain")
	{
		maxDiv();//最大化
	}
	document.getElementById("li_mail").className="my_mail_over";
	document.getElementById("li_other").className="othertext_out";
	document.getElementById("contentMainOne").style.display="block";
	document.getElementById("contentMainTwo").style.display="none";
	
	
}
function getMyOther()
{
	if(document.getElementById("li_thetipsop").className=="maxMain")
	{
		maxDiv();//最大化
	}

	document.getElementById("li_mail").className="my_mail_out";
	document.getElementById("li_other").className="othertext_over";
	document.getElementById("contentMainOne").style.display="none";
	document.getElementById("contentMainTwo").style.display="block";
}


function resizeDiv()
{
	i+=1;
	/*
	if (i>=1000)   //10 second close layer
	{
		closeDiv()//如果不想关闭,把这句删了
	}
	*/
	try
	{
	divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
	divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
	//docWidth = document.body.clientWidth;
	//docHeight = document.body.clientHeight;
	
	
	getbodyST();
	getbodySL();
	getdocWidth();
	getdocHeight();
	document.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(bodyST,10);
	document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(bodySL,10);
	}
	catch(e){}
}

function moveDiv()
{
	try
	{
	getbodyST();
	if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(bodyST,10)))
	{
		//最大化完成，显示最小化按钮
		ShowMaxOrMin(true);
		window.clearInterval(objTimer);
		objTimer = window.setInterval("resizeDiv()",1);
	}
	divTop = parseInt(document.getElementById("eMeng").style.top,10);
	document.getElementById("eMeng").style.top = divTop - 5;
	}
	catch(e){}
}
//最大化操作
function maxDiv()
{
	writeCookie("tips","0",null,"/");  //保持最大化状态
	window.clearInterval(objTimer);
	objTimer = window.setInterval("moveDiv()",10);

}


//最小化后让其保持一个在页面上的状态
function resizeMinDiv()
{
	try
	{
	divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
	divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
	//docWidth = document.body.clientWidth;
	//docHeight = document.body.clientHeight;
	getbodyST();
	getbodySL();
	getdocWidth();
	getdocHeight();
	document.getElementById("eMeng").style.top =docHeight +parseInt(bodyST,10)-35;
	document.getElementById("eMeng").style.left = docWidth-divWidth +parseInt(bodySL,10);
	}
	catch(e){}
}
//开始执行最小化
function moveMinDiv()
{
	try
	{
	getbodyST();
	if (parseInt(document.getElementById("eMeng").style.top,10) >= (docHeight +parseInt(bodyST,10)-35))
	{
		
		//最小化完成，显示最大化按钮
		ShowMaxOrMin(false);
	
		window.clearInterval(objTimer);
		objTimer = window.setInterval("resizeMinDiv()",1); //最小化后要让其一直保持到一个状态
		
		
		
	}
	divTop = parseInt(document.getElementById("eMeng").style.top,10);
	
	document.getElementById("eMeng").style.top =divTop+5;

	}
	catch(e){}
}
//最小化操作
function minDiv()
{
	writeCookie("tips","1",null,"/");  //保持最小化状态
	window.clearInterval(objTimer);
	objTimer = window.setInterval("moveMinDiv()",10);

}

function ShowMaxOrMin(tag)
{
	if(tag)  //true 最小化
	{
		document.getElementById("li_thetipsop").className="minMain";
		document.getElementById("li_thetipsop").onclick=function(){minDiv();};
	}
	
	else
	{
		
		document.getElementById("li_thetipsop").className="maxMain";
		document.getElementById("li_thetipsop").onclick=function(){maxDiv();};
	}
}





//关闭操作
/*
function closeDiv()
{

	objTimer_AlphaMin=setInterval("alpha_min()",100);

}
*/
//关闭操作
function closeDiv()
{
	writeCookie("tips","2",null,"/");  //关闭操作
	window.clearInterval(objTimer);
	objTimer = window.setInterval("moveCloseDiv()",10);
	
}

//开始执行关闭
function moveCloseDiv()
{
	try
	{
	getbodyST();
	if (parseInt(document.getElementById("eMeng").style.top,10) >= (docHeight +parseInt(bodyST,10)))
	{
		
	
	
		window.clearInterval(objTimer);
		
		document.getElementById('eMeng').style.display='none';
		
		
	}
	divTop = parseInt(document.getElementById("eMeng").style.top,10);
	
	document.getElementById("eMeng").style.top =divTop+5;

	}
	catch(e){}
}



function alpha_min()
{
	var temp_opacity=document.getElementById('eMeng').filters.alpha.opacity;  //获取当前的opacity;
	temp_opacity-=10;
	document.getElementById('eMeng').filters.alpha.opacity=temp_opacity;
	if(temp_opacity<=0)
	{
		document.getElementById('eMeng').style.display='none';
		if(objTimer_AlphaMin)  window.clearInterval(objTimer_AlphaMin);
		if(objTimer) window.clearInterval(objTimer);
	}

}
//加载弹框
function LoadTips()
{
	
	
	var arr=new Array();
	arr[arr.length]="<div class='tips_main' id='eMeng'>";
		arr[arr.length]="<div class='head'>";
			//arr[arr.length]="<ul><li class='my_mail_over' onclick='getMyMail()' id='li_mail'>我的邮件</li><li class='othertext_out' onclick='getMyOther()' id='li_other'>网站公告</li><li class='minMain' onclick='minDiv()'  id='li_thetipsop'></li><li id='li_close' class='close' onclick='closeDiv()'></li></ul>";
			arr[arr.length]="<ul><li class='my_mail_over' onclick='getMyMail()' style='display:none' id='li_mail'>我的邮件</li><li class='othertext_out' onclick='getMyOther()' id='li_other'>网站公告</li><li class='minMain'  style='display:none' onclick='minDiv()'  id='li_thetipsop'></li><li id='li_close' class='close' onclick='closeDiv()'>×</li></ul>";
			
			arr[arr.length]="</div>";
		arr[arr.length]="<div class='content' id='contentMainOne'></div>";
		
		arr[arr.length]="<div class='content'  id='contentMainTwo'></div>";
		
		
	arr[arr.length]="</div>";
	document.write(arr.join(""));
}
LoadTips();