﻿/*
* @projectDescription 	Natrelle Home Page slideshow project file
*                       
* @author	Tom Newton  Tom.Newton@rosetta.com
* @version	0.1
*
* PREREQUISITES:
*
* SIFR:	sifr.js, sifr.css
* YUI: /yuiloader/yuiloader-min.js
* YUI: /event/event-min.js
*/

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Global Properties/Methods
========================================================================================== */
// Create the global namespace
var natrelle = natrelle || {};
// Define sIFR 3 font objects and activate
natrelle.fonts = {
	futura_book: { src: '/Style%20Library/sifr/futura_book.swf' },
	futura_light: { src: '/Style%20Library/sifr/futura_light.swf' }
};
sIFR.activate(natrelle.fonts.futura_book, natrelle.fonts.futura_light);

// Define additional required files for YUI load on initialize
/* natrelle.requiredFiles = [
	{ name: "css_include", type: "css", fullpath: "/path_to/filename.css", varName: "CSS_INCLUDE" },
	{ name: "js_include", type: "js", fullpath: "/path_to/filename.js", varName: "JS_INCLUDE" }
]; */

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Initialize
========================================================================================== */
YAHOO.util.Event.onDOMReady(function(){
	// YUI Load on DOM ready
	var loader = new YAHOO.util.YUILoader({
		base: "/Style%20Library/Scripts/libs/yui/",
		require: ['imageloader', 'container', 'event', 'animation', 'connection', 'element'],
		loadOptional: false,
		onSuccess: function() {
			var slideShow = new natrelle.slideShow(); //instantiate slideshow when components are ready
		},
		timeout: 10000
	});
	// loops through and adds any additional modules specified 
	if(natrelle.requiredFiles) {
		var tmpNames = [];
		for(a=0;a<natrelle.requiredFiles.length;a++) {
			loader.addModule(natrelle.requiredFiles[a]);
			tmpNames.push(natrelle.requiredFiles[a].name);
		}
		loader.require(tmpNames);
	}
    loader.insert();
});


/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Home Page Slide Show Object
========================================================================================== */
/**
* Create a new instance of slideShow
*
* @classDescription	This class creates a new home page slideShow.
* @return {slideShow}	Returns a new slideShow.
* @type {Object}
* @constructor	
*/

