Anda di halaman 1dari 5

<script type="text/javascript">

var debug = 0; // set debug variable


if (debug === 1) { document.write("Starting the pageDropDown function"+"<BR>");}

var threshold = 0;
if (debug === 1) { document.write("Set Threshold to 0"+"<BR>");}

var divID = 'myPopUpGroup';


if (debug === 1) { document.write("Setup the divID variable"+"<BR>");}

function pageDropdown(){
var pageTable = document.getElementById('TabsTable');
if (debug === 1) { document.write("Fetched the TabsTable Table
object"+"<BR>");}

if( pageTable == undefined ){


if (debug === 1) { alert("Could not find TabsTable ID");}
}

var message = 'Pick a Page';


if (debug === 1) { document.write("Setup message"+"<BR>");}

var pageTR = pageTable.getElementsByTagName('tr')[0];


if (debug === 1) { document.write("Got TR child"+"<BR>");}

var newTR = document.createElement('tr');


if (debug === 1) { document.write("Created new TR"+"<BR>");}

var tabSepTD = document.createElement('td');


if (debug === 1) { document.write("Created new TD for TabSep"+"<BR>");}

tabSepTD.className = "TabSep";
tabSepTD.innerHTML = "&nbsp;";
if (debug === 1) { document.write("Setup new TabSep"+"<BR>");}

var tabHiCellTD = document.createElement('td');


if (debug === 1) { document.write("Created new TD for TabHiCell"+"<BR>");}

tabHiCellTD.className = "TabHiCell";
if (debug === 1) { document.write("Setup new TabHiCell"+"<BR>");}

var tabSepHiCellTD = document.createElement('td');


if (debug === 1) { document.write("Created new TD for
TabSepHiCell"+"<BR>");}

tabSepHiCellTD.className = "TabSep TabHiSep";


tabSepHiCellTD.innerHTML = "&nbsp;";
if (debug === 1) { document.write("Setup new TabSepHiCell"+"<BR>");}

var tabHiFontLinkA = document.createElement('a');


if (debug === 1) { document.write("Setup new tabHiFontLinkA"+"<BR>");}

tabHiFontLinkA.className = 'TabHiFontLink';
tabHiFontLinkA.href = 'javascript:void(null)';
if (debug === 1) { document.write("Updated tabHiFontLinkA"+"<BR>");}

//tabHiFontLinkA.onclick = new Function(";");


tabHiFontLinkA.onclick = function (event) {
return NQWPopupMenu(event,'myPopUpGroup');
};
if (debug === 1) { document.write("Set tabHiFontLinkA onClick:
"+String(tabHiFontLinkA.onclick)+"<BR>");}

var myPopUpGroupDIV = document.createElement('div');


if (debug === 1) { document.write("Created myPopUpGroupDIV"+"<BR>");}

myPopUpGroupDIV.className = 'NQWMenu';
myPopUpGroupDIV.setAttribute('menuInit','BannerInitPortalMenu');
myPopUpGroupDIV.id = divID;
myPopUpGroupDIV.onclick = function (){
NQWClearActiveMenu();
};

myPopUpGroupDIV.onmouseover = function (event){


NQWMenuMouseOver(event);
};

if (debug === 1) { document.write("Setup myPopUpGroupDIV"+"<BR>");}

var menuShadowWrapperTABLE = document.createElement('table');


if (debug === 1) { document.write("Created menuShadowWrapperTABLE"+"<BR>");}

menuShadowWrapperTABLE.cellspacing = 0;
menuShadowWrapperTABLE.className = 'menuShadowWrapper';
if (debug === 1) { document.write("Setup menuShadowWrapperTABLE"+"<BR>");}

var firstTR = document.createElement('tr');


var secondTR = document.createElement('tr');
var thirdTR = document.createElement('tr');
if (debug === 1) { document.write("Created three TRs"+"<BR>");}

var shadowMenuCellTD = document.createElement('td');


var shadowOffsetCellRightTD = document.createElement('td');
var shadowRightTD = document.createElement('td');
var shadowOffsetCellBottomTD = document.createElement('td');
var shadowBottomTD = document.createElement('td');
var shadowCornerTD = document.createElement('td');
if (debug === 1) { document.write("Created five TDs"+"<BR>");}

shadowMenuCellTD.className = 'shadowMenuCell';
shadowOffsetCellRightTD.className = 'shadowOffsetCellRight';
shadowRightTD.className = 'shadowRight';
shadowBottomTD.className = 'shadowBottom';
shadowOffsetCellBottomTD.className = 'shadowOffsetCellBottom';
shadowCornerTD.className = 'shadowCorner';
if (debug === 1) { document.write("Updated five TD's class names"+"<BR>");}

shadowRightTD.innerHTML = '&nbsp;';
shadowBottomTD.innerHTML = '&nbsp;';
if (debug === 1) { document.write("Added spaces to two TDs"+"<BR>");}

shadowMenuCellTD.rowSpan = 2;
shadowMenuCellTD.colSpan = 2;
if (debug === 1) { document.write("Updated shadowMenuCellTD's rowspan and
colspan"+"<BR>");}
var pageTDs = pageTR.getElementsByTagName('td');
if (debug === 1) { document.write("Got page TD array"+"<BR>");}

var count = 0;
if (debug === 1) { document.write("Setup count variable for number of
pages"+"<BR>");}

if (debug === 1) { document.write("Loop over page TD array"+"<BR>");}


for( var pageTD = 0; pageTD < pageTDs.length; pageTD++){
if(pageTDs[pageTD].className != 'TabHiCell' &&
pageTDs[pageTD].className != 'TabDimCell'){
continue;
}

var pageA =pageTDs[pageTD].getElementsByTagName('a')[0];


if (debug === 1) { document.write("Got the page anchor"+"<BR>");}

var text;
if (debug === 1) { document.write("Got the page anchor"+"<BR>");}

if(pageTDs[pageTD].className == 'TabHiCell'){
text = pageA.getElementsByTagName('span')[0].innerHTML;
message = text;
if (debug === 1) { document.write("Set message to:
"+message+"<BR>");}
}
else {
text = pageA.innerHTML;
}

var newA = document.createElement('a');


if (debug === 1) { document.write("Created new Anchor"+"<BR>");}

newA.className = 'NQWMenuItem';
if (debug === 1) { document.write("Set the anchor class name to
NQWMenuItem"+"<BR>");}

newA.target = '_self';
if (debug === 1) { document.write("Set the anchor target to
_self"+"<BR>");}

var preFunc = "";


if (debug === 1) { document.write("Setup the preFunc variable to
blank"+"<BR>");}

var stringFunc =
(String(pageA.onclick)).substr((String(pageA.onclick)).indexOf('return'),
(String(pageA.onclick)).length - 2 -(String(pageA.onclick)).indexOf('return'));
if (debug === 1) { document.write("Got string function:
"+stringFunc+"<BR>");}

stringFunc.replace(/"/gi,"'");
if (debug === 1) { document.write("Updated string function:
"+stringFunc+"<BR>");}

var newFunc = new Function (stringFunc);


if (debug === 1) { document.write("Created a new function
variable"+"<BR>");}

newA.onclick = newFunc;
if (debug === 1) { document.write("Set the anchor onclick:
"+String(newA.onclick)+"<BR>");}

newA.href = 'javascript:void(null)';
if (debug === 1) { document.write("Set the anchor href to
javascript:void(null)"+"<BR>");}

newA.name = 'DashboardBannerLink';
if (debug === 1) { document.write("Set the anchor name to
DashboardBannerLink"+"<BR>");}

newA.title = text;
if (debug === 1) { document.write("Set the anchor title to
"+newA.title+"<BR>");}

var newSpan = document.createElement('span');


if (debug === 1) { document.write("Created new span"+"<BR>");}

newSpan.className = 'TabHiFont';
if (debug === 1) { document.write("Set span class to
TabHiFont"+"<BR>");}

newSpan.innerHTML = text;
if (debug === 1) { document.write("Set span innerHTML to
"+newSpan.innerHTML+"<BR>");}

newA.appendChild(newSpan);
if (debug === 1) { document.write("Appended the span to the
anchor"+"<BR>");}

shadowMenuCellTD.appendChild(newA);
if (debug === 1) { document.write("Appended the anchor to the
TD"+"<BR>");}

count++;
if (debug === 1) { document.write("Incremented Count variable to:
"+count+"<BR>");}
}

tabHiFontLinkA.innerHTML = message;

firstTR.appendChild(shadowMenuCellTD);
firstTR.appendChild(shadowOffsetCellRightTD);
if (debug === 1) { document.write("Appended shadowMenuCellTD and
shadowOffsetCellRightTD to firstTR"+"<BR>");}

secondTR.appendChild(shadowRightTD);
if (debug === 1) { document.write("Appended shadowRightTD to
secondTR"+"<BR>");}

thirdTR.appendChild(shadowOffsetCellBottomTD);
thirdTR.appendChild(shadowBottomTD);
thirdTR.appendChild(shadowCornerTD);
if (debug === 1) { document.write("Appended shadowOffsetCellBottomTD,
shadowBottomTD and shadowCornerTD to thirdTR"+"<BR>");}
menuShadowWrapperTABLE.appendChild(firstTR);
menuShadowWrapperTABLE.appendChild(secondTR);
menuShadowWrapperTABLE.appendChild(thirdTR);
if (debug === 1) { document.write("Appended firstTR, secondTR and thirdTR to
menuShadowWrapperTABLE"+"<BR>");}

myPopUpGroupDIV.appendChild(menuShadowWrapperTABLE);
if (debug === 1) { document.write("Appended a menuShadowWrapperTABLE to
myPopUpGroupDIV"+"<BR>");}

tabHiCellTD.appendChild(tabHiFontLinkA);
if (debug === 1) { document.write("Appended a tabHiFontLinkA to
tabSepTD"+"<BR>");}

tabHiCellTD.appendChild(myPopUpGroupDIV);
if (debug === 1) { document.write("Appended a myPopUpGroupDIV to
tabSepTD"+"<BR>");}

newTR.appendChild(tabSepTD);
newTR.appendChild(tabHiCellTD);
newTR.appendChild(tabSepHiCellTD);
if (debug === 1) { document.write("Appended a tabSepTD, tabHiCellTD and
tabSepHiCellTD to newTR"+"<BR>");}

if( count >= threshold ){


pageTR.parentNode.insertBefore(newTR,pageTR);
pageTR.parentNode.removeChild(pageTR);
}
};

pageDropdown();

if (debug === 1) { document.write("Finished the pageDropDown function"+"<BR>");}


</script>

Anda mungkin juga menyukai