//get the textbox by name.
if it was not returned, then log an error. */
function getBrowserType()
{
var process, window;
process = Sys.WaitProcess("iexplore", 500);
if (process.Exists){
window = process.Window("IEFrame", "*");
if (window.WaitWindow("Shell DocObject View").Exists)
return "IE6";
else
if (window.WaitWindow("TabWindowClass").Exists)
return "IE7";
else
return "";
}
process = Sys.WaitProcess("firefox", 500);
if (process.Exists){
return "FireFox";
}
return "";
}
function getBrowserWindow()
{
var browserName;
browserName = getBrowserType();
switch(browserName)
{
case "IE6":
return Sys.Process("IEXPLORE").Window("IEFrame", "*", 1).Window("Shell DocObject View", "", 1).Window("Internet Explorer_Server", "", 1);
case "IE7":
return Sys.Process("iexplore").Window("IEFrame", "*", 1).Window("TabWindowClass","*", 1).Window("Shell DocObject View", "", 1).Window("Internet Explorer_Server","", 1);
case "FireFox":
return Sys.Process("firefox").Window("MozillaUIWindowClass", "*", 1).Window("MozillaWindowClass","", 1).Window("MozillaWindowClass", "", 3).Window("MozillaWindowClass", "",1).Window("MozillaContentWindowClass", "", 1).Window("MozillaWindowClass","", 1);
case "":
return Utils.CreateStubObject();
}
}
function getElement(itemTag, itemAttribute, itemText, itemNumber)
{
var i = 0;
var i2 = 0;
var foundIt = false;
var window = getBrowserWindow();
var page = window.Page("*");
var regx = new RegExp(itemText);
var noFound = 0;
var frames = window.document.frames.length
if (itemNumber == undefined){
itemNumber = 1;
}
//first try the main document body
var objA = window.document.body.getElementsByTagName(itemTag);
//loop through each item returned stopping at the specified itemNumber.
while(i<objA.length && (foundIt==false)){
if (regx.exec(trim(objA.getAttribute(itemAttribute).replace(/(<([^>]+)>)/ig," ")))){
noFound++;
if (noFound == itemNumber){
foundIt = true;
break;
}
}
i++;
}
if (!foundIt){
i=0; //reset the item iterator
while(i2<frames && (foundIt == false)){
//loop through each frame until you find the item or are out of frames.
var objA = window.document.frames[i2].document.getElementsByTagName(itemTag);
//loop through each item returned
while(i<objA.length && (foundIt==false)){
if (regx.exec(trim(objA.getAttribute(itemAttribute)))){
foundIt = true;
break;
}
i++;
}
i2++;
}
}
if(foundIt){
objA.scrollIntoView(true);
return objA;
}
else {
return null;
}
}
function trim(value)
// Removes leading and ending whitespaces
{
if(value==""){
return ""
}
else {
return LTrim(RTrim(value));
}
}
function LTrim(value)
//Removes leading whitespaces
{
var re = /\s*((\S+\s*)*)/;
return value.replace(re, "$1");
}
function RTrim(value)
// Removes ending whitespaces
{
var re = /((\s*\S+)*)\s*/;
return value.replace(re, "$1");
}
function clickObj(page, itemObj)
{
//Clicks on the center of the object that was passed in.
itemObj.scrollIntoView(false)
var objRect = itemObj.getBoundingClientRect()
var x = page.ScreenLeft + objRect.left + (objRect.right - objRect.left)/2
var y = page.ScreenTop + objRect.top + (objRect.bottom - objRect.top)/2
Sys.Desktop.MouseDown(VK_LBUTTON,x,y)
Sys.Desktop.MouseUp(VK_LBUTTON,x,y)
}