/***********************************************
* Used By CreatePaycheck.aspx for Search section
***********************************************/

function SelectAll(oSelectAll, sIndexName)
{
	var aInput = document.getElementsByTagName('input');

        
		for (i=0; i < aInput.length; i++)
		{
			if ( aInput[i].name.indexOf(sIndexName) > 0 && aInput[i].disabled != true)
			{
				aInput[i].checked = oSelectAll.checked;
			}
		}
}
	
function ShowOrHide(id) 
{
	if (document.getElementById(id).style.display == "none")
	{
		document.getElementById(id).style.display = "block";
	}
	else
	{
		document.getElementById(id).style.display = "none";
	}
}
	
function AutoGeneCheck() 
{
    if(confirm('Paycheck(s) will be saved based on the infomation above, are you sure to continue?'))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function eFileResubmit(field, msg)
{
    alert(msg);
    return;
} 

function DeleteConfirm(field)
{
    if(field.disabled == false)
    {
        if(confirm('Are you sure you want to delete the information?'))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
} 

function SavePaycheckLoginAlert()
{
    alert("Logging in will clear the information for this paycheck.");
    return;
} 

function SaveChangeConfirm()
{
    if(confirm('Are you sure you want to save the changes?'))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function NoBankInfoConfirm()
{
    if(confirm('If your bank information is insufficient, your paycheck may not print correctly.'))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function PaydayDiffConfirm(field)
{
    if(field.value == "Auto")
    {
        if(confirm('Paycheck(s) will be automatically saved based on the infomation above, are you sure to continue?'))
        {
            return true;
        }
        else
        {
            return false;
        }
        
     }
}

function TaxyearDiff(IsDiff)
{
    if(IsDiff)
    {
        if(confirm('Taxyear is different from Checkdate year, are you sure to continue?'))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

function VoidConfirm()
{
    if(confirm('Are you sure you want to void this paycheck?'))
    {
        return true;
    }
    else
    {
        return false;
    }
} 

//SSN auto complete
function validateAutoComplete (field, contents, forcematch)
{
//confirm("in")
    var found = false;
    for (var i = 0; i < contents.length; i++)
    {
        if (contents[i].toUpperCase().indexOf(field.value.toUpperCase()) == 0)
        {
            found = true;
            break;
        }
    }
    if (field.createTextRange)
    {
        if (forcematch && !found)
        {
            field.value=field.value.substring(0,field.value.length-1);
            return;
        }
     var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
     if (cursorKeys.indexOf(event.keyCode + ";") == -1)
     {
        var r1 = field.createTextRange();
        var oldValue = r1.text;
        var newValue = found ? contents[i] : oldValue;
        if (newValue != field.value)
        {
            field.value = newValue;
            var rNew = field.createTextRange();
            rNew.moveStart('character', oldValue.length);
            rNew.select();
        }
      }
    }
}

//show OR hide funtion depends on if element is shown or hidden
function expandcollapse(s_id) 
{ 
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(s_id).style.display == "none"){
			document.getElementById(s_id).style.display = 'block';
			swap(("img" + s_id),'imgCollapse');			
		} else {
			swap(("img" + s_id),'imgExpand');
			document.getElementById(s_id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				swap(("img" + s_id),'imgCollapse');
			} else {
				swap(("img" + s_id),'imgExpand');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				swap(("img" + s_id),'imgExpand');
				document.all.id.style.display = 'none';
			}
		}
	}
}

function expandall(s_partid) 
{
	var divs = document.getElementsByTagName('div')
	for(i=0;i<divs.length;i++){ 
		if(divs[i].id.match(s_partid)){
			if (document.getElementById) // DOM3 = IE5, NS6 
				divs[i].style.display = 'block'
			else
			if (document.layers) //Netscape 4
				document.layers[divs[i]].display = 'block'; 
			else //IE 4
				document.all[divs[i]].display = 'block';
		}
	}
	swapall(("img" + s_partid), 'imgCollapse');
}

function collapseall(s_partid) 
{
	var divs = document.getElementsByTagName('div')
	for(i=0;i<divs.length;i++){ 
		if(divs[i].id.match(s_partid)){
			if (document.getElementById) // DOM3 = IE5, NS6 
				divs[i].style.display = 'none'
			else
			if (document.layers) //Netscape 4
				document.layers[divs[i]].display = 'none'; 
			else //IE 4
				document.all[divs[i]].display = 'none';
		}
	}
	swapall(("img" + s_partid), 'imgExpand');
}

function RestoreNotice()
{
    //alert("We will look in to this issue.");
    alert("If you restore this check, some of checks that were prepare subsequently to this check will not show correct \"year-to-date\" amount.  Those checks will be identified by a RED dot.  However, if and when you prepare a new check, the \"year-to-date\" amount will be computed and displayed correctly.");
    return;
}

function DeletePaycheckConfirm(field)
{
    if(field.disabled == false)
    {
        if(confirm('If you delete this check, all checks that were saved subsequently to this check will NOT be changed.  Therefore, the \"year-to-date\" amount may not be correct and those checks will be identified by a RED dot.  However, if and when you prepare any new check, the \"year-to-date\" amount will be computed and displayed correctly.'))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
} 