/**
* Returns the HTML object identified by name.
*/
function getObj(name)
{
if (document.getElementById)
{
return document.getElementById(name);
}
else if (document.all)
{
return document.all[name];
}
else if (document.layers)
{
return document.layers[name];
}
}
/**
* Shows layer identified by layerID by setting visibility and display.
*/
function showLayer(layerID)
{
var oDiv = getObj(layerID);
oDiv.style.visibility = "visible";
oDiv.style.display = "block";
}
/**
* Redirects to another page.
*/
function gotoURL(url)
{
document.location.href = url;
}
/**
* Submits the form identified by formName.
*/
function submitForm(formName)
{
var form = document.forms[formName];
var formField = document.createElement("INPUT");
formField.type = "hidden";
formField.value = formName;
formField.name = "fn";
form.appendChild(formField);
form.submit();
}
/**
* Requests a servlet using an ajax connection.
*
* @param servlet the servlet that is called.
* @param formName the form that is submitted to the servlet.
* @param submitForm the form that is submitted after the servlet call was successfull.
*/
function requestForm(servlet, formName, submitForm)
{
var params = "";
for (i = 0; i < document.forms[formName].elements.length; i++)
{
if (document.forms[formName].elements[i].value != "")
{
params += "&" + document.forms[formName].elements[i].name + "=" + encodeHTML(document.forms[formName].elements[i].value);
}
}
params = "nocache=1738391959904" + params;
if (submitForm != null) params += "&fn=" + submitForm;
ajaxConnection = new AJAXConnection(servlet, params);
ajaxConnection.post();
var response = ajaxConnection.getResponseText();
if (response.indexOf("/myaccount/") == 0)
{
if (submitForm != null) document.forms[submitForm].submit();
else document.location.href = response;
}
else
{
showPopupBox("popupBox", response);
focusForm(formName);
}
}
/**
* Sets the focus on a field of a form. All variables are optional.
*
* @param formName the form that gets the focus.
* @param elementName the element in the form that gets the focus.
* @param layerID the layer which containing form gets the focus.
*/
function focusForm(formName, elementName, layerID)
{
if (formName == null)
{
if (layerID != null)
{
var oDiv = getObj(layerID);
var oForms = oDiv.getElementsByTagName("form");
if (oForms.length > 0) formName = oForms[0].name;
}
else
{
if (document.forms.length > 0) formName = document.forms[0].name;
}
}
if (formName != null && document.forms[formName] != null)
{
if (elementName != null)
{
document.forms[formName].elements[elementName].focus();
}
else
{
i = 0;
found = false;
while (i < document.forms[formName].elements.length && !found)
{
found = (document.forms[formName].elements[i].type != "hidden");
if (!found) i++;
}
if (found) document.forms[formName].elements[i].focus();
}
}
}
/**
* Shows the processing pop-up and submits the form identified by formName.
*/
function processForm(formName, viewSection)
{
var oDiv = getObj("box_" + viewSection);
oDiv.style.zIndex = '2';
var url = "/myaccount/includes/popup/popup_processing.jsp?nocache=1738391959904";
ajaxConnection = new AJAXConnection(url);
ajaxConnection.get();
showOverlay();
showPopupBox('popupBox', ajaxConnection.getResponseText());
submitForm(formName);
}
/**
* Escape and encode text
*/
function encodeHTML(value)
{
value = value.replace(/%/g, "%25");
value = value.replace(/\//g, "%2F");
value = value.replace(/\?/g, "%3F");
value = value.replace(/=/g, "%3D");
value = value.replace(/&/g, "%26");
value = value.replace(/@/g, "%40");
value = value.replace(/\+/g, "%2B");
return value;
}
/**
* Creates and shows a new window that shows the image identified by imageID.
*/
function showPopupWindow(imageID)
{
var image = document.images[imageID];
imageID = imageID.replace(/ /g, "_");
window.open("/myaccount/includes/popup/popup_image.jsp?i=" + image.src, imageID, "resizable=0,width=" + (image.width + 20) + ",height=" + (image.height + 20));
}