var _azSurveyWindow
var _azExitWindow
var _popUpReturnValue = false;

// 1. Find a UL with an ID matching the one passed in (ul)
// 2. Iterate through the LIs 
// 3. For each LI, if it contains an A tag, inspect the innerHTML and if its 
//     href = the current location, remove the A HREF and replace with just the 
//     text from the hyperlink
function deactivateCurrentURL(ul) {
	if (!ul.childNodes || ul.childNodes.length==0) { return false; }
	// Iterate LIs
	for (var i=0;i<ul.childNodes.length;i++) {
		var li = ul.childNodes[i];
		// Ignore everything but LI
		if (li.nodeName == "LI") {
			// Iterate things in this LI
			for (var j=0;j<li.childNodes.length;j++) {
				var ahref = li.childNodes[j];
				// Ignore everything but hyperlinks
				if (ahref.nodeName == "A") {
					// If this link points to the current page, 
					// change the innerHTML to suit us
					if (parent.location.href == ahref.href) {
						li.innerHTML='<span class="sidebarCurrentURL">' + ahref.innerHTML + '</span>';
					}
				}
			}
		}
	}
}

function resize() {
	//minumum height
	minHeight = 425;
	
	
	//get height of space between title and footer
	size = parseInt(document.getElementById("contentContainer").offsetHeight) - parseInt(document.getElementById("contentContainer").offsetTop);
	
			
	//make sure page is at least a certain height
	if (size < minHeight) {
		size = minHeight - parseInt(document.getElementById("contentContainer").offsetTop) - parseInt(document.getElementById("footerContainer").offsetHeight);
		
	}

	//check to see if right column is longer than content
	if (size < parseInt(document.getElementById("rightColumnContainer").offsetHeight)) {
		size = parseInt(document.getElementById("rightColumnContainer").offsetHeight); 
	}
	
	//check to see if left column is longer than content
	if (size < parseInt(document.getElementById("leftColumnContainer").offsetHeight)) {
		size = parseInt(document.getElementById("leftColumnContainer").offsetHeight); 
	}	
	
	//if height of contents is less than space available, than expand contents
	//and then set footer at bottom of content
	
	
	if (document.getElementById("contentContainer").offsetHeight < size ) {
		document.getElementById("contentContainer").style.height = size + 'px';	
		document.getElementById("footerContainer").style.top = 1 + size + parseInt(document.getElementById("contentContainer").offsetTop) + 'px';
		if(document.getElementById("bottomLinksContainer"))document.getElementById("bottomLinksContainer").style.top =  parseInt(document.getElementById("footerContainer").offsetTop) + parseInt(20) + 'px';
		if(document.getElementById("bottomBanner"))document.getElementById("bottomBanner").style.top =  parseInt(document.getElementById("footerContainer").offsetTop) + parseInt(iHeight) + parseInt(20) + 'px';
		
	}
	else {
		document.getElementById("footerContainer").style.top = 1 + parseInt(document.getElementById("contentContainer").offsetHeight) + parseInt(document.getElementById("contentContainer").offsetTop) + 'px';
		if(document.getElementById("bottomLinksContainer"))document.getElementById("bottomLinksContainer").style.top =   parseInt(document.getElementById("footerContainer").offsetTop) + parseInt(20)  + 'px';
		if(document.getElementById("bottomBanner"))document.getElementById("bottomBanner").style.top =   parseInt(document.getElementById("footerContainer").offsetTop) + parseInt(iHeight) + parseInt(20) + 'px';
		
		
		
	}
		
	//Set left colummn height
	document.getElementById("leftColumnContainer").style.height = parseInt(document.getElementById("contentContainer").offsetHeight) + parseInt(document.getElementById("contentContainer").offsetTop)+ parseInt(document.getElementById("footerContainer").offsetHeight)  + 'px';
	
	//Set right colummn height
	document.getElementById("rightColumnContainer").style.height = parseInt(document.getElementById("contentContainer").offsetHeight) + parseInt(document.getElementById("contentContainer").offsetTop) + parseInt(document.getElementById("footerContainer").offsetHeight) + 'px';
}
	
	
	
	
	
	
function resizeHomePage() {
	//banner height
	bannerHeight = 30;
	
	//minumum height
	minHeight = 425;
	
	//get height of space between title and footer
	size = parseInt(document.getElementById("contentContainer").offsetHeight) - parseInt(document.getElementById("contentContainer").offsetTop);
	
			
	//make sure page is at least a certain height
	if (size < minHeight) {
		size = minHeight - parseInt(document.getElementById("contentContainer").offsetTop) - parseInt(document.getElementById("footerContainer").offsetHeight);
	}

	//check to see if right column is longer than content
	if (size < parseInt(document.getElementById("rightColumnContainer").offsetHeight)) {
		size = parseInt(document.getElementById("rightColumnContainer").offsetHeight); 
	}
	
	//check to see if left column is longer than content
	if (size < parseInt(document.getElementById("leftColumnContainer").offsetHeight)) {
		size = parseInt(document.getElementById("leftColumnContainer").offsetHeight); 
	}	

	//if height of contents is less than space available, than expand contents
	//and then set footer at bottom of content
	if (document.getElementById("contentContainer").offsetHeight < size ) {
		document.getElementById("contentContainer").style.height = size + 'px';	
		document.getElementById("footerContainer").style.top = bannerHeight + size + parseInt(document.getElementById("contentContainer").offsetTop) + 'px';
		document.getElementById("bottomLinksContainer").style.top = bannerHeight + size  + parseInt(document.getElementById("footerContainer").offsetTop) + 'px';
		
	}
	else {
		document.getElementById("footerContainer").style.top = bannerHeight + parseInt(document.getElementById("contentContainer").offsetHeight) + parseInt(document.getElementById("contentContainer").offsetTop) + 'px';
		document.getElementById("bottomLinksContainer").style.top = bannerHeight +  parseInt(document.getElementById("footerContainer").offsetTop)  + 'px';
		
	}
		
	//Set left colummn height
	document.getElementById("leftColumnContainer").style.height = parseInt(document.getElementById("contentContainer").offsetHeight) + parseInt(document.getElementById("contentContainer").offsetTop) + parseInt(document.getElementById("footerContainer").offsetHeight) + 'px';

	//Set right colummn height
	document.getElementById("rightColumnContainer").style.height = parseInt(document.getElementById("contentContainer").offsetHeight) + parseInt(document.getElementById("contentContainer").offsetTop) + parseInt(document.getElementById("footerContainer").offsetHeight) + 'px';
	

	document.getElementById("leftColumnContainer").style.top = bannerHeight + 'px';
	document.getElementById("rightColumnContainer").style.top = bannerHeight + 'px';
	document.getElementById("breadcrumbContainer").style.top = bannerHeight + 'px';
	
	document.getElementById("contentContainer").style.top = parseInt(document.getElementById("breadcrumbContainer").offsetHeight) + bannerHeight + 'px';	

}
	
	
	
	
	
	
	
	
	
