totalInquiryBox = 0;

function trim(str) {
    return str.replace(/^\s+|\s+$/g, '');
}

function isValidPassword(pass) {
    var valid = true;
    if (strng == "") {
        valid = false;
    }
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length < 6) || (strng.length > 8)) {
        valid = false;
    }
    else if (illegalChars.test(strng)) {
        valid = false;
    }
    
    return valid;
}

function focusToNext(elmnt,content)
{
    if (content.length==elmnt.maxLength)
        {
            next=elmnt.tabIndex;
            if (next<document.forms[0].elements.length)
                {
                    document.forms[0].elements[next].focus()
                }
            }
        }
        
        function selectThisItem(item){
            return item.select();
        }
        
        function focusonDefault(){
            var firstForm = document.forms[0];
            str="";
            if(firstForm!=null){
                var formElements = firstForm.elements;
                for(var i = 0; i < formElements.length; i++)
                    {
                        if(formElements[i].type=="text"){
                            formElements[i].focus();
                            break;
                        }
                    } 	
                }
                
            }
            
            function checkDataRegistration(){ if(!document.getElementById('i_agree').checked){
                alert("Please read and agree to the terms and conditions by checking the box");
                return false; 
            }
            return true;
        }
        
        
        function createUserByPlan(registration_form,planId){
            if(planId==1){	
                registration_form.package[0].checked=true;
                registration_form.submit();
            }
            else if(planId==2){
                registration_form.package[1].checked=true;
                registration_form.submit();
            }
        }
        
        
        function checkInquiryData(add_inquiry_form,action_value){
            add_inquiry_form.Add.value = action_value;
            add_inquiry_form.submit();
        }
        
        function toggleBox(box1,box2){
            document.getElementById(box1).checked = false;
            document.getElementById(box2).checked = false;
        }
        
        /*function addInquiryBox(count){
        fullInquiryBox = document.getElementById("full_inquiry_box");
        
        for(i=0;i<count;i++){
        newBox = document.createElement("div");
        newBox.setAttribute("id", "inquiry_box_"+totalInquiryBox);
        newBox.innerHTML='<table width="100%" cellpadding="0" cellspacing="0"><tr> <td align="left" >Creditor Name : <input type="text" name="name_'+totalInquiryBox+'" size="15" value=""> </td><td align="left" >Inquiry Date:  <input type="text" name="inquiry_date_'+totalInquiryBox+'"  value="" readonly="true" onclick="javascript:createCalendar(this);" title="Click to open date window" size="10"> <td align="left" ><label><b>Eq</b></label> <input name="eq_'+totalInquiryBox+'" value="72" checked="checked" type="checkbox">&nbsp; <label><b>Ex</b></label> <input name="ex_'+totalInquiryBox+'" value="99" checked="checked" type="checkbox">&nbsp;	<label>Tr</label> <input name="tr_'+totalInquiryBox+'" value="100" checked="checked" type="checkbox">&nbsp; </tr> <tr> <td align="left" colspan="3" height="15" > </td>  </tr> </table>';
        fullInquiryBox.appendChild(newBox);
        
        totalInquiryBox++;
        }
        document.getElementById("total_boxes").value=totalInquiryBox;
        return false;
        }*/
        function changeAction(checklist)
        {
            
            document.getElementById(checklist).action="checklistsave.php";
        }
        function addInquiryBox(count){
            fullInquiryBox = document.getElementById("full_inquiry_box");
            
            for(i=0;i<count;i++){
                newBox = document.createElement("div");
                newBox.setAttribute("id", "inquiry_box_"+totalInquiryBox);
                
                eqVal = "eq_"+totalInquiryBox;
                exVal = "ex_"+totalInquiryBox;
                trVal = "tr_"+totalInquiryBox;
                
                newBox.innerHTML='<table width="100%" cellpadding="0" cellspacing="0"><tr> <td align="left" >Creditor Name : <input type="text" name="name_'+totalInquiryBox+'" size="15" value=""> </td><td align="left" >Inquiry Date:  <input type="text" name="inquiry_date_'+totalInquiryBox+'"  value="" readonly="true" onclick="javascript:createCalendar(this);" title="Click to open date window" size="10"> <td align="left" ><label><b>Eq</b></label> <input name="'+eqVal+'" id="'+eqVal+'" value="72" type="radio" onclick=toggleBox("'+exVal+'","'+trVal+'")>&nbsp; <label><b>Ex</b></label> <input name="'+exVal+'" id="'+exVal+'" value="99"  type="radio" onclick=toggleBox("'+eqVal+'","'+trVal+'")>&nbsp;	<label>Tr</label> <input name="'+trVal+'" id="'+trVal+'" value="100"  type="radio" onclick=toggleBox("'+eqVal+'","'+exVal+'")>&nbsp; </tr> <tr> <td align="left" colspan="3" height="15" > </td>  </tr> </table>';
                fullInquiryBox.appendChild(newBox);
                
                totalInquiryBox++;
            }
            document.getElementById("total_boxes").value=totalInquiryBox;
            return false;
        }
        
        function createElement(type_var,id,name_var,size) {
            var element = document.createElement("input");
            element.setAttribute("type", type_var);
            element.setAttribute("id", id);
            element.setAttribute("name", name_var);
            element.setAttribute("size", size);
            return element;
        }
        
        function createCalendar(inputValue){
            var _cal1 = new calendar(inputValue);
            _cal1.year_scroll = true;
            _cal1.time_comp = true; 
            _cal1.popup();
        }
        
        function displayTextBox(selectValue,selectNum){
            if(selectValue == 'yes'){
                document.getElementById('nc'+selectNum).style.display='none';
            }
            else{
                document.getElementById('nc'+selectNum).style.display='inline';
            }
        }
        
        
        function showHidePasswordBox(id){
            var passwdField = document.getElementById("showpassword_"+id);
            var passwdFieldText = document.getElementById("showpassword_text_"+id);
            
            if(passwdField.style.display!="none"){
                passwdField.style.display="none";
                passwdFieldText.style.display="";
                
            }
            else{
                passwdField.style.display="";
                passwdFieldText.style.display="none";
            }
        }
        
        
        function toggleSideBar(menuBar,whichMenu){
            if(whichMenu!=""){
                
                var menuContents = document.getElementById(whichMenu);
                if(menuContents!=null){
                    
                    if(menuContents.style.display==""){                      
                        menuContents.style.display="none";
                        menuBar.className="left_menu_heading_plus";
                    }
                    else{
                        menuContents.style.display="";
                        menuBar.className="left_menu_heading_minus";
                    }
                    
                }
            }
            
        }
        
        
        function toggleAddressBar(menuBar,whichMenu){
            if(whichMenu!=""){
                
                var menuContents = document.getElementById(whichMenu);
                if(menuContents!=null){
                    
                    if(menuContents.style.display==""){                      
                        menuContents.style.display="none";
                    }
                    else{
                        menuContents.style.display="";
                    }
                    
                }
            }
            
        }
        
        function postForm(formId,gotoValue){
            if(gotoValue!=""){
                document.getElementById('goto').value=gotoValue;
            }
            formId.submit();
        }
        
        
        function showTabExt(whichMenu){
            if(whichMenu!=""){
                
                var menuContents = document.getElementById(whichMenu);
                if(menuContents!=null){
                    
                    if(menuContents.style.display==""){                      
                        menuContents.style.display="none";
                    }
                    else{
                        menuContents.style.display="";
                    }
                    
                }
            }
            
        }        
