if (document.domain!='localhost' && document.domain!='www.dev') {
    document.domain = "emc.com";
}

var isPage10=false;


	var isActive=false;

        var slideTime=1;
        var slideAnims={};
        var slideAnims2={};

        function isNumberKey(ev) {
            if (ev==undefined) {
              enableControls();
              return false; // catch for rare IE8 bug where event is undefined
            } else {
              Event.extend(ev);
              var charCode = (ev.which) ? ev.which : ev.keyCode;
              if ((charCode >= 96 && charCode <= 105) || (charCode >= 48 && charCode <= 57)) {
		enableControls();
		return true;
              } else {
		return false;
	      }
            }
        }

        var changeTimer=0;
        function startChangeTimer() {
	  if (isActive) {
	    if ($('tooltip').getOpacity()==1 && $('capacity').value!='') {
	      toolTipJS('hideintro');
	    }
            clearTimeout(changeTimer);
	    var temp=$('capacity').value;
	    var tempArray=[];
	    for (i=0;i<temp.length;i++) {
		tempArray[i]=temp.charAt(i);
	    }
	    tempArray.each(function(el,ix){
	        if (tempArray[ix]=='0' || tempArray[ix]=='1' || tempArray[ix]=='2' || tempArray[ix]=='3' || tempArray[ix]=='4' || tempArray[ix]=='5' || tempArray[ix]=='6' || tempArray[ix]=='7' || tempArray[ix]=='8' || tempArray[ix]=='9' ) {
		    // do nothing
	        } else {
		    tempArray[ix]='';
	        }
	    });
	    $('capacity').value=tempArray.join('');
	    if ($('capacity').value>1000) {$('capacity').value=1000;}
            if ($('capacity').value=='' || $('capacity').value<1) {
              changeTimer=setTimeout(function(){
                toolTipJS('showintro');
              },3000);
            } else {
              changeTimer=setTimeout(calcWithTrack,0.333*1000);
            }
	  }
        }

        function calcWithTrack() {
          setTimeout(function(){trackEvent('event28');},slideTime*1000);
          calc();
        }

        var isDragging=false;
        var startOffset=0;
	var processDragEv=false;
        function startDrag(ev) {
            if (!isDragging && isActive) {
                processDragEv=true;
                startOffset=mouseX(ev)-ev.element().cumulativeOffset().left+ev.element().up().cumulativeOffset().left;
                doDrag(ev);
                isDragging=true;
            }
        }

        function stopDrag(ev) {
            if (isDragging && isActive) {
                processDragEv=false;
                isDragging=false;
                if ($('capacity').value!='') {
                  trackEvent('event29');
                  calc();
                }
            }
        }

        function doDrag(ev,doAnim) {
	    if (doAnim==undefined) {doAnim=false;}
            var obj = $$('#sliderControl .handle').first();
            var mX=mouseX(ev)-startOffset;
            var maxX=obj.up().getWidth()-obj.getWidth();
            if (mX<0) {
                mX=0;
            } else if (mX>maxX) {
                mX=maxX;
            }
            obj.style.left = mX+'px';
            if ($('capacity').value=='') {
              toolTipJS('showintro');
            } else {
              calc(doAnim);
            }
        }

        function barClick(ev) {
            if (isActive) {
	      startOffset=-10
		+($$('#sliderControl .handle').first().getWidth()/2)
		+ev.element().cumulativeOffset().left
		+((BrowserDetect.browser!='Opera')?((document.viewport.getDimensions().width-$(document.body).getWidth())/2):0)
		-$(document.body).positionedOffset().left;
              trackEvent('event29');
	      doDrag(ev,true);
	    }
        }

        function touchMove(ev) {
            if (isActive) {
	      doDrag(ev);
	    }
            ev.preventDefault(); // iphone -- prevent scrolling on this element
        }

        function mouseX(evt) {
	    var val;
	    if (evt.changedTouches==undefined) {
                if (!evt) { evt = window.event; }
                if (evt.pageX) {
		    val = evt.pageX;
                } else if (evt.clientX) {
                    val = evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
                } else {
                    val = 0;
                }
            } else {
                val = evt.changedTouches[0].pageX;
            }
	    return val-((BrowserDetect.browser=='Opera')?10:0)-((BrowserDetect.browser=='Explorer')?10:0);
        }

        var barMin=10;
        var barMaxTravel=110;
        function doBar(el,perc,fullVal,doTween) {
            el.writeAttribute('fullVal',fullVal);
            el.writeAttribute('perc',perc);
            var newHeight=barMin+(perc*barMaxTravel);
            var changeAmt=Math.abs(el.select('.barTop').first().getHeight()-newHeight);
            if (slideAnims[el.id]!=undefined) { slideAnims[el.id].cancel(); }
            if (slideAnims2[el.id]!=undefined) { slideAnims2[el.id].cancel(); }
            if (doTween) {
                var slideTimeAdjusted=slideTime;
                slideAnims[el.id]=new Effect.Morph(el.select('.barTop').first(),{
                    style: {
                        top: Math.round(newHeight)+'px'
                    },
                    duration: slideTimeAdjusted,
                    fps: 30,
                    afterUpdate: function() {
                      update(el);
                    },
                    transition: Effect.Transitions.Quad.easeInOut
                });
                slideAnims2[el.id]=new Effect.Morph($('valueHolder'+el.id),{
                    style: {
                        width: Math.round(fullVal*Math.abs(1-perc)*100)+'px'
                    },
                    duration: slideTimeAdjusted,
                    fps: 30,
                    transition: Effect.Transitions.Quad.easeInOut
                });
            } else {
                el.select('.barTop').first().style.top=newHeight+'px';
		$('valueHolder'+el.id).style.width=(fullVal*perc)+'px';
            }
        }

        function roundVal(inVal) {
          if (inVal<10) {
            inVal=(Math.round(inVal*100)/100);
          } else if (inVal>10 && inVal<100) {
            inVal=(Math.round(inVal*100)/100);
          } else {
            inVal=Math.round(inVal);
          }
          return inVal;
        }

        function update(el) {

            try {

              var currentVal=roundVal(parseInt($('valueHolder'+el.id).style.width)/100);

              var barTopPos=parseInt(el.select('.barTop').first().getStyle('top').replace('px','')); // yes i know this is wacky, weird bug in ff? can't use .style.top
              el.select('.barBot').first().style.height=(el.up().getHeight()-barTopPos-(barMaxTravel/2))+'px';
              el.select('.barLabel').first().update(currentVal+' '+$('unit').value);
              el.select('.barLabel').first().style.height=((el.up().getHeight()-barTopPos-(barMaxTravel/2)+(barMin*2))/2)+'px';
              if (el.select('#barDiffLabel').length>0) {
                  var tempValEMC=parseInt($('valueHolderbarEMC').style.width)/100;
                  var tempValAlt=parseInt($('valueHolderbarAlt').style.width)/100;
                  $('barDiffLabel').update(roundVal(tempValAlt-tempValEMC)+' '+$('unit').value+' '+labelLess);
                  $('barDiffLabel').setStyle({'top':((barTopPos/2)-(barMin/2))+'px'});
                  var tempPercLower=(1-(roundVal(tempValEMC)/roundVal(tempValAlt)))*100;
                  tempPercLower=Math.max(20,Math.round(tempPercLower));
                  if (tempPercLower<1000 && tempPercLower>0) {
                  // do nothing
                  } else {
                    tempPercLower=0;
                  }
                  $('resultsTextHead').update(labelResultsText.split('<span>').join('<span>'+tempPercLower+'% '));
              }

              } catch(err) {
                //do nothing, this is just a quick and dirty fix for IE6 errors introduced in rushed changes to form
              }
        }

        function updateBothBars(){

          //hide intro tooltip if visible
          if ($('tooltip').getOpacity()==1 && $('capacity').value!='' && !ttIsOn) {
            toolTipJS('hideintro');
          }

          update($('barEMC'));
          update($('barAlt'));
        }

        var labelNAS='';//$('sliderReadoutNAS').innerHTML;
        var labelSAN='';//$('sliderReadoutSAN').innerHTML;
        var labelLess='';//$('barDiffLabel').innerHTML;
        var labelResultsText='';//$('resultsTextHead').innerHTML;

	var overlayRemoveDelay=0.5;

	var sliderVal;

        var updateInt;

        function calc(doAnim) {
            if (doAnim==undefined) { doAnim=true; }

	    //reveal if first time with data
	    if (overlayRemoveDelay==0.5) {
	      $$('.barTop').each(function(el,ix){
		new Effect.Morph(el,{
		  style: {top:'145px'},
		  duration: overlayRemoveDelay
		});
	      });
	      $$('.barBot').each(function(el,ix){
		new Effect.Morph(el,{
		  style: {height:'10px'},
		  duration: overlayRemoveDelay,
                  afterFinish: function() {
                    updateInt=setInterval(updateBothBars,33);
                  }
		});
	      });
	      new Effect.Opacity($('barsBoxFader'),{
		duration: overlayRemoveDelay,
		delay: overlayRemoveDelay,
		from: 0.8,
		to: 0,
		afterFinish: function() {
		  $('barsBoxFader').remove();
		}
	      });
	      new Effect.Opacity($('sliderFader'),{
		duration: overlayRemoveDelay,
		delay: overlayRemoveDelay,
		from: 0.8,
                to: 0,
		afterFinish: function() {
		  $('sliderFader').remove();
		}
	      });
	      new Effect.Opacity($('resultsTextInitial'),{
		duration: overlayRemoveDelay,
		to: 0,
		afterFinish: function() {
		  $('resultsTextInitial').style.display='none';
		  $('resultsText').setOpacity(0).style.display='block';
		  new Effect.Opacity($('resultsText'),{
		    duration: overlayRemoveDelay,
		    to: 1
		  });
		}
	      });
	    }

            sliderVal=100*(parseInt($$('#sliderControl .handle').first().style.left)/($('sliderControl').getWidth()-$$('#sliderControl .handle').first().getWidth()));

            $('sliderReadoutNAS').update(100-Math.round(sliderVal)+labelNAS);
            $('sliderReadoutSAN').update(Math.round(sliderVal)+labelSAN);

	    baseVal=$('capacity').value.split(' ').join('');
	//    if (baseVal<1) {
	//	$('capacity').value='';
	//	baseVal=1;
	//    }
	//    if (baseVal=='') {
	//	$('capacity').value=1;
	//	baseVal=1;
	//    }
            //var valEMC=baseVal*1.47; // USING FLAT 47% INCREASE NOW getValueInRange('cap',baseVal);
	/* UPDATED 030311 */
            var valEMC=baseVal*1.61; // USING FLAT 61% INCREASE 
            var valAlt=valEMC*getValueInRange('mix',Math.round(sliderVal));

            setTimeout(function(){
              doBar($('barEMC'),Math.abs((valEMC/valAlt)-1),valAlt,1);
              doBar($('barAlt'),0,valAlt,1);
            },overlayRemoveDelay*1000);

	    overlayRemoveDelay=0;

        }

	//calc math
	var valuesTables={};
	//valuesTables['cap']={max:1000,values:[]};
	//valuesTables['cap']['values'][0]    =0;
	//valuesTables['cap']['values'][2]    =2.72;
	//valuesTables['cap']['values'][5]    =6.7;
	//valuesTables['cap']['values'][10]   =13.3;
	//valuesTables['cap']['values'][20]   =26.6;
	//valuesTables['cap']['values'][50]   =66.5;
	//valuesTables['cap']['values'][100]  =133;
	//valuesTables['cap']['values'][200]  =266;
	//valuesTables['cap']['values'][500]  =665;
	//valuesTables['cap']['values'][1000] =1330;

	//valuesTables['mix']={max:100,values:[]};
	//valuesTables['mix']['values'][0]   =1.244;
	//valuesTables['mix']['values'][10]  =1.26;
	//valuesTables['mix']['values'][20]  =1.29;
	//valuesTables['mix']['values'][30]  =1.33;
	//valuesTables['mix']['values'][40]  =1.38;
	//valuesTables['mix']['values'][50]  =1.44;
	//valuesTables['mix']['values'][60]  =1.51;
	//valuesTables['mix']['values'][70]  =1.60;
	//valuesTables['mix']['values'][80]  =1.75;
	//valuesTables['mix']['values'][90]  =1.86;
	//valuesTables['mix']['values'][100] =2;
	
	/* UPDATED 030311 */
	valuesTables['mix']={max:100,values:[]};
	valuesTables['mix']['values'][0]   =1.33;
	valuesTables['mix']['values'][10]  =1.40;
	valuesTables['mix']['values'][20]  =1.47;
	valuesTables['mix']['values'][30]  =1.54;
	valuesTables['mix']['values'][40]  =1.61;
	valuesTables['mix']['values'][50]  =1.66;
	valuesTables['mix']['values'][60]  =1.72;
	valuesTables['mix']['values'][70]  =1.78;
	valuesTables['mix']['values'][80]  =1.85;
	valuesTables['mix']['values'][90]  =1.85;
	valuesTables['mix']['values'][100] =1.85;

	function getValueInRange(whichRange,inValue) {
		if (valuesTables[whichRange]['values'][inValue]==undefined) {
			maxCapacity=valuesTables[whichRange]['max'];
			outVal=0;
			lowVal=inValue;
			highVal=inValue;
			while(valuesTables[whichRange]['values'][lowVal]==undefined && lowVal>0) {
				lowVal--;
			}
			while(valuesTables[whichRange]['values'][highVal]==undefined && highVal<maxCapacity) {
				highVal++;
			}
			diff=inValue-lowVal;
			perc=diff/(highVal-lowVal);
			valDiff=valuesTables[whichRange]['values'][highVal]-valuesTables[whichRange]['values'][lowVal];
			outVal=valuesTables[whichRange]['values'][lowVal]+(valDiff*perc);
		} else {
			outVal=valuesTables[whichRange]['values'][inValue];
		}
		return outVal;
	}


        // tooltips
        // mouseenter/mouseleave support for non-ie browsers, use "addEvent" to add events
        function addEvent(_elem, _evtName, _fn, _useCapture) { if (typeof _elem.addEventListener != 'undefined'){ if (_evtName === 'mouseenter') { _elem.addEventListener('mouseover', mouseEnter(_fn), _useCapture); } else if (_evtName === 'mouseleave') { _elem.addEventListener('mouseout', mouseEnter(_fn), _useCapture); } else { _elem.addEventListener(_evtName, _fn, _useCapture); } } else if (typeof _elem.attachEvent != 'undefined'){ _elem.attachEvent('on' + _evtName, _fn); } else { _elem['on' + _evtName] = _fn; } }
        function mouseEnter(_fn){return function(_evt){var relTarget = _evt.relatedTarget;if (this === relTarget || isAChildOf(this, relTarget)){ return; }_fn.call(this, _evt);}};
        function isAChildOf(_parent, _child){if (_parent === _child) { return false; }while (_child && _child !== _parent){ _child = _child.parentNode; }return _child === _parent;}

        var ttIsOn=false;
        var ttEffect;
        function toolTipJS(ev) {
            var evTargEl;
            if (ev=='showintro' || ev=='hideintro') {
                evTargEl=$('intro');
            } else {
	      if (ev.changedTouches==undefined) {
		evTargEl=Event.extend(ev).element();
	      } else {
		evTargEl=ev.changedTouches[0];
	      }
            }
            if (touchTTIsOn || ev.type=='mouseover' || ev.type=='mouseenter' || ev=='showintro') {
		var offLeft=(BrowserDetect.browser=='Opera')?((document.viewport.getDimensions().width-$(document.body).getWidth())/2)-10:0;
                if (ev=='showintro') {
                    $('tooltipContent').update(evTargEl.innerHTML);
                    $('tooltip').clonePosition($('capacity'),{setLeft:true,setTop:true,setWidth:false,setHeight:false,offsetLeft:($('tooltip').getWidth()/-2)+($('capacity').getWidth()/2)-offLeft,offsetTop:15});
                } else {
                    $('tooltipContent').update(evTargEl.up('.stepBox').select('.tooltip').first().innerHTML);
                    $('tooltip').clonePosition(evTargEl,{setLeft:true,setTop:true,setWidth:false,setHeight:false,offsetLeft:-118+(evTargEl.getWidth()/2)-offLeft,offsetTop:20});
                }

                $('tooltip').setStyle({
                    display: 'block'
                });
                ttIsOn=true;
                if (ttEffect!=undefined) {
                    ttEffect.cancel();
                }
                ttEffect=new Effect.Opacity($('tooltip'),{
                    duration: 0.25,
                    to: 1
                });
            } else {
                ttIsOn=false;
                if (ttEffect!=undefined) {
                    ttEffect.cancel();
                }
                ttEffect=new Effect.Opacity($('tooltip'),{
                    duration: 0.25,
                    to: 0,
                    afterFinish: function() {
                        if (!ttIsOn) {
                            $('tooltip').setStyle({
                                display: 'none'
                            });
                        }
                    }
                });
            }
        }

	var touchTTIsOn=false; // special var used only for tracking click-triggered tooltips (primarily for iPhone, gPhone)

        function showIntro() {
            setTimeout(function(){toolTipJS('showintro')},1000);
        }

	function enableControls() {
            if (!isActive) {
              //var URL1=$('m1TrackingURL').innerHTML;
              //URL1=URL1.split('&amp;').join('&');
              //URL1=URL1.split('[[EMAIL]]').join(userEmail);
              //$('contactHiddenIframe').src=URL1;
              isActive=true;
              $('unit').disabled=false;
            }
	}

	function calcCleanup() {
	    toolTipJS('hideintro');
	}

        // init -- called by form return func
        var hasInitted=false;
        function calcInit() {

          if (!hasInitted) {

	    Event.observe($$('#sliderControl .handle').first(),'touchstart',function(ev){
		startDrag(ev);
		ev.stop();
	    });
	    Event.observe($$('#sliderControl .handle').first(),'touchmove',touchMove);

	    Event.observe($$('#sliderControl .handle').first(),'mousedown',function(ev){
		startDrag(ev);
		ev.stop();
	    });
	    Event.observe(document,'mouseup',stopDrag);

	    Event.observe($('sliderControl'),'mousedown',barClick);

	    Event.observe($('capacity'),'keydown',isNumberKey);
	    //$('capacity').onkeydown=isNumberKey;
	    Event.observe($('capacity'),'keyup',startChangeTimer);
	    Event.observe($('unit'),'change',function(){
              if ($('capacity').value=='') {
                toolTipJS('showintro');
              } else {
                calc();
              }
            });

	    Event.observe(document,'mousemove',function(ev){if (processDragEv) {doDrag(ev);}});

            if ($('showGuarantee')) {
		Event.observe($('showGuarantee'),'click',function(ev){ //show Guarantee content on sweeps page only
		    $('guaranteeText').style.display='block';
		    $('showGuarantee').style.display='none';
		    ev.stop();
		});
	    }

	    //grab and store text for display updates
	    labelNAS=$('sliderReadoutNAS').innerHTML;
	    labelSAN=$('sliderReadoutSAN').innerHTML;
	    labelLess=$('barDiffLabel').innerHTML;
	    $('barDiffLabel').innerHTML=''; // clear for initial display
	    labelResultsText=$('resultsTextHead').innerHTML.split('<SPAN>').join('<span>').split('</SPAN>').join('</span>');

	    $('valueHolderbarEMC').wrap('div', { 'class': 'valueHolderHider' });
	    $('valueHolderbarAlt').wrap('div', { 'class': 'valueHolderHider' });
	    $('valueHolderbarEMC').style.width='0px';
	    $('valueHolderbarAlt').style.width='0px';

            $('capacity').value='';

	    // add tooltip, related events
	    $(document.body).insert({top:'<div id="tooltip"><div class="ttTop"></div><div class="ttMid"><div id="tooltipContent"></div></div><div class="ttBot"></div></div>'});
	    $('tooltip').setOpacity(0);
	    $$('.iButton').each(function(el,ix) {
		addEvent(el,'mouseenter',function(ev) {
		  touchTTIsOn=false;
		  toolTipJS(ev);
		});
		addEvent(el,'mouseleave',function(ev) {
		  if (!touchTTIsOn) {
		      toolTipJS(ev);
		  }
		});
		el.observe('mouseup',function(ev) {
		  touchTTIsOn=true;
		  toolTipJS(ev);
		});
	    });
	    Event.observe(document,'mousedown',function(ev) {
	      if (touchTTIsOn) {
		touchTTIsOn=false;
		toolTipJS(ev);
	      }
	    });
	    Event.observe(document,'touchstart',function(ev) {
		touchTTIsOn=false;
		toolTipJS(ev);
	    });
	    $('barsBoxFader').clonePosition($('barsBox'));
	    $('sliderFader').clonePosition($$('.slider').first());
	    $$('#sliderControl .handle').first().style.left=(($('sliderControl').getWidth()/2)-($$('#sliderControl .handle').first().getWidth()/2))+'px';
	    $('unit').disabled=true;
	    showIntro();

            hasInitted=true;

          }

	    toolTipJS('showintro');

	}


