var browser = browserDetect();

//*-- Browser Detection --*/
function browserDetect()  {
	ns4 = (document.layers)&&(navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4) ? 'ns4' : false;
	ie4 = (document.all)&&(navigator.appName.indexOf("Microsoft") > -1)&&(parseInt(navigator.appVersion)==4)&&(navigator.appVersion.indexOf('MSIE 6') <0) ? 'ie4' : false;
	ie5 = (document.getElementById)&&(navigator.appName.indexOf("Microsoft") > -1)&&(navigator.appVersion.indexOf('MSIE 6') <0) ? 'ie5' : false;
	ie55 = (document.getElementById)&&(navigator.appName.indexOf("Microsoft") > -1)&&(navigator.appVersion.indexOf('MSIE 5.5') >=0) ? 'ie55' : false;
	ie6 = (document.getElementById)&&(navigator.appName.indexOf("Microsoft") > -1)&&(navigator.appVersion.indexOf('MSIE 6') >=0) ? 'ie6' : false;
	ns6 = (document.getElementById)&&(navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)>4) ? 'ns6' : false;
	return (ns4 || ie55 || ie5 || ie4 || ns6 || ie6);
}
var browser = browserDetect();

if (browser == "ns4") {
	onresize = redo;
}

function redo() {
	location.reload();
}

/*-- [End] Browser Detection --*/

/*-- Cross-Browser Object Access Function --*/
function myDOM(id)	{
	//alert(id)
	if (browser == 'ns4')  {return ns4ElementById(id);}
	if (browser == 'ns6')  {return document.getElementById(id);}
	if (browser == 'ie4')  {return eval('document.all.'+ id);}
	if (browser == 'ie5')  {return document.getElementById(id);}
	if (browser == 'ie55')  {return document.getElementById(id);}
	if (browser == 'ie6')  {return document.getElementById(id);}
	return false;
}

/*-- Search Layers Array by ID [Netscape 4 Work-Around] --*/
function ns4ElementById(layerId,me)	{
	var foundIt = false;
	var whereAmI = (me) ? me : document.layers;
	if (whereAmI[layerId])  {
		return whereAmI[layerId];
	}
	for (var i=0; i<whereAmI.length; i++)  {
	  if (whereAmI[i].document.layers){
	  		foundIt = ns4ElementById(layerId,whereAmI[i].document.layers);
	  }
	  if (foundIt)  {
	  return foundIt;
	  }
	}
	return null;
}

/*-- [End] Cross-Browser Object Access Function --*/

//***************************//

//       functions           //

//***************************//
/*-- Image Access Function -- Syntax: getImage(layer's ID).images[image's name attribute] --*/
function getImage(id)  {
	if (browser == 'ns4')  {
		return myDOM(id).document;
	}
	else  {
		return document;
	}
}

/*-- Form Access Function -- Syntax: getForm(layer's ID).forms[form's name attribute] --*/
function getForm(id)  {
	if (browser == 'ns4')  {return myDOM(id).document;}
	else  {return document;}
}

/*-- Style Access Function -- Syntax: getStyle(layer's ID).CSS attribute -- Support for CSS attributes varies depending on the browser --*/
function getStyle(id)  {
	if (browser == 'ns4')  {return myDOM(id);}
	else  {return myDOM(id).style;}		
}

var offSwitch = '';
var onSwitch = '_down';
var overSwitch = '_over';

function swapImage()  {
	if (typeof(arguments[0]) == 'number')  {
		if (document.images['nav'+arguments[0]].src.indexOf(onSwitch) == -1) {
			document.images['nav'+arguments[0]].src = eval('navImages[arguments[0]].'+arguments[2]+'.src');
		}
	} else {
		if (browser != 'ie5')  {
			cImgTag = arguments[0].innerHTML;
			if (browser == 'ie6' || browser == 'ie55')  {
				namePattern = /name=([a-zA-Z0-9_\-]+)/;
				npRE = new RegExp(namePattern);
				cImgName = npRE.exec(cImgTag);
				cImg = document.images[RegExp.$1].src;
				imgTypePattern = /http:\/\/[^\/]+[^\.]+(\..+)/;
				itRE = new RegExp(imgTypePattern);
				itRE.exec(cImg);
				imgType = RegExp.$1;
			} else  {
				cImgName = cImgTag.match(/name="([^"]+)"/);
				cImg = document.images[cImgName[1]].src;
				imgTypeMatch = cImg.match(/http:\/\/[^\/]+[^\.]+(\..+)/);
				imgType = imgTypeMatch[1];
			}
			newImg = cImg.replace(arguments[1]+imgType, arguments[2]+imgType);
			document.images[cImgName[1]].src = newImg;
		}
	}
}

function rollOn()  {
	thisSwitch = (typeof(arguments[0]) == 'number') ? 'over' : overSwitch;
	if(navhilight != arguments[0]){
	swapImage(arguments[0],offSwitch,thisSwitch);
	}
}

