function ShowValidationSummary() {
  Page_ClientValidate();
  if (!Page_IsValid) {
    document.getElementById('summaryTable1').style.display = 'block';
    document.getElementById('summaryTable2').style.display = 'block';
  }
  else {
    document.getElementById('summaryTable1').style.display = 'none';
    document.getElementById('summaryTable2').style.display = 'none';
  }
}

$().ready(function() {

  //--ACCORDIONS START
  //hide description on the clickable accordions
  $(".jQaccordion .description").not($(".expandedOnLoad").parent().find(".description")).hide();
  //$(".jQaccordion .description").not($(".expandedOnLoad").parent().find(".description")).css("height", "0px");
  $(".expandedOnLoad").parent().addClass("active");

  //showDescription(trigger, closeSelf, severalCanBeOpen, speed);

  $(".accordionmenu .jQtrigger").click(function() {
    showDescription(this, true, false, 250);
    return false;
  });
  $(".keychallenges .jQtrigger").click(function() {
    showDescription(this, true, false, 200);
    return false;
  });
  $(".searchfilter .jQtrigger").click(function() {
    showDescription(this, true, true, 250);
    return false;
  });
  $(".filterwide .jQtrigger").click(function() {
    showDescription(this, true, true, 250);
    return false;
  });
  //--ACCORDIONS END


  //--THICKBOX START
  //hide inline content
  $("#choosecountry").hide();
  //add class to TB_window
  var b2cPresent = false;
  $("#headerbar.b2c").each(function() {
    b2cPresent = true;
  });
  $(".thickbox").click(function() {
    if (b2cPresent == true) {
      $("#TB_window").addClass("b2c");
    }
  });
  //--THICKBOX END


  //--TOOLTIP START
  $(".leftmenu a").hover(function() {
    $(this).parent().find("> .tooltip").show();
  }, function() {
    $(this).parent().find("> .tooltip").hide();
  });
  $(".leftmenu a").mousemove(function(e) {
    $(this).parent().find("> .tooltip").css({
      top: (e.pageY - $(this).parent().find("> .tooltip").height() / 2) + "px",
      left: (e.pageX + 15) + "px"
    });
    $(this).css({ cursor: "pointer" });
  });
  //--TOOLTIP END


  //--JOB SCROLL START
  var scrolldistance = 448;
  var jobscrollpages = $(".jobscroll .searchcontent ul").children().size();
  var currentpage = 0;
  $(".jobscrollbottom").append('<a href="#" class="scrollprevious previousinactive"></a><div class="scrollindicator"><span></span></div><a href="#" class="scrollnext"></a>');
  $(".jobscroll .scrollindicator span").css("width", 10 * jobscrollpages - 2 + "px");
  $(".jobscroll .scrollnext").click(function() {
    jobscroller("forward");
    return false;
  });
  $(".jobscroll .scrollprevious").click(function() {
    jobscroller("back");
    return false;
  });
  function jobscroller(scrolldirection) {
    if (scrolldirection == "forward") {
      currentpage++;
    } else {
      currentpage--;
    }
    if (currentpage < 0) {
      currentpage++;
    } else if (currentpage >= jobscrollpages) {
      currentpage--;
    }
    $(".jobscroll .searchcontent ul").animate({ left: "" + (-(scrolldistance * currentpage)) + "" }, 500);
    if (currentpage == 0) {
      $(".scrollprevious").addClass("previousinactive");
    } else {
      $(".scrollprevious").removeClass("previousinactive");
    }
    if (currentpage == jobscrollpages - 1) {
      $(".scrollnext").addClass("nextinactive");
    } else {
      $(".scrollnext").removeClass("nextinactive");
    }
    $(".jobscroll .scrollindicator span").css("background-position", "left " + ((-(currentpage * 25)) + 15) + "px");
  }
  //--JOB SCROLL END


  //--DROPDOWN MENU START
  $("ul.subnav").parent().find("a span:eq(0)").append("<span class='subnavTrigger'></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

  $("ul.topnav li .subnavTrigger").click(function() { //When trigger is clicked...															
    //Following events are applied to the subnav itself (moving subnav up and down)

    $(this).parent().parent().parent().find("ul.subnav:eq(0)").slideDown('fast').show(); //Drop down the subnav on click
    $(this).parent().parent().parent().addClass("subNavActive");

    $(this).parent().parent().parent().hover(function() {
    }, function() {
      $(this).parent().find("ul.subnav").slideUp(200); //When the mouse hovers out of the subnav, move it back up
      $(this).parent().find("ul.subnav").queue(function() {
        $(this).parent().removeClass("subNavActive");
        $(this).dequeue();
      });
    });
    return false;
    //Following events are applied to the trigger (Hover events for the trigger)
  }).hover(function() {
    $(this).addClass("subhover"); //On hover over, add class "subhover"
  }, function() { //On Hover Out
    $(this).removeClass("subhover"); //On hover out, remove class "subhover"
  });
  //--DROPDOWN MENU END



  //--QUICK LOGIN AND SEARCH START
  $("#searchandlogindrawer > div").each(function() {
    $(this).css("top", -($(this).height() + 25));
  });
  var previousDrawer = "";
  $(".jqQuickSearchAndLoginTrigger a").click(function() {
    $(".jqQuickSearchAndLoginTrigger").not($(this).parent()).removeClass("triggerTrigged");
    $(this).parent().toggleClass("triggerTrigged");
    thisTrigger = $(this).parent().attr("id");
    thisDrawer = thisTrigger.substring(0, thisTrigger.length - 7);
    $("#searchandlogindrawer > div").each(function() {
      if ($(this).position().top > -($(this).height() + 25)) {
        $(this).animate({ top: "" + drawerTopPosition + "" }, 300);
        //$("#searchandlogindrawer").animate( { height:"0px" }, 350 );
      }
    });

    if (thisDrawer != previousDrawer) {
      $("#" + thisDrawer + "").animate({ top: "0px" }, 350);
      previousDrawer = thisDrawer;
      drawerTopPosition = -($("#" + thisDrawer + "").height() + 25);
      $("#searchandlogindrawer").animate({ height: "140px" }, 250);
    } else {
      $("#" + thisDrawer + "").animate({ top: "" + drawerTopPosition + "" }, 350);
      $("#searchandlogindrawer").animate({ height: "0px" }, 350);
      previousDrawer = "";
    }
    return false;
  });
  //--QUICK LOGIN AND SEARCH END


  //--EMBEDDING FLASH MOVIES
  //get mapzone
  if ($("#globalmapmain").length > 0) {
    if ($("#globalmapmain").attr("class")) {
      var theMapZone = $("#globalmapmain").attr("class").substr(7, 1);
    } else {
      var theMapZone = "2";
    }

    //embed map on global front page
    $('#globalmapmain').flash(
			{ src: '/flash/global_map.swf',
			  width: 639,
			  height: 313,
			  wmode: 'transparent',
			  flashvars: { mapZone: theMapZone }
			},
			{ version: 9 }
		);
  }
  //get mapzone
  if ($("#choosecountry").length > 0) {
    if ($("#choosecountry").attr("class")) {
      var theMapZoneModal = $("#choosecountry").attr("class").substr(7, 1);
    } else {
      var theMapZoneModal = "2";
    }

    //embed map for modal window 'choose country'
    $('#choosecountry').flash(
			{ src: '/flash/global_map.swf',
			  width: 639,
			  height: 313,
			  wmode: 'transparent',
			  flashvars: { mapZone: theMapZoneModal }
			},
			{ version: 9 }
		);
  }

  //--FONT SIZE
  var currentSize = readCookie('fontSize');
  if (currentSize) {
    resizeFont(currentSize);
  }
  $(".textincrease a").click(function() {
    if ($(this).is(".fontsizeloop")) {
      switch (currentSize) {
        case "bigger":
          currentSize = "biggest";
          break;
        case "biggest":
          currentSize = "normal";
          break;
        default:
          currentSize = "bigger";
          break;
      }
    } else {
      currentSize = $(this).attr("class");
    }
    resizeFont(currentSize);
    return false;
  });
  //--FONT SIZE END
  
  
});


function mouseOverDescription(trigger, speed) {
  if (severalCanBeOpen != true) {
    $(trigger).parent().parent().find(".description").not($(trigger).parent().find(".description")).slideUp(speed);
    $(trigger).parent().parent().find("li").not($(trigger).parent()).removeClass("active");
  }
}


function showDescription(trigger, closeSelf, severalCanBeOpen, speed) {
  if (severalCanBeOpen != true) {
    $(trigger).parents(".jQaccordion").find(".description").not($(trigger).parent().find(".description")).stop(true, true).slideUp(speed);
    $(trigger).parents(".jQaccordion").find("li").not($(trigger).parent()).removeClass("active");
  }
  if (closeSelf == true) {
    $(trigger).parent().find(".description").slideToggle(speed);
    $(trigger).parent().toggleClass("active");
    return false;
  } else {
    $(trigger).parent().find(".description").slideDown(speed);
    $(trigger).parent().addClass("active");
    return false;
  }
}


function resizeFont(currentFontSize) {
  var articleFontSize = "100";
  switch (currentFontSize) {
    case "normal":
      articleFontSize = "100";
      break;
    case "bigger":
      articleFontSize = "110";
      break;
    case "biggest":
      articleFontSize = "120";
      break;
  }
  $("div.content").attr("style", "font-size:" + articleFontSize + "%");
  createCookie('fontSize', currentFontSize, 30);
}

//------------------cookie functions http://www.quirksmode.org/js/cookies.html------------------
function createCookie(name, value, days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
  }
  else var expires = "";
  document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') c = c.substring(1, c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
  }
  return null;
}
function eraseCookie(name) {
  createCookie(name, "", -1);
}
//------------------cookie functions end------------------