/* PAGE REVEAL JS */

//    //catch to prevent JS error, M1 form was calling this when it shouldn't be, need to keep it quiet
//    function openWindow(inEmail) {
//	// do nothing
//    }

  var contactClicked=false;
  var userEmail;
  function unlockContent(inEmail) {
    if (hasOpenedAnOverlay) { //prevents Firefox trying to unlock content on a reload since it doesn't reset iframe URLs
        preFormSubmitted=true;
	userEmail=inEmail;
	if (!isPage10) {
	    $$('#'+cOverlay+' .beforeContent').each(function(el,ix) { el.style.display='none'; });
	    $(cOverlay.split('the').join('formIframe')).style.display='none';
	    $$('#'+cOverlay+' .afterContent, #'+cOverlay+' .formAfterContent').each(function(el,ix) { el.style.display='block'; });
	    //insert email into URLS
	    $$('#'+cOverlay+' a.addEmailLinks').each(function(el,ix){
		el.href=el.href.split('[[EMAIL]]').join(inEmail);
	    });
	    $$('#'+cOverlay+' div.addEmailLinks').each(function(el,ix){
		el.innerHTML=el.innerHTML.split('[[EMAIL]]').join(inEmail);
	    });
	} else {
	    $('formIframe').style.display='none';
	    $$('.beforeContent').each(function(el,ix) { el.style.display='none'; });
	    $$('.afterContent').each(function(el,ix) { el.style.display='block'; });
	    $$('.formAfterContent').each(function(el,ix) { el.style.display='block'; });
	    //insert email into URLS
	    $$('a.addEmailLinks').each(function(el,ix){
		el.href=el.href.split('[[EMAIL]]').join(inEmail);
	    });
	}
	// track
	switch (cOverlay) {
	    case 'theSweeps':
		trackEvent('event27');
		break;
	    case 'theWhitepaper':
		trackEvent('event30');
		break;
	    default:
	}
	if (isPage10) { trackEvent('event30'); }
    }
  }

