
var isHome = false;
isHome = (location.href.indexOf("index.htm")>=0)||(location.href.indexOf(".htm")<0)
//window.onload=animate

function initPage() 
{
	checkMenuHighLight()
	checkMails()
	var ww = window.screen.availWidth;
	if(ww<1024)
	{
		document.getElementsByTagName("body")[0].style.marginLeft = "0px";
	}
	else
	{
	var w = Math.abs(parseInt((ww-755)/2)) + "px";
	document.getElementsByTagName("body")[0].style.marginLeft = w;
	}
	if(document.getElementById("img_presentation")){doPresentation();};
	animate();
}


function checkMenuHighLight()
{
	var arMenEn = ["company","products","where","test","faq","references","press"];
	var arDirEn = ["/medic_clean_air/","/hepa_filters/","/where/","/hospital_infections/","/faq/","/references/","/press/"];
	var arMen = arMenEn;
	var arDir = arDirEn;

	var menuToHighLight = "xyzzyx";
	var loc = location.href;
	for(i=0;i<arDir.length;i++)
	{
		if(loc.indexOf(arDir[i])>=0)
		{
			menuToHighLight = arMen[i];
		}
	}

	if(isHome){menuToHighLight =  arMen[0]}
	var ar = document.getElementsByTagName("a");
	for (i=0;i<ar.length;i++)
	{
		var inner = ar[i].innerHTML.toLowerCase();
		if
		(
			( inner.indexOf("<div") >= 0 )&&
			(ar[i].className.indexOf("m0l0")>=0)&&
			(ar[i].getElementsByTagName("div")[0].innerHTML.toLowerCase().indexOf(menuToHighLight )>=0)
		)
		{
			ar[i].className = "m0l0oover"
		}
	}
}

function checkMails()
{
	var linkAr = document.getElementsByTagName("a");
	var lnk = "";
	var link = "";
	for(i=0;i<linkAr.length;i++)
	{
		if(linkAr[i].id.indexOf("antispam")>=0)
		{
			lnk = linkAr[i].id.split("antispam")[1].split("_");
			link = lnk[0] + "@";
			for(j=1;j<lnk.length;j++)
			{
				link += lnk[j] + "." ;
			}
			link = link.slice(0,link.length-1)
			//link = "mailto:" + link;
			linkAr[i].href = "mailto:" + link + "?subject=mail from medicCleanAir website&body=Contact request:";
			linkAr[i].innerHTML = link;
		}
	} 	
}

function openLink(url)
{
	var w = window.screen.availWidth;
	var h = window.screen.availHeight;
	var formatw = "width=" + parseInt(w*2/3) + ",height=" + parseInt(h*2/3) + ",left=" + parseInt(w*1/4) + ",top=" + parseInt(h*1/4);
	//formatw += ",menu=yes,scrollbars=yes";
	formatw += ",toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,maximized=1,taskbar=yes";
	var openW = window.open(url,'link',formatw)
	openW.focus()
}

/*   BEGIN CODE FOR PRESENTATION  */

var imgHolder;
var idp=1;
var initInterval = 4000
var interVal = initInterval;
var setInterv = null;

function doPresentation() {
	imgHolder = document.getElementById("img_presentation");
	setInterv = window.setInterval("changePic()",interVal)
}

function changePic()
{
	idp++
	if(idp==9){idp=1};
	newImgSrc = "../img/deco/references_presentation" + idp + ".jpg";
	crossfade(document.getElementById('img_presentation'),newImgSrc ,'1','alt')
}
	
function slower()
{
	stopShow()
	interVal +=1000;
	setInterv = window.setInterval("changePic()",interVal)
}

function faster()
{
	stopShow()
	interVal -=1000;
	if(interVal==0){interVal = 1000;}
	doPresentation()
}

function stopShow()
{
	window.clearInterval(setInterv);
}

function restartShow()
{
	interVal = initInterval;
	doPresentation()
}
/*   END CODE FOR PRESENTATION  */


/* BEGIN CODE ANTI COPY  */

var boodschap="Copyright, 2000-2007 MedicCleanAir";
function click(e) 
{
	if(document.all) 
	{
		if(event.button ==2) 
		{
			alert(boodschap);
			return false;
		}
	}
	if(document.layers) 
	{
		if(e.which ===3) 
		{
			alert(boodschap);
			return false;
		}
	}
}

if(document.layers) 
{
	document.captureEvents(Event.MOUSEDOWN);
}
else
{
	document.onmousedown=click;
}

/* END CODE ANTI COPY  */


function openAirscheme()
{
	var ImgFile= "../img/nav/air_scheme.gif";
	if(isHome){ImgFile="mediccleanair_en/img/nav/air_scheme.gif"}
	var w = 730;
	var h = 535;
	var formatw = "width=" + w+ ",height=" + h+ ",left=" + parseInt(window.screen.availWidth-w-50) + ",top=" + parseInt(window.screen.availHeight-h-50);
	formatw += ",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,maximized=1,taskbar=no";
	var openW = window.open(ImgFile,'link',formatw)
	openW.focus()
}

function openMetric()
{
	var ImgFile= "../img/nav/metric.gif";
	if(isHome){ImgFile="mediccleanair_en/img/nav/metric.gif"}
	var w = 730;
	var h = 535;
	var formatw = "width=" + w+ ",height=" + h+ ",left=" + parseInt(window.screen.availWidth-w-50) + ",top=" + parseInt(window.screen.availHeight-h-50);
	formatw += ",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,maximized=1,taskbar=no";
	var openW = window.open(ImgFile,'link',formatw)
	openW.focus()
}


/* BEGIN CODE FOR TICKER   */
temp="";
nextchar=-1;
nextline=1;
lines=line.length-1 //--Number of lines


function animate(){

//read cookie
var allcookies = document.cookie
var pos = allcookies.indexOf("nextLine=");
if(pos!=-1)
{
	var start=pos+9
	var end = allcookies.length;
	var value = parseInt(allcookies.substring(start,end))
	nextline= value
	//if(nextline==lines){nextline=1;writeCookie();}
}




if (temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines)
{
	nextline++;
	writeCookie();
	nextchar=-1;
	document.getElementById("ticker").value=temp;
	temp="";
	setTimeout("nextstep()",3000)
}
else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length)
{
	nextline=1;
	writeCookie();
	nextchar=-1;
	document.getElementById("ticker").value=temp;
	temp="";
	setTimeout("nextstep()",3000)
}
else
{
nextstep()
}
}

function nextstep()
{
	nextchar++;
	temp+=line[nextline].charAt(nextchar);
	document.getElementById("ticker").value=temp
	setTimeout("animate()",15)
}


function writeCookie() {
	var cook = "nextLine="+nextline
	var nextYear = new Date()
	nextYear.setFullYear(nextYear.getFullYear()+1);
	document.cookie = cook + ";expires=" + nextYear.toGMTString() + ";path=/"
}

/* END CODE FOR TICKER   */


/* BEGIN BOOKMARKING  */

var bookmarkurl="http://www.mediccleanair.com/"
var bookmarktitel="MedicCleanAir"
function bookMark(){
	if (document.all)
	{
		window.external.AddFavorite(bookmarkurl,bookmarktitel)
	}
	if (window.sidebar)
	{
	window.sidebar.addPanel(bookmarktitel, bookmarkurl, "")
	}
}
/* END BOOKMARKING  */

	