﻿function init(){
	MM_preloadImages('images/butn01-1.gif','images/butn02-1.gif','images/butn03-1.gif','images/butn04-1.gif','images/butn05-1.gif');
	getLoginBlock();
	getMsg();
	for(i=1;i<=3;i++)
		getNewsList(i);
}

function getLoginBlock(){
	var url="include/asp/login.asp";
	var pars="level=0";
	var myAjax=new Ajax.Updater(
			{success: "login_block"},
			url, 
			{
				method: "post", 
				parameters: pars,
				onFailure: rptErr,
				evalScripts: true
			});
}

function getNewsList(theNewsCat){
	var url="include/asp/getnewslist.asp";
	var pars="c="+theNewsCat;
	var myAjax=new Ajax.Updater(
			{success: "news_list_"+theNewsCat},
			url, 
			{
				method: "post", 
				parameters: pars,
				onFailure: rptErr,
				evalScripts: true
			});
}

function trim(theString){
	while(theString.substr(0,1)==" ")
		theString=theString.substr(1);

	while(theString.substr(theString.length-1,1)==" ")
		theString=theString.substr(0,theString.length-1);

	return theString;
}

function sendLoginReq(act){
	var url="http://www.xtcisco.com/index.aspx";

		var msg="";
		var j=0;
		var acnt=$F("ALLY_ACNT");
		var pwd=$F("ALLY_PWD");
		//alert("ddddd");
		//url+="?aaa="+escape(acnt)+"&bbb="+escape(pwd);
		//alert("ddddd23");
		acnt=trim(acnt);
		pwd=trim(pwd);
		msg+=acnt==""?(++j)+". 请输入您的帐号\n":"";
		msg+=pwd==""?(++j)+". 请输入您的密码\n":"";
		if(msg!="")
			{
			alert(msg);
			return false;
		    }
			//alert(url);
        //document.getElementById("LOGIN_FORM").action=url;
        //document.getElementById("LOGIN_FORM").submit();
}

function rptErr(theReq){
	alert("Error occured !");
	//document.write(theReq.responseText);
}

function clearMsg(){
	if($("login_msg")) Element.hide("login_msg");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var strDiv="";
strDiv="eMeng";


window.onresize = resizeDiv;
window.onerror = function(){}
//短信提示使用(asilas添加)
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{

	try{
	divTop = parseInt(document.getElementById(strDiv).style.top,10)
	divLeft = parseInt(document.getElementById(strDiv).style.left,10)
	divHeight = parseInt(document.getElementById(strDiv).offsetHeight,10)
	divWidth = parseInt(document.getElementById(strDiv).offsetWidth,10)
	docWidth = document.documentElement.clientWidth;
	docHeight = document.documentElement.clientHeight;
	document.getElementById(strDiv).style.top = parseInt(document.documentElement.scrollTop,10) + docHeight + 10 +"px";//  divHeight
	document.getElementById(strDiv).style.left = parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth + "px";
	document.getElementById(strDiv).style.visibility="visible"
	objTimer = window.setInterval("moveDiv()",10)
	}
	catch(e){}
}

function resizeDiv()
{
	i+=1

	try{
	divHeight = parseInt(document.getElementById(strDiv).offsetHeight,10)
	divWidth = parseInt(document.getElementById(strDiv).offsetWidth,10)
	docWidth = document.documentElement.clientWidth;
	docHeight = document.documentElement.clientHeight;
	document.getElementById(strDiv).style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)+"px";
	document.getElementById(strDiv).style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)+"px";
	}
	catch(e){}
}

function moveDiv()
{
	try
	{
	if(parseInt(document.getElementById(strDiv).style.top,10) <= (docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)))
	{
	window.clearInterval(objTimer)
	objTimer = window.setInterval("resizeDiv()",1)
	}
	divTop = parseInt(document.getElementById(strDiv).style.top,10)
	document.getElementById(strDiv).style.top = divTop - 1 + "px"
	}
	catch(e){}
}
function closeDiv()
{
	document.getElementById(strDiv).style.visibility='hidden';
	if(objTimer) window.clearInterval(objTimer)
}
window.onload=init;
