//<script>
var baseHRef = document.getElementsByTagName('BASE')[0].href;

function body_click() {
   var el =  event.srcElement;
   while (el != null) {
        if (el.tagName && el.tagName.toLowerCase() == 'a') {
            var a = el.href;
            var b = document.location.protocol + '//' + document.location.hostname + '/';
            if (a.indexOf(b) != 0 && a.indexOf('javascript:') != 0 && a.indexOf('mailto:') != 0 && a.indexOf('http://cme.thrombosisclinic.com/') != 0 && a.indexOf('http://www.excerptamedica.com') != 0 && a.indexOf('http://www.mosbysdrugconsult.com/') != 0 && a.indexOf('http://home.mdconsult.com/') != 0 && a.indexOf('http://www.epharmasurvey.com/') != 0 && a.indexOf('https://www.elseviercme.com/') != 0) {
				window.showModalDialog(baseHRef + 'en/secnav/leaving.aspx?url=' + escape(a), null, 'dialogHeight:225px; dialogWidth:370px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: No; status: No; scroll: No;');
				return false;
            }
        }
        el = el.parentElement;
    }
}
document.onclick = body_click;

function doSeach(txt) {
	if (txt!='Enter a Keyword') {
		location = baseHRef +'en/secnav/search.aspx?kw=' + txt;
	};
}

function doSearchKey(txt) {
	if (window.event.keyCode == 13) {
		doSeach(txt);
		event.cancelBubble = true;  
		event.returnValue = false;  
		return false; 
	}
}

function AddToFavorite() {
     if (document.all){
          window.external.AddFavorite('http://www.thrombosisclinic.com/','ThrombosisClinic.com');
     } else if (window.sidebar) {
	window.sidebar.addPanel('ThrombosisClinic.com', 'http://www.thrombosisclinic.com/', "")
     }
}

function HomepageOnload() {
	//document.getElementById('txtDateTime').innerHTML = LocalDateTime();
	if (GetCookie("PopupShown") != "true") {
		SetCookie("PopupShown", "true");
		var retval = window.showModalDialog(baseHRef + 'en/secnav/RegisterPopUp.aspx', null, 'dialogHeight:205px; dialogWidth:370px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: No; status: No; scroll: No;');
		if (retval == true) {
			location = baseHRef + 'en/secnav/registraction.aspx';
		}
	}
}

function LocalDateTime() {
	var mydate  = new Date();
	var year    = mydate.getYear();
	var day     = mydate.getDate();
	var month   = mydate.getMonth();	
	var weekday = mydate.getDay();
	var hour    = mydate.getHours();
	var minute  = mydate.getMinutes();
	var apm	    = 'AM';

	if (year<2000) year += (year < 1900) ? 1900 : 0;
	if (hour>11) {
		hour -= 12;
		apm = 'PM';
	} 
	if (minute < 10) minute = "0" + String(minute);

	var montharray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
	var dayarray   = new Array("Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday");


	return dayarray[weekday] + ", " + montharray[month] + " " + day + ", " + year + ", " + hour + ":" + minute + " " + apm;
}

function GetTitle() {
	var tags = document.getElementsByTagName('META');
	for(var i=0; i< tags.length; i++) {
		if(tags[i].name == 'title') return tags[i].content;
	}
	return "";
}

function SetCookie(sName, sValue) {
	var expires = new Date();
	expires.setTime(expires.getTime() + 1000 * 60 * 60 * 24 * 365);
	document.cookie = sName + "=" + escape(sValue) + "; expires=" + expires.toGMTString();
}

function GetCookie(sName) {
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++) {
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) return unescape(aCrumb[1]);
	}
	// a cookie with the requested name does not exist
	return null;
}

function checkAvailSize()
{
	//var availH = window.screen.availHeight - (window.screen.availHeight-document.body.clientHeight);
	//alert("test");
	if(window.screen.availHeight < 595)
	{
		window.resizeTo(745+10,window.screen.availHeight);
	}
}

function openW(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint = 0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
//</script> 