natrelle.slideShow = function(cfg) {
	this.config = {
		// main thumbnail nav
		// [(0)main thumb ID, (1)panel thumb ID, (2)additional class for styling, (3)quote, (4)associative name - currrently only used for reference to the MS or PSD]
		thumbNav: [
			['lady1','woman1','Manche Frauen lieben alles an ihrem K&#246;rper –<br/> mit Ausnahme ihrer Br&#252;ste.','Lara'],
			['lady2','woman2','Manche Frauen stellen mit 40 Jahren voller Begeisterung fest, dass sie endlich die Br&#252;ste haben k&#246;nnen, die sie sich immer schon gew&#252;nscht haben.','Emily'],
			['lady3','woman3','Viele Frauen sehen in einer Brustvergr&#246;&#223;erung die Chance, die verloren gegangene Straffheit ihrer Br&#252;ste zur&#252;ck zu erlangen.','Olivia'],
			['lady4','woman4','Viele Frauen erlangen nach der Geburt ihrer Kinder ihre fr&#252;here Figur wieder zur&#252;ck … aber nicht die Form ihrer Br&#252;ste.','Johanna'],
			['lady5','woman5','Schwangerschaft und Stillzeit k&#246;nnen zu Ver&#228;nderungen der Br&#252;ste einer Frau f&#252;hren; einige Frauen w&#252;nschen sich ganz einfach die Br&#252;ste zur&#252;ck, die sie vor der Geburt ihrer Kinder hatten.','Vanessa'],
			['lady6','woman6','Manche Frauen sind sehr zufrieden mit ihren hohen, straffen Br&#252;sten, aber gegen ein wenig mehr Dekollet&#233; h&#228;tten sie nichts einzuwenden!','Diana'],
			['lady7','woman7','Viele Frauen sehnen sich nach mehr weiblicher Ausstrahlung, ... aber ihre kleinen Br&#252;ste stehen dem im Wege. ','Evie'],
			['lady8','woman8','Weil Ihre Br&#252;ste klein sind ...<br/> f&#252;hlen Sie sich nicht so weiblich, wie Sie es eigentlich sollten.','Kate'],
			['lady9','woman9','Manche Frauen haben das Gef&#252;hl, dass sich mit dem &#196;lterwerden nicht nur die Straffheit ihrer Br&#252;ste, sondern gleichzeitig auch das eigene Selbstwertgef&#252;hl geringer wird.','Lilly']
		],		// thumbnail image options configurator
		thumbOptions: {
			mainThumb: "_thumb.png", // will use the id of position 1 in thumbnav array plus this, plus the mainImgExtension to set the appropriate image
			mainOn: "_thumb_on.png",
			mainShadow: "_thumb_shadow.png",
			mainBig: "_big.jpg",
			panelThumb: "_panelthumb.png" // will use the id of position 2 in thumbnav array plus this, plus the panelImgExtension to set the appropriate image
		},
		imagePath: "/Style%20Library/Images/Natrelle/home/",
		logoPNG: "hp_logo_top.png",
		quotePNG: "hp_quote.png",
		panelID: "slideshow_panel",
		panelFilePath: "/Style%20Library/panels/", // path to panel html
		closeID: "panel_close",
		slideID: "slide_viewer", // ID of slide container on panel
		slideImgWidth: 56, // width of each image in slide container
		slideVisible: 4, // number of visible images on panel slide viewer
		mainNavItems: 5,
		mainNavPrefix: "hp_nav",
		mainNavOverImage: "hp_nav_over.png"
	};
	
	//empty YUI custom event obj - will manually fire this to trigger the preload imagegroup once specified
	this.loadEvent = {};
	//panel obj
	this.panel = {};
	// panel slide anim
	this.stAnim = {};
	// active quote (panel only);
	this.activeQuote = "";
	this.activeThumb = "lady5"; // active 'lady' set here by default
	this.activeNav = "hp_nav1"; //active main navigation element, requires a default value but has no impact
	this.bigImageFade = new YAHOO.util.Anim(); // big image fade animation to use on active thumbnail
	this.htmlObjects = [];  // empty array to use for YUI html elements associated with each item in the gallery
	this.mainThumbstripActive = false;  // main thumbstrip active state off by default
	this.mainNavActive = false;  // main thumbstrip active state off by default
	this.modalKeyClose = {}; // empty modal close esc key listener obj
	//initialize!
	this.init(this);
};

