/* Functions from file resources/index.jsp */


var xmlhttp;

function leaveSite_resources(url){
  pWidth = 675;
  pHeight = 650;
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
  interstitial=window.open(url,'interstitial', config='width=' + pWidth + ',height=' + pHeight + ',top=' + positionTop + ',left=' + positionLeft + ',resizable=1,menubar=0,location=0,directories=0,toolbar=no,scrollbars=1,status=1');
}

function showLock(remoteUser) {
    var locks = document.getElementsByName("lock");
	for (var i= 0; i< locks.length; i++) {
   
	   if (remoteUser != null ) {
			locks[i].style.display="none";
	   } else { 
			//locks[i].style.display="block";
	   }		
	}
}

/* Functions from file foldercontents/prodinfo/dropdown.jsp, portlets/generic/genericPageflow/HCPProducts.jsp */

function openSelectedFile(tagName)
    {
        var obj = document.getElementById(tagName);
        if(obj.selectedIndex==0) return;
        var selectObj = obj.options[obj.selectedIndex];
        eval(selectObj.value);
    }

/* Functions from file foldercontents/clintrials/header.jsp */

function handleTrialTroveURL(href,params,sessionId)
    {
        var jsessionid = getCookieValue("JSESSIONID");
        if(jsessionid)
        {
            window.location = href+"?"+params;
            return false;
        }else{
            window.location = href + ";jsessionid="+sessionId+"?"+params;
            return false;
        }
    }
    
/* Function from files foldercontents/clintrials/header.jsp, foldercontents/clintrials/links.jsp, foldercontents/links_no_trialtrove.jsp, foldercontents/trailtrove.jsp, portlets\common\HCPLeftNavigation.jsp,portlets\common\HCPOpenPDF.jsp,generic\genericPageflow\*.jsp  */
function getCookieValue( name ) 
      {
        var c = document.cookie; 
        var begin = c.indexOf( name ); 
        if( begin < 0 ) return( "" ); 
        begin += name.length + 1; 
        var end = c.indexOf( ";", begin ); 
        if( end == -1 ) end = c.length; 
        return( c.slice( begin, end ) );
      }
      
/* Functions from files portlets\login\HCPLogin.jsp, \generic\genericPageflow\home\login.jsp */

String.prototype.trim = function()
{
    var x = this.replace(/(^\s*)|(\s*$)/g,"");
    return x.replace(/^\[ \t]*$/g,"");
}

function trapLoginEnter(event)
{
    var e = event ? event : window.event;

    if (e.keyCode == 13)       // Enter key pressed
    {
        e.cancelBubble = true;
        e.returnValue = false; 
        //var loginForm = document.getElementById("login_form");
        document.login_form.submit();
    }
}

function trapInstantAccessEnter(event)
{
    var e = event ? event : window.event;

    if (e.keyCode == 13)       // Enter key pressed
    {
        e.cancelBubble = true;
        e.returnValue = false; 
        //var loginForm = document.getElementById("login_form");
        instantAccess();
    }
}

function instantAccess()
{
    document.getElementById("rocheid").value=document.getElementById("rid").value.trim();
    document.instantAccess_form.submit();    
}

/* Functions from files \generic\genericPageflow\home\login.jsp*/

function login()
{
    document.login_form.submit();
}

/* Function from file \portlets\search\askQuestion\AskMedicalGroup.jsp*/

function AMG_validate(emailExp)
  {     
     var valid = true;
     var emailValid = true;
	 var questionValid = true;
	 
     var questForm = document.getElementById(getNetuiTagName("askQuestionForm", this));
     var email = questForm[getNetuiTagName("email", this)].value.trim();
     if(email == "")
     {
        //appendNewError("<i18n:getMessage messageName='email_missing'/>");
        emailValid = false;
		valid = false;
     }
     else if(email.search(emailExp) != 0)
     {
        //appendNewError("<i18n:getMessage messageName='email_invalidformat'/>");
        emailValid = false;
		valid = false;
     } 
     
     var q = questForm[getNetuiTagName("question", this)].value.trim();
     if(q.length < 1 || q.length > 2000)
     {
        //appendNewError("<i18n:getMessage messageName='question_invalidlength'/>");
        questionValid = false;
		valid = false;
     }

     if(!valid)
     {
        //document.getElementById("error_msg_server").className = "hide";
        //document.getElementById("error_msg_client").className = "error_msg generic_errors"; 
		document.getElementById("generic_errors").className = "error_msg"; 
        document.location = "#top";
		
		var htmlText = "";
		if (!questionValid) {
		    htmlText += "<li>Ask your question";
		}
		if (!emailValid) {
		    htmlText += "<li>E-mail address"
		}
		document.getElementById("errors").innerHTML = htmlText;
     }
     return valid;
     
  }

/* Function from file portlets\register\DisplayInstantAccessHelpPage.jsp */

 function DIAH_validate()
  {
     var regForm = document.getElementById(getNetuiTagName("reg_form", this));
     
     return validateRocheId(regForm);
     
  }
  
