// BROWSER CSS 
if (client.engine == 'msie')   { document.writeln('<link href="css/msie.css"  rel="stylesheet" type="text/css" media="all" />'); }
//if (client.os == 'mac')        { document.writeln('<link href="css/mac.css"   rel="stylesheet" type="text/css" media="all" />'); }
//if (client.engine == 'webkit') { document.writeln('<link href="css/webkit.css" rel="stylesheet" type="text/css" media="all" />'); }

// ROLL OVER
function init() {
	
	//stickNav(getFileName()); 
	
	var bArr = getElementsByClass("ro_button"); // get all images with "ro_button" class
	for(var i = 0; i < bArr.length; i++) // cycle through them and set their mouseover mouseout events (changing src)
		if(bArr[i].addEventListener){
			bArr[i].addEventListener('mouseover', function(event) { this.src = this.src.substring(0, this.src.lastIndexOf(".")) + "_o.gif"; }, false);
			bArr[i].addEventListener('mouseout', function(event) { this.src  = this.src.substring(0, this.src.lastIndexOf(".")-2) + ".gif"; }, false);
		}
		else{
			bArr[i].onmouseover = function() { this.src = this.src.substring(0, this.src.lastIndexOf(".")) + "_o.gif"; }
			bArr[i].onmouseout = function() { this.src = this.src.substring(0, this.src.lastIndexOf(".")-2) + ".gif"; }
		}
		
		
		
}


// GENERAL UTILS
function getElementsByClass(val){ 
	var all = document.all || document.getElementsByTagName('*');
	var arr = [];
	for(var k = 0; k < all.length; k++) if(all[k].className == val) arr[arr.length] = all[k];
	return arr;
}
function getObj(name){
  if(document.getElementById) this.obj = document.getElementById(name);
  else if(document.all) this.obj = document.all[name];
  return this.obj;
}


// STICKY NAV

function getFileName() {

	var url = window.location.toString();
	var limit;
	
	if (url.indexOf("?") >= 0) {
		limit = url.indexOf("?"); 
	} else {
		limit = url.length;	
	}
	
	url = url.substring(0,limit);
	
	var fn = url.substring((url.lastIndexOf("/")+1),(url.length-1));
	fn = fn.substring(0,fn.lastIndexOf("."));
	
	return fn;
}

function stickNav(fn) { //function takes fn as file name string (no extension) and looks for image element with corresponding id

	//if the element exists
	if (getObj("nav_" + fn)) {
		
		var but = getObj("nav_" + fn);
		but.className = "";
		but.src = but.src.replace(".gif","_o.gif");
		(but.parentNode.nodeName == 'A') ? but.parentNode.href='javascript:void(0);':void(0);
	} else {
		//there is no element with that ID, so do nothing
	}
	
}




	function popUp(url) {
	window.open(url,'popup','height=435,width=630,resizable=1,scrollbars=0,location=0,toolbar=0,status=0,left=170,top=135,screenX=170,screenY=135').focus;
	}


	function linkMe(num)	{
		switch (num) 	{


			case 1:
				handleJumpPage('http://www.breastimplantstoday.com');
			break;
			
			case 2:
				handleJumpPage('http://www.plasticsurgery.org/');
			break;
			
			case 3:
				handleJumpPage('http://www.surgery.org/');
			break;
			
			case 4:
				handleJumpPage('http://www.fda.gov/cdrh/breastimplants/');
			break;
			case 5:
				handleJumpPage('http://www.cancer.gov/');
			break;
			case 6:
				handleJumpPage('http://www.komen.org');
			break;
			case 7:
				handleJumpPage('http://www.nap.edu/catalog/9618.html');
			break;
			case 8:
				handleJumpPage('http://cms.komen.org/komen/AboutBreastCancer/Treatment/3-5-8?ssSourceNodeId=298&ssSourceSiteId=Komen');
			break;
			case 9:
				handleJumpPage('/pdf/LittlePinkBook.pdf');
			break;
		}
} // end function

	
	
	
	
//opens the "do you want to leave" confirmation page
function handleJumpPage(url) {
	popUp('confirm.html?goPage=' + escape(url));
} // end function

	
	
// handles popup on find a doctor page	
function findDoctor() {

			href='components/search.aspx';
			window.open(href, 'findDoctor','width=516,height=600,scrollbars=1,channelmode=0,location=0,toolbar=0,status=0,directories=0,menubar=0,resizable=0,dependent=1');
		 
} // end function


// this function serves the confirm page popup from resource page
// opens the url passed in the query string as new window
function goRef() {
		var qStr = document.location.href.split('?')[1];
		var qStrValues = qStr.split('&');
		for (var loop in qStrValues) { 
			if (qStrValues[loop].split('=')[0] == 'goPage') {
				if (window.opener && !window.opener.closed) {
					
					window.open(unescape(qStrValues[loop].split('=')[1]), 'outsideSite','width=900,height=600,scrollbars=1,channelmode=0,location=1,toolbar=1,status=0,directories=0,menubar=1,resizable=1,dependent=1');
					
					//this line opens location in existing parent window
					//window.opener.location.href = unescape(qStrValues[loop].split('=')[1]);
					
					self.close(); // now close popup window
				
				} else { // if main window no longer exists
					window.location.href = unescape(qStrValues[loop].split('=')[1]);
				} // end if
			} // end if
		} // end for loop
	} // end function