function go(TD, flag)
{
	if (flag > 0) {	
		if (leave(flag) == true) {
			window.location=TD.getElementsByTagName("A")[0].href;
		}
	}
	else {
		window.location=TD.getElementsByTagName("A")[0].href;
	}
}

function leave(destination) {
	switch(destination)
	{
		case 1 :
			// external	
			//return confirm("You have selected a link that will take you to a site maintained by a third party who is solely responsible for its contents. AstraZeneca provides this link as a service to Web site visitors. AstraZeneca is not responsible for the Privacy Policy of any third party Web sites. We encourage you to read the privacy policy of every Web site you visit. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			return openExitPopUp(destination);
			break;
		case 2 :
			// global
			//return confirm("You have selected a link that will take you to the AstraZeneca International Web site which is managed by AstraZeneca in the United Kingdom. It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			return openExitPopUp(destination);
			break;
		case 3 :
			// canada
			return confirm("You have selected a link that will take you to the AstraZeneca Canada Web site, maintained by AstraZeneca in Canada. It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			break;
		case 4 :
			// boston
			return confirm("You have selected a link that will take you to the AstraZeneca R&D Boston Web site, maintained by AstraZeneca Research in Boston, MA. It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			break;
		case 5 :
			// other country
			return confirm("You have selected a link that will take you to a non-US AstraZeneca Web site. It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			break;
		case 6 :
			// Hemscott
			return confirm("This link will take you to a site maintained by Hemscott Group Limited who is solely responsible for its contents. AstraZeneca provides this link as a service to Web site visitors. AstraZeneca is not responsible for the Privacy Policy of any third party Web sites. We encourage you to read the privacy policy of every Web site you visit. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			break;
		case 7 :
			//Canada	
			return confirm("You have selected a link that will take you to the AstraZeneca Canada Web site, maintained by AstraZeneca in Canada. It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			break;	
			
		case 8 : //iThirdPartySpan
			return confirm("Este enlace lo llevará a un sitio que es mantenido por terceros, que son los únicos responsables de su contenido.\n\nAstraZeneca proporciona este enlace como un servicio a los visitantes a su sitio web. AstraZeneca no es responsable de la Política de Privacidad de sitios web de terceros. Por favor, lea la política de privacidad de cada sitio web que visite.\n\nHaga clic en Cancelar para regresar o en OK para continuar.");
			break;		
		case 9 :
			// India
			return confirm("You have selected a link that will take you to the AstraZeneca India Web site, maintained by AstraZeneca in India. It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click 'Cancel' to return to AstraZeneca's US site or 'OK' to continue.");
			break;
		case 10 :
			// Abraxane	
			return openExitPopUp(destination);
			break;
					
	}
}

//for backward compatibility with older press releases
function leaveAZUS(destination) {
	return leave(destination);
}

function openWindow(url) {
	openWindowParam(url, 600, 400);
}

function openWindowParam(url, width, height) {
	window.open(url,'_blank','width=' + width + ',height=' + height + ',left=10,top=10,resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,location=yes,directories=no');
}


function openWebRecruiterWindow() {
	window.open('/content/careers/careerOpportunites.asp','careerOpportunites','width=770,height=420,status=yes,toolbar=yes,location=yes,menubar=yes,screenX=100,screenY=100,top=100,left=100,scrollbars=no,resizable=yes')
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


function IsInputDangerous(controlentry)
{
	var entry = controlentry.value;
	// define pattern
	var pattern = "(<\s*(script|object|applet|embed|form)\s*>)";
	pattern = pattern + "|" + "(<.*>)";
	pattern = pattern + "|" + "(&.{1,5};)" ;
	//pattern = pattern + "|" + "eval\s*\"; 
 	pattern = pattern + "|" + "(event\s*=)";
	
	//pattern = pattern.replace("<", "(<|%60|<)");
	//pattern = pattern.replace(">", "(>|%62|>)");	
		
	var checkobject = new RegExp(pattern);
	
	checkobject.ignoreCase=true;
	checkobject.global=false;
	
	if(checkobject.test(entry)) 
	{
		alert('Please enter a valid search criteria.');
		controlentry.focus();
		return false;
	} 
	else
	{	return true;	}
}

function openSurveyWindow() {
	if(document.referrer);
	_azSurveyWindow=dhtmlwindow.open("googlebox", "iframe", "/content/survey/survey2007.asp", "AZ Survey", "width=450px,height=400px,resize=0,scrolling=1,center=0,left=30px,top=10px", "recal");
}

function openPrivacyStatement() {
	var PrivacyWindow=dhtmlwindow.open("PrivacyStatement", "iframe", "http://www.azprivacystatement.com", "AZ Privacy Statement", "width=700px,height=450px,resize=0,scrolling=1,center=0", "recal")
}

function closeSurveyWindow() {
	_azSurveyWindow.onclose=function(){return true;}
	dhtmlwindow.close(_azSurveyWindow);
}

//Pop-Up Enhancement [MQC-3315] - Neeraj

function openExitPopUp(destination) {
	if(document.referrer);
	specs = 'dialogHeight: 370px; dialogWidth: 350px; Scroll=No; Titlebar=No; edge: Raised; center: Yes; unadorned: Yes; help: No; resizable: No; status: No;';
	window.showModalDialog('/includes/ExitPopUp.asp?dest='+destination,window, specs);
	_azExitWindow = _popUpReturnValue;
	_popUpReturnValue=false;
	return _azExitWindow;
}

function popUpReturnValue(value)
{
_popUpReturnValue = value;
}

//Change MQC-3315 Complete.

function open_video()
{
	window.open('http://amhqewsnt4:8444/videos/azus.asp','mywindow','width=600,height=450,toolbar=no,location=no,directories=yes,status=no, menubar=no,scrollbars=no,copyhistory=no,resizable=yes,directories=no');
}