/* Function from file portlets\register\DisplayInstantAccessRegPage.jsp*/ 

function DIAR_validate()
  {
     document.getElementById("error_msg_client_list").innerHTML = "";
     var valid = true;
     var regForm = document.getElementById(getNetuiTagName("reg_form", this));
     
     valid = validateMail(regForm) ? valid : false;     
     
     valid = validatePassword(regForm) ? valid : false;
     
     valid = validateConfirmPassword(regForm) ? valid : false;
  
     valid = validateOptIn(regForm) ? valid : false;  
     
     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
     
  }
  
/* Function from file portlets\register\DisplayRegistrationPage.jsp*/ 

 function DRP_validate()
  {
	  
     document.getElementById("error_msg_client_list").innerHTML = "";
     var valid = true;
     var regForm = document.getElementById(getNetuiTagName("reg_form", this));
     
     valid = validateMail(regForm) ? valid : false;     
     
     valid = validatePassword(regForm) ? valid : false;
     
     valid = validateConfirmPassword(regForm) ? valid : false;    
     
     //valid = validateDesignation(regForm) ? valid : false;
     
     valid = validateFirstName(regForm) ? valid : false;
     
     valid = validateLastName(regForm) ? valid : false;
     
     valid = validateZipcode(regForm) ? valid : false;
     
     //valid = validateAuthOption(regForm) ? valid : false;
     
     valid = validateOptIn(regForm) ? valid : false;
  
     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
     
  }
 
 /* Function from file portlets\register\DisplayRejectedRegistrationStep3.jsp*/ 
 
 function DRRS_validate()
  {
     document.getElementById("error_msg_client_list").innerHTML = "";
     
     
     var regForm = document.getElementById(getNetuiTagName("reg_form", this));
     
     var valid = true;
     
     //valid = validateAuthOption(regForm) ? valid : false;
  
     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
     
  }
  
/* Function from file portlets\register\DisplayUserPreferenceEditPage.jsp */ 

function DUPE_validate()
  {
     document.getElementById("error_msg_client_list").innerHTML = "";
     var valid = true;
     var regForm = document.getElementById(getNetuiTagName("reg_form", this));
     
     valid = validateMail(regForm) ? valid : false;
     //REX 4.0 changes - changed validateDesignation to validateMyProfileDesignation
     //valid = validateMyProfileDesignation(regForm) ? valid : false;
     
     valid = validateFirstName(regForm) ? valid : false;
     
     valid = validateLastName(regForm) ? valid : false;
     
     valid = validateZipcode(regForm) ? valid : false;
     
     //valid = validateOptIn(regForm) ? valid : false;

     // valid = validatePraticeStates(regForm) ? valid : false;
  
     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
     
  }

/* Function from file portlets\register\HCPChangePassword.jsp */   

function HCPCP_validate()
  {
     document.getElementById("error_msg_client_list").innerHTML = "";
     var valid = true;
     var regForm = document.getElementById(getNetuiTagName("edit_password_form", this));

     if(!validateOldPassword(regForm))
     {
        valid = false;
     }
     
     if(!validatePassword(regForm))
     {
        valid = false;
     }
     
     if(!validateConfirmPassword(regForm))
     {
        valid = false;     
     }

     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
     
  }   
  
/* Function from file portlets\search\gsaSearch\Details.jsp ;Changed on 16/04/2008*/   
  
  function D_validateMail(infoForm)
  {
    var emailExp = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$/;
    var valid = true;
    var email = infoForm[getNetuiTagName("email", this)].value.trim();
    if(email == "")
    {
        appendNewError("<i18n:getMessage messageName='email_missing'/>");
        valid = false;
    }
    else if(email.search(emailExp) != 0)
    {
        appendNewError("<i18n:getMessage messageName='email_invalidformat'/>");
        valid = false;
    }
    return valid;
  }	

   /* Updated on 16/04/2008; Function call D_validateMail*/	
  function D_validate()
  {
     document.getElementById("error_msg_client_list").innerHTML = "";
     var valid = true;
     var infoForm = document.getElementById(getNetuiTagName("infotrieve_form", this));
     valid = D_validateMail(infoForm) ? valid : false;     
     
     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
  }
  
/* Functions from file portlets\search\gsaSearch\HCPSearchForm.jsp*/

function HCPSF_validate()
{
    if(search_flag==1) return false;
      
    var term = document.getElementById(getNetuiTagName("searchTerm", this));
    term.value = term.value.trim();
    if(term.value == "")
    {
        return false;
    }
    else
    {
        search_flag = 1;
        return true;
    }
}

function changeTerm(termBox, clear)
{
    if(clear && termBox.value == oldTerm)
    {
        termBox.value='';
    }
    else if(!clear && termBox.value=='')
    {
        termBox.value= oldTerm;
    }
}

