﻿function StateIsValid(statecontrol, countrycontrol)
{
    var ddState = document.getElementById(statecontrol);
    var ddCountry = document.getElementById(countrycontrol);
                
    var st = ddState.selectedIndex;
    var cy = ddCountry.selectedIndex;
                
    //document.writeln('cy:' + cy + ' st:' + st);
    var iv = true;
                
    if (cy==0 && st>50)
    {
        iv = false;
    }
    else if (cy==1 && st<51)
    {
        iv = false;
    }
    else
    {
        iv = true;
    }   
    return iv;
}

function SetUp(cntrlid, max) {
    var oValue = parseInt(document.getElementById(cntrlid).value);
    var nValue = oValue + 1;
    
    if (nValue >= max) {
        nValue=max
    }
    document.getElementById(cntrlid).value = nValue
}


function SetDown(cntrlid, min) {
    var oValue = parseInt(document.getElementById(cntrlid).value);
    var nValue = oValue - 1;
    
    if (nValue <= min) {
        nValue=min
    }
    document.getElementById(cntrlid).value = nValue
}

function CenterPopup(URL, w, h) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=' + w + ',height=' + h + ',left = 540,top = 430');");
}

function capsDetect(e) {
    if (!e) { e = window.event; } if (!e) { MWJ_say_Caps(false); return; }
    //what (case sensitive in good browsers) key was pressed
    var theKey = e.which ? e.which : (e.keyCode ? e.keyCode : (e.charCode ? e.charCode : 0));
    //was the shift key was pressed
    var theShift = e.shiftKey || (e.modifiers && (e.modifiers & 4)); //bitWise AND
    //if upper case, check if shift is not pressed. if lower case, check if shift is pressed
    MWJ_say_Caps((theKey > 64 && theKey < 91 && !theShift) || (theKey > 96 && theKey < 123 && theShift));
}
function MWJ_say_Caps(oC) {
    if (typeof (capsError) == 'string') { if (oC) { alert(capsError); } } else { capsError(oC); }
}
