JQuery Notes 1


$(document).ready(function () {
   // Get URL and convert to lower case
   var urlStringInLowerCase = document.location.href.toLowerCase();
   if (urlStringInLowerCase.indexOf('/fr/') >= 0)
   {
      $('#ctl00_IdWelcome_ExplicitLogout_ctl00_ctl01').attr('text', 'English');
      $('#ctl00_IdWelcome_ExplicitLogout_ctl00_ctl01').attr('onMenuClick', "window.location='javascript:ChangeLang(1033);';");
   }
   else
   {
      $('#ctl00_IdWelcome_ExplicitLogout_ctl00_ctl01').attr('text', vlang);
      $('#ctl00_IdWelcome_ExplicitLogout_ctl00_ctl01').attr('onMenuClick', "window.location='javascript:ChangeLang(1036);';");
   }


   // Hide Menu Item - My Setting
   var menu = document.getElementsByTagName('ie:menuitem');
   for (var i = 0; i < menu.length; i++) { 
       var itm = menu[i];
      // Regular Expression
      var rex = /(.)*?PersonalInformation$/;
      if (itm.id.match(rex))
      { itm.hidden = true; }
   }
   //code to vanish the search string when clicked on search box
   var searchBox = $(document).find(':input[name$="InputKeywords"]');
   var prompt = ""; searchBox.addClass("cibc-sb");
   if (urlStringInLowerCase.indexOf('/fr/') >= 0) {
      prompt = "Chercher une personne";
   }
   else {
       prompt = "Search people";
   }
   searchBox.attr("value", prompt);
   searchBox.focus(function () {
      $(this).removeClass("cibc-sb");
      ($(this).attr("value") == prompt) ? $(this).attr("value", "") : 0;
   }).blur(function () {
      ($(this).attr("value") == "") ? $(this).attr("value", prompt).addClass("cibc-sb") : 0;
   });
});


function ChangeLang(value) {
var url = window.location.href.toLowerCase();
var today = new Date();
var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
// Set Cookie
document.cookie = "lcid=" + value + ";path=/;expires=" + oneYear.toGMTString();
if (value == "1033") {
window.location.href = url.replace('/fr/', '/en/');
}
else {
window.location.href = url.replace('/en/', '/fr/');
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s