function trapEnter(event)
{
    var e = event ? event : window.event;

    if (e.keyCode == 13)       // Enter key pressed
    {
        if(search_flag==1)
            return;        

        e.cancelBubble = true;
        e.returnValue = false; 
        if(HCPSF_validate())
        {
            document.getElementById(getNetuiTagName("searchForm", this)).submit();
            search_flag = 1;
        }
    }
}

function unlock(nodePath)
{
    var form = document.getElementById(getNetuiTagName("loginTrapForm", this));
    form[getNetuiTagName("trapNodePath", this)].value = nodePath;
    form.submit();
}

/* Functions from file portlets\standalone\registration\DisplayConfigurationPage.jsp */

function DCP_validate()
  {
     document.getElementById("error_msg_client_list").innerHTML = "";
     var valid = true;
     var regForm = document.getElementById(getNetuiTagName("reg_form", this));
     
     valid = validateConfArea(regForm) ? valid : false;     
     
     valid = validateConfCode(regForm) ? valid : false;
     
     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
     
  }


/* Functions from file portlets\standalone\registration\DisplayRegistrationPage.jsp ;Changed on 16/04/2008*/ 

function DRPSR_validate(showOptinJS)
  {
     
	
	 document.getElementById("error_msg_client_list").innerHTML = "";
     var valid = true;
     var regForm = document.getElementById(getNetuiTagName("reg_form", this));
     
     valid = validateMail(regForm) ? valid : false;     
     
     valid = validatePassword(regForm) ? valid : false;
     
     valid = validateConfirmPassword(regForm) ? valid : false;    
     
    // valid = validateDesignation(regForm) ? valid : false;
     
     valid = validateFirstName(regForm) ? valid : false;
     
     valid = validateLastName(regForm) ? valid : false;
     
     valid = validateZipcode(regForm) ? valid : false;
     
     //valid = validateAuthOption(regForm) ? valid : false;
     if(showOptinJS){
        valid = validateOptIn(regForm) ? valid : false;
	
     }
     if(!valid)
     {
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
     }
     return valid;
     
  }

/* Functions from file portlets\survey\survey.jsp */

function S_validate() {
    
    var valid = false;
    var errMsg = "Please answer at least one question.<br>"; 
    var curForm = document.getElementById(getNetuiTagName("survey_form", this));
    document.getElementById("error_msg_client_list").innerHTML = "";
    var els = curForm.elements;
    
    
    var chooseNo = 1;
    
    var lastElement;
    for(var i=0;i<els.length;i++)
    {
        if (els[i].name == lastElement) 
        {
            continue;
        } else if ((els[i].name.indexOf("_qust_")>0) && (els[i].type == "checkbox" || els[i].type == "radio"))
        {
            var sVal = GetValueChoose(els[i]);
            if (sVal.length != 0) 
            {
                valid = true;
                continue;
            }
            chooseNo++;
            lastElement = els[i].name;
        }
    }
    if (!valid) 
    {
        appendNewError(errMsg);
        document.getElementById("error_msg_server").className = "doNotDisplay";
        document.getElementById("error_msg_client").className = "error_msg"; 
        document.location = "#";
    }
    return valid;
}

function GetValueChoose(el)
{
    var sValue = "";
    var tmpels = document.getElementsByName(el.name);
    for(var i=0;i<tmpels.length;i++)
    {
        if(tmpels[i].checked)
        {
            sValue += "1";
        }
    }
    return sValue;
}

function appendNewError(errorMsg)
{
    var oNewNode = document.createElement("li");
    document.getElementById("error_msg_client_list").appendChild(oNewNode);
    oNewNode.innerHTML = errorMsg;
}

/* Functions from file resources\interstitial.jsp */

function I_openExternalSite(url) 
{
    var externalURL = unescape(url);
      
    if(externalURL.indexOf("/rochehcpp/")!=0)
    {
        if ( externalURL.trim().toLowerCase().indexOf("http://") != 0 && externalURL.trim().toLowerCase().indexOf("https://") != 0)
        {
            externalURL = "http://"+externalURL;
        }
    }
    
    
    pWidth = 640;
    pHeight = 480;
    positionTop = ((height/2) - (pHeight/2));
    positionLeft = ((width/2) - (pWidth/2));
    window.self.close();
    externalSite=window.open(externalURL,'ExternalResources', config='width=' + pWidth + ',height=' + pHeight + ',top=' + positionTop + ',left=' + positionLeft + ',resizable=1,menubar=1,location=1,directories=0,toolbar=yes,scrollbars=1,status=1');
    externalSite.focus();
}

function I_openTrialTrove(url)
{
	var path = "/rochehcpp/TrialTrove";

    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        alert("Your browser does not support XMLHTTP!");
    }
    
    xmlhttp.onreadystatechange=function()
    {
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				I_openExternalSite(url);
			}
	
		}
	}
 
 	xmlhttp.open("GET",path,true);
    xmlhttp.send(null);
}


function funct_queryString(val){
        var q  = location.search.substr(1);
        var index = q.indexOf('=');
        var key = q.substring(0,index);
        var value = q.substring(index + 1, q.length);    
        if (key.toLowerCase()==val.toLowerCase()) 
            return value;
        else
            return '';
    }

