var isNS4;
var isIE4;
var isIE5;
var isNS6;
var pageHeight=530;
var pageWidth=760;
var offSetLeft=0;
var offSetTop=0;
var topBoundary=0;
var leftBoundary=0;
var rightBoundary=0;
var bottomBoundary=0;
var divList = new Array(0);

var siteList = new Array(3);
siteList[1] = "medical";
siteList[2] = "motorsport";
siteList[3] = "legal";
var pageList = new Array(7);
pageList[0] = "Index.php";
pageList[1] = "aboutUs.php";
pageList[2] = "contactUs.php";
pageList[3] = "feedback.php";
pageList[4] = "authors.php";
pageList[5] = "contractPublishing.php";
pageList[6] = "distributors.php";
pageList[7] = "bookstore.php";

function setPages(pageNumbering){
	if (pageCount > 1){
		if ((x=MM_findObj('pageOf'))!=null){
			x.style.visibility='visible';
		}
		if ((x=MM_findObj('backButton'))!=null){
			x.style.visibility='visible';
		}
		if ((x=MM_findObj('atPageNumber'))!=null){
			x.style.visibility='visible';
		}
		if ((x=MM_findObj('nextButton'))!=null){
			x.style.visibility='visible';
		}
	}
	if (pageNumbering == 1){
		skipToPage(currentPage);
	}
}
function backPage(){
	if ((x=MM_findObj('content'))!=null){
		currentPage=currentPage-1;
		if (currentPage < 1){
			currentPage = 1;
		}
		x.innerHTML=cPages[currentPage-1];
		setPageNumber(currentPage);
	}
}
function forwardPage(){
	if ((x=MM_findObj('content'))!=null){
		currentPage=currentPage+1;
		if (currentPage > pageCount){
			currentPage = pageCount;
		}
		x.innerHTML=cPages[currentPage-1];
		setPageNumber(currentPage);
	}
}
function skipToPage(pageNo){
	if ((x=MM_findObj('content'))!=null){
		currentPage=pageNo;
		if (currentPage > pageCount){
			currentPage = pageCount;
		}
		if (currentPage < 0){
			currentPage = 1;
		}
		x.innerHTML=cPages[currentPage-1];
		setPageNumber(currentPage);
	}
}
function setPageNumber(pageNo){
	if ((x=MM_findObj('atPageNumber'))!=null){
		newText = pageNo+" of "+pageCount;
		textMicroSite="tfmPageNo"+microSite.toString();
		x.innerHTML='<span class='+textMicroSite+'>'+newText+'</span>';
	}
}
function gotoPage(pageNumber, subPageNumber){
	targetPage="";
	if (pageNumber == 0){
		targetPage=siteList[microSite]+"/";
	}
	if (pageNumber == pageKey){
		skipToPage(subPageNumber);
	} else {
		targetPage=targetPage+pageList[pageNumber]+"?MSI="+microSite+"&gotoPage="+subPageNumber;
		currentPage=document.URL;
		if (currentPage.indexOf("?")>=0){
			keyString=currentPage.substring(currentPage.indexOf("?")+1,currentPage.length);
			currentPage=currentPage.substring(0,currentPage.indexOf("?"));
			if (keyString.indexOf("TFMVisitorID")>=0){
				startPos=keyString.indexOf("TFMVisitorID");
				if (keyString.indexOf("&",startPos)>=0){
					endPos=keyString.indexOf("&",startPos);
				} else {
					endPos=keyString.length;
				}
				keyString=keyString.substring(startPos,endPos);
				if (keyString.substring(keyString.length) == "#"){
					keyString=keyString.substring(0,keyString.length-1);
				}
			} else {
				keyString="";
			}
		} else {
			keyString="";
		}
		if (currentPage.lastIndexOf("/") < 10){
			siteAddress=currentPage
		} else {
			siteAddress=currentPage.substring(0,currentPage.lastIndexOf("/"));
		}
		siteAddress=siteAddress+"/";
		newPage=siteAddress+targetPage+"&"+keyString;
		window.location=newPage;
	}
}
function newMM_findObj(n) {
	var x,d;
	d=document;
	if (isNS4){
   x = d.layers[n];
	} else if (isIE4) {
   x = d.all[n];
	} else if (isIE5 || isNS6) {
   x = d.getElementById(n);
	}
	return x;
}
function MM_findObj(n, d) {
	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 && d.getElementById) {
		x=d.getElementById(n);
	}
	return x;
}
function MM_swapImage() {
	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=imageSet+a[i+2];
		}
	}
}
function MM_swapImgRestore() {
	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() {
	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=imageSet+a[i];
			}
		}
	}
}
function whichBrowser() {
	var d;
	d=document;
	isNS4 = (d.layers) ? true : false;
	isIE4 = (d.all && !d.getElementById) ? true : false;
	isIE5 = (d.all && d.getElementById) ? true : false;
	isNS6 = (!d.all && d.getElementById) ? true : false;
}
function submitIT(opt,optForm,submitCode){
	if ((x=MM_findObj('submitType'+submitCode))!=null){
		x.value=opt;
	}
	if ((x=MM_findObj(optForm))!=null){
		x.submit();
	}
}
function resetIT(optForm){
	if ((x=MM_findObj(optForm))!=null){
		x.reset();
	}
}
function setFieldFocus(fieldName){
	if ((x=MM_findObj(fieldName))!=null){
		x.focus();
		x.select();
	}
}
function loadTagArray(){
		divList = document.getElementsByTagName('div');
}
function setPosition(){
	if (isNS6){
		scnHeight = window.innerHeight -20;
    scnWidth = window.innerWidth - 20;
	} else {
		scnWidth=document.body.offsetWidth;
		scnHeight=document.body.offsetHeight;
	}
	offSetLeft=Math.ceil((scnWidth-pageWidth)/2);
	if (offSetLeft<0){
		offSetLeft=0;
	}
	offSetTop=Math.ceil((scnHeight-pageHeight)/2);
	if (offSetTop<0){
		offSetTop=0;
	}
}
function rePosition(){
	if (isNS6){
		scnHeight = window.innerHeight -20;
    scnWidth = window.innerWidth - 20;
	} else {
		scnWidth=document.body.offsetWidth;
		scnHeight=document.body.offsetHeight
	}
	newOffSetLeft=Math.ceil((scnWidth-pageWidth)/2);
	if (newOffSetLeft<0){
		newOffSetLeft=0;
	}
	newOffSetTop=Math.ceil((scnHeight-pageHeight)/2);
	if (newOffSetTop<0){
		newOffSetTop=0;
	}
	diffSetLeft=newOffSetLeft-offSetLeft;
	diffSetTop=newOffSetTop-offSetTop;
	for (i=0;i<divList.length;i++){
		itmName=divList[i].id;
		if (itmName != ""){
			itm = document.getElementById(itmName);
			newLeft=itm.style.pixelLeft + diffSetLeft;
			newTop=itm.style.pixelTop + diffSetTop;
			itm.style.pixelLeft = newLeft;
			itm.style.pixelTop = newTop;
		}
	}
	offSetLeft=newOffSetLeft;
	offSetTop=newOffSetTop;
}
whichBrowser();
if (isNS6){
	window.onresize=rePosition();
}

if(window.attachEvent && isIE5){
	window.attachEvent("onload",restoreStyles);
}
function restoreStyles(){
	inputList = document.getElementsByTagName("INPUT");
	for(i=0;i<inputList.length;i++){
		inputList[i].style.backgroundColor = "#FFFFFF";
	}
	selectList = document.getElementsByTagName("SELECT");
	for(i=0;i<selectList.length;i++){
		selectList[i].style.backgroundColor = "#FFFFFF";
	}
}