function rollOff()  {
	thisSwitch = (typeof(arguments[0]) == 'number') ? 'off' : offSwitch;
	
		
	if(navhilight != arguments[0]){
	swapImage(arguments[0],overSwitch,thisSwitch);
	}
}

var navhilight = null;
function hilite()  {document.images['nav'+arguments[0]].src = navImages[arguments[0]].down.src; navhilight=arguments[0]; }

function emailFriend()  {document.location = "mailto:?subject=Prolieve (TM) Thermodilatation System Treatment&body="+document.location;}

function printPage()  {    var newLoc = document.location.href;
	if (document.location.search)  {
		versionString = '&version=print';		if (newLoc.indexOf('emailEntry') > -1)  {            rExp = new RegExp("[\?\&]{1}emailEntry");            temp = newLoc.replace(rExp, "");            newLoc = temp;            versionString = '?version=print';        }
	}
	else  {	   versionString = '?version=print';    }    if (browser.indexOf('ie') >= 0)  {document.tracker.location.href = "print_track.html?EI_print_ref="+newLoc;}
	else  {document.getElementById('tracker').src = "print_track.html?EI_print_ref="+newLoc;}
	window.open(newLoc+versionString);
}

function popWin(toWhere)  {
	if (toWhere == 'toDoc')  {
		window.open ('interstitial_todoc.html','','location=0,menubar=0,resizable=0,status=0,titlebar=0,height=220,width=200,top=100,left=100')
	}
	if (toWhere == 'survey')  {
		if (!document.cookie)  {window.open ('exit_survey.html' + arguments[1],'','scrollbars=1,location=0,menubar=0,resizable=0,status=0,titlebar=0,height=600,width=450,top=20,left=100')}
	}
}

function offSite(toWhereUrl)  {window.open ('interstitial_offsite.html?newLoc='+toWhereUrl,'','location=0,menubar=0,resizable=0,status=0,titlebar=0,height=160,width=398,top=100,left=100')}

function checkVersion()  {
	if (document.location.search.indexOf('version=print') > -1)  {
		document.write('<link rel="stylesheet" type="text/css" media="screen" href="assets/css/print.css" /><link rel="stylesheet" type="text/css" media="print" href="assets/css/print.css" />');
		if (document.location.href.indexOf('index.html') > -1)  {document.write('<link rel="stylesheet" type="text/css" media="screen" href="assets/css/indexprint.css" /><link rel="stylesheet" type="text/css" media="print" href="assets/css/indexprint.css" />');}
	}
}

var origContent2;
var origContent;
function initialize(navID) {
	contentResizer();
	align();
	hilite(navID);
}



if (browser == 'ns6')  {
	//document.write("<style>#container #colB{ position: relative; left: 3px; float: right ;}</style>");
}

function contentResizer()  {

	if (document.getElementById("A2").offsetHeight<400){
		document.getElementById("A2").style.height = 400 + 'px';
	}

	a = document.getElementById("X1");
	b = document.getElementById("container");
	c = document.getElementById("navbar");
	
	a.style.height = null;
	b.style.height = null;
	c.style.height = null;
	
	
	
	
	
	ah = (a) ? a.offsetHeight : 0;
	bh = (b) ? b.offsetHeight : 0;
	ch = (c) ? (c.offsetHeight<448 ? 448 : c.offsetHeight) : 0;
			
	highest = (ah>bh) ? (ah>ch ? ah : ch) : (bh>ch ? bh : ch);
	
		
	//alert("A : "+ao+"\nB : "+bo+"\nC : "+co+"\nHighest = "+highest);
	
	if (a)  {a.style.height = (highest + (browser=='ns6' ? -17 : -12) - document.getElementById("nav").offsetHeight) +"px";}
	
	if (b)  {b.style.height = (highest -8) + "px";}
		
	if (c)  {c.style.height = highest + (browser=='ns6' ? -8 : 0) + "px";}
	
	
}




function align(){
	if (navigator.userAgent.indexOf("IE") > 0)  {browserWidth = document.body.offsetWidth - 20;}
	else {browserWidth = window.innerWidth;}
	var designCenterOffset = (browserWidth/2)-(794/2);
		
	if(designCenterOffset<0){
		designCenterOffset == 0;
	}
	
	setDesignCenter(designCenterOffset);
}


function setDesignCenter(dco)  {
	
	dco = Math.floor(dco) + "px";
	document.getElementById("header").style.left = dco;
	document.getElementById("main").style.left = dco;
	document.getElementById("footer").style.left = dco;
	
	document.getElementById("header").style.visibility = 'visible';
	document.getElementById("main").style.visibility = 'visible';
	document.getElementById("footer").style.visibility = 'visible';
	document.getElementById("X1").style.visibility = 'visible';
}

var fontBase = 10;
function fontSizer(delta)  {
	fontBase = (delta==10 ? delta : fontBase + delta);	
	if(fontBase==0){fontBase=1;}
	document.getElementsByTagName("body").item(0).style.fontSize = fontBase+"px";
	contentResizer();
}

var contentShowing = 1;





window.onresize = align;


checkVersion();