/* Functions from the file resources\resources.jsp */

function iframeResize()
{
  alert("adjust");
  //var theFrame = document.getElementById("resourceframe");
  var theFrame = window.frames["resourceframe"];
  alert(theFrame);
  alert(theFrame.document);
  alert(theFrame.document.body);
  if(window.frames["resourceframe"].document &&  document.frames["resourceframe"].document.body)
  { 
     document.frames["resourceframe"].height = document.frames["resourceframe"].document.body.scrollHeight;  
     alert(document.frames["resourceframe"].height);
  }

} 

function dyniframesize(iframename,FFextraHeight) 
{
alert(FFextraHeight);
    alert("ok");
	var pTar = null;
	if (document.getElementById)
    {
		pTar = document.getElementById(iframename);
	}
	else
    {
		eval('pTar = ' + iframename + ';');
	}
	alert(pTar);
	if (pTar && !window.opera)
    {
		//begin resizing iframe
		pTar.style.display="block"
		alert(pTar.contentDocument.body);
		if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight)
        {alert(pTar.contentDocument.body.offsetHeight);
			//ns6 syntax
			pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; 
		}
		else if (pTar.Document && pTar.Document.body.scrollHeight)
        {alert(pTar.Document.body.scrollHeight);
			//ie5+ syntax
			pTar.height = pTar.Document.body.scrollHeight;
		}
	}
}

/* Functions from the file visitorTools\visitorToolsEditPage.jsp */

function SetOptions(the_select, text_array, value_array) {
    the_select.options.length = text_array.length;
    for (loop=0; loop < text_array.length; loop++) {
        the_select.options[loop].text = text_array[loop];
        the_select.options[loop].value = value_array[loop];
    }
}

/* Functions from file portlets\common\Disclaimer.jsp */

function goon(url)
{
    alert(url);
    var parentWin;
    if(window.parent)
    {
        parentWin = window.parent;
    }
    else
    {
        parentWin = window;
    }
    var openerWin = parentWin.opener;
    
    if(openerWin && !openerWin.closed)
    {
        openerWin.document.location = url;
    }
    else
    {
        window.open(url);
    }
    parentWin.close();
}

    function openVideoFile(nodePath)
    {        
        var winFeature = "height=600,width=800,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes";
        window.open('/rochehcpp/portlets/common/DisplayPDFContent.jsp?pdfNodePath='+nodePath,'_blank',winFeature);    
        window.close();
    }


function callOpennerUnlock(nodePath)
{
    if(window.opener && !window.opener.closed && window.opener.unlock)
    {
        window.opener.unlock(nodePath);
    }
    else
    {
        alert("The RocheExchange Portal Window Closed or Not In Search Page!");
    }
    window.close();
}


/* Functions from file portlets\common\Disclaimer4special.jsp */

function setCurUserCookie4Speaker()
{
    var rightNow = new Date();
    var expdate = new Date();
    //expdate.setTime (expdate.getTime() + 365 * (24 * 60 * 60 * 1000));
    setCookie(cookieTitle, "speaker",null,"/");
}

function setCookie (name, value)
{
    //alert(name+"---"+value);
    try
    {
        var argv = setCookie.arguments;
        var argc = setCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
            ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
            ((path == null) ? "" : ("; path=" + path)) +
            ((domain == null) ? "" : ("; domain=" + domain)) +
            ((secure == true) ? "; secure" : "");
    }
    catch(e)
    {
        alert("JS error:"+e);
    }
}

function openPDFFileEx(nodePath)
{
    setCurUserCookie4Speaker();
    openPDFFile(nodePath);
    opener.window.location.reload();
    window.close();
} 

function downloadFile(url)
{
    setCurUserCookie4Speaker();
    window.location = url;
    opener.window.location.reload();
    //window.close();
}

/* Function from file portlets\common\HCPLeftNavigation.jsp, generic\genericPageflow\*.jsp */

function handleURL(aLink,sessionId)
{
    var href = aLink.href;
    var jsessionid = getCookieValue('JSESSIONID');
    if(jsessionid)
    {
        return true;
    }
    else
    {
        window.location = aLink.href+';jsessionid='+sessionId;
        return false;
    }
}

