// Media Utils

// Globals
var DESC_CONTAINER_ID = "idStrategyDesc";
var PANEL_ID_PRFX = "idPanel";

var PANEL_DESC_0 = "How can we help you exceed your marketing and sales objectives? Scroll over the images above to see how our services can help you and your company achieve breakthrough results.";
var PANEL_DESC_1 = "Market validation is the key to understanding your customer needs and purchasing behavior.  It powers your messaging and positioning, product roadmap, and target market strategy - getting you to market faster.";
var PANEL_DESC_2 = "Make your message matter. Compelling messaging and positioning tells your prospective customers what you do and why it's important to them.  It defines your place in the market and differentiates you from the competition.";
var PANEL_DESC_3 = "Focusing on a specific market niche or segment is the fastest path to market entry and expansion. It paves the way to sustained revenue growth and market leadership.";
var PANEL_DESC_4 = "It's all in the execution.  Optimizing marketing and sales processes generates more qualified opportunities, shortens sales cycles, and maximizes revenue.  It's the ultimate competitive advantage.";

var INTERFRAME_DELAY = 50;
var INTERFRAME_OPACITY_PERCENT_CHANGE = 10;
var REST_OPACITY_PERCENT = 50;

var nDelay;
var nOpacityPercentage;
var sTimeoutMethodPrfx;


/**
 * Show panel and description as per target index
 */
function showPanel( nIndex ) {

  nDelay = 0;
  nOpacityPercentage = REST_OPACITY_PERCENT;
	sTimeoutMethodPrfx = "setPanelOpacity(" + nIndex + ", ";

	document.getElementById(DESC_CONTAINER_ID).innerHTML = eval("PANEL_DESC_" + nIndex);
  
  while (nOpacityPercentage < 100) {
	
		nOpacityPercentage += INTERFRAME_OPACITY_PERCENT_CHANGE;
	  setTimeout(sTimeoutMethodPrfx + nOpacityPercentage + ")", nDelay);
	  nDelay += INTERFRAME_DELAY;
	}
}


/**
 * Hide panel as per target index
 */
function hidePanel( nIndex ) {

  nDelay = 0;
  nOpacityPercentage = 100;
	sTimeoutMethodPrfx = "setPanelOpacity(" + nIndex + ", ";

	document.getElementById(DESC_CONTAINER_ID).innerHTML = PANEL_DESC_0;
  
  while (nOpacityPercentage > REST_OPACITY_PERCENT) {
	
		nOpacityPercentage -= INTERFRAME_OPACITY_PERCENT_CHANGE;
	  setTimeout(sTimeoutMethodPrfx + nOpacityPercentage + ")", nDelay);
	  nDelay += INTERFRAME_DELAY;
	}
}


/**
 * Set target panel to given opacity
 */
function setPanelOpacity( nPanelIndex, nOpacityPercentage ) {
	
  var oPanelStyle = document.getElementById(PANEL_ID_PRFX + nPanelIndex).style;
	var sAdjustedPercentage = (nOpacityPercentage / 100) + "";

  oPanelStyle.filter = "alpha(opacity=" + nOpacityPercentage + ")";
  oPanelStyle.opacity = sAdjustedPercentage;
  oPanelStyle.MozOpacity = sAdjustedPercentage;
  oPanelStyle.setAttribute("-khtml-opacity", sAdjustedPercentage);
}

