﻿/* Subfeature Controller - 0.9.20101103*/
isIE6 = false;

(function($) {
if(!document.defaultView||!document.defaultView.getComputedStyle){var oldCurCSS=jQuery.curCSS;jQuery.curCSS=function(a,b,c){if(b==='background-position'){b='backgroundPosition'}if(b!=='backgroundPosition'||!a.currentStyle||a.currentStyle[b]){return oldCurCSS.apply(this,arguments)}var d=a.style;if(!c&&d&&d[b]){return d[b]}return oldCurCSS(a,'backgroundPositionX',c)+' '+oldCurCSS(a,'backgroundPositionY',c)}}var oldAnim=$.fn.animate;$.fn.animate=function(a){if('background-position'in a){a.backgroundPosition=a['background-position'];delete a['background-position']}if('backgroundPosition'in a){a.backgroundPosition='('+a.backgroundPosition}return oldAnim.apply(this,arguments)};function toArray(a){a=a.replace(/left|top/g,'0px');a=a.replace(/right|bottom/g,'100%');a=a.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var b=a.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(b[1],10),b[2],parseFloat(b[3],10),b[4]]}$.fx.step.backgroundPosition=function(a){if(!a.bgPosReady){var b=$.curCSS(a.elem,'backgroundPosition');if(!b){b='0px 0px'}b=toArray(b);a.start=[b[0],b[2]];var c=toArray(a.options.curAnim.backgroundPosition);a.end=[c[0],c[2]];a.unit=[c[1],c[3]];a.bgPosReady=true}var d=[];d[0]=((a.end[0]-a.start[0])*a.pos)+a.start[0]+a.unit[0];d[1]=((a.end[1]-a.start[1])*a.pos)+a.start[1]+a.unit[1];a.elem.style.backgroundPosition=d[0]+' '+d[1]};
})(jQuery);
var MFGArray = new Array();
var subFeaturePosition = new Array();
subFeaturePosition[1] = "0px";
subFeaturePosition[2] = "-136px";
subFeaturePosition[3] = "-272px";
var subFeatureMovement = 350;
function fadeSubFeature(sfID, sf1, sf2, sf3){
	jQuery("#"+sfID+"_1 a img").animate({
		opacity: sf1
	}, 200);
	jQuery("#"+sfID+"_2 a img").animate({
		opacity: sf2
	}, 200);
	jQuery("#"+sfID+"_3 a img").animate({
		opacity: sf3
	}, 200);
}
if (!mobileDevice){
	//jQuery(".subFeatureContent").mouseenter(function(){
	jQuery(".subFeatureContent").click(function(){
		var sfID = jQuery(this).attr('ID').split("_");
		switch(sfID[1]) {
			case "1":
				if (jQuery(this).css("top") != subFeaturePosition[1]) {
					jQuery("#"+sfID[0]+"_1").stop().animate({
						top: subFeaturePosition[1]
					}, subFeatureMovement);
					jQuery("#"+sfID[0]+"_2").stop().animate({
						top: subFeaturePosition[2]
					}, subFeatureMovement);
				}
				break;
			
			case "2":
				if (jQuery("#"+sfID[0]+"_1").css("top") != subFeaturePosition[1] && jQuery("#"+sfID[0]+"_2").css("top") == subFeaturePosition[2]) {
					break;
				}
				jQuery("#"+sfID[0]+"_1").stop().animate({
					top: "-135px"
				}, subFeatureMovement);
				jQuery("#"+sfID[0]+"_2").stop().animate({
					top: subFeaturePosition[2]
				}, subFeatureMovement);
				break;
			
			case "3":
				if (jQuery("#"+sfID[0]+"_1").css("top") == subFeaturePosition[1] || jQuery("#"+sfID[0]+"_2").css("top") == subFeaturePosition[2]) {
					jQuery("#"+sfID[0]+"_1").stop().animate({
						top: "-135px"
					}, subFeatureMovement);
					jQuery("#"+sfID[0]+"_2").stop().animate({
						top: "-272px"
					}, subFeatureMovement);
				}
				break;
		}
	});
	jQuery('.subFeatureBox').mouseenter(function(){
		jQuery(this).css('background-position', '0px -150px');
		jQuery(this).stop().animate({
			backgroundPosition: '0px -10px'
		}, 400);
	});
	jQuery('.subFeatureBox').mouseleave(function(){
		jQuery(this).stop().animate({
			backgroundPosition: '0px -150px'
		}, 400);
	});
}
jQuery(window).ready(function(){
	if (!mobileDevice){
		jQuery('.subFeatureBox').each(function(){
			if (isIE6){
				jQuery(this).css("height", "220px");
			} else {
				jQuery(this).css("height", "260px");
			}
		});
		jQuery('.subFeatureContent').each(function() {
			if (!isIE6){
				//jQuery(this).prepend('<div class="subFeatureContentGradient"></div>');
				jQuery(this).mouseenter(function(){
					jQuery(this).children('.subFeatureContentGradient').stop().animate({
						opacity:0.1
					}, 500);
				});
				jQuery(this).mouseleave(function(){
					jQuery(this).children('.subFeatureContentGradient').stop().animate({
						opacity:0
					}, 500);
				});
			}
			
			var sfID = jQuery(this).attr('ID').split("_");
			switch (sfID[1]){
				case "1":
					jQuery("#"+sfID[0]+"_1").css("top", subFeaturePosition[1]);
					break;
				case "2":
					jQuery("#"+sfID[0]+"_2").css("top", subFeaturePosition[2]);
					break;
				case "3":
					jQuery("#"+sfID[0]+"_3").css("top", subFeaturePosition[3]);
					break;
			}
		});
	}
});