/* Functions from file portlets\common\HCPOpenPDF.jsp*/

   function isAcrobatReaderPresent() {
        var mime = navigator.mimeTypes["application/pdf"];
        if(navigator.appName == "Netscape") {
            return mime;
        } else if(navigator.appName == "Microsoft Internet Explorer") {
            var acrobat=new Object();

            acrobat.installed=false;
            acrobat.version='0.0';

            if (navigator.plugins && navigator.plugins.length)
            {
                for (x=0; x < navigator.plugins.length; x++)
                {
                    if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1)
                    {
                        acrobat.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);
                        if (acrobat.version.toString().length == 1) acrobat.version+='.0';
                        acrobat.installed=true;
                        break;
                    }
                }
            }
            else if (window.ActiveXObject)
            {
                for (x=2; x<10; x++)
                {
                    try
                    {
                        var oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
                        if (oAcro)
                        {
                            acrobat.installed=true;
                            acrobat.version=x+'.0';
                        }
                    }
                    catch(e) {}
                }

                try
                {
                    var oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
                    if (oAcro4)
                    {
                        acrobat.installed=true;
                        acrobat.version='4.0';
                    }
                }
                catch(e) {}

                try
                {
                    var oAcro7=new ActiveXObject('AcroPDF.PDF.1');
                    if (oAcro7)
                    {
                        acrobat.installed=true;
                        acrobat.version='7.0';
                    }
                }
                catch(e) {}

            }

            return acrobat.installed;
        }
    }



    function alertAcrobat() {
        if(isAcrobatReaderPresent()) {
            alert("Adobe Acrobat Plugin is there!");
        } else {
            alert("You do not have Adobe Acrobat Plugin!");
        }
    }
    
    function openPDFHint()
    {
        var winFeature = "height=650,width=675,status=no,toolbar=no,menubar=no,location=no";
        window.open('/rochehcpp/resources/pdfdownload.html',null, winFeature);
    }
    
    /*Updated on 23/04/2008*/ 	
    function openPDFFile(nodePath)
    {      
        var decodedNodePath = decodeURIComponent(nodePath);
        if(isAcrobatReaderPresent())
        {
            var winFeature = "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=yes";
            window.open(DisplayPDFContentPath+'?pdfNodePath='+decodedNodePath,'_blank',winFeature);    
        }
        else
        {
            openPDFHint();
        }
    }    

	
/*Updated for REX 3.5 DEA fix ,on 30/01/2008*/ 	
   function openWebFile(filePath,isPDF,nodePath,isDirectLink)
    {    
    	var decodedFilePath = filePath;
    	if(isDirectLink)
    	{
            decodedFilePath = decodeURIComponent(filePath);
        }
        
        var decodedNodePath = decodeURIComponent(nodePath);
        if(isPDF)
        {
            if(isAcrobatReaderPresent())
            {
                var winFeature = "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=yes";
                window.open(DisplayWebPDFContentPath+'?filePath='+decodedFilePath+'&nodePath='+decodedNodePath,'_blank',winFeature);    
            }
            else
            {
                openPDFHint();
            }
        }
        else
        {
            var winFeature = "height=600,width=800,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes";
            //window.open(decodedFilePath,'_blank',winFeature);    
            window.open(DisplayWebPDFContentPath+'?filePath='+decodedFilePath+'&nodePath='+decodedNodePath,'_blank',winFeature);    
        }
    } 
         
    //for compatiable with old codes.
    function openPDFFileFrowFrowWeb(filePath)
    {        
        //var decodedFilePath = decodeURIComponent(filePath);
        var decodedFilePath = filePath;
        if(isAcrobatReaderPresent())
        {
            var winFeature = "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=yes";
            window.open('/rochehcpp/portlets/common/DisplayWebPDFContent.jsp?filePath='+decodedFilePath,'_blank',winFeature);    
        }
        else
        {
            openPDFHint();
        }
    }       
    
    /*Changed on 23/04/2008 TBV*/
    // Here DisplayPDFContent.jsp is reused. The page uses one iFrame to show the node content.
    function openFile(nodePath)
    {        
        var decodedNodePath = decodeURIComponent(nodePath);
        var winFeature = "height=600,width=800,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes";
        window.open(DisplayPDFContentPath+'?pdfNodePath='+decodedNodePath,'_blank',winFeature);    
    }
    
    
    /*Changed on 23/04/2008 */
    function disClaimer(nodePath, isPDF, isLocked)
    {
        var winFeature = "height=650,width=675,status=no,toolbar=no,menubar=no,location=no,resizable=yes";
        var decodedNodePath = decodeURIComponent(nodePath);
        if(isPDF)
        {
            if(isAcrobatReaderPresent())
            {
                window.open(DisplayPDFContentPath+'?disclaimer=true&isLocked='+isLocked+'&pdfNodePath='+decodedNodePath,'_blank',winFeature);    
            }
            else
            {
                openPDFHint();
            }
        }
        else
        {
            window.open(DisclaimerPath+'?isPDF=false&isLocked='+isLocked+'&nodePath='+decodedNodePath,'_blank',winFeature);    
        } 
    }
    
    /*Changed on 23/04/2008 TBV*/    
    function disClaimer4Special(nodePath, isPDF,areaName)
    {
        var winFeature = "height=650,width=675,status=no,toolbar=no,menubar=no,location=no,resizable=yes";
        var decodedNodePath = decodeURIComponent(nodePath);
        
        if(isPDF)
        {
            if(isAcrobatReaderPresent())
            {
                window.open(Disclaimer4specialPath+'?isPDF=true&areaName='+areaName+'&nodePath='+decodedNodePath,'_blank',winFeature);    
            }
            else
            {
                openPDFHint();
            }
        }
        else
        {
            window.open(Disclaimer4specialPath+'?isPDF=false&areaName='+areaName+'&nodePath='+decodedNodePath,'_blank',winFeature);    
        } 
    }
    
    /*Changed on 23/04/2008 */
    function disClaimer(nodePath)
    {
        var winFeature = "height=650,width=750,status=no,toolbar=no,menubar=no,location=no,resizable=yes";
        var decodedNodePath = decodeURIComponent(nodePath);
        window.open(DisclaimerPath+'?nodePath='+decodedNodePath,'_blank',winFeature);    
    }
    
