
                           var curID = 0;



                            function clear_input(type){

                                 if (type == 'search') {
                                     lid = "hsb";
                                     LID = document.getElementById(lid);
                                      var input = eval(LID);
                                      if (!input.value) {
                                        return;
                                      }
                                      else if (input.value == 'Search'){
                                        input.value = '';
                                        return
                                      }
                                      else {
                                        return;
                                      }
                                }
                                else if (type == 'home_signup_user') {
                                    lid = "home_signup_user";
                                    LID = document.getElementById(lid);
                                     var input = eval(LID);
                                     if (!input.value) {
                                       return;
                                     }
                                     else if (input.value == ' Select a Username'){
                                       input.value = '';
                                       return
                                     }
                                     else {
                                       return;
                                     }
                                }
                                else if (type == 'home_signup_email') {
                                    lid = "home_signup_email";
                                    LID = document.getElementById(lid);
                                     var input = eval(LID);
                                     if (!input.value) {
                                       return;
                                     }
                                     else if (input.value == ' Email Address'){
                                       input.value = '';
                                       return
                                     }
                                     else {
                                       return;
                                     }
                                }
                                else if (type == 'user') {
                                    lid = "sn_username";
                                    LID = document.getElementById(lid);
                                     var input = eval(LID);
                                     if (!input.value) {
                                       return;
                                     }
                                     else if (input.value == ' Username'){
                                       input.value = '';
                                       return
                                     }
                                     else {
                                       return;
                                     }
                                }
                                else if (type == '7day_tempusername') {
                                    lid = "7day_tempusername";
                                    LID = document.getElementById(lid);
                                     var input = eval(LID);
                                     if (!input.value) {
                                       return;
                                     }
                                     else if (input.value == ' Select a Username'){
                                       input.value = '';
                                       return
                                     }
                                     else {
                                       return;
                                     }
                                }
                                else if (type == '7day_tempemail') {
                                    lid = "7day_tempemail";
                                    LID = document.getElementById(lid);
                                     var input = eval(LID);
                                     if (!input.value) {
                                       return;
                                     }
                                     else if (input.value == ' Email Address'){
                                       input.value = '';
                                       return
                                     }
                                     else {
                                       return;
                                     }
                                }
                                else if (type == 'pass') {
                                   pid = "sn_password1";
                                   PID = document.getElementById(pid);
                                   tid = "sn_password";
                                   TID = document.getElementById(tid);

                                   TID.style.display = 'none';
                                   PID.style.display = '';
                                   PID.focus();
                                }

                            }
                            function unclear_input(type){

                                 if (type == 'search') {
                                     lid = "hsb";
                                     LID = document.getElementById(lid);
                                      var input = eval(LID);
                                      if (!input.value) {
                                        input.value = 'Search';
                                        return;
                                      }
                                      else if (input.value == 'Search'){
                                        input.value = 'Search';
                                        return
                                      }
                                      else {
                                        return;
                                      }
                                 }
                                    else if (type == 'home_signup_user') {
                                        lid = "home_signup_user";
                                        LID = document.getElementById(lid);
                                         var input = eval(LID);
                                         if (!input.value) {
                                           input.value = ' Select a Username';
                                           return;
                                         }
                                         else if (input.value == ' Select a Username'){
                                           input.value = ' Select a Username';
                                           return
                                         }
                                         else {
                                           return;
                                         }
                                    }
                                    else if (type == 'home_signup_email') {
                                        lid = "home_signup_email";
                                        LID = document.getElementById(lid);
                                         var input = eval(LID);
                                         if (!input.value) {
                                           input.value = ' Email Address';
                                           return;
                                         }
                                         else if (input.value == ' Email Address'){
                                           input.value = ' Email Address';
                                           return
                                         }
                                         else {
                                           return;
                                         }
                                    }
                                    else if (type == 'user') {
                                        lid = "sn_username";
                                        LID = document.getElementById(lid);
                                         var input = eval(LID);
                                         if (!input.value) {
                                           input.value = ' Username';
                                           return;
                                         }
                                         else if (input.value == ' Username'){
                                           input.value = ' Username';
                                           return
                                         }
                                         else {
                                           return;
                                         }
                                    }
                                    else if (type == '7day_tempusername') {
                                        lid = "7day_tempusername";
                                        LID = document.getElementById(lid);
                                         var input = eval(LID);
                                         if (!input.value) {
                                           input.value = ' Select a Username';
                                           return;
                                         }
                                         else if (input.value == ' Select a Username'){
                                           input.value = ' Select a Username';
                                           return
                                         }
                                         else {
                                           return;
                                         }
                                    }
                                    else if (type == '7day_tempemail') {
                                        lid = "7day_tempemail";
                                        LID = document.getElementById(lid);
                                         var input = eval(LID);
                                         if (!input.value) {
                                           input.value = ' Email Address';
                                           return;
                                         }
                                         else if (input.value == ' Email Address'){
                                           input.value = ' Email Address';
                                           return
                                         }
                                         else {
                                           return;
                                         }
                                    }
                                    else if (type == 'pass') {
                                       pid = "sn_password1";
                                       PID = document.getElementById(pid);
                                       tid = "sn_password";
                                       TID = document.getElementById(tid);

                                       var input = eval(PID);
                                       if (!input.value) {
                                           TID.style.display = '';
                                           PID.style.display = 'none';
                                           return;
                                       }
                                        else {
                                          return;
                                       }
                                    }

                            }
                            function submitSearch() {
                                 pid = "hsb";
                                 PID = document.getElementById(pid);
                                 var surl = '/?page=search&other=' + PID.value;
                                 window.location = surl
                                 return true;
                            }

                            function submitAdvSearch(tmp) {
                                 pid = tmp;
                                 PID = document.getElementById(pid);

                                 if (pid == "bible_id"){

                                    cid = 'bible_chapter';
                                    CID = document.getElementById(cid);

                                    var surl = '/?page=search&bible_id=' + PID.value + '&bible_chap=' + CID.value;
                                    window.location = surl
                                 }

                                  else  if (pid == "verse_id"){


                                    cid = 'bible_chapter';
                                    CID = document.getElementById(cid);

                                     vid = 'bible_verse';
                                    VID = document.getElementById(vid);
                                    PID = document.getElementById('bible_id');
                                 
                                    var surl = '/?page=search&bible_id=' + PID.value + '&bible_chap=' + CID.value + '&bible_verse=' + VID.value;

                                    window.location = surl;
                                 }
                                 else if (pid == "keyword_id") {
                                    var surl = '/?page=search&keyword_id=' + PID.value;
                                    window.location = surl
                                 }
                                   else if (pid == "seasonal_id") {
                                    var surl = '/?page=search&keyword_id=' + PID.value;
                                    window.location = surl
                                 }
                                 else if (pid == "cat_id") {
                                    //var surl = '/?page=search&category_id=' + PID.value;
                                    window.location = surl
                                 }
                                 return true;
                            }

                            function searchEnter(evt) {
                                var charCode = (evt.which) ? evt.which : event.keyCode
                                var charString = String.fromCharCode(charCode);

                                if (charCode == 13){
                                    submitSearch();
                                    return true;
                                }
                                return true;
                            }

                           function showAdvancedSearch() {
                              effect_1 = Effect.SlideDown('advancedsearchlayer',{duration:0.4});
                              return false;

                           }

                           function hideAdvancedSearchDelay(){
                                    effect_1 = Effect.SlideUp('advancedsearchlayer',{duration:0.4});
                                    clearInterval(curID);
                                    return false;
                           }

                           function hideAdvancedSearch() {
                              clearInterval(curID);
                              curID = setInterval(hideAdvancedSearchDelay, 1250);
                              return false;
                           }

                           function resetAdvancedSearchTimer() {
                              clearInterval(curID);
                           }

                           function submitPageNum () {
                              PID = document.getElementById('svar');
                              DID = document.getElementById('perpage_num');
                              EID = document.getElementById('tmp_amt_pp');


                              var surl = '/?page=search' + PID.value + '&num=' + DID.value + '&tmp_amt_pp=' + EID.value;
                              window.location = surl
                              //PID.submit();
                              return true;
                           }

                           function submitSortChange () {
                              PID = document.getElementById('svar2');
                              DID = document.getElementById('sortType');
                              EID = document.getElementById('tmp_amt_pp');


                              var surl = '/?page=search' + PID.value + '&sort=' + DID.value + '&num=' + EID.value;
                              window.location = surl
                              //PID.submit();
                              return true;
                           }

                           function showTrialSignup() {
                              PID = document.getElementById('trial_homepage');
                              SID = document.getElementById('homepage');
                              EID = document.getElementById('7day_tempusername');
                              BID = document.getElementById('7day_tempemail');
                              CID = document.getElementById('reg_user_name');
                              VID = document.getElementById('reg_user_email');
                              FID = document.getElementById('flash_header');

                              CID.value = EID.value;
                              VID.value = BID.value;
                              FID.style.display = "none";

                              effect_1 = Effect.BlindUp("homepage",{duration:1.0});
                              effect_2 = Effect.BlindDown("trial_homepage",{duration:1.0});
                            //  setTimeout('effect_2 = Effect.BlindDown("trial_homepage",{duration:1.0});',1015);

                              return false;
                           }

                           function createStateMenu(pid, sid, ssid) {

                              PID = document.getElementById(pid);
                              SID = document.getElementById(sid);
                              SSID = document.getElementById(ssid);

                              value = PID.value;

                              // go ahead and make the check request
                              reqUrl = "/index.php?page=home&action=getstate&country=" + value;
                              //alert(reqUrl);
                              var request = HTTP.newRequest();
                              request.onreadystatechange = function() {
                                 if (request.readyState == 4 && request.status == 200) {
                                    if (request.getResponseHeader("Content-type") == "text/xml") {

                                       var doc = request.responseXML;

                                             var root = doc.getElementsByTagName('root')[0];
                                             var respon = root.getElementsByTagName('response')[0];
                                             var items = root.getElementsByTagName('response')[0];
                                             var avail = items.getAttribute("available");

                                             var selOptText = new Array();
                                             var selOptValue = new Array();
                                             var cnt = 0;

                                             if (avail == 'true') {

                                                for (var iNode = 0; iNode < items.childNodes.length; iNode++) {
                                                   var node = items.childNodes.item(iNode);

                                                   selOptText[cnt] = node.firstChild.nodeValue;
                                                   selOptValue[cnt] = node.getAttribute("value");
                                                //   alert(node.getAttribute("value"));
                                                   cnt++;
                                                }

                                                // remove the old plain text input field
                                                SSID.removeChild(SID);

                                                // add pull down option menu for states
                                                var newSelect = document.createElement('select');

                                                var newSelectID = sid;
                                                var newSelectName = sid;

                                                newSelect.setAttribute('id',newSelectID);
                                                newSelect.setAttribute('name',newSelectName);


                                                   for (x = 0; x < selOptText.length; x++) {

                                                      var newOption = document.createElement('option');
                                                      var newOptionValue = selOptValue[x];
                                                      var newOptionText = selOptText[x];

                                                      newOption.setAttribute('value',newOptionValue);
                                                      newOption.innerHTML = newOptionText;
                                                      newSelect.appendChild(newOption);
                                                   }

                                                SSID.appendChild(newSelect);
                                                return true;
                                             }
                                             else {
                                                 SID.disabled = "";
                                                 SID.value = "";
                                                 return true;
                                             }
                                             return true;
                                    }
                                    else {
                                       SID.disabled = "";
                                       SID.value = "";
                                       return true;
                                    }
                                 }
                              }
                              request.open("GET", reqUrl);
                              request.send(null);
                           }
