﻿// n = ID of element
// c = element object

// toggle the visibility of an element by ID
function vis(n)
{
    var c = gEle(n);
    if (c) {
        if (c.style.display == "none")
            c.style.display = "block";
        else if (c.style.display == "block")
            c.style.display = "none";
    } 
}

// sets the visibility of element n; v = {0,1}
function sVis(n,v)
{
    var c = gEle(n);
    if (c) {
        if (v == 0) c.style.display = "none";
        else if (v == 1) c.style.display = "block";
    }
}

// changes the style of the underlying element
function hover(c,v)
{
    if (c == null) return;
    c.className = v;
}

// in case the class is being overriden for some reason, explicitly change
// the style
function hoverC(c,fc,bc,ptr)
{
    var e = gEle(c);
    if (e == null) return;
    e.style.backgroundColor = bc;
    e.style.color = fc;
    e.style.cursor = ptr;
}

// sets a variable value (where applicable)
function sVar(n,v)
{
    var c = gEle(n);    
    if (c) { c.value = v; }
    else { alert('input ' + n + 'is null for value ' + v + '.'); }
}

// gets a variable value (where applicable)
function gVar(n)
{
    var c = gEle(n);
    if (c) return c.value;
    else return null;
}

function sIdx(n,i)
{
    var c = gEle(n);
    if (c) c.selectedIndex = i;
}

function gIdx(n)
{
    var c = gEle(n);
    if (c) return c.selectedIndex;
    else return null;
}

// gets an element object
function gEle(n)
{
    return document.getElementById(n);        
}

// handle postback - sender (ID), value
function doPostback(n,v)
{
    sVar("__sender",n);
    sVar("__value",v);
    document.forms["form1"].submit();
}

function confirmAction()
{
    var cc = confirm("Are you sure?");
	if (cc == true)
		return true;
	else
		return false;
}