/*Updated on 18/04/2008*/ 
function showSecureFile(nodePath)
{
    var actualURL = secureURLPath + '/' + nodePath;
    window.location = actualURL;	
}

function showHTMLFile(nodePath)
{
    showSecureFile(nodePath);
}

/*Updated on 23/04/2008 TBV */
function showPDFFile(nodePath)
{
	  if (remoteUser == null) {
	showSecureFile(nodePath);
	 } else { 
    var actualURL = virtual_rep+'/'+nodePath;
    openPDFFile(actualURL);
	 } 
}

/*Updated on 23/04/2008  */
function showSamples()
{
    window.location = sampleUrl;
}

function externalResources(url,w,h)
{
  pWidth = w;
  pHeight = h;
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
  leaveSite('/rochehcpp/resources/interstitial.jsp?url=' + url);
}

function submit_resources_search() 
{
    var resURL = 'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Search&db=PubMed';
    var term = getKeywords();
    if(term!='')
    {
        resURL = encodeURIComponent(resURL+'&term='+term);
    }
    else
    {
        resURL = encodeURIComponent(resURL);
    }
    externalResources('/rochehcpp/resources/resources.html?resource=' + resURL,675,650);
}

function getKeywords()
{
    return encodeURIComponent(document.getElementById("search_text").value.trim());
}

/*Updated on 18/04/2008*/ 
function submit_public_search() 
{
    var v = document.getElementById("public_search");
    v.value = v.value.trim();
    if(v.value!="")
    {
	    document.publicationSearchForm.gsaSearchPortlet_1user.value = remoteUser;
		document.publicationSearchForm.gsaSearchPortlet_1therapeuticType.value =areaNameJS;
        document.publicationSearchForm.action = searchUrlJS;
		document.publicationSearchForm.submit();
        var obj_btn = document.getElementById("public_search_button");
        if (obj_btn!=null)
        {
            document.getElementById("public_search_button").disabled = true;
        }
    }
    return ;
}
/* Functions from file \portlets\common\HCPSearch.jsp. Changed on 2May 2008 by Arathi*/

function submitSearchForm(searchbarIndexJS)
{
    if(search_flag==1) return;
    
    var v = document.getElementById("searchTerm");
    v.value = v.value.trim();
    if(v.value=="" || v.value == searchbarIndexJS)
    {
        return;
    }
    else
    {
        document.searchForm.submit();
        search_flag = 1;
        return;
    }
}

function trapSearchEnter(event,searchbarIndexJS)
{
    var e = event ? event : window.event;
    if (e.keyCode == 13)       // Enter key pressed
    {
        if(search_flag==1)
            return;
        
        e.cancelBubble = true;
        e.returnValue = false; 
        submitSearchForm(searchbarIndexJS);
    }
}

function limitText(field, maxlength) {
    if (field.value.length > maxlength) {
        field.value = field.value.substring(0, maxlength);
    } 
}

/* Functions from file portlets\generic\genericPageflow\HCPAccLock.jsp */

function HAL_trapEnter(event)
{
    var e = event ? event : window.event;

    if (e.keyCode == 13)       // Enter key pressed
    {
        e.cancelBubble = true;
        e.returnValue = false; 
        var loginForm = document.getElementById(getNetuiTagName("goLogin", this));
        loginForm.submit();
    }
}

/* Functions from file portlets\generic\genericPageflow\HCPHomeSearchbar.jsp*/

function HCPHS_submitSearchForm(searchbarIndexJS)
{
    if(search_flag==1) return false;
    
    var v = document.getElementById("searchTerm");
    v.value = v.value.trim();
    if(v.value == "" || v.value == "<i18n:getMessage messageName="+searchbarIndexJS+"/>")
    {
        return false;
    }
    else
    {
        search_flag = 1;        
        return true;
    }
    
}
function HCPHS_trapSearchEnter(event,searchbarIndexJS)
{
    var e = event ? event : window.event;
    

    if (e.keyCode == 13)       // Enter key pressed
    {
        if(search_flag==1)
            return;
                
        e.cancelBubble = true;
        e.returnValue = false; 
        if(HCPHS_submitSearchForm(searchbarIndexJS)){
            document.forms["searchForm"].submit();
        }
    }
}

/* Functions from file portlets\generic\genericPageflow\HCPPreHome.jsp */