/* METHODS */
// Initialize
natrelle.slideShow.prototype.init = function(o) {
    o.loadEvent = new YAHOO.util.CustomEvent("loadEvent"); 
	for(i=0;i<o.config.thumbNav.length;i++) {
		o.htmlObjects.push({
			thumbnail: new YAHOO.util.Element(o.config.thumbNav[i][0] + "_off"),
			thumbnailOn: new YAHOO.util.Element(o.config.thumbNav[i][0] + "_on"),
			thumbnailOff: new YAHOO.util.Element(o.config.thumbNav[i][0] + "_shadow"),
			bigContainer: new YAHOO.util.Element(o.config.thumbNav[i][0] + "_big"),
			quoteContainer: new YAHOO.util.Element(o.config.thumbNav[i][0] + "_quote")
		});
	}
	YAHOO.util.Event.on('hp_nav', "mouseover", o.events.navOver, o);
	YAHOO.util.Event.on('hp_nav', "mouseout", function() {
		o.switchNav(o.activeNav, false);
	});
	YAHOO.util.Event.on('hp_slideshow', "mouseover", o.events.thumbOver, o);
	YAHOO.util.Event.on('hp_slideshow', "click", o.events.thumbClick, o);
	
	o.initQuotes(o);
	o.loadImages(o);
	o.loadPanel();
};
// places all active quotes and sIFRize them
natrelle.slideShow.prototype.initQuotes = function(o) {
	for(i=0;i<o.config.thumbNav.length;i++) {
		var quoteContainer = document.getElementById(o.config.thumbNav[i][0] + "_quote");
		quoteContainer.innerHTML = o.config.thumbNav[i][2];
	}
	// sIFR replacement on all of the quotes newly inserted above:
	sIFR.replace(natrelle.fonts.futura_book, {
	  	selector: 'div.hp_dropquote',
	  	css: '.sIFR-root { color: #3C270E; text-align: center; font-size:14px}',
	  	wmode: 'transparent'
	});
};
// register and attempt to preload all pngs
natrelle.slideShow.prototype.loadImages = function(o) {
	var preloadImageGroup = new YAHOO.util.ImageLoader.group();
	preloadImageGroup.addCustomTrigger(o.loadEvent);
	// register logo and tagline png replacements
	preloadImageGroup.registerPngBgImage('hp_logo_t', o.config.imagePath + o.config.logoPNG);//register logo PNG
	preloadImageGroup.registerPngBgImage('hp_quote_t', o.config.imagePath + o.config.quotePNG);//register quote (tagline) PNG
	// loop through and register all main navigation images
	for(j=0;j<o.config.mainNavItems;j++){
		var navBkgContainer = o.config.mainNavPrefix + (j+1) + "_bkg";
		var navOverContainer = o.config.mainNavPrefix + (j+1) + "_over";
		
		preloadImageGroup.registerPngBgImage(navBkgContainer, o.config.imagePath + o.config.mainNavPrefix + (j+1) + ".png");
		preloadImageGroup.registerPngBgImage(navOverContainer, o.config.imagePath + o.config.mainNavOverImage);
	}
	// loop through and register all thumbnav images; on, off, shadow, and big
	for(i=0;i<o.config.thumbNav.length;i++) {
		preloadImageGroup.registerPngBgImage(o.htmlObjects[i].thumbnail.get('id'), o.config.imagePath + o.config.thumbNav[i][0] + o.config.thumbOptions.mainThumb);
		preloadImageGroup.registerPngBgImage(o.htmlObjects[i].thumbnailOn.get('id'), o.config.imagePath + o.config.thumbNav[i][0] + o.config.thumbOptions.mainOn);
		preloadImageGroup.registerPngBgImage(o.htmlObjects[i].thumbnailOff.get('id'), o.config.imagePath + o.config.thumbNav[i][0] + o.config.thumbOptions.mainShadow);
		preloadImageGroup.registerBgImage(o.htmlObjects[i].bigContainer.get('id'), o.config.imagePath + o.config.thumbNav[i][0] + o.config.thumbOptions.mainBig);
	}
	// fire the custom load event to trigger immediate preloading
	o.loadEvent.fire();
	
};
//toggles on/off a main (thumbnail, big image, quote, etc) element based on id/toggle
natrelle.slideShow.prototype.toggleThumb = function(id,o,isActive) {
	
	o.bigImageFade.stop(true); // stops any previous animations, firing any oncomplete subsribers that may exist
	
	// get the index of the element
	var thisIndex = 0; // index is 0 by default
	for(i=0;i<o.config.thumbNav.length;i++) {
		if(o.config.thumbNav[i][0] == id){
			thisIndex = i;
			break;
		}	
	}
	var htmlObjects = o.htmlObjects[thisIndex];
	var quoteNodes = htmlObjects.quoteContainer.get('childNodes');
	var quoteObject = {};
	
	for(j=0;j<quoteNodes.length;j++) {
		if(quoteNodes[j].className == "sIFR-flash"){
			quoteObject = new YAHOO.util.Element(quoteNodes[j]);
			quoteObject.setStyle('display', 'block');
			break;
		}
	}
	
	
	
	o.bigImageFade = new YAHOO.util.Anim(htmlObjects.bigContainer); //resets the animation to container specified
	o.bigImageFade.method = YAHOO.util.Easing.easeOut;
	
	// if element is 'active' toggle the element on
	if(isActive) {
		// elements to set to visible:
		YAHOO.util.Dom.setStyle([htmlObjects.bigContainer, htmlObjects.quoteContainer, htmlObjects.thumbnailOn, quoteObject], 'visibility', 'visible');
		// elements to set to hidden:
		YAHOO.util.Dom.setStyle([htmlObjects.thumbnailOff], 'visibility', 'hidden');
		// set specific styles
		htmlObjects.thumbnailOn.setStyle('bottom', '0px');
		htmlObjects.thumbnailOn.setStyle('height', '137px');
		
		
		//slides the "read more" up
		var slideAnim = new YAHOO.util.Anim(htmlObjects.thumbnailOn, { 
		  height: {from: 137, to: 167} 
		}, 0.5, YAHOO.util.Easing.easeOut);
		slideAnim.animate();
		
		//'big'image fade in animation
		o.bigImageFade.attributes.opacity = {from:0, to:1};
		o.bigImageFade.duration = 0.5;
		
	} else {
		// big image fade out and oncomplete set container to hidden
		o.bigImageFade.attributes.opacity = {from:1, to:0};
		o.bigImageFade.duration = 0.5;
		o.bigImageFade.onComplete.subscribe(function(){
			// elements to set to visible:
			YAHOO.util.Dom.setStyle([htmlObjects.thumbnailOff], 'visibility', 'visible');
			// elements to set to hidden:
			YAHOO.util.Dom.setStyle([htmlObjects.bigContainer, htmlObjects.quoteContainer, htmlObjects.thumbnailOn, quoteObject], 'visibility', 'hidden');
			// set specific styles
			quoteObject.setStyle('display', 'none');
		});
		
	}
	o.bigImageFade.animate();
	
};
// toggle the sifr replaced quote object tag 
natrelle.slideShow.prototype.toggleQuote = function(id,show,o,i) {
	var quoteContainer = document.getElementById(id + "_quote");
	var quoteObject = quoteContainer.getElementsByTagName("object"); // the sIFR
	if(show){
		quoteObject[0].style.display = "block";
		quoteObject[0].style.visibility = "visible";
	}else{
		quoteObject[0].style.display = "none";
		quoteObject[0].style.visibility = "hidden";
	}
}
// enable the thumbstrip by turning off the 'fake' backgrounds 
// of those elements *hopefully* replaced by the preloaded ones
// this method fires when the thumbstrip is moused over for the first time
// and removes this listener from the dom when fired
natrelle.slideShow.prototype.enableThumbstrip = function() {
	// remove the default 'fake' backgrounds specified in the stylesheet
	document.getElementById("hp_slideshow").style.background = "none";
	document.getElementById("hp_top").style.background = "none";
	document.getElementById("hp_logo").style.background = "none";
	document.getElementById("hp_quote").style.background = "none";
	// set the transparent logo and quote divs to visible
	document.getElementById("hp_logo_t").style.visibility = "visible";
	document.getElementById("hp_quote_t").style.visibility = "visible";
	this.defaultThumbs(this);
	this.enableNav();
};
// switches all thumbnails to the default state (thumbnail on, shadow on, "read more" image off)
natrelle.slideShow.prototype.defaultThumbs = function(o) {
	for(i=0;i<o.config.thumbNav.length;i++) {
		var htmlObjects = o.htmlObjects[i]; // associated html object for each element
		// global elements to set to visible:
		YAHOO.util.Dom.setStyle([htmlObjects.thumbnail, htmlObjects.thumbnailOff], 'visibility', 'visible');
		// specific styling for the default 'active' element
		if(o.activeThumb == o.config.thumbNav[i][0]) {
			// elements to set to visible:
			YAHOO.util.Dom.setStyle([htmlObjects.bigContainer, htmlObjects.thumbnailOn], 'visibility', 'visible');
			// elements to set to hidden:
			YAHOO.util.Dom.setStyle([htmlObjects.thumbnailOff], 'visibility', 'hidden');
			// toggle the sifr quote on
			//o.toggleQuote(o.config.thumbNav[i][0],true,o);
		// default styles for all other 'non active' elements
		} else {
			// elements to set to visible:
			YAHOO.util.Dom.setStyle([htmlObjects.thumbnailOff], 'visibility', 'visible');
			// elements to set to hidden:
			YAHOO.util.Dom.setStyle([htmlObjects.bigContainer, htmlObjects.thumbnailOn], 'visibility', 'hidden');
			// elements to set opacity to zero
			YAHOO.util.Dom.setStyle([htmlObjects.bigContainer], 'opacity', 0);
			// toggle the sifr quote off
			//o.toggleQuote(o.config.thumbNav[i][0],false,o);
		}
	}
};
// ========== MAIN NAVIGATION METHODS ============= //
// enable the transparent main navigation
natrelle.slideShow.prototype.enableNav = function() {
	var o = this;
	// remove the default backgrounds from css
	document.getElementById("hp_nav").style.background = "none";
	// loop through and turn on background png's
	for(i=0;i<o.config.mainNavItems;i++) {
		document.getElementById(o.config.mainNavPrefix + (i+1) + "_bkg").style.visibility = "visible";
	}
};
//enables/disables the hover state on passed nav item
natrelle.slideShow.prototype.switchNav = function(id, showHover) {
	if(showHover){
		document.getElementById(id + "_over").style.visibility = "visible";
	} else {
		document.getElementById(id + "_over").style.visibility = "hidden";
	}
};



