//Specific Functions for the Plan Finder Plans Page
var planTypes = new Array('pff', 'hmo', 'pre', 'msa');
function initPlans() {
    for(var x=0; x < planTypes.length; x++) {
        if(document.getElementById(planTypes[x])) {
            document.getElementById(planTypes[x]).onclick=expandCollapse;
            document.getElementById(planTypes[x]+"Link").onclick=expandCollapse;
        }
    }
    document.getElementById("expandall").onclick=expandAll;
//    var inputs = document.getElementsByTagName('input');
//    for (var i=0;i<inputs.length;i++) {
//        if (inputs[i].type == "checkbox")
//            inputs[i].onclick = checkCompares;
//    }
}
function expandCollapse() {    
    finishAction(document.getElementById(this.id.replace(/Link/g,'')))
}
function expandAll() {
    if (this.firstChild.nodeValue == "Expand All") {
        this.firstChild.nodeValue = "Collapse All";
        for(var x=0; x<planTypes.length; x++) {
            el = document.getElementById(planTypes[x])
            el.className = "minus";
            el = document.getElementById(planTypes[x]);
            document.getElementById(el.id+'Body').style.display ="inline";
        }        
    }
    else {
        this.firstChild.nodeValue = "Expand All"    
        for(var x=0; x<planTypes.length; x++) {
            el = document.getElementById(planTypes[x])
            el.className = "plus";
            el = document.getElementById(planTypes[x]);
            document.getElementById(el.id+'Body').style.display ="none";
        }        
    }
}
function finishAction(el) {
    (el.className == "plus") ? el.className = "minus" : el.className = "plus";
    (document.getElementById(el.id+'Body').style.display == "none") ? document.getElementById(el.id+'Body').style.display='inline' : document.getElementById(el.id+'Body').style.display='none';
}
var compareCounter=0;
function checkCompares(id) {
    if(id.checked==true)
        compareCounter++;
    else
        compareCounter--;
    
    if(compareCounter>3 || compareCounterMSA>0) {
        alert("You can only select a maximum of three plans to compare.")
        id.checked=false;
        compareCounter--;
    }
}
//Specific Functions for the Plan Finder Comparison Page
var theTable, theTableBody;
var remCount=0;
function initCompare() {
    var trs = document.getElementsByTagName('tr');
    for (var i=0;i<trs.length;i++) {
        trs[i].onmouseover = function () { if(this.className=="") this.style.backgroundColor = "#f0f0f0" };
        trs[i].onmouseout = function () { if(this.className=="") this.style.backgroundColor = "white" };
    }    
    theTable = document.getElementById("compareTable")
    theTableBody = theTable.tBodies[0]
}
function deleteColumn(col) {
    if(remCount<1) {
        var oneRow;
        if (theTable.tHead) {
            oneRow = theTable.tHead.rows[1]
            oneRow.deleteCell(1)
        }
        for (var i = 0; i < theTableBody.rows.length; i++) {
            oneRow = theTableBody.rows[i]
            oneRow.deleteCell(col)
        }
        remCount++
    }
}