function setLastlastVisitCookie (oldSplValue)
{
    var rightNow = new Date();
    var expdate = new Date();
    expdate.setTime (expdate.getTime() + 365 * (24 * 60 * 60 * 1000));
    //expdate.setTime (expdate.getTime() + 1 * (10 * 60 * 1000)); //+1 day  
    SetCookie (oldSplValue, rightNow.getTime(), expdate, "/");

    /*
    if(!CookieEnable()) 
    { 
        document.frm.cookie_flag.value = "close";
    }
    else
    {
        document.frm.cookie_flag.value = "open";
    }
    document.frm.submit();
    */
}

function CookieEnable() 
{ 
    var result=false; 
    if(navigator.cookiesEnabled) 
        return true; 
    document.cookie = "testcookie=yes;"; 
    var cookieSet = document.cookie; 
    if (cookieSet.indexOf("testcookie=yes") > -1) 
        result=true; 
    document.cookie = ""; 
    return result; 
} 

/* Functions from file framework\skeletons\default\head.jsp */

function joinSession(uri,sessionId)
{
    var jsessionid = getCookieValue('JSESSIONID');
    if(jsessionid)
    {
        return uri;
    }
    else
    {
        return uri+';jsessionid='+sessionId;
    }
}

/* Function from file \portlets\search\contactML\contactMLForm.jsp  */

function ML_validate()
  {     
     var valid = true;
     var nameValid  = true;
	 var phoneValid = true;
     var emailValid = true;
     var zipValid   = true;
	 var questionValid = true;
     var emailExp = /^[\w-\.]+@([\w-]+\.)+[\w-]{3,3}$/;
	 var zipExp = /^\\d{5}$/;
     var formName ="contactMLForm";
     
     var mlForm = document.getElementById(getNetuiTagName(formName, this));
     
     
     var name = mlForm[getNetuiTagName("name", this)].value.trim();
     if(name.length >0)
     {
            appendNewError("<i18n:getMessage messageName='name_missing'/>");
            nameValid = false;
            valid = false;
     } 
     
     var phone = mlForm[getNetuiTagName("phone", this)].value.trim();
     if(phone.length >0)
     {
            appendNewError("<i18n:getMessage messageName='phone_missing'/>");
            phoneValid = false;
            valid = false;
     } 
     
     var email = mlForm[getNetuiTagName("email", this)].value.trim();
     if(email.length >0)
     {
        if(email.search(emailExp) != 0)
        {  
            appendNewError("<i18n:getMessage messageName='email_invalidformat'/>");
            emailValid = false;
            valid = false;
        } 
     } 
     
     var zip = mlForm[getNetuiTagName("zip", this)].value.trim();
     if(zip.length >0)
     {
            appendNewError("<i18n:getMessage messageName='zip_missing'/>");
            zipValid = false;
            valid = false;
     }else if(zip.search(zipExp) != 0){
            appendNewError("<i18n:getMessage messageName='zip_invalidformat'/>");
            zipValid = false;
            valid = false;
     }    
     var q = mlForm[getNetuiTagName("question", this)].value.trim();
     if(q.length < 1 || q.length > 200)
     {
        appendNewError("<i18n:getMessage messageName='question_invalidlength'/>");
        questionValid = false;
		valid = false;
     }

     return valid;
     
  }
  
  //Added by Jharna for opening PopUp1 in new window
  function conFirmationPopUp(url)
    {
		var winFeature = "height=650,width=750,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes";
        //var decodedNodePath = decodeURIComponent(nodePath);
        //window.open('/rochehcpp/portlets/generic/genericPageflow/goConfirmationPopUp.do?nodePath='+decodedNodePath+'&where='+where,'_blank',winFeature);    
        window.open(url,'_blank',winFeature);    
    }

  // for REX4.0 - Added by Muthu for Other Contents to open PopUp1 in new window
  function otherContentConfPopUp(nodePath)
    {
		var winFeature = "height=650,width=750,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes";
        var decodedNodePath = decodeURIComponent(nodePath);
        window.open('/rochehcpp/portlets/generic/genericPageflow/goConfirmationPopUp.do?nodePath='+decodedNodePath,'_blank',winFeature);    
        //window.open(nodePath,'_blank',winFeature);    
    }

  // for REX4.0 - Added by Muthu for Clinical Trials to open PopUp1 in new window
  function conFirmationPopup_CT(nodePath,sourceType)
    {
        //alert(nodePath);
        var winFeature = "height=650,width=750,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes";
        //window.open(ConfirmationPopup1Path_CT,'_blank',winFeature);    
        window.open(ConfirmationPopup1Path_CT+'?source_from=portal&sourceType='+sourceType+'&nodePath='+nodePath,'_blank',winFeature);    
    }
    
    
    /* Function from file portlets\generic\genericPageflow\HCPConfirmationPopUp.jsp*/ 
   
        function PopUp_validate()
	    {  
	       var valid = true;
	       var zipExp = /^\d{5}([\-]\d{4})?$/;
	       var regForm = document.getElementById(getNetuiTagName("goContinueForm", this));
	       var firstName = regForm[getNetuiTagName("firstName", this)].value.trim();
	       if(firstName.length <= 0)
			 {
			        appendNewError("<i18n:getMessage messageName='firstname_missing'/>");
					valid = false;
			 } 
	       
	       var lastName = regForm[getNetuiTagName("lastName", this)].value.trim();
	       if(lastName.length <= 0)
			 {
			        appendNewError("<i18n:getMessage messageName='lastname_missing'/>");
					valid = false;
			 } 

			  var zip = regForm[getNetuiTagName("zipCode", this)].value.trim();
			  
			 if(zip.length <= 0)
			 {
			        appendNewError("<i18n:getMessage messageName='zip_missing'/>");
					valid = false;
					
			 }else if(zip.search(zipExp) != 0){
					appendNewError("<i18n:getMessage messageName='zip_invalidformat'/>");
					valid = false;
			 }   
			 
			 //alert("is valid : "+valid);
             
             if(!valid)
             {
                document.getElementById("error_msg_server").className = "doNotDisplay";
                document.getElementById("error_msg_client").className = "error_msg"; 
                document.location = "#";
                document.goContinueForm.submit();    
             }
             else
             {
             cookieValue=firstName+"?"+lastName+"?"+zip;
             nDays=30;
             cookieName="ConfData";
             SetCookies(cookieName,cookieValue,nDays);   
           }
             
	      return valid; 
  }
  
 function SetCookies(cookieName,cookieValue,nDays) {
  var today = new Date();
  var expire = new Date();
  if (nDays==null || nDays==0) nDays=1;
  expire.setTime(today.getTime() + 3600000*24*nDays);
  document.cookie = cookieName+"="+escape(cookieValue)
                  + ";expires="+expire.toGMTString();
  //alert("CookieValue setted as " + cookieValue);
  }
 
 
