// HCP_functions.js
// Created by Amy Bradstreet with assistance from Jeremy Ramsay
// 23/11/2002

function checkData()
//Checks data entered on the search and search_results pages
	{
	//Confirm a product is selected
	if (userinfo.sProduct.value.length < 1)
		{
		alert("Please select a Product.")
		userinfo.sProduct.focus()
		return (false)
		}

	//Confirm a question is entered
	if (userinfo.sQuestion.value.length < 1)
		{
		alert("Please Enter a Question.")
		userinfo.sQuestion.focus()
		return (false)
		}
		
	//Confirm the question entered is not longer than 2000 characters.
	if (userinfo.sQuestion.value.length > 2000) {
		alert('Please modify your question.  The current question is ' + userinfo.sQuestion.value.length + ' characters.  The maximum question length is 2000 characters.  ');
		userinfo.sQuestion.focus();
		return false;
	}
	
	//Confirm the question does not contain the characters <!--
	//if (userinfo.sQuestion.value.indexOf("<!--") != -1) {
	//	alert('Please modify your question.  The question may not contain the character string <!--.')
	//	userinfo.sQuestion.focus()
	//	return false;	
	//}
	
	
	//Confirm the question contains 2 or more words <!--
		var re = /\s+/g;
		var words = userinfo.sQuestion.value.split(re);
		//alert('Initial words.length: ' + words.length);
		if (words.length < 2) {
		alert('Please modify your question to be in the form of a question consisting of 2 or more words.')
		userinfo.sQuestion.focus()
		return false;	
	}

	//Replace carriage returns, and <> characters if they exist
		//replace carriage return
		userinfo.sQuestion.value = userinfo.sQuestion.value.replace(/\r|\n|\r\n/g, '');
		// replace < and > characters with &lt; and &gt; respectively
		// This is better handled in the ASP code
		//userinfo.sQuestion.value = userinfo.sQuestion.value.replace(/</gi , "&lt;");
		//userinfo.sQuestion.value = userinfo.sQuestion.value.replace(/>/gi , "&gt;");		
		//alert (userinfo.sQuestion.value);

}


	
function openpopup(){
//Opens the confirmation popup, requiring the user to confirm they are a HCP practicing in the US
	var popurl="confirm.aspx";
		winpops=window.open(popurl,"confirm_hcp","width=400,height=200,alwaysraised");
		if (winpops.focus) winpops.focus();
}


function openpopup_help(){
//Opens the search_help popup
var popurl="search_help.aspx"
winpops=window.open(popurl,"","width=500,height=600,")
}

function HCP_US_leaveMessage() {
//Popup indicating the user is leaving the HCP Web Site
	alert('Thank you for visiting the AstraZeneca Medical Information Web Site. You are now leaving this site to access the AstraZeneca US Web site (www.AstraZeneca-US.com).');
}

function HCP_IC_leaveMessage() {
//Popup indicating the user is leaving the HCP Web Site to access the Information Center Contact Us Website available at AstraZeneca-US
	alert('Thank you for visiting the AstraZeneca Medical Information Web Site. You are now leaving this site and will be redirected to the Contact Us site provided by the Information Center at AstraZeneca.');
}

function HCP_SR_leaveMessage() {
//Popup indicating the user is accessing SR Information and standard disclaimer and PI information for this document
	alert('The information you are about to view is supplied to you as a professional courtesy in response to your unsolicited request.  It is intended to provide general information you requested to assist you in forming your own conclusions and making decisions.  This information is current as of the date it is viewed.  \n\nThe following document may contain information that has not been approved by the FDA for the product that you have selected. Before prescribing any AstraZeneca product, please see the full prescribing information.  AstraZeneca does not recommend the use of AstraZeneca products in any manner other than as described in the full prescribing information. \n\nInformation concerning certain investigational compounds is available on this site and is provided as a professional courtesy. These investigational compounds are not approved by the Food and Drug Administration for use in the United States.  Providing this information does not constitute an assertion of safety or efficacy, or a recommendation for use, for any condition.');
}

function HCP_leaveMessage() {
//Popup indicating the user is leaving the HCP Web Site
//	alert('Thank you for visiting the AstraZeneca Medical Information Web Site. You are now leaving this site to access Prescribing Information available on the AstraZeneca US Web site (www.AstraZeneca-US.com).');
	alert('You are now leaving this site to access the AstraZeneca US web site (www.AstraZeneca-US.com). Prescribing Information can obtained from this site or by calling the Information Center at AstraZeneca at 1-800-236-9933.');
}

function leaveMessage() {
	alert('Thank you for visiting the AstraZeneca Medical Information Web Site. You are now leaving our site to access information intended for an international audience, intended for those interested in AstraZeneca international business.');
}

function HCP_Prod_leaveMessage() {
//Popup indicating the user is leaving the HCP Web Site
	alert('Thank you for visiting the AstraZeneca Medical Information Web Site. You are now leaving this site and will be redirected to General Product Information supplied by AstraZeneca US (www.AstraZeneca-US.com).');
}

//Field checks, no longer used these are now done by the IC-validation.js
function check_PIR_form(frm){
//Popup indicating the user is leaving the HCP Web Site
    if (!frm.email.value){
    alert("Please enter your E-mail address.");
    frm.email.focus();
    return false;
    }
    if (frm.email.value.indexOf('@') == -1){
    alert('Please enter a valid E-mail address.');
    frm.email.focus();
    return false;
    }
    if (frm.email.value.indexOf('.') == -1){
    alert('Please enter a valid  E-mail address.');
    frm.email.focus();
    return false;
    }
    if (!frm.name.value){
        frm.name.focus();
        return false;
    }
    if (args[i].value=="@.")  {
		alert("Please enter a valid E-mail address.");
	args[i].focus();
	return false;
	}
			   
	if (args[i].value==".@")  {
		alert("Please enter a valid E-mail address.");
	args[i].focus();
	return false;
	}
    
    
    frm.submit();

}

//Toggles the search box displayed/not displayed on the search results page
var isIE=document.all?true:false;
var layers = isIE?document.all.tags("DIV"):null;
function changeall(v)
{
 if(!isIE)return; /* only do things for IE */
 for(var i=0;i<layers.length;i++)
   justOne(i,v);
}
function justOne(i,v)
{ 
	if (layers[i].id!="level0Content")
	{
		layers[i].style.display=v?'none':'block'; 
	}
}
	