//////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: imgOn() // Arguments: 'imgName' - string value of the img tag // Returns: - // Objective: swaps the src of 'imgName' with preloaded 'imgName' + 'on' .src //////////////////////////////////////////////////////////////////////////////////////////////////////// function SwapOn(imgName) { if (document.images) { KillAll(); document[imgName].src = eval(imgName + "_on.src"); } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: imgOff() // Arguments: 'imgName' - string value of the img tag // Returns: - // Objective: swaps the src of 'imgName' with preloaded 'imgName' + 'off' .src //////////////////////////////////////////////////////////////////////////////////////////////////////// function SwapOff(imgName) { if (document.images) { document[imgName].src = eval(imgName + "_off.src"); } } function KillAll(){ SwapOff('left_about'); SwapOff('left_tested'); SwapOff('left_treated'); SwapOff('left_living'); SwapOff('left_resources'); SwapOff('left_video'); } function MM_findObj(n, d) { var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i 12)){ alert(err48); //alert("Start Month"); return false; }else{ // Check that for each month, entered the input doesnt exceed the max number of days if (((smm == 4) || (smm == 6) || (smm == 9) || (smm == 11)) && (sdd > 30)) { alert(err48); //alert("Start Day Correspond to month 1"); return false; }else{ if (((smm == 1) || (smm == 3) || (smm == 5) || (smm == 7) || (smm == 8) || (smm == 10) || (smm == 12)) && (sdd > 31)) { alert(err48); //alert("Start Day Correspond to month 2"); return false; }else{ if ((syyyy < 2000) || (syyyy > 2078)){ alert(err48); //alert("Start Y2K"); return false; }else{ //smm--; //alert( syyyy + " " + smm + " " + sdd); startdate = Date.UTC(syyyy, smm, sdd); //************************************************** // Begin End Date routine //************************************************** if ((emm < 1) || (emm > 12)){ alert(err49); //alert("End Month"); return false; }else{ // Check that for each month, entered the input doesnt exceed the max number of days if (((emm == 4) || (emm == 6) || (emm == 9) || (emm == 11)) && (edd > 30)) { alert(err49); //alert("End Date correspond to month1"); return false; }else{ if (((emm == 1) || (emm == 3) || (emm == 5) || (emm == 7) || (emm == 8) || (emm == 10) || (emm == 12)) && (edd > 31)) { alert(err49); //alert("End Date correspond to month2"); return false; }else{ if ((eyyyy < 2000) || (eyyyy > 2078)){ alert(err49); //alert("End Y2K"); return false; }else{ //alert(startdate + "---" + currdate); if (startdate < currdate){ alert(err52); return false; }else{ //emm--; var enddate = Date.UTC(eyyyy, emm, edd); //************************************************** // Dates are valid at this point , compare them //************************************************** if (enddate < startdate){ alert(err50); //alert("End Date is less than start date"); return false; }else{ if (document[formName][field2].value.length == 1) { document[formName][field2].value = "0" + document[formName][field2].value; } if (document[formName][field1].value.length == 1) { document[formName][field1].value = "0" + document[formName][field1].value; } if (document[formName][field5].value.length == 1) { document[formName][field5].value = "0" + document[formName][field5].value; } if (document[formName][field4].value.length == 1) { document[formName][field4].value = "0" + document[formName][field4].value; } return true; } } } } } } } } } } }else{ alert(err51); return false; } // Objective 2. }else{ if ((IsPosDate(smm)) && (IsPosDate(sdd)) && (IsPosDate(syyyy))){ // Check the month field if ((smm < 1) || (smm > 12)){ alert(err51); return false; }else{ // Check that for each month, entered the input doesnt exceed the max number of days if (((smm == 4) || (smm == 6) || (smm == 9) || (smm == 11)) && (sdd > 30)) { alert(err51); return false; }else{ if (((smm == 1) || (smm == 3) || (smm == 5) || (smm == 7) || (smm == 8) || (smm == 10) || (smm == 12)) && (sdd > 31)) { alert(err51); return false; }else{ if ((syyyy < 2000) || (syyyy > 2078)){ alert(err51); return false; }else{ //smm--; startdate = Date.UTC(syyyy, smm, sdd); //alert(startdate + "---" + currdate); if (startdate < currdate){ alert(err56); return false; }else{ if (document[formName][field2].value.length == 1) { document[formName][field2].value = "0" + document[formName][field2].value; } if (document[formName][field1].value.length == 1) { document[formName][field1].value = "0" + document[formName][field1].value; } return true; } } } } } }else{ alert(err51); return false; } } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: IsBlank() // Arguments: 'field' - the name of the html form field // Returns: Boolean // Objective: Checks the field (Textbox, Textarea) for whitespace and blank //////////////////////////////////////////////////////////////////////////////////////////////////////// function IsBlank(formName, field){ var the_length; var whitespace; if (document[formName][field].value == ""){ return false; }else{ the_length = (document[formName][field].value.length - 1); for(i=0; i<=the_length; i++){ if (document[formName][field].value.charAt(i) == " "){ whitespace = 1; }else{ whitespace = 0; break; } } if (whitespace == 1){ return false; } } return true; } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: IsChecked() // Arguments: 'field' - the name of the html form field // Returns: Boolean // Objective: Checks the field set (Checkbox, Radio) for one or more selections //////////////////////////////////////////////////////////////////////////////////////////////////////// function IsChecked(formName, field){ var the_length = (document[formName][field].length - 1); var ischecked = 0; for (i=0; i<=the_length; i++){ if (document[formName][field][i].checked){ ischecked = 1; break; } } if (ischecked == 0){ return false; }else{ return true; } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: IsSingleChecked() // Arguments: 'field' - the name of the html form field // Returns: Boolean // Objective: Checks the field set (Checkbox, Radio) for one or more selections //////////////////////////////////////////////////////////////////////////////////////////////////////// function IsSingleChecked(formName, field){ if (!document[formName][field].checked){ return false; }else{ return true; } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: IsEmail() // Arguments: 'field' - the name of the html form field // Returns: Boolean // Objective: Checks the field (Text) an email address containing '@' and '.' //////////////////////////////////////////////////////////////////////////////////////////////////////// function IsEmail(formName, field){ var the_length; if (document[formName][field].value == ""){ return false; }else{ if ((document[formName][field].value.indexOf("@") > -1 ) && (document[formName][field].value.indexOf(".") > -1 )){ return true; }else{ return false; } } return true; } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: IsSelected() // Arguments: 'field' - the name of the html form field, // 'multiple' - Boolean variable defining if that select box allows multiple selections // Returns: Boolean // Objective: 1. If multiple == true checks that ANY of the options are selected // 2. If multiple == false checks that an option other than the first one is selected. The // first option has text like "Please select an option". //////////////////////////////////////////////////////////////////////////////////////////////////////// function IsSelected(formName, field, multiple){ if (multiple){ if (document[formName][field].options.selectedIndex >= 0){ return true; }else{ return false; } }else{ if (document[formName][field].options.selectedIndex > 0){ return true; }else{ return false; } } return true; } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: NumSelect() // Arguments: 'field' - the name of the html form field, // Returns: integer // Objective: Returns the number of options in the selection list. //////////////////////////////////////////////////////////////////////////////////////////////////////// function NumSelect(formName, field) { return document[formName][field].length } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: IsPasswordValid() // Arguments: 'newpass', 'newpassconfirm' - names of html form fields // Returns: Boolean // Objective: Checks that the newpass == newpassconfirm (put in your password 2x to confirm) and that // Password is at least 8 chars. //////////////////////////////////////////////////////////////////////////////////////////////////////// function IsPasswordValid(formName, newpass, newpassconfirm){ //alert("In IsPasswordValid"); if (document[formName][newpass].value.length < 4) { alert(err58); return false; } if (document[formName][newpass].value != document[formName][newpassconfirm].value){ alert(err11); return false; } return true; } //////////////////////////////////////////////////////////////////////////////////////////////////////// // function: GetItemForKey //parameters : in_Array, in_Key // return: a_NameValuePairs // purpose: Returns an array of arrays //////////////////////////////////////////////////////////////////////////////////////////////////////// function GetItemsForKey(in_Array, in_Key){ var a_NameValuePairs = new Array(); var j = 0; for (var i=0; i -1) { for (i=0; i<=the_length; i++){ if (document[formName].elements[from_field][i].checked){ if (document[formName].elements[to_field].value == ""){ document[formName].elements[to_field].value = document[formName].elements[from_field][i].value; }else{ document[formName].elements[to_field].value = ((document[formName].elements[to_field].value) + delim + (document[formName].elements[from_field][i].value)); } } } } //alert(document[formName].elements[to_field].value); } // END //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Gather_Input() // Arguments: 'to_field' -the name of the field (select) in the form to be moved // 'from_field' - the name of the field (text) in the html form // Returns: - // Objective: Takes all the options in from_field and moves them to to_field, in the following format // name::value; //////////////////////////////////////////////////////////////////////////////////////////////////////// function Gather_Input(formName, from_field, to_field, delim){ document[formName].elements[from_field].value = ""; var the_length = (document[formName].elements[from_field].options.length - 1); if (the_length > -1) { //alert("test"); for (i=0; i<=the_length; i++){ if (document[formName].elements[to_field].value == ""){ document[formName].elements[to_field].value = document[formName].elements[from_field].options[i].value; }else{ document[formName].elements[to_field].value = ((document[formName].elements[to_field].value) + delim + (document[formName].elements[from_field].options[i].value)); } } } //alert(document[formName].elements[to_field].value); } // END //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Limit_Input() // Arguments: 'field' - names of html form fields // 'limit' - numeral variable holding the max length of text area // Returns: Boolean // Objective: Trims the field (Textarea) to the amount of characters in 'limit'. Done to avoid // database field limit errors //////////////////////////////////////////////////////////////////////////////////////////////////////// function Limit_Input(formName, field,limit){ if (document[formName][field].value.length > limit ) { document[formName][field].value = document[formName][field].value.substring(0,limit); err55 = err55.replace(/__LENGTH__/, limit); alert(err55); } } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Page Flow Functions // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Page_Submit() // Arguments: none // Returns: Page Submission // Objective: Each page has a Validate_Page function within it, if that returns true, the page is // submitted //////////////////////////////////////////////////////////////////////////////////////////////////////// function Page_Submit(formName){ if (Validate_Page()){ document[formName].submit(); } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Page_Cancel() // Arguments: none // Returns: page goes back 1 history // Objective: performs the function of the browser back button //////////////////////////////////////////////////////////////////////////////////////////////////////// function Page_Cancel(){ history.back(-1); } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Confirm_Action() // Arguments: 'message' - The message to be displayed in confirm box. // 'dest' - Target url // Returns: - // Objective: Displays a warning message that the user has to accept in order for the action to occur //////////////////////////////////////////////////////////////////////////////////////////////////////// function Confirm_Action(message, dest){ if (confirm(message)){ window.location.href=dest; } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Confirm_Action() // Arguments: 'message' - The message to be displayed in confirm box. // 'dest' - Target url // Returns: - // Objective: Displays a warning message that the user has to accept in order for the action to occur //////////////////////////////////////////////////////////////////////////////////////////////////////// function Confirm_Delete(formName, message, action){ if (confirm(message)){ document[formName].action = action; document[formName].submit(); } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: SelfClose() // Arguments: none // Returns: closes a window // Objective: Used for pop up windows, session management. If the opener window was closed, this function // will close a popup window and alert a message when called by onBlur. //////////////////////////////////////////////////////////////////////////////////////////////////////// function SelfClose(){ if (window.opener.closed){ alert("No parent browser window, this window will close."); window.close(); } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Close_Popup() // Arguments: none // Returns: closes a window // Objective: Simple window closer fucntion //////////////////////////////////////////////////////////////////////////////////////////////////////// function Close_Popup(){ window.close(); window.opener.focus(); } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Go_There() // Arguments: 'dest' - string url // Returns: links to a new page // Objective: Used primarily for drop down navigation, where urls are the values of the drop down options. // Takes window to page defined in 'dest'. Called by onChange. //////////////////////////////////////////////////////////////////////////////////////////////////////// function Go_There(dest) { window.location.href = dest; } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: leaveSite(site) // Arguments: 'site' - string url // Returns: displays notice, then links to a new page // Objective: Used for leaving Schering-controlled sites, displays notice that Schering is not responsible // for the site you are about to visit //////////////////////////////////////////////////////////////////////////////////////////////////////// function leaveSite(site) { // to use this // instead of using an tag // the syntax is // if (confirm('You are now leaving all-about-hepatitisc.com Web site.\n\nThis link is provided as a convenience to you; however, by including this link to another site Schering Corporation expressly disclaims any and all liability with respect to access to or use of this other site. We do not screen other sites for content and we do not endorse, support, or attest to the accuracy or completeness of this site.\n\nContinue to ' + site + '?') == 1) { window.open(site, 'perceptions','toolbar=yes,width=600,height=400,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes') //window.open(site) } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Pop_Up() // Arguments: 'destination' - string url // 'width', 'height' - dimensions of window to be opened // Returns: opens 'destination' in new window // Objective: Opens a new window to url == 'destination' with dimensions desired //////////////////////////////////////////////////////////////////////////////////////////////////////// function Pop_Up(destination, width, height) { var pop = window.open(destination,"newWindow","scroll=yes,resizable=yes,status=no,width=" + width+ ",height=" + height + ",scrollbars=yes,copyhistory=no"); } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Select_All() // Arguments: 'field' - name of html form field // Returns: - // Objective: Selects every options in a select box //////////////////////////////////////////////////////////////////////////////////////////////////////// function Select_All(formName, field){ var the_length = (document[formName].elements[field].options.length - 1); for (i=0; i<=the_length; i++) { document[formName].elements[field].options[i].selected = true; } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Deselect_All() // Arguments: 'field' - name of html form field // Returns: - // Objective: De - Selects every options in a select box //////////////////////////////////////////////////////////////////////////////////////////////////////// function Deselect_All(formName, field){ var the_length = (document[formName].elements[field].options.length - 1); for (i=0; i<=the_length; i++) { document[formName].elements[field].options[i].selected = false; } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: Portal_Close() // Arguments: 'portal_item' - numeral value // Returns: -page submission // Objective: Populates a hidden field with 'portal_item' (the portal feed to be closed), submits the page //////////////////////////////////////////////////////////////////////////////////////////////////////// function Close_Portal(formName, portid){ if (document[formName].UserId.value != ""){ document[formName].PortId.value = portid; document[formName].submit(); }else{ alert(err54); } } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Page Display functions // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: imgOn() // Arguments: 'imgName' - string value of the img tag // Returns: - // Objective: swaps the src of 'imgName' with preloaded 'imgName' + 'on' .src //////////////////////////////////////////////////////////////////////////////////////////////////////// function imgOn(imgName) { if (document.images) { document[imgName].src = eval(imgName + "_on.src"); document.sub_img.src = eval(imgName + "_sub_img_on.src"); } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: imgOff() // Arguments: 'imgName' - string value of the img tag // Returns: - // Objective: swaps the src of 'imgName' with preloaded 'imgName' + 'off' .src //////////////////////////////////////////////////////////////////////////////////////////////////////// function imgOff(imgName) { if (document.images) { document[imgName].src = eval(imgName + "_off.src"); document.sub_img.src = sub_img_off.src; } } //////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: WriteDate() // Arguments: none // Returns: Document.write (Date) // Objective: determines current date based on client clock and prints out date on html page //////////////////////////////////////////////////////////////////////////////////////////////////////// function WriteDate() { var today=new Date(); document.write(today.getMonth() + 1); document.write ("." + today.getDate()); var y = today.getYear(); if ( y < 1000 ) y += 1900; document.write ("." + y); var tmp = today.getHours(); var hr = (tmp <= 12) ? tmp : (tmp-12); hr = ( hr < 10 ) ? "0" + hr : hr; var sym = (tmp < 12) ? " a.m." : " p.m."; if (hr == "00"){hr=12;} var TodayMinutes = (( today.getMinutes() < 10) ? "0" : "" ) + today.getMinutes(); var TodaySeconds = (( today.getSeconds() < 10) ? "0" : "" ) + today.getSeconds(); document.write(" " + hr + ":" + TodayMinutes); } // END //////////////////////////////////////////////////////////////////////////////////////////////////////// //--> isOnPage("<%= request.getRequestURI() %>");