var style_cookie_name = "LSS_TS_Style" ;
var style_cookie_duration = 30 ;

function trackFlashEvent (key) {
  if (domn.indexOf ("colgate.com") > -1) {
    s_pageName='/Colgate/MX/PC/Products/WomensDeodorant/TeenSpirit/' + key;
    // Omniture tracking code 
    sendAnalyticsEvent('');
  }
    
  // Google Analytics code
  pageTracker._trackPageview(key);
}

function getGoogleMapsKey () {
  var scKey = "ABQIAAAAmwGKq0bj3BKyNMkKujtWlRRVU-tYpiI8A7hvgZribpoCTb2BNhQd6Lo-_gY_Ek2pBw4svX3CDkqLLA";
  var cpKey = "ABQIAAAA7EgMUSwxsL4-IKDwPHlGixQbBZZ_s4bek5lKvmIPbm8nyd-w5xTJBDJd_04WGkszlSnt67qpTGfZYA";
  var cpKeyProd = "ABQIAAAA7EgMUSwxsL4-IKDwPHlGixTd7WsdJcq6kwxIxTmP69rGMA2qHxQZ0IxgR88Kx8GkVyguYmW8tAyzCQ";
  //var tsKey = "ABQIAAAA7EgMUSwxsL4-IKDwPHlGixQQ8W7Q7w8T7wBw_aKLpgKiGhm0dxSIuZSqAGCJhRRnzA5MqC0KTUs3fQ";
  var domn = document.domain;
  
  var envKey = scKey; 

  if (domn.indexOf ("colgate.com.mx") > -1) {
    envKey = cpKeyProd;
  }  
  else if (domn.indexOf ("colgate.com") > -1) {
    envKey = cpKey;
  }

  
  /* else if (domn.indexOf("teenspirit.com.mx") > -1) {
    envKey = tsKey;
  } */
  
  return envKey;
}
 
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}


function checkBodySize () {
  /* Flash Movie width 680px
     Left pillow width 276px
     Right pillow width 240px
     Total required width 1254*/

  var ver = getInternetExplorerVersion();
  if ((ver != -1 && ver < 7.0) || document.body.clientWidth < 1254) {
     document.getElementById("left_pillow").style.display = "none";
     document.getElementById("right_pillow").style.display = "none";
  } else {
     document.getElementById("left_pillow").style.display = "inline";
     document.getElementById("right_pillow").style.display = "inline";
  }
}

function switch_style ( css_title )
{
  var i, link_tag ;
  for (i = 0, link_tag = document.getElementsByTagName("link"); i < link_tag.length ; i++ ) {
    if ((link_tag[i].rel.indexOf( "stylesheet" ) != -1) && link_tag[i].title) {
      link_tag[i].disabled = true ;
      if (link_tag[i].title == css_title) {
        link_tag[i].disabled = false ;
      }
    }
    set_cookie( css_title );
  }
}
function set_style_from_cookie()
{
  var css_title = get_cookie_style( );
  if (css_title.length > 0) {
    switch_style( css_title );
  }
}

function set_cookie ( cookie_value, valid_domain )
{
	set_cookie_general(style_cookie_name, cookie_value, valid_domain);
}

function set_cookie_general ( cookie_name, cookie_value, valid_domain )
{
  var domain_string = valid_domain ? ("; domain=" + valid_domain) : '' ;
  document.cookie = cookie_name +
                    "=" + encodeURIComponent( cookie_value ) +
                    "; max-age=" + 60 * 60 *
                    24 * style_cookie_duration +
                    "; path=/" + domain_string ;
}

function get_cookie_style()
{
  return get_cookie_general(style_cookie_name);
}

function get_cookie_general ( cookie_name )
{
  var allCookies = document.cookie.split(';') ;
  for (var i = 0; i < allCookies.length; i ++) {
    var tempCookieHolder = allCookies[i].split('=');
    tempCookieHolder[0] = tempCookieHolder[0].replace(/^\s+|\s+$/g, ''); 
    if (tempCookieHolder[0] == cookie_name && tempCookieHolder.length > 1) {
      return unescape( tempCookieHolder[1].replace(/^\s+|\s+$/g, '') );
    }
  }
  
  return '' ;
}
