


 var callbackTimerLength = 20000;
var shownAlertError = 0;
var allowClicks = 1;
var showDiv = 0;
var divLeft = 0;
var divTop = 0;
function updatePopupDivPos(){
if (showDiv != 0) {
 document.getElementById("dhtmlWindowToMove").style.left = divLeft + document.body.scrollLeft;
document.getElementById("dhtmlWindowToMove").style.top = divTop + document.body.scrollTop;
if (document.body.offsetHeight > 500){
setTimeout("updatePopupDivPos()",1000);
};
};
};
function hideSelect(currentElement,what){
if (!what){
currentElement = document.childNodes[0];
what = "hidden";
};
if (currentElement.tagName == "SELECT"){
currentElement.style.visibility = what;
};
for (var i=0; i < currentElement.childNodes.length; i++ ) {
hideSelect(currentElement.childNodes[i],what);
};
};
function dhtmlWindow(left,top,width,height){
divLeft = left;
divTop = top;
var docFrag = document.createDocumentFragment();
var bodyTag = document.getElementsByTagName("BODY")[0];
var outerDiv = document.createElement('DIV');
outerDiv.className = "window";
outerDiv.style.width = width+6;
outerDiv.style.height = height + 20;
outerDiv.style.left = left;
outerDiv.style.top = top;
var innerDiv = document.createElement('DIV');
innerDiv.className = "titleBar";
var chrome = document.createElement('DIV');
chrome.className = "titleBarText";
chrome.innerHTML="&nbsp;";
var theIframe = document.createElement('IFRAME');
theIframe.className = "clientArea";
theIframe.style.width = width;
theIframe.style.height = height - 5;
innerDiv.appendChild(chrome);
outerDiv.appendChild(innerDiv);
outerDiv.appendChild(theIframe);
outerDiv.setAttribute("id","dhtmlWindowToMove");
docFrag.appendChild(outerDiv);
bodyTag.insertBefore(docFrag,bodyTag.firstChild);
 this.src = src;
this.titleBarText = titleBarText;
this.show = show;
this.hide = hide;
 function titleBarText(titleBarText){
if (titleBarText!=""){innerDiv.innerHTML = titleBarText;}
else {innerDiv.innerHTML = "&nbsp;";}
}
hideSelect();  document.getElementsByTagName("body").item(0).onload = hideSelect;  function src(url){theIframe.src = url;}
function show(){hideSelect(document.childNodes[0],'hidden'); outerDiv.style.visibility = "visible"; showDiv = 1; setTimeout("updatePopupDivPos()",500);}
function hide(){hideSelect(document.childNodes[0],'visible'); outerDiv.style.visibility = "hidden"; showDiv = 0;}
}
var tableValuesArray = new Array();
var tableAttribArray = new Array();
var oldGroupDeleteColumn = "";
function setProcessing(theForm,type,groupID){
allowClicks = 0;
pIcon = "<img src='/ar/i18n/en_US/aol/img/shared/processing.gif' alt=''>";
if (type == "alertGroup"){
oldGroupDeleteColumn = getID(groupID + "DeleteColumn").innerHTML;
getID(groupID + "DeleteColumn").innerHTML = pIcon;
} else {
for (var i=0; i<theForm.length; i++ ) {
if (theForm[i].name = "eachAlert" && theForm[i].checked ) {
theItem = ((theForm[i].value).split(":"))[0];
currentRows = getID(theItem).getElementsByTagName("td");
if (type == "reminder"){
currentRows.item(5).innerHTML = pIcon;
} else if (type == "alert"){
currentRows.item(3).innerHTML = pIcon;
};
};
};
};
};
function callbackError(ID,action){
if (shownAlertError == 0){
alert(callbackErrorMessage);
shownAlertError = 1;
};
if (action == "error"){
listViewProcessingCallback(ID,"off");
} else {
getID(ID + "DeleteColumn").innerHTML = oldGroupDeleteColumn;
};
};
function listViewProcessingCallback(alertID,action){
clearTimeout(noCallbackTimer);
if (action == "error" || action == "errorGroup"){
callbackError(alertID,action);
} else {
 killIframe = getID("iframe-"+alertID)
 killIframe.parentNode.removeChild(killIframe);
grayOutAlert(alertID,action);
if(action=="delete"){
redoTableColors();
deleteEmptyCats();
}
}
}
function processingCallback(which){
if (which == "start"){
allowClicks = 0;
shownAlertError = 0;
} else if (which == "end"){
allowClicks = 1;
shownAlertError = 0;
selectCheckBoxes(false);
hiddenIframe.location.href = "about:blank";
}
}
function noCallback(){
alert(callbackErrorMessage);
location.href = location.href;
};
function populate(whatToPopulate){
tableToSort = getID(tableToSortID);
countTRs = tableToSort.getElementsByTagName("tr");
var arrayCounter = 0;
for (var i=0; i < countTRs.length; i++){
var currentTRID = countTRs.item(i).getAttribute("id");
if (currentTRID != "dontSortMe"){
countTDs = countTRs.item(i).getElementsByTagName("td");
if (whatToPopulate == "array"){
tableValuesArray[arrayCounter] = new Array();
tableAttribArray[arrayCounter] = new Array();
tableAttribArray[arrayCounter][0] = currentTRID;
tableAttribArray[arrayCounter][1] = countTRs.item(i).className;
for (var j=0; j < countTDs.length; j++){
tableValuesArray[arrayCounter][j] = countTDs.item(j).innerHTML;
};
} else {
countTRs.item(i).className = tableAttribArray[arrayCounter][1];
countTRs.item(i).setAttribute("id",tableAttribArray[arrayCounter][0]);
for (var j=0; j < countTDs.length; j++){
countTDs.item(j).innerHTML = tableValuesArray[arrayCounter][j];
};
};
arrayCounter += 1;
};
};
};
function ClickHandler(){
var letClicksThru = true;
this.allowClicks = allowClicks;
this.handleClick = handleClick;
this.status = status;
function allowClicks(status){letClicksThru = status;}
function handleClick(){
if ( letClicksThru ) return true;
return false;
}
function status(){
return letClicksThru;
}
}
function selectCheckBoxes(status){
if (allowClicks == 1){
var tagsArr = document.getElementsByTagName("input");
for (var i=0; i<tagsArr.length; i++ ){
if(tagsArr[i].type == "checkbox") {
if (!status){ tagsArr[i].checked = false; } else { tagsArr[i].checked = true; }
}
}
}
}
function OnSubmitHook (f) {
if (!f){
f = document.forms[0];
};
var allow = true
for(var j=0; j<f.elements.length; j++) {
var e = f.elements[j]
if (e.submitHook) {
 var res = e.submitHook()
allow = allow && res
}
if (e.submitEvalHook) {
var res = eval(e.submitEvalHook)
allow = allow && res
}
}
return allow
}
function hide(id) {
var e = getID(id)
if (e == undefined) return
e.style.display = "none"
e.isShown = false
}
function show(id) {
var e = getID(id)
if (e==undefined) return
e.style.display = ""
e.isShown = true
}
var printWin = "";
function printIt(type){
if (typeof(printWin) == "object" && !printWin.closed ) printWin.close();
printWin = window.open("/" + rootCTX + "/shared/print-popup.ev?" + type + "=1","printWin","width=350,height=300");
}
function cpLogger(cp,url,winArgs) {  var h="/" + rootCTX + "/shared/cpl.ev?cp=" + cp + "/"+escape(url);
if (url.indexOf("aol://")!=-1) {
 window.frames['clickpath'].location.href=h;  location.href=url;  } else {
if ( winArgs == "default" ) {
 window.open(h);
} else if ( winArgs != null ) {
 window.open(h,"",winArgs);
} else {
 location.href=(h);
}
}
}
var noCallbackTimer;
function deleteFromDir(imgObj)
{
if (confirm(deleteMsg)){
 var alertID = (imgObj.parentNode.parentNode.getAttribute('id')).substring(4);
var newIframe =createHiddenFrame(alertID);
newIframe.src = "/ar/shared/update-alerts2.ev?from_dir=1&num=1&type=alert&status=delete&ids="+alertID;
}
}
function updateAlert(imgObj){
var status;
var i = imgObj.getAttribute("src");
if(i.indexOf("trash")!=-1) status = "delete";
else {status = i.indexOf("off")!=-1?"on":"off";}
var aID = (imgObj.parentNode.parentNode.getAttribute('id')).substring(4);
updateStatusNEW(status,"alert",deleteMsg,aID);
}
function updateStatusNEW(status,type,c,alertID){
var IDs = "";
var doSubmit = false;
if (status == "on" || status=="off"){doSubmit=true;}
else if ( status == "delete" && confirm(c)){doSubmit = true;}
if(doSubmit){
newIframe =createHiddenFrame(alertID);
newIframe.src = "/ar/shared/update-alerts2.ev?num=1&type=alert&status="+status+"&ids="+alertID;;
}
}
function createHiddenFrame(alertID)
{
var iframeName= "iframe-"+alertID;
var newIframe = document.createElement("iframe",iframeName);
newIframe.setAttribute("style","display:none;");
newIframe.setAttribute("name",iframeName);  newIframe.setAttribute("id",iframeName);
document.body.appendChild(newIframe);
return newIframe;
}
function subCh(div){
if(currentSelectedMenuItem!=null){
currentSelectedMenuItem.className = oldClassName;
currentSelectedMenuItem.getElementsByTagName("img")[0].setAttribute("src","/ar/img/shared/folder_closed.gif");
}
currentSelectedMenuItem = div;
getID(div.id).className = "menuOn";
getID(div.id).getElementsByTagName("img")[0].setAttribute("src","/ar/img/shared/folder_open.gif");
getID("the_channels_iframe").src = "http://"+location.host+"/ar/directory/show_channels.ev?ch="+div.id.substring(2)+"&pch="+div.id.substring(2);
}
function getID(id){return document.getElementById(id);}
var currentSelectedMenuItem;
var oldClassName;
function sAts(div,p){
if(currentSelectedMenuItem!=null){
currentSelectedMenuItem.className = oldClassName;
currentSelectedMenuItem.getElementsByTagName("img")[0].setAttribute("src","/ar/img/shared/folder_closed.gif");
}
currentSelectedMenuItem = div;
oldClassName = div.className;
getID(div.id).className = "menuOn";
getID(div.id).getElementsByTagName("img")[0].setAttribute("src","/ar/img/shared/folder_open.gif");
var loc = "http://"+location.host+"/ar/directory/show_channels.ev?ch="+div.id.substring(2);
if(p!=null) loc += "&pch="+p;
getID("the_channels_iframe").src = loc;
}
function showAll(){
var trArr = getID("alerts").getElementsByTagName("tr");
for(i=0; i<trArr.length; i++){
trArr[i].style.display="";
}
}
function filterDelMethod(byWhat){
var trArr = getID("alerts").getElementsByTagName("tr");
var img;
var found;
showAll();
for(i=0; i<trArr.length; i++){
if(trArr[i].id.indexOf("atr_")!=-1){
 img = trArr[i].getElementsByTagName("img");
found = false;
if(byWhat=="email"){
for(ii=0; ii<img.length; ii++){
if(img[ii].getAttribute("src").indexOf("mail")!=-1){
found = true;
break;
}
}
if(!found){
trArr[i].style.display="none";
}
}
if(byWhat=="aim"){
for(ii=0; ii<img.length; ii++){
if(img[ii].getAttribute("src").indexOf("aim")!=-1){
found = true;
break;
}
}
if(!found){
trArr[i].style.display="none";
}
}
if(byWhat=="device"){
for(ii=0; ii<img.length; ii++){
if(img[ii].getAttribute("src").indexOf("device")!=-1){
found = true;
break;
}
}
if(!found){
trArr[i].style.display="none";
}
}
}
}
hideEmptyCats();
redoTableColors();
}
function filter(byWhat){
var trArr = getID("alerts").getElementsByTagName("tr");
var img;
for(i=0; i<trArr.length; i++){
img = trArr[i].getElementsByTagName("img");
if(img.length!=0){
if(byWhat=="off"){
if((img[0].getAttribute("src")).indexOf("off")!=-1){
trArr[i].style.display="";
} else {
trArr[i].style.display="none";
}
} else if(byWhat=="on"){
if((img[0].getAttribute("src")).indexOf("on")!=-1){
trArr[i].style.display="";
} else {
trArr[i].style.display="none";
}
} else {
trArr[i].style.display="";
}
} else {
trArr[i].style.display="";
}
}
hideEmptyCats();
redoTableColors();
}
function hideEmptyCats(){
 var trArr = getID("alerts").getElementsByTagName("tr");
var catName;
var i=0;
var currentCatIndex;
while(true){
if(trArr[i].id.indexOf("cats_")!=-1){
currentCatIndex = i;
catName = trArr[i].id.split("_")[1];
 hideCat = true;
for(x=(i+1); x<trArr.length; x++){
if(trArr[x].getAttribute("p")!=null && trArr[x].getAttribute("p").indexOf(catName)!=-1){
i=x;
if(trArr[x].style.display==""){
 hideCat = false;
break;
}
} else {
 i=x-1;
break;
}
}
if(hideCat){
trArr[currentCatIndex].style.display="none";
}
}
i++;
if(i >= trArr.length) break;
}
}
function deleteEmptyCats(aID){
 var trArr = getID("alerts").getElementsByTagName("tr");
var catName;
var i=0;
var currentCatIndex;
while(true){
if(trArr[i].id.indexOf("cats_")!=-1){
currentCatIndex = i;
catName = trArr[i].id.split("_")[1];
 deleteCat = true;
for(x=(i+1); x<trArr.length; x++){
if(trArr[x].getAttribute("p")!=null && trArr[x].getAttribute("p").indexOf(catName)!=-1){
i=x;
if(trArr[x].style.display==""){
 deleteCat = false;
break;
}
} else {
 i=x-1;
break;
}
}
if(deleteCat){
getID("alerts").getElementsByTagName("tbody").item(0).removeChild(trArr[i]);
} else {
 hideEmptyCats();
}
}
i++;
if(i >= trArr.length) break;
}
}
function grayOutAlert(aID,status){
if(status=="delete"){
getID("alerts").getElementsByTagName("tbody").item(0).removeChild(getID("atr_"+aID));
return;
}
var imgSrc;
var imgSrcArr;
var imgArr = getID("atr_"+aID).getElementsByTagName("img");
for(i=0; i<imgArr.length; i++){
imgSrc = imgArr[i].getAttribute("src");
if(status=="on"){
imgSrcArr = imgSrc.split("_off");
if(imgSrcArr.length==2)imgArr[i].setAttribute("src",imgSrcArr[0]+"_on"+imgSrcArr[1]);
if(i==0){
imgArr[i].setAttribute("alt",alertOff);
imgArr[i].setAttribute("title",alertOff);
}
} else {
imgSrcArr = imgSrc.split("_on");
if(imgSrcArr.length==2)imgArr[i].setAttribute("src",imgSrcArr[0]+"_off"+imgSrcArr[1]);
if(i==0){
imgArr[i].setAttribute("alt",alertOn);
imgArr[i].setAttribute("title",alertOn);
}
}
}
}
function editAlert(alertID, typeCode){
location.href = "/ar/alerts/edit-alert.ev?cp=awmped&alert_id=" + alertID + "&type_code=" + typeCode + "&_w=wiz.clear";
}
function redoTableColors(){
var trArr = getID("alerts").getElementsByTagName("tr");
for(i=1,ii=1; i<trArr.length; i++){
if(trArr[i].style.display!="none" && trArr[i].getAttribute("id")!=null && trArr[i].getAttribute("id").indexOf("atr_")!=-1){ if((ii%2)==1) trArr[i].className = "mColor2";
else trArr[i].className = "mColor1";
ii++;
}
}
}
function processingCallback(status){
;
}
var d;
function u(td){
var updateURI = "/ar/shared/show_delivery_options";
var aid = td.parentNode.parentNode.getAttribute("id");
d = new dhtmlWindow(100,100,600,350);
d.show();
var p = "alert_id";
var u = "_alert";
if(aid.indexOf("-")!=-1){
p = "sub_id";
u = "_subscription";
}
d.src(updateURI+u+".ev?"+p+"="+aid.substring(4));
}
function updateFoot(theID,theID2,offSet){
var a,b;
if(offSet==null)offSet=135;
if(theID2!=null){
a=parseInt(document.getElementById(theID).offsetHeight)
b=parseInt(document.getElementById(theID2).offsetHeight)
if(a>b){
document.getElementById("foot").style.top = document.getElementById(theID).offsetHeight + offSet + 10;
} else {
document.getElementById("foot").style.top = document.getElementById(theID2).offsetHeight + offSet + 10;
}
} else {
document.getElementById("foot").style.top = document.getElementById(theID).offsetHeight + offSet + 10;
}
}
window.onscroll=updatePopupDivPos;
