var stories = [
								{
									'name':'Ginger Martin',
									'id':'GingerMartin',
									'photo':'pat_stor1.jpg',
									'movie':'Ginger_Martin.flv',
									'Treatment':'Re:store',
									'Condition':'Wrinkles',
									'Age':'50',
									'Gender':'Female',
									'Courtesy of':'Dr. Rutledge Forney, MD of Dermatology Affiliates, Atlanta, GA',
									'description':'',
									'provider':'Rutledge Forney, MD',
									'practice':'Dermatology Affiliates, Atlanta, GA',
									'url':'http://www.dermatologyaffiliates.com',
									'bio':'Dr. Forney received her Bachelor of Arts degree in the field of Management Science from Duke University in Durham, North Carolina. In 1996, she graduated cum laude from Emory University School of Medicine. Following her internship in the Department of Medicine at Duke University Medical Center, Dr. Forney served as Resident and Chief Resident in the Department of Dermatology at the University of California, San Francisco. Since 2003, she has been on the Atlanta Medical Association Board of Directors. In addition, she is the President of the Atlanta Dermatological Association. Dr. Forney practices dermatologic surgery at Dermatology Affiliates in Atlanta, Georgia.'
								},
								{
									'name':'Laura Matkin',
									'id':'LauraMatkin',
									'photo':'pat_stor2.jpg',
									'movie':'Laura_Matkin.flv',
									'Treatment':'Re:store',
									'Condition':'Wrinkles',
									'Age':'50',
									'Gender':'Female',
									'Courtesy of':'Gregory Nikolaidis, MD Westlake Dermatology and Cosmetic Surgery',
									'description':'',
									'provider':'Gregory Nikolaidis, MD',
									'practice':'Westlake Dermatology and Cosmetic Surgery',
									'url':'http://www.westlakedermatology.com',
									'bio':'Dr Nikolaidis received his dermatology specialty training at the University of California San Diego, after a pediatrics internship at Baylor College of Medicine in Houston. Dr. Nikolaidis graduated cum laude from Trinity University in Texas and went on to graduate at the top of his class with honors in the Basic Sciences from Baylor College of Medicine. He is a national leader in minimally invasive cosmetic procedures. Dr. Nikolaidis is board certified by the American Board of Dermatology and is a Fellow of the American Medical Association, the American Academy of Dermatology, the American Society for Mohs Surgery, the Texas Medical Association and the Travis County Medical Society.'
								},
								{
									'name':'Kathleen Horay',
									'id':'KathleenHoray',
									'photo':'pat_stor3.jpg',
									'movie':'Kathleen_Horay.flv',
									'Treatment':'Re:store',
									'Condition':'Skin Resurfacing',
									'Age':'45',
									'Gender':'Female',
									'Courtesy of':'Steven Nielson, MD Laser Me Beautiful Center Westmont, NJ',
									'description':'',
									'provider':'Steven Nielson, MD',
									'practice':'Laser Me Beautiful Center',
									'url':'',
									'bio':'Dr. Nielson received his education at the Pennsylvania College of Medicine in Philadelphia. He served his residency at the New York Community Hospital in Brooklyn, New York, which is affiliated with the New York Weill Cornell Medical Center. Dr. Nielson has been performing cosmetic procedures for several years at his Laser Me Beautiful center in Westmont, New Jersey'
								},
								{
									'name':'Betsy Cantor',
									'id':'BetsyCantor',
									'photo':'pat_stor4.jpg',
									'movie':'Betsy_Cantor.flv',
									'Treatment':'Re:store',
									'Condition':'Melasma',
									'Age':'34',
									'Gender':'Female',
									'Courtesy of':'Grant Stevens, MD Marina del Rey, California',
									'description':'',
									'provider':'Grant Stevens, MD',
									'practice':'',
									'url':'http://www.marinaplasticsurgery.com',
									'bio':'Dr. Stevens is a California board- certified plastic surgeon and the Medical Director of Plastic Surgery Associates in Marina del Rey and Palos Verdes. He specializes in cosmetic plastic surgery and has been named one of America\'s Best Physicians in The Guide to Top Doctors. He is an active member at Daniel Freeman Marina Hospital where he is the past Chairman of The Department of Surgery. He is also on staff at St. John\'s Medical Center and The Marina Outpatient Surgery Center. He was appointed by the governor to The Medical Board of California Medical Quality Review Board, and is on the Plastic Surgery Faculty at UCLA and USC. Dr. Stevens has authored many journal articles, lectured at international, national and regional meetings, and appeared on a number of national broadcast and cable television shows.'
								}
							];

