// JavaScript Document

// Function to check whether the username entered is valid or not.
function isValidUsername(sText, errtxt)
{
   var IsValid=true;
   var Char;
   var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";

   for (i = 0; i < sText.length && IsValid == true; i++) 
	  { 
	  Char = sText.charAt(i); 
	  if (ValidChars.indexOf(Char) == -1) 
		 {
			 alert(errtxt);
			 IsValid = false;
		 }
	  }
   return IsValid;
}

// Function to check whether the text box is blank
function isBlank(val, errtxt)
{
	if(val==null)
	{
		return true;
	}
	for(var i=0;i<val.length;i++)
	{
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r"))
		{
			return false;
		}
	}
	if ( errtxt )
		alert(errtxt);
	return true;
}

// Function to open a popup
function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

function MM_swapImgRestore()
{ //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages()
{ //v3.0
	var d=document;
	if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d)
{ //v4.0
	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<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage()
{ //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var MM_contentVersion = 5;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin )
{
	var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i = 0; i < words.length; ++i)
	{
	if (isNaN(parseInt(words[i])))
	continue;
	var MM_PluginVersion = words[i];
	}
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1))
{
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

function MM_reloadPage(init)
{  //reloads the window if Nav4 resized
	if (init==true) with (navigator)
	{
		if ((appName=="Netscape")&&(parseInt(appVersion)==4))
		{
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//Function to open the bi sites dropdown items in a new window
function jumpmenu()
{
	
	var strURL = document.frmbisites.bisites.value;
	if (strURL != "")
	{
		redir(strURL);
	
	}
}
function jumpmenu2()
{
	
	var strURL = document.frmbisites.bisites.value;
	if (strURL != "")
	{
		window.open(strURL);
		//window.open(document.frmbisites.bisites.value);
	}
}
function redir_old(url)
{
	
//alert("You are now leaving the Boehringer Ingelheim UK site.  Medical information including licensed uses and availability may be different outside of the UK.");
var ans = confirm("You are now leaving the Boehringer Ingelheim UK site.  Medical information including licensed uses and availability may be different outside of the UK.");

if(ans == true)
window.open(url);
else
return;

}

/*function popDisclaim(url, win_width, win_height)
{
	var ans = confirm("You are now leaving the Boehringer Ingelheim UK site.  Medical information including licensed uses and availability may be different outside of the UK.");

if(ans == true)
{
win_popup = window.open(url, "win_popup","width="+win_width+",height="+win_height+",menubar=no,toolbar=no,resizable=yes");
win_popup.focus();
}
else{
return;}
}*/
function popDisclaim(url, win_width, win_height)
{
msg = "You are now leaving the Boehringer Ingelheim UK site.  Medical information including licensed uses and availability may be different outside of the UK.<br /><br />Do you want to continue?";

myDialog.setDialog('confirm','BIUK',msg);
		myDialog.action = function() { 
			//alert("You clicked " + myDialog.getButtonClicked() + "!"); 
			conf_flag = myDialog.getButtonClicked();
			if(conf_flag == 'yes')
			{
				win_popup = window.open(url, "win_popup","width="+win_width+",height="+win_height+",menubar=no,toolbar=no,resizable=yes");
				win_popup.focus();
			}
			else{
				return;}
			}
	myDialog.start();

}

/*
function disclaim(url)
{
//alert("You are now leaving the Boehringer Ingelheim UK site.No guarantees for the accuracy of the information provided by 3rd parties are made by Boehringer Ingelheim UK site.");

var ans = confirm("You are now leaving the Boehringer Ingelheim UK site.No guarantees for the accuracy of the information provided by 3rd parties are made by Boehringer Ingelheim UK site.");

if(ans == true)
	window.open(url);
else
	return;
}*/

function disclaim(url)
{
	
msg = "You are now leaving the Boehringer Ingelheim UK site.No guarantees for the accuracy of the information provided by 3rd parties are made by Boehringer Ingelheim UK site.<br /><br />Do you want to continue?";

myDialog.setDialog('confirm','BIUK',msg);
		myDialog.action = function() { 
			//alert("You clicked " + myDialog.getButtonClicked() + "!"); 
			conf_flag = myDialog.getButtonClicked();
			if(conf_flag == 'yes')
			{
				window.open(url);
			}
			}
	myDialog.start();

}

function disclaim2(url)
{
alert("You are now leaving the Boehringer Ingelheim UK site.No guarantees for the accuracy of the information provided by 3rd parties are made by Boehringer Ingelheim UK site.");

window.open(url,"_parent");
}



function extdisclaim(url)
{
msg = "You are now leaving the Boehringer Ingelheim Ltd UK site. The linked site is not under the control of Boehringer Ingelheim Ltd and Boehringer Ingelheim Ltd shall not be responsible for the contents of any linked site or any link contained in a linked site,or any changes or updates to such sites. Neither is Boehringer Ingelheim Ltd responsible for webcasting or any other form of transmission received from any linked site. This link is provided to you only as a convenience, and the inclusion of any link does not imply endorsement by Boehringer Ingelheim Ltd of the site.<br /><br />Do you want to continue?";

myDialog.setDialog('confirm','BIUK',msg);
		myDialog.action = function() { 
			//alert("You clicked " + myDialog.getButtonClicked() + "!"); 
			conf_flag = myDialog.getButtonClicked();
			if(conf_flag == 'yes')
			{
				window.open(url);
			}
			}
	myDialog.start();

}


/*function intdisclaim(url)
{
	
	alert(url);
	
}*/

function addToFavorites_old() 
{ 
	titleElement = document.getElementsByTagName('title')[0];
	var urlAddres = window.location.href;
	titlevalue=titleElement.innerHTML;
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(titlevalue, urlAddres,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( urlAddres, titlevalue); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
 }

} 

function addToFavorites() 
{ 
	titleElement = document.getElementsByTagName('title')[0];
	var urlAddres = window.location.href;
	titlevalue=titleElement.innerHTML;
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(titlevalue, urlAddres,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( urlAddres, titlevalue); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }

} 

function popwin(url)
{
	window.open (url, 'DementiaLinkPopup', config='height=400,width=680, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
}

function popBookmarkWin(sitename)
{
	var url;
	var strURL = encodeURIComponent(document.location.href);	// could be set dynamically to your blog post's permalink
	var strTitle = escape(document.title);		 //same here, this could be set dymaically instead of the page's current title
	
	switch(sitename)
	{
		case 'delicious':
			url = "http://del.icio.us/post?v=4&noui&jump=list&url="+strURL+"&amp;title="+strTitle
			
			break;
		case 'digg':
			url = "http://digg.com/remote-submit?phase=2&url="+strURL+"&title="+strTitle
			break;
		case 'reddit':
			url = "http://reddit.com/submit?url="+strURL+"&amp;title="+strTitle
			break;
		case 'facebook':
			url = "http://www.facebook.com/sharer.php?u="+strURL+"&amp;t="+strTitle
			break;
		case 'stumble':
			url = "http://www.stumbleupon.com/submit?url="+strURL+"&amp;title="+strTitle
			break;
		default:
	}
	
	window.open (url, 'DementiaLinkPopup', config='height=400,width=680, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');

}

function redir(url)
{
	var strUrl;
	
	strHref = document.getElementById('idCommon').href
	//alert(strHref.indexOf('?'));
	if(strHref.indexOf('?') > -1)
		strHref = strHref.substring(0, strHref.indexOf('?'));
	
	//str = "../lightwindow/redir.html"
	
	document.getElementById('idCommon').href = strHref + "?url="+url;
	
	//setTimeout('fireEvent(document.getElementById(\'id1\'),\'click\',\'id1\')',1250);
	fireEvent(document.getElementById('idCommon'),'click','idCommon');
	
}
						

function fireEvent(obj,evt,lnkId){
	
	var fireOnThis = obj;
	//alert(obj);
	if( document.createEvent ) {
	  var evObj = document.createEvent('MouseEvents');
	  evObj.initEvent(evt, true, true);
	  fireOnThis.dispatchEvent(evObj);
	} else if( document.createEventObject ) {
	  //fireOnThis.fireEvent('on'+evt);
	  document.getElementById(lnkId).click();

	}
}
function rightTrim(sString)
{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
