var GE_config = {
  GE_baselink:"./",
  GE_offleftClass:"GECSoffleft",
  GE_flash1: {
    GE_tag: "h1",
    GE_swf: "./swf/GE_Inspira_Medium.swf",
    GE_swfVars: {
      GE_color:"333333", // Unit : Hexadecimal
      GE_leading: -1,
      GE_fontsize: 20  //Unit : pixel
    }
  },
  GE_flash2: {
    GE_tag: "h2:eq(1)",
    GE_swf: "./swf/GE_Inspira.swf",
    GE_swfVars: {
      GE_color:"505060",  // Unit : Hexadecimal
      GE_leading: 8,
      GE_fontsize: 13   //Unit : pixel
    }
  }
}


jQuery.fn.hoverClass = function(c) {
  return this.each(function(){
    jQuery(this).hover( 
      function() { jQuery(this).addClass(c); },
      function() { jQuery(this).removeClass(c); }
    );
  });
};

function GE_show(elt) {
  targetNodesSize = jQuery(elt).size();
  if (targetNodesSize < 1) { return 0; }
  jQuery(elt).each(
    function() {
      if (jQuery(this).is("."+GE_config.GE_offleftClass)) {
        jQuery(this).removeClass(GE_config.GE_offleftClass);
      }
    }
  );
  return targetNodesSize;
}

function GE_hide(elt) {
  targetNodesSize = jQuery(elt).size();
  if (targetNodesSize < 1) { return 0; }
  jQuery(elt).each(
    function() {
      if (jQuery(this).not("."+GE_config.GE_offleftClass)) {
        jQuery(this).addClass(GE_config.GE_offleftClass);
      }
    }
  );
  return targetNodesSize;
}

function GE_ieHack() {
  if (!jQuery.browser.msie) { return 0; }
  jQuery("#GECSMenu li").hoverClass("sfhover");
  jQuery("#GECSLanguageList").bgiframe();
  jQuery("#GECSFooter > ul > li").each(
    function(i) {
      if (i != 0) {
        jQuery(this).prepend("<span class=\"before\">|</span>");
      }
    }
  );
  return 1;
}

function GE_GECSTable() {
  var GECSTable = jQuery(".GECSLeftColumn .GECSTable");
  if (jQuery(GECSTable).size() < 1) { return 0; }
  jQuery(GECSTable).each(
    function() {
      var GECSTableTextLnks = jQuery("a:eq(1)",this), GECSTableTextImg = jQuery("img", this);
      if (jQuery(GECSTableTextLnks).size() > 0) {
          var padd = Math.ceil( (jQuery(this).height() - jQuery(GECSTableTextLnks).height()) / 2 -1);
          jQuery(GECSTableTextLnks).css("padding", padd + "px 3px 0 3px");
      }
    }
  );
  return 1;
}


function GE_sIFR(targetNode, targetSwf, targetStyle) {
  if (jQuery(targetNode).size() < 1) { return false; }
  swfWidth = jQuery(targetNode).width();
  swfHeight = jQuery(targetNode).height() + 6;
  return  jQuery(targetNode).flash({src:targetSwf, width:swfWidth, height:swfHeight, flashvars: {gridfittype:"pixel", zoomsupport:"false", opacity:"100", kerning:"true", lines:"1", zoom:"100", selectable:"true", content:jQuery(targetNode).get(0).innerHTML, width:swfWidth, height:swfHeight, css:targetStyle[0], size:targetStyle[1] }});
}

function GE_customerArea() {
  var selects = jQuery("#GECSCustomerArea").find("select");
  if (jQuery(selects).size() < 1) { return 0; }
  submiters = jQuery("#GECSCustomerArea").find("input");
  jQuery(submiters).each(
    function() {
      if (jQuery(this).attr("type") == "image") {
        GE_hide(jQuery(this));
      }
    }
  );
  jQuery(selects).each(
    function() {
      jQuery(this).css({width:"164px",margin:"0"});
      jQuery(this).change(
        function() {
          curIndex = jQuery(this).get(0).selectedIndex;
          curValue = jQuery(this).get(0).options[curIndex].value;
          if ((curIndex > 0) || (curValue != "")) {
            switch(curValue.substr(0,1)) {
              case "#" :
                hideSelects = GE_hide("#GECSCustomerArea .GECSadditionalOption");
                showTargetSelect = GE_show(curValue);
              break;
              default :
                //document.location.href = curValue;
			    if (curValue > ""){
					window.open(curValue);
			    }
              break;
            }
          }
        }
      );
    }
  );
  return 1;
}

function GE_countryMenu() {
  if (jQuery("#GECSLanguage").size() < 1) { return 0; }
  jQuery("#GECSLanguage").hover(
    function() {
      jQuery(this).removeClass("languageButtonOff").addClass("languageButtonOn");
      languageList = GE_show("#GECSLanguageList");
    }, function() {
      jQuery(this).removeClass("languageButtonOn").addClass("languageButtonOff");
      languageList = GE_hide("#GECSLanguageList");
    }
  );
  jQuery("#GECSLanguageList > ul > li > ul").each(
    function() {
      jQuery("a:last",this).css("border","0");
    }
  );
  return 1;
}

function GE_subMenu() {
  if (jQuery("#GECSnav").size() < 1) { return 0; }
    jQuery("#GECSnav > li > ul").each(
      function() {
        var curPage = jQuery(this).find("strong");
        if (jQuery(curPage).size() < 1) {
          jQuery(this).addClass("GECSoffleft");
        }
        else {
          jQuery(this).addClass("GECSactiveSubMenu");
        }
        if (jQuery(this).parent().children("strong").size() > 0) {
          jQuery("> ul",jQuery(this).parent()).removeClass("GECSoffleft");
        }
      }
    );
    jQuery("#GECSnav > li > ul > li").each(
      function() {
        var curPage = jQuery(this).find("strong");
        if (jQuery(curPage).size() < 1) {
          jQuery("> ul",jQuery(this)).addClass("GECSoffleft");
        }
      }
    );
    return 1;
}

jQuery(document).ready(
  function() {

    // Initialize Internet Explorer Hack
    ie6 = GE_ieHack();
    tables  = GE_GECSTable();

    // sIFR
   // headerTitle = GE_sIFR(GE_config.GE_flash1.GE_tag, GE_config.GE_flash1.GE_swf, Array(".sIFR-root%7Bfont-size%3A" + GE_config.GE_flash1.GE_swfVars.GE_fontsize + "px%3Bcolor%3A#" + GE_config.GE_flash1.GE_swfVars.GE_color + "%3Bleading%3A" + GE_config.GE_flash1.GE_swfVars.GE_leading + "%3B%7B",GE_config.GE_flash1.GE_swfVars.GE_fontsize));
   // headerTitleDescription = GE_sIFR(GE_config.GE_flash2.GE_tag, GE_config.GE_flash2.GE_swf, Array(".sIFR-root%7Bfont-size%3A" + GE_config.GE_flash2.GE_swfVars.GE_fontsize + "px%3Bcolor%3A#" + GE_config.GE_flash2.GE_swfVars.GE_color +"%3Bleading%3A" + GE_config.GE_flash2.GE_swfVars.GE_leading + "%3B%7D",GE_config.GE_flash2.GE_swfVars.GE_fontsize));

    // Customer Area Shortcut links
   shortcutLinks = GE_customerArea();

    // Country Menu
    countryMenu = GE_countryMenu();

    // subMenu
    subMenu = GE_subMenu();

  }
);
