﻿        var onlySave=false;
        
        function optPubClick(){
        var div=document.getElementById('divPage1point5');
        var page=document.getElementById('divPage1');
        var opt=document.getElementById('optPubOfRecord');
            hideThis('divPage1point5');
            if(opt.checked==true){
                showThis('divPage1point5');
                page.style.height='';
           } 
        }
        
        function changeFlipFlop(){
            if(isChecked('chkDirMakeUpFlipFlop')){
                showThis('divFlipFlop');
            }else{
                hideThis('divFlipFlop');
            }
        }
        function showThis(v,f){
            var v=docE(v);
            v.style.display='';
            if(f){
                focusThis(f);
            }
        }
        
        function hideThis(v){
            var v=docE(v);
            v.style.display='none';
        }
        
        function focusThis(v){
            var v=document.getElementById(v);
            v.select();
            v.focus();
        }
        
        function showHidden(){
            if(isChecked('optPubOfRecord')){
                optPubClick();
            }
            if(isChecked('chkDirMakeUpFlipFlop')){
                changeFlipFlop();
            }
            if(isChecked('optCoboundYes')){
                showThis('divCoBound');
            }
            if(isChecked('optCompanionArtworkYes')){
                showThis('lblArtworkYes');
            }
            if(isChecked('optCompanionNationalYes')){
                showThis('lblNationalIndicator');
            }
        }
        
        function isChecked(v){
            var ret=false;
            var opt=document.getElementById(v);
            if(opt){
                ret=opt.checked;
            }
            return ret;
        }
        
        function copyText(s,d){
            var src=document.getElementById(s);
            var dest=document.getElementById(d);
            if(!src){
                dest.value='';
            }else{
                dest.value=src.value;
            } 
        }
        function helpMe(v){
            if(v){
                var h=CodeRequest.HelpText(v).value;
                var t=document.getElementById('helpTitle');
                var hlp=document.getElementById('helpText');
                if(h.HelpTitle){ 
                    t.innerHTML=h.HelpTitle;
                    hlp.innerHTML=h.HelpText;
                }else{
                    t.innerHTML='('+v+') No Help';
                    hlp.innerHTML='I\'m sorry, there is no Help Defined for that item.';
                } 
                showThis('divHelp'); 
            }else{
                hideThis('divHelp');
                alert('I\'m sorry, there is no Help Defined for that item.');
            }
        }
        
        function dirNameChange(){
            var l=document.getElementById('txtDirFullName').value.length;
            if(l>20){
                showThis('divAbbrvName');
            }else{
                hideThis('divAbbrvName');
            }
        }
        function getEmail(){
            if(hasValue('txtPubEmail')){
                if(!hasValue('txtEmail')){
                    copyText('txtPubEmail','txtEmail'); 
                }
            }
            showThis('divEmail','txtEmail');
        }
        function saveRequest(){
            hideThis('divEmail');
            var bEmail=(document.getElementById('txtEmail').value.length>5);
            if(bEmail){
                onlySave=true;
                document.getElementById('form1').submit();
             }else{
                alert('You cannot save without providing an email address.');
                getEmail(); 
            }  
        }
        
        function changeASection(){
            var a=isChecked('chkDirMakeUpCom');
            var b=isChecked('chkDirMakeUpDual');
            if(a||b){
                showThis('divASection');
            }else{
                hideThis('divASection');
            }
        }
        
        function docE(v){
            var e=document.getElementById(v);
            if(!e){
                alert('Element ' + v + ' was not found!');
            }
            return e;
        }