// TRACKING

  function trackEvent(eventName) {
    try {
      s.events=eventName;
      s.linkTrackEvents=eventName;
      s.t();
    } catch(err) {}
    try {
      console.log('TRACK EVENT: '+eventName);
    } catch(err) {}
  }

// FORM IFRAME RESIZING

  function resizeIframe(toHeight) {
    toHeight-=45; // fix for extra space from market first
      if (!isPage10) {
	new Effect.Morph($(cOverlay.split('the').join('formIframe')),{
          duration: 0.5,
          style: {
              height: (toHeight+30)+'px'
          }
	});
      } else {
	new Effect.Morph($('formIframe'),{
          duration: 0.5,
          style: {
              height: (toHeight+30)+'px'
          }
	});
      }
  }

// bypass reg for internal use using URL ending in ?bypass-reg
//Event.observe(window,'load',function() {
//  if (window.location.href.indexOf('bypass-reg')>=0) {
//    unlockContent('BYPASS');
//  }
//});
//

// reset all iframe URLs on page load to prevent Firefox triggering unlockContent on page load
document.observe("dom:loaded", function() {
    $$('.iframeBox iframe').each(function(el,ix) {
	el.src='/images/common/spacer.gif';
    });
});

/* NIGHTSHADE/OVERLAY SCRIPTS */