// BEGIN CoreMetrics tracking stuff
var elementTagPatientStory = function(e)
	{
		cmCreatePageElementTag('Story:'+stories[parseInt((new Event(e)).target.id.split('_')[1])].name,'Fraxel:Patient Stories');
	}
var elementTagPracticeUrl = function(e)
	{
		cmCreatePageElementTag('PracticeUrl:'+(new Event(e)).target.get('text').split('.')[1],'Fraxel:Patient Stories');
	}
var elementTagEventAttachment = function()
	{
		var docUrlClassName = 'practiceUrl';
		var storyNameClassName = 'storyName';
		var storyTextClassName = 'galleryStoryText';
		var storyImgClassName = 'galleryPortrait';
		var docUrls = $('colLeftPat').getElements('a[class='+docUrlClassName+']').each(function(el){el.addEvent('click',elementTagPracticeUrl);});
		var storyNames = $('2d').getElements('span[class='+storyNameClassName+']').each(function(el){el.addEvent('click',elementTagPatientStory);});
		var storyTexts = $('2d').getElements('div[class='+storyTextClassName+']').each(function(el){el.addEvent('click',elementTagPatientStory);});
		var storyImgs = $('2d').getElements('img[class='+storyImgClassName+']').each(function(el){el.addEvent('click',elementTagPatientStory);});
	}
// END CoreMetrics tracking stuff

var switchStory = function(e)
	{
		if($type(e)=='event'){var storyId = new Event(e).stop().target.id.split('_')[1];}
		else{var storyId = e.id.split('_')[1];}
		var moviePath = '/assets/SWFs/';
		loadVideo(moviePath + stories[storyId].movie);
		drawStoryDetail(storyId);
	}
var drawStories = function()
	{
		var storiesContainer = $('2d');
		var portraitPath = '/images/';
		var thisStory,storyContainer,portrait,storyTextContainer,storyName,treatmentHeader,treatment,conditionHeader,condition,courtesy;
		var lineBreak = new Element('br');
		for(var i=0;i<stories.length;i++)
			{
				thisStory = stories[i];
				storyContainer =  new Element('div',{'class':'images_row' + (i%2),id:'storyContainer_'+i}).addEvent('click',switchStory);
				portrait = new Element('img',{'src':portraitPath + thisStory.photo,'class':'galleryPortrait',id:'galleryPortrait_'+i,align:'left',alt:thisStory.name,title:thisStory.name}).addEvent('click',switchStory);
				storyTextContainer = new Element('div',{'class':'galleryStoryText','id':'galleryStoryText_'+i});
				storyName = new Element('span',{'class':'storyName',id:'storyName_'+i}).appendText(thisStory.name).addEvent('click',switchStory);
				treatmentHeader = new Element('span',{'class':'storyMetaHeader'}).appendText('Treatment: ');
				treatment = new Element('span',{'class':'storyMeta'}).appendText(thisStory.Treatment);
				conditionHeader = new Element('span',{'class':'storyMetaHeader'}).appendText(' For: ');
				condition = new Element('span',{'class':'storyMeta'}).appendText(thisStory.Condition);
				courtesy = new Element('span',{'class':'storyMeta'}).appendText(thisStory['Courtesy of']);
				storyTextContainer.adopt(storyName,lineBreak.clone(),treatmentHeader,treatment,conditionHeader,condition,lineBreak.clone(),courtesy);
				storiesContainer.adopt(storyContainer.adopt(portrait,storyTextContainer));
			}
	}
var drawStoryDetail = function(storyId)
	{
		var ids = ('storyName,storyTreatment,storyCondition,storyAge,storyGender,storyCourtesy').split(',');
		var keys = ('name,Treatment,Condition,Age,Gender,Courtesy of,description').split(',');
		var storyContainers;
		for(var i=0;i<ids.length;i++)
			{
				$(ids[i]).empty().appendText(stories[storyId][keys[i]]);
			}
		storyContainers = $('colLeftPat').getElements('div[class=story]').each(function(el){el.setStyle('display','none');});
		$(stories[storyId].id).setStyle('display','block');
	}

 var loadVideo = function(path)
	 {
	 		//var storyId = new Event(e).target.id.split('_')[1];
			var flash = new SWFObject("/common/SWFs/player.swf", "movie", "322", "262", "9", "#FFFFFF");
			if(flash)
				{
					flash.addVariable("path", path);
					flash.write("swfContainer");
				}
			else
				{
					alert('Flash player not found');
				}
	 }
var init = function()
	{
		drawStories();
		$('storyContainer_0').fireEvent('click',$('storyContainer_0'));
		//coremetrics
		elementTagEventAttachment();
	}
	
window.addEvent('domready',init);





