	var oc;	
	var navLastLoaded = "t1";
        var lastSelectedAudit = 0;
	
	function ri(a) 
	{
		oc = a.style.backgroundColor;
		a.style.backgroundColor = '#FFD4CF';
	}
	
	function ro(a) 
	{
		a.style.backgroundColor = oc;
	}
		
	function jumpURL(a,linkurl)
	{
		a.style.backgroundColor = oc;
		window.location=linkurl;
	}
	
	function toggleDiv(divName)
	{
		var divVar = eval('top.' + divName);
		
		if(divVar.style.display == 'block')
		{
			divVar.style.display = 'none';
		}
		else
		{
			divVar.style.display = 'block';
		}
		
		return;
	
	}
	
	function bookmarkPage(pagename,pageurl)
	{
		if(window.external)
		{						
			window.external.AddFavorite(location.href + "?" + pageurl, pagename)
		}
		else
		{
			alert("Feature Not Supported By Your Browser");
		}
	}

	function showSection(n, sw)
	{	// show/hide section n		
		
		var ds = document.getElementById("section"+n);
		var ts = document.getElementById(n);		
		
		if(sw)
		{
			ts.className = "active";
			ds.style.display = "block";
			navLastLoaded = n;
		}
		else
		{
			ts.className = "";
			ds.style.display = "none";
		}			
	}

        function changesection(currentTab)
        {
                if(navLastLoaded != "")
		{
			showSection(navLastLoaded,false);
		}
		
		showSection(currentTab,true);	
        }

	function chsection(sectionname)
	{		
		currentTab = sectionname.id;				
		
		// Check To See If We Have The Auto-Save Enabled
		
		if(document.MainForm)
		{
			if(document.MainForm.AutoSaveTab)
			{
				if(document.MainForm.AutoSaveTab.value == '1')
				{
					// Save The Form
					
					document.MainForm.NextTab.value = currentTab;					
					
					document.MainForm.submit();
					return;
				}
			}
		}
		
		if(navLastLoaded != "")
		{
			showSection(navLastLoaded,false);
		}
		
		showSection(currentTab,true);		
	}

function setCookie(name, value) {
    document.cookie= name + "=" + escape(value) + ";path=/";
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function selectAll(formelement)
{
    for(counter=0;counter<formelement.options.length;counter++)
    {
        formelement.options[counter].selected = true;
    }
}

function sortField(sortfield,sortdirection)
{ 
    document.SortForm.SortField.value = sortfield;
    document.SortForm.SortDirection.value = sortdirection; 

    document.SortForm.submit();
}

function loadAuditPage()
{
    var currentAudit = getCookie("OldAuditID")

    //alert("Current Audit: " + currentAudit);

    if(currentAudit)
    {
        var element = document.getElementById('A' + currentAudit);

        if(element)
        {
            element.className = 'selectedRow';
            lastSelectedAudit = currentAudit;
        }
    }
}

function flagAudit(auditid)
{
    if(lastSelectedAudit > 0)
    {
        var element = document.getElementById('A' + lastSelectedAudit);
        element.className = 'standardSmallerRow';
    }

    var element = document.getElementById('A' + auditid);

    if(element)
    {
        element.className = 'selectedRow';
        lastSelectedAudit = auditid;
    }
    
    setCookie("OldAuditID",auditid);
}