var hasOpenedAnOverlay=false; // for tracking whether an overlay has been opened, used to prevent Firefox unlocking content after a reload

Event.observe(window,'load',function(){
	$(document.body).insert({
		top: '<div id="nightShade"></div><div id="nightShadeContainer"><table id="nightShadeContainerInner" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" valign="top"><div id="nightShadeContainerInnerCollapser"><div id="nscTL"><div id="nscTR"></div></div><div id="sideL"><div id="sideR"><div id="nightShadeContainerContent"></div><div id="nightShadeClose"><img src="/images/products/unified-storage/new-aug10/close.gif" width="18" height="19" border="0" /></div><div class="clearBothTight"></div></div><div class="clearBothTight"></div></div><div id="nscBL"><div id="nscBR"></div></div></td></tr></table></div></div>'
	});
	$('nightShadeContainerContent').update($('overlayContent').innerHTML);
	$('overlayContent').remove();
	$('nightShade').observe('click',overlayRemove);
	$('nightShadeClose').observe('click',overlayRemove);
	$('nightShadeContainer').observe('click',overlayRemoveWrapper);
	$('nightShade').setOpacity(0);
	$('nightShadeContainer').setOpacity(0);
        if (BrowserDetect.browser=='Explorer') {
                if (BrowserDetect.version==7) { // needed for ie7 only
                        $('nightShade').setOpacity(0);
                        //$('overlayImage').setOpacity(0);
                } else if (BrowserDetect.version==6) { // needed for ie6 only
                        $('nightShade').style.position='absolute';
                        //$('overlayImage').style.position='absolute';
                        Event.observe(window,'resize',nightShadeUpdate);
                        Event.observe(window,'scroll',nightShadeUpdate);
                        nightShadeUpdate();
                }
        }
});
var cOverlay='';
var preFormSubmitted=false;
function openOverlay(which) {
    if (cOverlay!=which && $('nightShade')!=null) {
	hasOpenedAnOverlay=true;
	if (cOverlay=='') {
	    $('nightShade').setOpacity(0);
	    $('nightShadeContainer').setOpacity(0);
	}
	cOverlay=which;
	try{toolTipJS('hideintro');}catch(err){}
	$$('.overlayPage').each(function(el,ix) {
	    if (el.id==which) {
		el.style.display='block';
		el.style.visibility='visible';
		if (cOverlay!='theCalc') {
		    if (!el.hasClassName('iframeIsNotBlank')) {
			el.addClassName('iframeIsNotBlank');
			    var iframeID=el.id.split('the').join('formIframe');
			    if ($(iframeID)) {
				if (!preFormSubmitted || cOverlay=='theContact') {
				    $(iframeID).src=el.select('.iframeURLpre').first().innerHTML.split('&amp;').join('&');
				} else {
				    unlockContent(userEmail);
				    $(iframeID).src=el.select('.iframeURLpost').first().innerHTML.split('&amp;').join('&');
				}
			    }
		    }
		}
	    } else {
		el.style.display='none';
		el.style.visibility='hidden';
	    }
	});
	$('nightShade').style.display='block';
	$('nightShadeContainer').style.display='block';
	new Effect.Parallel(
	    [
		new Effect.Opacity($('nightShade'),{
		    duration: 0.6,
		    to: 0.6
		}),
		new Effect.Opacity($('nightShadeContainer'),{
		    duration: 0.6,
		    to: 1,
		    afterFinish: function() {
			$('nightShadeContainer').style.filter='';
		    }
		})
	    ],
	    {
		fps: 30,
		sync: true
	    }
	);
	//inits as needed based on which
	switch (which) {
	    case 'theCalc':
                trackEvent('event38');
		if ((BrowserDetect.browser=='Explorer') && (BrowserDetect.version==6)) {
		    $('sideR').style.marginRight='9px'; /* fix layout issue on overlay border */
		} else {
		    $('sideR').style.marginRight='0px'; // un-fix layout issue on overlay border */
		}
		calcInit();
		break;
            case 'theSweeps':
                trackEvent('event39');
		$('sideR').style.marginRight='0px'; // un-fix layout issue on overlay border
                break;
            case 'theWhitepaper':
                trackEvent('event40');
 		$('sideR').style.marginRight='0px'; // un-fix layout issue on overlay border
               break;
	    default:
	}
    }
}
function overlayRemove() {
    switch (cOverlay) {
	case 'theCalc':
	    calcCleanup();
	    break;
	default:
    }
    cOverlay='';
    new Effect.Parallel(
	[
	    new Effect.Opacity($('nightShade'),{
		duration: 0.6,
		to: 0
	    }),
	    new Effect.Opacity($('nightShadeContainer'),{
		duration: 0.6,
		to: 0,
		afterFinish: function() {
		    $('nightShade').style.display='none';
		    $('nightShadeContainer').style.display='none';
		    $('nightShade').style.filter='';
		    $('nightShadeContainer').style.filter='';
		    $$('.overlayPage').each(function(el,ix) {
			el.style.display='none';
		    });
		}
	    })
	],
	{
	    fps: 30,
	    sync: true
	}
    );
}
function overlayRemoveWrapper(ev) {
    if (ev.element().id=='nightShadeContainer') {
	overlayRemove();
	ev.stop();
    }
}
function nightShadeUpdate() { // needed for ie6 only
    winSize={};
    winSize.width = document.documentElement.clientWidth;
    winSize.height = $(document.body).getHeight();//documentElement.clientHeight;
    //window.alert(winSize.height);
    //winSize=document.viewport.getDimensions();
    if ($('nightShade') ) {
        $('nightShade').style.width=winSize.width+'px';
        $('nightShade').style.height=(winSize.height+100)+'px';
        $('nightShadeContainer').style.width=Math.max(1000,winSize.width)+'px';
        $('nightShadeContainer').style.height=(winSize.height+100)+'px';
        //$('nightShade').style.top=(document.documentElement.scrollTop-50)+'px';
        //$('nightShadeContainer').style.top=(document.documentElement.scrollTop-50)+'px';
        pageFix=document.body.cumulativeOffset();
        $('nightShade').style.left=(0-pageFix.left)+'px';
        $('nightShadeContainer').style.left=(0-pageFix.left)+'px';
    }
}


/* QUOTES */

var cImg;
var quotesList;
var maxImgNum;
var quoteInt;
Event.observe(window,'load',quotesInit);

function quotesInit() {
    cImg=0;
    quotesList = $$('.quotesDiv');
    maxImgNum = $$('.quotesDiv').length-1;
    $$('.quotesDiv').each(function(el,ix) { el.setOpacity(0); el.style.display='none'; });
    $$('.quotesDiv').first().setOpacity(1).style.display='block';
    quoteInt = setInterval(function() { changeQuote(1,false); },60000);
}
function changeQuote(dir,kill) {
    if (kill!=false) { clearInterval(quoteInt); }
    cImg+=dir;
    if (cImg>maxImgNum) { cImg=0;  }
    if (cImg<0) { cImg=maxImgNum; }
    $$('.quotesDiv').each(function(el,ix) {
	if (ix==cImg) {
	    new Effect.Opacity(el,{to:1,delay:0.5,duration:0.5,beforeUpdate:function(){el.style.display='block';}});
	} else {
	    new Effect.Opacity(el,{to:0,duration:0.5,afterFinish:function(){el.style.display='none';}});
	}
    });
}

