﻿
// Global Variable Declarations
var isLoaded = false;

// Global Functions

// Adds appropriate targets to anchor tags.
function processAnchorTargets()
{
    if (!document.getElementsByTagName) return;

    var anchors = document.getElementsByTagName("a");
    
    for (var i=0; i < anchors.length; i++)
    {
        var anchor = anchors[i];
        
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup")
        {
            anchor.target = "_blank";
        }
    }
}

// Submits form[0]
function submitForm()
{
    document.forms[0].submit();
    return true;
}

// Submit Target Form
function submitTargetForm(in_formIndex)
{
    document.forms[in_formIndex].submit();
    return true;
}


// Window Openers
function popWindow(in_targetUrl, in_windowParameters)
{
    //windowParameters are very browser dependent.  Be sure to test in all browswers when
    //changing window parameters.

    //For instance for Both IE and Netscape browsers to absolutely position a window properly 2 sets
    // of dimensions should be included example: screenX=0,screenY=0,left=0,top=0
    //To set the height and width of the windows example: width=625,height=400
    //A Good PopupWindow in all browsers with no toolbar, no scrollbar, and not resizable.
    //windowParameters = "scrollbars=no,width=625,height=400";
    
    if ( in_windowParameters.length == 0 )
    {
        in_windowParameters = "resizable,dependent,toolbar,scrollbars,location,status,menubar";
    }
    
    popupWin = window.open(in_targetUrl,'PopupWindow',in_windowParameters);
    
    return false;
}

function popWindowWithTarget(in_targetUrl, in_targetWindowName, in_windowParameters)
{
    if ( in_windowParameters == null )
    {
        in_windowParameters = "";
    }
    
    popupWin = window.open(in_targetUrl,in_targetWindowName,in_windowParameters);
    
    return false;
}

function openChildWindow(targetUrl,windowName,windowParameters)
{

    childWindow = window.open(targetUrl,windowName,windowParameters);

    if (childWindow.opener == null)
    {
    	childWindow.opener = self;
    }
}


function closeSelfWindow()
{
	window.self.close();
    return false;
}

function refreshParentPageAndClose()
{
	window.opener.location.reload();
	closeSelfWindow();
	return false;
}

function refreshParentPageAndClose(refreshUrl)
{
	if (refreshUrl != null) {
		window.opener.location.href = refreshUrl;
	}
	else {
		window.opener.location.reload();
	}
	closeSelfWindow();
	return false;
}


// Global Initialization

function blurInputs()
{
    if (!document.getElementsByTagName) return;

    var inputs = document.getElementsByTagName("input");
    
    for (var i=0; i < inputs.length; i++)
    {
        var inp = inputs[i];
        inp.blur();
    }
    
}

function globalInit()
{
    isLoaded = true;
} 

function autoClose()
{
    processAnchorTargets();
    window.setTimeout('closeSelfWindow()', 5000);
    isLoaded = true;
}


function closeSelfWindow()
{

	window.self.close();
    return false;
}



function selectTextBox(textboxId)
{
	var textbox=document.getElementById(textboxId);
	if(textbox!=null)
	{
		textbox.focus();
		textbox.select();
		
	}
}