// ========== BEGIN MODAL PROTOTYPES ============= //
// the methods below pertain to the modal panel and mini thumbnail navigator only
// =================================================================================

// instantiates an empty panel to the DOM accessable through the application scope
natrelle.slideShow.prototype.loadPanel = function() {
	var o = this;
	o.panel = new YAHOO.widget.Panel(o.config.panelID, {visible:false, draggable:false, close:false, modal:true, underlay:"none", width:"972px", height:"511px",  fixedcenter:true });
	o.panel.render(document.body);
    document.getElementById(o.config.panelID).className = ""; //remove default yui panel styles
};
// shows a panel based off passed 'id' argument
// the id must match up to the filename of the panel to be shown/loaded
natrelle.slideShow.prototype.showPanel = function(id) {
	var o = this;
	o.loadExternalHTML(o.config.panelFilePath + id + ".html");
};
// hides the panel and removes any content from the body
// this is usually executed from a listener so the arguments are as such
natrelle.slideShow.prototype.hidePanel = function(e,o) {
	o.panel.hide();
	o.panel.setBody("");
	o.modalKeyClose.disable();
};
natrelle.slideShow.prototype.loadExternalHTML = function(filePath) {
    //Load XML Content
    var obj = this; //internal obj re-reference
    var successHandler = function(o) {
        var html = o.responseText;
		obj.panel.setBody(html);
		obj.panel.render(document.body);
		YAHOO.util.Event.addListener(obj.config.closeID, "click", obj.hidePanel, obj);
		//key listener for modal close event
    	obj.modalKeyClose = new YAHOO.util.KeyListener(document, { keys:27 }, function() {
			obj.hidePanel(this,obj);
		}, "keyup");
		
		obj.panel.show();
		obj.enablePanelThumbs();
		obj.modalKeyClose.enable();
		
		// replace panel tagline html with sIFR text
		sIFR.replace(natrelle.fonts.futura_book, {
		  selector: 'div.tagline',
		  css: '.sIFR-root { color: #6F3826; }',
		  wmode: 'transparent'
		});
		
		// replace panel copy (right below tagline) with sIFR text
		sIFR.replace(natrelle.fonts.futura_light, {
		  selector: 'div.panel_copy',
		  css: '.sIFR-root { color: #333333; leading: 13; }',
		  wmode: 'transparent'
		});
    }
    //define the AJAX failure handler
    var failureHandler = function(o) {
        //alert the status code and error text
        alert(o.status + " : " + o.statusText);
    }
    //define the callback object
    var callback = {
        success:successHandler,
        failure:failureHandler
    };
    //initiate the transaction
    var transaction = YAHOO.util.Connect.asyncRequest("GET", filePath, callback, null);
};
// load panel thumbnail slider and images
natrelle.slideShow.prototype.enablePanelThumbs = function() {
	var o = this;
	var preloadImageGroup = new YAHOO.util.ImageLoader.group();
	preloadImageGroup.addCustomTrigger(o.loadEvent);
	// load the control images
	preloadImageGroup.registerPngBgImage('tbl_on', o.config.imagePath + 'btn_slideleft_on.png');
	preloadImageGroup.registerPngBgImage('tbl_off', o.config.imagePath + 'btn_slideleft_off.png');
	preloadImageGroup.registerPngBgImage('tbl_over', o.config.imagePath + 'btn_slideleft_over.png');
	preloadImageGroup.registerPngBgImage('tbr_on', o.config.imagePath + 'btn_slideright_on.png');
	preloadImageGroup.registerPngBgImage('tbr_off', o.config.imagePath + 'btn_slideright_off.png');
	preloadImageGroup.registerPngBgImage('tbr_over', o.config.imagePath + 'btn_slideright_over.png');
	
	// load the thumbnail images
	for(i=0;i<o.config.thumbNav.length;i++) {
		//register the image
		var container = o.config.thumbNav[i][1];
		var gotoID = o.config.thumbNav[i][0];
		preloadImageGroup.registerPngBgImage(o.config.thumbNav[i][1], o.config.imagePath + o.config.thumbNav[i][1] + o.config.thumbOptions.panelThumb);
		// thumbnail click event subscribe
		YAHOO.util.Event.addListener(container, 'click', function(){
			o.showPanel("lady" + this.id.substr(5,1));
		});
		
	}
	YAHOO.util.Event.on('slide_viewer', "mouseover", o.events.miniThumbHandler, o);
	YAHOO.util.Event.on('slide_viewer', "mouseout", o.events.miniThumbHandler, o);
	o.enableThumbControls(true,o);
	
	o.loadEvent.fire();
	//o.setOpacity(this);
	
	// scroll to currently selected panel is visible on the panel thumbstrip nav
	var tmpThumbPos = document.getElementById("hp_modal").className.substr(4,1);
	if(tmpThumbPos > 2) {
		o.slideyThumbs(false, (o.config.slideImgWidth*(tmpThumbPos - 2)),false,0.1);
	}
	
	// set the active quote based on the number pulled from the hpmodal classname above
	// this number minus one is it's position in the array =)
	o.activeQuote = o.config.thumbNav[tmpThumbPos-1][2];
	var dropQuote = document.getElementById('dropquote');
	dropQuote.innerHTML = o.activeQuote;
	
};
// scrolls the mini thumbnail navigator on the panel left or right
natrelle.slideShow.prototype.slideyThumbs = function(goLeft,scrlBy,stopAnim,d) {
	var o = this;
	if(!stopAnim) {
		var tmpDirection = scrlBy || o.config.slideImgWidth * 9;
		var duration = d || 2;
		// if left go negative
		if (goLeft) { tmpDirection = 0 - tmpDirection; }
		var attributes = {
			scroll: { by: [tmpDirection, 0] }
		};
		o.stAnim = new YAHOO.util.Scroll(o.config.slideID, attributes);
		o.stAnim.duration = duration;
		o.stAnim.animate();
	} else {
		o.stAnim.stop();	
	}
};
// enables and disables the left/right thumb nav controls
natrelle.slideShow.prototype.enableThumbControls = function(enable, o) {
	document.getElementById('tbl_on').style.display = "block";
	document.getElementById('tbr_on').style.display = "block";
	if (enable) {
		YAHOO.util.Event.addListener("tbl_on", "mouseover", function(){
			document.getElementById('tbl_over').style.display = "block";
			o.slideyThumbs(true);
		});
		YAHOO.util.Event.addListener("tbr_on", "mouseover", function(){
			document.getElementById('tbr_over').style.display = "block";
			o.slideyThumbs(false);
		});
		YAHOO.util.Event.addListener("tbl_on", "mouseout", function(){
			document.getElementById('tbl_over').style.display = "none";
			o.stAnim.stop();	
		});
		YAHOO.util.Event.addListener("tbr_on", "mouseout", function(){
			document.getElementById('tbr_over').style.display = "none";
			o.stAnim.stop();	
		});
	} else {
		
	}
};
// ==== EVENT HANDLERS ==== //
// =================================================================================
natrelle.slideShow.prototype.events = {
	
	
	// mouseover main thumbnail handler
	thumbOver: function(e,o) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		// activate thumbstrip if not enabled
		if(!o.mainThumbstripActive) {
			o.enableThumbstrip();
			o.mainThumbstripActive = true;
		}
		// if the current mouse target class matches a thumb, execute it's methods
		while (elTarget.id != "hp_slideshow") {
			if(YAHOO.util.Dom.hasClass(elTarget, 'thumbnail')) {
				//alert("The thumbnail id moused over is " + elTarget.id);
				if(o.activeThumb != elTarget.id){
					//first turn the previous active element off
					o.toggleThumb(o.activeThumb,o,false);
					//then toggle the currently moused over item on
					o.toggleThumb(elTarget.id,o,true);
					//finally set this to the active thumb
					o.activeThumb = elTarget.id;
				}
				break;
			} else {
				elTarget = elTarget.parentNode;
			}
		}
	},
	
	
	// mouse click main thumbnail handler
	thumbClick: function(e,o) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		// if the current mouse target class matches a thumb, execute it's methods
		while (elTarget.id != "hp_slideshow") {
			if(YAHOO.util.Dom.hasClass(elTarget, 'thumbnail')) {
				//alert("The thumbnail id clicked is " + elTarget.id);
				o.showPanel(elTarget.id);
				break;
			} else {
				elTarget = elTarget.parentNode;
			}
		}
	},
	
	
	// mouseover main navigation handler
	navOver: function(e,o) {	
		var elTarget = YAHOO.util.Event.getTarget(e);
		// activate thumbstrip if not enabled
		if(!o.mainNavActive) {
			o.enableNav();
			o.mainNavActive = true;
		}
		// if the current mouse target class matches a thumb, execute it's methods
		while (elTarget.id != "hp_nav") {
			if(elTarget.nodeName.toUpperCase() == "LI") {
				//alert("The thumbnail id moused over is " + elTarget.id);
				// first turn the previous active nav item off
				o.switchNav(o.activeNav, false);
				// then set the active nav and style
				o.switchNav(elTarget.id, true);
				o.activeNav = elTarget.id;
				break;
			} else {
				elTarget = elTarget.parentNode;
			}
		}
	},
	
	// mini thumbstrip nav item handler - does mouseover/mouseout based on event.type
	// check this in IE before release as e.type may differ cross browser/platform even tho yui
	miniThumbHandler: function(e,o) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		// if the current mouse target class matches a thumb, execute it's methods
		while (elTarget.id != "slide_viewer") {
			if(YAHOO.util.Dom.hasClass(elTarget, 'thumb')) {
				var dropQuote = document.getElementById('dropquote');
				var shadowContainer = document.getElementById(elTarget.id + "_shadow");
				//on mouseover
				if(e.type == "mouseover"){
					// hide the shadow of the currently moused over item
					shadowContainer.style.visibility = "hidden";
					// display the quote of the currently moused over item
					for(i=0;i<o.config.thumbNav.length;i++) {
						if(elTarget.id == o.config.thumbNav[i][1]) {
							dropQuote.innerHTML = o.config.thumbNav[i][2];
						}
					}
				} else if(e.type == "mouseout") {
					// turn the shadow back on on mouseout
					shadowContainer.style.visibility = "visible";
					// revert back to the active panels' quote
					dropQuote.innerHTML = o.activeQuote;
				}
				break;
			} else {
				elTarget = elTarget.parentNode;
			}
		}
	}
};
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * END Home Page Slide Show Object END
========================================================================================== */

// Adding press release code here!

$(document).ready(function() {
	var today = new Date;
	if(today.getFullYear() <= 2012 && today.getMonth() <= 3) {
		$('#bgcontainer').prepend('<div id="pressrelease-wrapper"><ul id="pressrelease"><li class="left">Fragen zur aktuellen Presse?</li><li class="right"><p>Haben Sie Fragen bezüglich der Qualität und Sicherheit unserer Implantate?<br />Lesen Sie die neuste Allergan Pressemitteilung.</p><a target="_blank" href="/Documents/breast%20implant%20quality%20safety.pdf"><span class="left"></span><span class="text">JETZT LESEN</span><span class="right"></span></a></li></ul></div>');
	} 
});
