// JavaScript Document
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images ) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


function swapmds(id) {
	
	//alert(num);
	if(id ==1) {
		var md = document.getElementById("md");
		var doctor = "Edward Akelman, MD";
		md.firstChild.nodeValue=doctor;
		document.title = "University Orthopedics :: " + doctor;
		var subtitle = "Hand, upper extremity and microvascular surgery";
		var skill = document.getElementById("specialty");
		skill.firstChild.nodeValue=subtitle;
		//document.mdplayer.src = "http://www.youtube.com/v/_ZBVqDhaP5k&hl=en&fs=1";
		swfobject.embedSWF("http://www.youtube.com/v/D9kPGjEkD7I&hl=en&fs=1&rel=0&ap=%2526fmt%3D18&showinfo=0", "playerspot", "425", "344", "9.0.0");
		//var mi = document.getElementById("moreinfo");
		//link.setAttribute('href','http://www.universityorthopedics.com/doctor.asp?id=21');
		//alert(link);
		//link.appendChild(document.createTextNode('Learn more about Dr. Palumbo'));
		//mi.appendChild(link);
		//mi.firstChild.nodeValue=link;
		document.getElementById('moreinfo').innerHTML="Learn more about Doctor Akelman";
    	document.getElementById('moreinfo').href ="http://www.universityorthopedics.com/md_akelman.asp";
		
		
	} else if (id ==2) {
		var md = document.getElementById("md");
		var doctor = "Paul Fadale, MD";
		md.firstChild.nodeValue=doctor;
		document.title = "University Orthopedics :: " + doctor;
		var subtitle = "Sports medicine - knees, shoulders and ankles of athletes";
		var skill = document.getElementById("specialty");
		skill.firstChild.nodeValue=subtitle;
		//document.mdplayer.src = "http://www.youtube.com/v/_ZBVqDhaP5k&hl=en&fs=1";
		swfobject.embedSWF("http://www.youtube.com/v/q7jAhHNcXXs&hl=en&fs=1&rel=0&ap=%2526fmt%3D18&showinfo=0", "playerspot", "425", "344", "9.0.0");
		//var mi = document.getElementById("moreinfo");
		//link.setAttribute('href','http://www.universityorthopedics.com/doctor.asp?id=21');
		//alert(link);
		//link.appendChild(document.createTextNode('Learn more about Dr. Palumbo'));
		//mi.appendChild(link);
		//mi.firstChild.nodeValue=link;
		document.getElementById('moreinfo').innerHTML="Learn more about Doctor Fadale";
    	document.getElementById('moreinfo').href ="http://www.universityorthopedics.com/md_fadale.asp";
	} else if (id ==3) {
		var md = document.getElementById("md");
		var doctor = "Gary M. Ferguson, MD";
		md.firstChild.nodeValue=doctor;
		document.title = "University Orthopedics :: " + doctor;
		var subtitle = "Reconstructive surgery and joint replacement";
		var skill = document.getElementById("specialty");
		skill.firstChild.nodeValue=subtitle;
		//document.mdplayer.src = "http://www.youtube.com/v/_ZBVqDhaP5k&hl=en&fs=1";
		swfobject.embedSWF("http://www.youtube.com/v/o1kBbHF7Fjk&hl=en&fs=1&rel=0&ap=%2526fmt%3D18&showinfo=0", "playerspot", "425", "344", "9.0.0");
		//var mi = document.getElementById("moreinfo");
		//link.setAttribute('href','http://www.universityorthopedics.com/doctor.asp?id=21');
		//alert(link);
		//link.appendChild(document.createTextNode('Learn more about Dr. Palumbo'));
		//mi.appendChild(link);
		//mi.firstChild.nodeValue=link;
		document.getElementById('moreinfo').innerHTML="Learn more about Doctor Ferguson";
    	document.getElementById('moreinfo').href ="http://www.universityorthopedics.com/md_ferguson.asp";
	} else if (id ==4) {
		var md = document.getElementById("md");
		var doctor = "Andrew Green, MD";
		md.firstChild.nodeValue=doctor;
		document.title = "University Orthopedics :: " + doctor;
		var subtitle = "Shoulder, elbow and upper extremity";
		var skill = document.getElementById("specialty");
		skill.firstChild.nodeValue=subtitle;
		//document.mdplayer.src = "http://www.youtube.com/v/_ZBVqDhaP5k&hl=en&fs=1";
		swfobject.embedSWF("http://www.youtube.com/v/ta29uyqQ_zg&hl=en&fs=1&rel=0&ap=%2526fmt%3D18&showinfo=0", "playerspot", "425", "344", "9.0.0");
		//var mi = document.getElementById("moreinfo");
		//link.setAttribute('href','http://www.universityorthopedics.com/doctor.asp?id=21');
		//alert(link);
		//link.appendChild(document.createTextNode('Learn more about Dr. Palumbo'));
		//mi.appendChild(link);
		//mi.firstChild.nodeValue=link;
		document.getElementById('moreinfo').innerHTML="Learn more about Doctor Green";
    	document.getElementById('moreinfo').href ="http://www.universityorthopedics.com/md_green.asp";
	} else if (id ==5) {
		var md = document.getElementById("md");
		var doctor = "Mark Palumbo, MD";
		md.firstChild.nodeValue=doctor;
		document.title = "University Orthopedics :: " + doctor;
		var subtitle = "Reconstructive and trauma surgery for the\r adult spine";
		var skill = document.getElementById("specialty");
		skill.firstChild.nodeValue=subtitle;
		//document.mdplayer.src = "http://www.youtube.com/v/_ZBVqDhaP5k&hl=en&fs=1";
		swfobject.embedSWF("http://www.youtube.com/v/_7Pli-HAlds&hl=en&fs=1&rel=0&ap=%2526fmt%3D18&showinfo=0", "playerspot", "425", "344", "9.0.0");
		//var mi = document.getElementById("moreinfo");
		//link.setAttribute('href','http://www.universityorthopedics.com/doctor.asp?id=21');
		//alert(link);
		//link.appendChild(document.createTextNode('Learn more about Dr. Palumbo'));
		//mi.appendChild(link);
		//mi.firstChild.nodeValue=link;
		document.getElementById('moreinfo').innerHTML="Learn more about Doctor Palumbo";
    	document.getElementById('moreinfo').href ="http://www.universityorthopedics.com/md_palumbo.asp";
		document.getElementById('ptstoriesinfo').innerHTML="See Dr. Palumbo and patient Roxanne Sardelli Greenway talk about the road to her \"After.\"";
    	document.getElementById('ptstoriesinfo').href ="http://test.duffyshanley.com/UO-0118_Website/09-patient-roxanne.html";
		
	}

		
}

function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}
function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}
function displayItem(key){
if(queryString(key)=='false') 
{
//document.write("you didn't enter a ?name=value querystring item.");
}else{
var id = (queryString(key));
//alert(queryString(key));
swapmds(id);
}
}

// Cookie Functions 
function createCookie(name,value,days) {
	// createCookie(UOHaitiTab,1,7);
	
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
// Set the background Image on Sub Pages (Throw a variable into the function if the pages are a level deep)
function setTab() {
	var newTab = readCookie('UOHaitiTab');
	
	if(newTab == '1') {
		TabbedPanels1.showPanel(0);
		swapBG('UOHAITI-tab-doctors.jpg');
	} else {
		TabbedPanels1.showPanel(1);
		swapBG('UOHAITI-tab-news.jpg');
	}
	
}