﻿// JScript File

function showStart(cntrl){
     var cPanel = document.getElementById(cntrl);
     cPanel.style.display = 'inline';
}

function hideStart(cntrl){
     var cPanel = document.getElementById(cntrl);
     cPanel.style.display = 'none';
}
		
function showHide(cntrl, hidCntrl, test){
    var cTest = document.getElementById(cntrl);
    var cPanel = document.getElementById(hidCntrl);
    
    if (cTest.options[cTest.selectedIndex].value == test){
        cPanel.style.display = 'inline';
    } else {
        cPanel.style.display = 'none';
    }
}	

function showHideMultiple(cntrl, hidCntrl, test){
    var cTest = document.getElementById(cntrl);
    var cPanel = document.getElementById(hidCntrl);
    var optionFound = false;
    
    for (var i = 0; i < cTest.options.length; i++) { 
		if (cTest.options[i].selected && cTest.options[i].value == test) optionFound = true;
	}
    
    if (optionFound){
        cPanel.style.display = 'inline';
    } else {
        cPanel.style.display = 'none';
    }
}

function showHideMultipleMulti(cntrl, hidCntrl, test1, test2){
    var cTest = document.getElementById(cntrl);
    var cPanel = document.getElementById(hidCntrl);
    var optionFound = false;
    
    for (var i = 0; i < cTest.options.length; i++) { 
		if (cTest.options[i].selected && cTest.options[i].value == test1) optionFound = true;
		if (cTest.options[i].selected && cTest.options[i].value == test2) optionFound = true;
	}
    
    if (optionFound){
        cPanel.style.display = 'inline';
    } else {
        cPanel.style.display = 'none';
    }
}

function checkOther(cntrl, tbxCntrl, otherValue){
    var success = true;
    var foundOther = false;
    
    var list = document.getElementById(cntrl);
    var tbx = document.getElementById(tbxCntrl);
    
    for (var i = 0; i < list.length; i++) { 
		if (list.options[i].value == otherValue && list.options[i].selected) {
				foundOther = true;
		}
	}
	
	if (foundOther && tbx.value == '') {
	    success = false;
	}
   
    return success;
}

function popup(loc, width, height, scrolling) {
	if(!width){width=400}
	if(!height){height=300}
	if(!scrolling){scrolling=0}

	var cTop = (screen.availHeight/2) - (height/2);
    var cLeft = (screen.availWidth/2) - (width/2);
   	var myBars = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no';
	var myOptions = 'scrollbars='+scrolling+',width='+width+'px,height='+height+'px,top='+cTop+',left='+cLeft+',resizable=no';
	var myFeatures = myBars + "," + myOptions;
	window.open(loc, '', myFeatures);
}