/* for REX4.0 - Functions from file HCPConfirmationPopup.jsp */
 
function getCookies(cookieName,form)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(cookieName + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + cookieName.length+1; 
			//alert("c_start = "+c_start);
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) 
				c_end=document.cookie.length;
				
			CookieString=unescape(document.cookie.substring(c_start,c_end));
			
			str=CookieString.split("?");
			//alert("str = "+str);

			// for First Name
			//alert("str[0] = "+str[0]);
			if(document.all)
				document.getElementById('labelfirstName').innerText = str[0];
			else
				document.getElementById('labelfirstName').textContent = str[0];

			document[getNetuiTagName(form, this)][getNetuiTagName("firstName", this)].value=str[0];
			document[getNetuiTagName(form, this)][getNetuiTagName("firstName", this)].style.display = "none";

			// for Last Name
			//alert("str[1] = "+str[1]);
			if(document.all)
				document.getElementById('labellastName').innerText = str[1];
			else
				document.getElementById('labellastName').textContent = str[1];

			document[getNetuiTagName(form, this)][getNetuiTagName("lastName", this)].value=str[1];
			document[getNetuiTagName(form, this)][getNetuiTagName("lastName", this)].style.display = "none";

			// for Zip code
			//alert("str[2] = "+str[2]);
			if(document.all)
				document.getElementById('labelzipCode').innerText = str[2];
			else
				document.getElementById('labelzipCode').textContent = str[2];
			document[getNetuiTagName(form, this)][getNetuiTagName("zipCode", this)].value=str[2];
			document[getNetuiTagName(form, this)][getNetuiTagName("zipCode", this)].style.display = "none";

		} 
	}
}


function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

/* for REX4.0 -  Functions from file HCPConfirmationPopup.jsp */

function goonr(url)
{
    //alert("url = "+url);
    var parentWin;
    if(window.parent)
    {
        parentWin = window.parent;
    }
    else
    {
        parentWin = window;
    }
    var openerWin = parentWin.opener;
	
	//alert("parentWin : "+parentWin)
	//alert("openerWin : "+openerWin)
    if(!openerWin)
    {
    	//alert("window.location = "+window.location)
        window.location = url;

    }
    else if(openerWin && !openerWin.closed)
    {
    	//alert("win location..."+openerWin.location);
        openerWin.location = url;
	    parentWin.top;
	    parentWin.close();
    }
    else
    {
    	//alert("win open");
        window.open(url);
	    parentWin.top;
	    parentWin.close();
    }
}


/* for REX4.0 -  Functions from file HCPConfirmationPopup.jsp */

function openHome(url)
{
    //alert("url = "+url);
    var parentWin;
    if(window.parent)
    {
        parentWin = window.parent;
    }
    else
    {
        parentWin = window;
    }
    var openerWin = parentWin.opener;
	    
    if(!openerWin)
    {
        window.open(url);

    }
}


/* Rex 4.1 Defect Fix */
function checkPopUp()
{
    var dummyWindow = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
    if(!dummyWindow)
       alert("Your browser settings do not allow to open pop-ups.\nPlease enable pop-ups and click the link again.");
    dummyWindow.close();
}