checklogin.js全文翻译
// **********************
// PowerEasy Cms2006
// userlogin part
// code by nt2003
// **********************
var siteroot
var userstat
var username
var userid = 0
var userpass
var showtype
var popmessage
var messagecur = 0
var messageold = 0
function LoadUserLogin(iroot,itype,iusepop)
{
if(iroot == ''){
siteroot="/"
}else{
siteroot=iroot
}
if(itype == ''){
showtype = 0
}else{
showtype = parseInt(itype)
}
if(iusepop == ''){
popmessage = 0
}else{
popmessage = parseInt(iusepop)
}
ShowUserLogin()
}
function ShowUserLogin()
{
var url = siteroot + "User/User_ChkLogin.asp"
var pars = "action=xmlstat"
var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars, onComplete: ShowLoginForm, onFailure: reportError})
}
function ShowLoginForm(originalRequest)
{
var xml
if(window.ActiveXObject){
xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async=false
} else {
$('UserLogin').innerHTML = "<IFRAME id=\"UserLogin\" src=\""+ siteroot + "UserLogin.asp?ShowType=" + (showtype+1) + "\" frameBorder=\"0\" width=\"170\" scrolling=\"no\" height=\"145\"></IFRAME>"
}
xml.load(originalRequest.responseXml)
var root = xml.getElementsByTagName("body")
if(xml.readyState != 4 || root.length == 0){
userstat = "notlogin"
username = ""
userpass = ""
}else{
var loginstat = root.item(0).getElementsByTagName("checkstat").item(0).text
if(loginstat=='err'){
userstat = "notlogin"
username = root.item(0).getElementsByTagName("user").item(0).text
userpass = ""
if(root.item(0).getElementsByTagName("errsource").item(0).text==''){
var tempstr = "<div id=\"loginerr\" style=\"display: nonecolor: redbackground:#55FF88text-align: centerheight: 20border: 1px solid #000000\"></div>"
}else{
var tempstr = "<div id=\"loginerr\" style=\"color: redbackground:#55FF88text-align: centerheight: 20border: 1px solid #000000\">" + root.item(0).getElementsByTagName("errsource").item(0).text + "</div>"
}
if(showtype==0){
tempstr += "<table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
tempstr += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"userbox\">"
tempstr += "<tr><td height=\"25\" align=\"right\"><span class=\"userlog\">用户名:</span></td><td height=\"25\" colspan=\"2\"><input name=\"UserName\" type=\"text\" id=\"UserName\" size=\"16\" maxlength=\"20\" style=\"width:110px\"></td></tr>"
tempstr += "<tr><td height=\"25\" align=\"right\"><span class=\"userlog\">密 码:</span></td><td height=\"25\" colspan=\"2\"><input name=\"UserPassword\" type=\"password\" id=\"UserPassword\" size=\"16\" maxlength=\"20\" style=\"width:110px\"></td></tr>"
if(root.item(0).getElementsByTagName("checkcode").item(0).text=='1'){
tempstr += "<tr><td height=\"25\" align=\"right\"><span class=\"userlog\">验证码:</span></td><td height=\"25\"><input name=\"CheckCode\" type=\"text\" id=\"CheckCode\" size=\"6\" maxlength=\"6\" style=\"width:49px\"></td><td><a href=\"javascript:refreshimg()\" title=\"看不清楚,换个图片\"><img id=\"checkcode\" src=\"" + siteroot + "inc/checkcode.asp\" style=\"border: 1px solid #ffffff\"></a></td></tr>"
}
tempstr += "</table><table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
tempstr += "<tr><td colspan=\"2\" align=\"center\">"
tempstr += "<table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"5\" cellpadding=\"0\">"
tempstr += "<tr><td colspan=\"2\" align=\"center\"><input name=\"Login\" type=\"image\" id=\"Login\" src=\""+ siteroot +"Images/logins_01.gif\" style=\"width:45pxheight:39pxborder:0px\" align=\"middle\" value=\" 登 录 \" onclick=\"CheckUser(" + root.item(0).getElementsByTagName("checkcode").item(0).text + ")\"> <input type=\"checkbox\" name=\"CookieDate\" value=\"3\">永久登录"
tempstr += "</td></tr></table>"
tempstr += "<table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">"
tempstr += "<tr><td rowspan=\"2\"><img src=\""+ siteroot +"Images/loginr_01.gif\" alt=\"\"></td><td><a href=\""+ siteroot +"Reg/User_Reg.asp\" target=\"_blank\"><img src=\""+ siteroot +"Images/loginr_02.gif\" alt=\"新用户注册\" border=\"0\"></a></td></tr>"
tempstr += "<tr><td><a href=\""+ siteroot +"User/User_GetPassword.asp\" target=\"_blank\"><img src=\""+ siteroot +"Images/loginr_03.gif\" alt=\"忘记密码?\" border=\"0\"></a></td></tr>"
tempstr += "</table>"
tempstr += "</tr></table>"
}else{
if(showtype==3)
{
tempstr += "<table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
tempstr += "<tr><td align=\"right\"><font color=\"#FFFFFF\">用户名</font></td><td><input name=\"UserName\" type=\"text\" id=\"UserName\" size=\"8\" maxlength=\"20\" style=\"width:40px\"></td>"
tempstr += "<td align=\"right\"><font color=\"#FFFFFF\">密码</font></td><td><input name=\"UserPassword\" type=\"password\" id=\"Password\" size=\"8\" maxlength=\"20\" style=\"width:40px\"></td>"
tempstr += "<td align=\"right\"><font color=\"#FFFFFF\">验证码</font></td>"
if(root.item(0).getElementsByTagName("checkcode").item(0).text=='1'){
tempstr += "<td><input name=\"CheckCode\" type=\"text\" id=\"CheckCode\" size=\"8\" maxlength=\"6\" style=\"width:40px\"></td><td><a href=\"javascript:refreshimg()\" title=\"看不清楚,换个图片\"><img id=\"checkcode\" src=\"" + siteroot + "inc/checkcode.asp\" style=\"border: 1px solid #ffffff\"></a></td>"
}
tempstr += "<td><input type=\"checkbox\" name=\"CookieDate\" value=\"3\"><font color=\"#FFFFFF\">永久登录 </font>"
tempstr += "</td><td><input name=\"Login\" type=\"image\" id=\"Login\" src=\"" + siteroot + "Images/toplogin.gif\" value=\"\" onclick=\"CheckUser(" + root.item(0).getElementsByTagName("checkcode").item(0).text + ")\" style=\"width:45pxheight:18px\"></td><td><a href=\"" + siteroot + "Reg/User_Reg.asp\" target=\"_blank\"><font color=\"#FFFFFF\">注册</font></a> <a href=\"" + siteroot + "User/User_GetPassword.asp\" target=\"_blank\"><font color=\"#FFFFFF\">忘记密码</font></a></td></tr></table>"
}
else{
tempstr += "<table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
tempstr += "<tr><td height=\"25\" align=\"right\">用户:</td><td height=\"25\"><input name=\"UserName\" type=\"text\" id=\"UserName\" size=\"16\" maxlength=\"20\" style=\"BACKGROUND-COLOR:#6666ff width:80px\"></td>"
tempstr += "<td height=\"25\" align=\"right\">密码:</td><td height=\"25\"><input name=\"UserPassword\" type=\"password\" id=\"Password\" size=\"16\" maxlength=\"20\" style=\"BACKGROUND-COLOR:#6666ff width:80px\"></td>"
if(root.item(0).getElementsByTagName("checkcode").item(0).text=='1'){
tempstr += "<td height=\"25\" align=\"right\">验证码:</td>"
tempstr += "<td height=\"25\"><input name=\"CheckCode\" type=\"text\" id=\"CheckCode\" size=\"6\" maxlength=\"6\" style=\"BACKGROUND-COLOR:#6666ff\"><a href=\"javascript:refreshimg()\" title=\"看不清楚,换个图片\"><img id=\"checkcode\" src=\"" + siteroot + "inc/checkcode.asp\" style=\"border: 1px solid #ffffff\" align=\"middle\"></a></td>"
}
tempstr += "<td height=\"25\" colspan=\"2\" align=\"right\">Cookie:<select name=\"CookieDate\" style=\"border: 1px solid #ffffff\"><option selected value=\"0\">不保存</option><option value=\"1\">保存一天</option><option value=\"2\">保存一月</option><option value=\"3\">保存一年</option></select>"
tempstr += "<input name=\"Login\" type=\"submit\" id=\"Login\" value=\"登 录\" onclick=\"CheckUser(" + root.item(0).getElementsByTagName("checkcode").item(0).text + ")\"></td><td height='25'><a href=\"" + siteroot + "Reg/User_Reg.asp\" target=\"_blank\">【用户注册】</a><a href=\"" + siteroot + "User/User_GetPassword.asp\" target=\"_blank\">【找回密码】</a></td></tr></table>"
}
}
var apiTempHtml = getAPIUrls(root,username,userpass)
$('UserLogin').innerHTML = tempstr + apiTempHtml
}else{
userstat = "login"
username = root.item(0).getElementsByTagName("user").item(0).text
userid = root.item(0).getElementsByTagName("userid").item(0).text
userpass = root.item(0).getElementsByTagName("userpass").item(0).text
var plus_day = new Date( )
var plus_hr= plus_day.getHours( )
var timehello="hello"
if (( plus_hr >= 0 ) && (plus_hr < 6 ))
timehello = "<font color=\"#000000\">凌晨好!</font>"
if (( plus_hr >= 6 ) && (plus_hr < 9))
timehello = "<font color=\"#000000\">早上好!</font>"
if (( plus_hr >= 9 ) && (plus_hr < 12))
timehello = "<font color=\"#000000\">上午好!</font>"
if (( plus_hr >= 12) && (plus_hr <14))
timehello = "<font color=\"#000000\">中午好!</font>"
if (( plus_hr >= 14) && (plus_hr <17))
timehello = "<font color=\"#000000\">下午好!</font>"
if (( plus_hr >= 17) && (plus_hr <18))
timehello = "<font color=\"#000000\">傍晚好!</font>"
if ((plus_hr >= 18) && (plus_hr <23))
timehello = "<font color=\"#000000\">晚上好!</font>"
function CheckUser(checktype)
{
var UserName = $F('UserName')
var Password = $F('UserPassword')
var CheckCode = ''
if(checktype=='1'){
CheckCode = $F('CheckCode')
}else{
var CheckCode = 0
}
var CookieDate = $F('CookieDate')
if(UserName==''){
$('loginerr').innerHTML = "请填写用户名!"
Element.show('loginerr')
Field.focus('UserName')
}else{
if(Password==''){
$('loginerr').innerHTML = "请填写密码!"
Element.show('loginerr')
Field.focus('UserPassword')
}else{
if(checktype=='1' && CheckCode==''){
$('loginerr').innerHTML = "请填写验证码!"
Element.show('loginerr')
Field.focus('CheckCode')
}else{
$('UserLogin').innerHTML = "验证中..."
var checkurl = siteroot + "User/User_ChkLogin.asp?action=xml"
// creat user xml file
var xml_dom = new ActiveXObject("Microsoft.XMLDOM")
xml_dom.async=false
var xmlproperty = xml_dom.createProcessingInstruction("xml","version=\"1.0\" encoding=\"gb2312\"")
xml_dom.appendChild(xmlproperty)
var objRoot = xml_dom.createElement("root")
var objField = xml_dom.createNode(1,"username","")
objField.text = UserName
objRoot.appendChild(objField)
objField = xml_dom.createNode(1,"password","")
objField.text = Password
objRoot.appendChild(objField)
objField = xml_dom.createNode(1,"checkcode","")
objField.text = CheckCode
objRoot.appendChild(objField)
objField = xml_dom.createNode(1,"cookiesdate","")
if(CookieDate>0){
objField.text = CookieDate
}
objRoot.appendChild(objField)
xml_dom.appendChild(objRoot)
// send to server
var userhttp = getHTTPObject()
userhttp.open("POST",checkurl,false)
userhttp.onreadystatechange = function ()
{
if (userhttp.readyState == 4 && userhttp.status==200){
ShowLoginForm(userhttp)
}else{
reportError()
}
}
userhttp.send(xml_dom)
}
}
}
}
function GetNewMessage()
{
var url = siteroot + "User/User_ChkLogin.asp"
var pars = "action=xmlstat"
var myAjax = new Ajax.Request(url, {method: 'get', parameters: pars, onComplete: ShowNewMessage})
}
function ShowNewMessage(originalRequest)
{
var xml2 = new ActiveXObject("Microsoft.XMLDOM")
xml2.async = false
xml2.load(originalRequest.responseXml)
var root2 = xml2.getElementsByTagName("body/unreadmessage")
var msgstat2 = root2.item(0).getElementsByTagName("stat").item(0).text
var messageloop2 = root2.item(0).getElementsByTagName("item")
messagecur = messageloop2.length
if(messagecur != messageold){
messageold = messagecur
ShowLoginForm(originalRequest)
}
}
function havemessage()
{
$('usermessage').className='havemessaged'
}
function hidemessage()
{
$('usermessage').className='havemessage'
}
function UserLogout()
{
var outurl = siteroot + "User/User_Logout.asp"
var outpars = "action=xml"
var outAjax = new Ajax.Request(outurl, {method: 'post', parameters: outpars, onComplete: ShowUserLogin, onFailure: reportError})
}
function reportError()
{
$('UserLogin').innerHTML = "<a href=\"#\" onclick=\"ShowUserLogin()\">错误,服务器无响应!</a>"
}
function refreshimg(){
document.all.checkcode.src = siteroot + "inc/checkcode.asp"
}
var glabelid
var gvalue
var gurl
var gtime
var dstat=0
// *****************
// dynapage part
// *****************
function ShowDynaPage(labelid,ipage,tflash,rootdir,value)
{
var pagename = "dyna_page_" + labelid
$(pagename).innerHTML = "updateing..."
gurl = rootdir + "dyna_page.asp"
glabelid = labelid
gtime = tflash
// creat send xml file
var dy_dom = new ActiveXObject("Microsoft.XMLDOM")
dy_dom.async=false
var xmlproperty = dy_dom.createProcessingInstruction("xml","version=\"1.0\" encoding=\"gb2312\"")
dy_dom.appendChild(xmlproperty)
var objRoot = dy_dom.createElement("root")
var objField = dy_dom.createNode(1,"id","")
objField.text = labelid
objRoot.appendChild(objField)
objField = dy_dom.createNode(1,"rootdir","")
objField.text = rootdir
objRoot.appendChild(objField)
objField = dy_dom.createNode(1,"page","")
objField.text = ipage
objRoot.appendChild(objField)
objField = dy_dom.createNode(1,"value","")
objField.text = value
objRoot.appendChild(objField)
dy_dom.appendChild(objRoot)
gvalue = dy_dom
// sent to server
var dyhttp = getHTTPObject()
dyhttp.open("POST",gurl,false)
dyhttp.onreadystatechange = function ()
{
if (dyhttp.readyState == 4 && dyhttp.status==200)
{
//$("dyna_body_" + labelid).innerHTML = dyhttp.responseText
DynaPageResponse(dyhttp,labelid,tflash)
}
}
dyhttp.send(dy_dom)
if(parseInt(tflash)>9){
if(dstat==0){
dstat=1
new PeriodicalExecuter(reFlashDynaPage,parseInt(tflash))
}
}
}
function reFlashDynaPage()
{
var pagename1 = "dyna_page_" + glabelid
$(pagename1).innerHTML = "updateing..."
// sent to server
var fdyhttp = getHTTPObject()
fdyhttp.open("POST",gurl,false)
fdyhttp.onreadystatechange = function ()
{
if (fdyhttp.readyState == 4 && fdyhttp.status==200){
DynaPageResponse(fdyhttp,glabelid,gtime)
}
}
fdyhttp.send(gvalue)
}
function DynaPageResponse(pageRequest,rid,rflash)
{
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load(pageRequest.responseXml)
var tempdom = xml.getElementsByTagName("stat")
var stat = tempdom.item(0).text
if(stat=='err'){
$("dyna_body_" + rid).innerHTML = xml.getElementsByTagName("infomation")
}else{
tempdom = xml.getElementsByTagName("id")
var tid = tempdom.item(0).text
if(tid!=''){
tempdom = xml.getElementsByTagName("rootdir")
var temprootdir = tempdom.item(0).text
tempdom = xml.getElementsByTagName("content")
var tempcontent = tempdom.item(0).text
if(tempcontent!=''){
$("dyna_body_" + tid).innerHTML = tempcontent
}
tempdom = xml.getElementsByTagName("totalpage")
var temptotalpage = tempdom.item(0).text
tempdom = xml.getElementsByTagName("currentpage")
var tempcurrentpage = tempdom.item(0).text
tempdom = xml.getElementsByTagName("totalitem")
var temptotalitem = tempdom.item(0).text
tempdom = xml.getElementsByTagName("value")
var tempvalue = tempdom.item(0).text
GetPageList(tid,temprootdir,temptotalpage,tempcurrentpage,temptotalitem,tempvalue,0,rflash)
}
}
}
function GetPageList(t1,d1,p1,p2,p3,v1,m1,rt1)
{
if(parseInt(p2)<1){
p2=1
}
if(p1>1){
var temppage
if(m1==0){
if(parseInt(p2)>1){
temppage = "<img src=\"" + d1 + "Skin/blue/first.gif\" style=\"cursor:hand\" onclick=\"ShowDynaPage(" + t1 + ",1," + rt1 + ",'" + d1 + "','" + v1 + "')\">"
temppage += " <img src=\"" + d1 + "Skin/blue/prev.gif\" style=\"cursor:hand\" onclick=\"ShowDynaPage(" + t1 + "," + (parseInt(p2)-1) + "," + rt1 + ",'" + d1 + "','" + v1 + "')\">"
}else{
temppage = "<img src=\"" + d1 + "Skin/blue/first_d.gif\">"
temppage += " <img src=\"" + d1 + "Skin/blue/prev_d.gif\">"
}
var beginlog
var endlog
if(parseInt(p2)>5){
beginlog = parseInt(p2)-4
temppage = temppage + "."
}else{
beginlog = 1
}
if((parseInt(p2)+4)<=p1){
endlog = parseInt(p2)+4
}else{
endlog = p1
}
for (var i = beginlog i <= endlog i++) {
if(parseInt(p2)==i){
temppage += " [<b><font color=red>" + i + "</font></b>] "
}else{
temppage += " <b style=\"cursor:hand\" onclick=\"ShowDynaPage(" + t1 + "," + i + "," + rt1 + ",'" + d1 + "','" + v1 + "')\">" + i + "</b> "
}
}
if((parseInt(p2)+4)<p1){
temppage = temppage + "."
}
if(parseInt(p2)<parseInt(p1)){
temppage += "<img src=\"" + d1 + "Skin/blue/next.gif\" style=\"cursor:hand\" onclick=\"ShowDynaPage(" + t1 + "," + (parseInt(p2)+1) + "," + rt1 + ",'" + d1 + "','" + v1 + "')\">"
temppage += " <img src=\"" + d1 + "Skin/blue/end.gif\" style=\"cursor:hand\" onclick=\"ShowDynaPage(" + t1 + "," + p1 + "," + rt1 + ",'" + d1 + "','" + v1 + "')\">"
}else{
temppage += "<img src=\"" + d1 + "Skin/blue/next_d.gif\">"
temppage += " <img src=\"" + d1 + "Skin/blue/end_d.gif\">"
}
}else{
if(parseInt(p2)>1){
temppage = " <img src=\"" + d1 + "Skin/blue/prev.gif\" style=\"cursor:hand\" onclick=\"ShowDynaPage(" + t1 + "," + (parseInt(p2)-1) + "," + rt1 + ",'" + d1 + "','" + v1 + "')\">"
}else{
temppage = " <img src=\"" + d1 + "Skin/blue/prev_d.gif\">"
}
if(parseInt(p2)<p1){
temppage += "<img src=\"" + d1 + "Skin/blue/next.gif\" style=\"cursor:hand\" onclick=\"ShowDynaPage(" + t1 + "," + (parseInt(p2)+1) + "," + rt1 + ",'" + d1 + "','" + v1 + "')\">"
}else{
temppage += "<img src=\"" + d1 + "Skin/blue/next_d.gif\">"
}
}
$("dyna_page_" + t1).innerHTML = temppage
}else{
Element.hide("dyna_page_" + t1)
}
}
//***************************
// xmlHTTPinit
//***************************
function getHTTPObject(){
var xmlhttp_request = false
try{
if( window.ActiveXObject ){
for( var i = 5 i i-- ){
try{
if( i == 2 ){
xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" )
}else{
xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" )
xmlhttp_request.setRequestHeader("Content-Type","text/xml")
xmlhttp_request.setRequestHeader("Content-Type","gb2312")
}
break
}catch(e){
xmlhttp_request = false
}
}
}else if( window.XMLHttpRequest ){
xmlhttp_request = new XMLHttpRequest()
if (xmlhttp_request.overrideMimeType) {
xmlhttp_request.overrideMimeType('text/xml')
}
}
}catch(e){
xmlhttp_request = false
}
return xmlhttp_request
}
//***************************
//cont for Visitor part
//***************************
function addfangke(ibid,idir)
{
// alert(username)
if(userstat == 'login'){
if(idir==0){
var fangurl = "index.asp?action=addfang"
}else{
var fangurl = idir + "/index.asp?action=addfang"
}
var fang_dom = new ActiveXObject("Microsoft.XMLDOM")
fang_dom.async=false
var pfang = fang_dom.createProcessingInstruction("xml","version=\"1.0\" encoding=\"gb2312\"")
fang_dom.appendChild(pfang)
var fangRoot = fang_dom.createElement("root")
var fangField = fang_dom.createNode(1,"blogid","")
fangField.text = ibid
fangRoot.appendChild(fangField)
fangField = fang_dom.createNode(1,"username","")
fangField.text = username
fangRoot.appendChild(fangField)
fangField = fang_dom.createNode(1,"userid","")
fangField.text = userid
fangRoot.appendChild(fangField)
fang_dom.appendChild(fangRoot)
var VHttp = getHTTPObject()
VHttp.open("POST",fangurl,false)
VHttp.send(fang_dom)
}
}
//***************************
//Pop-it menu part
//***************************
var defaultMenuWidth="150px" //set default menu width.
var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
function geneinner(id,name,url,itype){
linkset[0] = ''
linkset[0] += '<a href="'+siteroot+'User/User_Space.asp?Action=AddRss&url=' + url + '"><span style="color:darkblue">add to my RssRead</span></b></a>'
return linkset
}
// do not edit
var ie5=document.all && !window.opera
var ns6=document.getElementById
if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}
function showmenutxt(e,content,optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=content
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}
function showmenu(e,id,name,url,optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=geneinner(id,name,url,'rss')
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}
function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true
return false
}
function hidemenu(){
if (window.menuobj){
menuobj.style.visibility="hidden"
}
}
function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement)){
hidemenu()
}else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)){
hidemenu()
}
}
function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}
function clearhidemenu(){
if (window.delayhide){
clearTimeout(delayhide)
}
}
function getAPIUrls(root,username,userpass){
var strTempHTML = ""
var iName,iPass
var syskey = root.item(0).getElementsByTagName("syskey").item(0).text
var savecookie = root.item(0).getElementsByTagName("savecookie").item(0).text
if (savecookie != "") {
savecookie = "&savecookie=" + savecookie
}else{
savecookie = "&savecookie="
}
if (syskey != "" && username != "") {
iName = "&username=" + username
if (userpass != "") {
iPass = "&password=" + userpass
}else{
iPass = "&password="
}
var iUrls = root.item(0).getElementsByTagName("apiurl")
for (var i=0 i<iUrls.length i++){
strTempHTML += "<iframe frameborder=\"0\" width=\"1\" height=\"1\" src=\"" + iUrls.item(i).text + "?syskey=" + syskey + iName + iPass + savecookie + "\" \/>"
}
}
return strTempHTML
}
if (ie5||ns6){
document.onclick=hidemenu
}