/* == GLOBAL VARIABLES ========================================================================== */
var pgHash = location.hash;
var pgHost = location.host;
var pgHref = location.href;
var pgPath = location.pathname;
var pgTitle = document.title;
var referrer = '';
var ajaxHash = '';
var inPrintView = false;
var winH = window.innerHeight;
var winW = window.innerWidth;
var uA = navigator.userAgent.toLowerCase();
var istablet=false;
var userAgent;
var addthis_cnt = 0;
//By Chandu on July 5th,2011
/* ==function to remove Host Name from the HASH URL's ==*/
function getHashedURL(hash_URL) {
if (hash_URL.indexOf(location.host) >= 0) {
hash_URL = hash_URL.replace("http://" + location.host, "");
}
return hash_URL;
}
function IsValidHashedUrl(hash_URL) {
if ((hash_URL.toUpperCase().indexOf("HTTP://") >= 0) || (hash_URL.toUpperCase().indexOf("HTTPS://") >= 0)) {
var sapHost = location.hostname.toUpperCase();
var hashHost = hash_URL.slice(hash_URL.indexOf("://") + 3, hash_URL.indexOf("/", 8) + 1).toUpperCase();
if (sapHost == hashHost)
return true;
else
return false;
}
else
return true;
}
//End Change By Chandu
/* == JQUERY SCRIPTING ========================================================================== */
$(window).load(function () {
var URL="";
if(document.getElementById("path")){
URL= document.getElementById("path").value;
}
var c_value = document.cookie;
/* ==== DETECT MOBILE DEVICES ==== */
detectUserAgent();
if(URL.indexOf("/en_us.html")==-1){
set_country_redirect_flag();
}
var noredirect=get_cookie("noredirect");
if(window.location.href.indexOf("noredirect=1")==-1 ){
if(userAgent!="default" && userAgent!="ipad"&& noredirect==null && document.getElementById("homepageidentifier") && !istablet){
window.location.href="http://Vedicsys.com"
}
}else{
var time="";
if(document.getElementById("time")){
time= document.getElementById("path").value;
}
var tExpDate=new Date();
tExpDate.setTime( tExpDate.getTime()+(time*60*1000) );
var pLabel ="noredirect";
var pVal="1"
document.cookie= pLabel + "=" +escape(pVal)+
( (time==null) ? "" : ";expires="+ tExpDate.toGMTString() );
}
// var path=window.location.toString();
if(document.getElementById("bumper")){
if(URL.indexOf("/en_us")!=-1){
var country_redirect=have_country_redirect_flag();
if(country_redirect){
var el = document.getElementById("bumper");
el.style.height="0px";
}else{
var el = document.getElementById("bumper");
el.style.height="visible";
}
}else{
var el = document.getElementById("bumper");
el.style.height="0px";
}
}
/* ==== DISABLE AJAX CACHING ====*/
$.ajaxSetup({ cache: false });
/* ==== DETECT MOBILE DEVICES ==== */
detectUserAgent();
/* ==== INIT AJAX LOADER ANIMATION ===== */
//setupAjaxLoader();
/* ===== COUNTRY SELECTOR COOKIE CODE ===== */
//cookie check has been moved into '/global/ui/js/head.js'
//set cookie
if ($('#cs_page_identifier').length > 0) {
$('.worldlist a').click(function (e) {
set_current_country($(this).attr('href')); //set the country cookie (aka "SelectedCountryPath")
if ($(this).attr('id') == 'ca_fr') { //if canada french, set sub-cookie
set_cookie('SAP.SITE.COOKIE', 'PC.LNG=French'); //no exp date = session cookie
}
});
}
/* ===== CORPORATE SITE ======= */
if ($('#corporate').length > 0) {
var currPath = window.location.pathname;
var currDir = currPath.substr(1).split('/', 1);
var currSubDir = currPath.substr(1).split('/', 2);
currSubDir = currSubDir[1];
if (currSubDir != 'index.epx') { $('#nav-main a[href*="' + currSubDir + '"]').addClass('on'); }
$('#subleftcol a[href*="' + currPath + '"]').addClass('on');
//swap 'en' and 'de' directories in the URL accordingly
$('#corporate-headerright a').click(function (e) {
var targSelector = $(this).attr('href').substr(1);
if (targSelector == 'country-selector.epx') {
if (currDir == 'corporate-de') {
location.href = currPath.replace('corporate-de', 'corporate-en');
}
}
if (targSelector == "country-selector-de.epx") {
if (currDir == 'corporate-en') {
location.href = currPath.replace('corporate-en', 'corporate-de');
}
}
e.preventDefault();
});
}
/* ===== RIGHT COLUMN "ARTICLEDISPLAY" TABLE WIDTH RESIZE =========== */
if ($('#articledisplay').length > 0) {
$('#articledisplay table').each(function () {
if ($(this).attr('width') > 557) {
$(this).attr('width', 557);
}
});
}
/* ===== INITIALIZE EVENTS PAGE =========== */
if ($('.searchevents').length > 0) {
initSearchEventsForm(); // initialize eventsLeftNav Search Form
if ($('.datepicker').length > 0) { initEventDatePicker(); } // initialize datepicker object
}
if ($('.event-results').length > 0) { //if events search results page
$('.user-actions').hide(); //don't display save/share buttons
}
/* ===== POST PAGE-LOAD INITS ===== */
/*$(window).hashchange(function () {
var classParam = getParamByName('class');
var pgHash = location.hash;
// Check for Cross Site Scripting - By Chandu
if (!IsValidHashedUrl(pgHash)) {
location.href = pgHash.replace("#", "");
return false;
}
//End Cross Site Scripting Changes
if ($('body#home').length > 0) { //is the home page (aka 'new experience')
if (pgHash === "#" || pgHash === "" || pgHash === 'undefined' || pgHash === null) { closeOverlay(); window.location.hash = ""; }
else {
pgHash = pgHash.substr(1);
var getHref = pgHash;
openOverlay(getHref, classParam);
//ajaxHash is used to control the on-states of 2nd and 3rd level navigation
ajaxHash = getHref; //populate ajaxHash
}
}
else if ($('body#secondary').length > 0) { //is secondary page (ie. ByDesign)
pgHash = pgHash.substr(1);
if (pgHash.length > 0) {
var getHref = pgHash;
openOverlay(getHref, classParam);
}
var currPath = location.pathname.substring(1);
var targStr = currPath.split('/');
if (targStr[2] == 'sap-bydesign') { //confirm we are in ByDesign
var navArray = $('#nav-main ul li a');
switch (targStr[3]) {
case 'what-is-sap-business-bydesign': $(navArray[0]).addClass('on'); break;
case 'delivery': $(navArray[1]).addClass('on'); break;
case 'customer-testimonials': $(navArray[2]).addClass('on'); break;
case 'buy-now': $(navArray[3]).addClass('on'); break;
case 'see-it-in-action': $(navArray[4]).addClass('on'); break;
case 'resources': $(navArray[5]).addClass('on'); break;
}
}
if (targStr[2] == 'sales-on-demand') { //confirm we are in SalesOnDemand
var navArray = $('#nav-main ul li a');
switch (targStr[3]) {
case 'see-it-in-action': $(navArray[0]).addClass('on'); break;
case 'try-and-buy': $(navArray[1]).addClass('on'); break;
case 'delivery': $(navArray[2]).addClass('on'); break;
}
}
}
else { //is a static page (ie search results/asset viewer)
pgHash = pgHash.substr(1);
if (pgHash.length > 0) {
var getHref = pgHash;
openOverlay(getHref, classParam);
}
}
}); $(window).hashchange();
*/
initInputs();
//initialize background hero images
//initialize UMP (universal media player) - removed 07.08.11 - *VS*
//if ($('.UMP_div').length > 0) { initUMP(); }
/* ===== IE Z-INDEX BUGFIX TEST ===== */
if ($.browser.msie && $.browser.version <= 7) {
var zIndexNumber = 10;
$('div').each(function () {
$(this).css('zIndex', zIndexNumber);
zIndexNumber += 10;
}); //$('#page').css('zIndex', '110');
}
/* === MULTI HEADER PHONE NUMBER CHECK AND HOVER FUNCTIONALITY === */
var isHeaderPhone = $('#utilitynav-phone');
if (isHeaderPhone[0]) {
var headerPhoneWrap = '#utilitynav-phone';
var headerPhoneCount = $(headerPhoneWrap + ' span').size();
if (headerPhoneCount > 1) {
$(headerPhoneWrap).addClass('multi');
$(headerPhoneWrap + ' span').addClass('hoveroff');
$(headerPhoneWrap + ' span:first').removeClass('hoveroff').addClass('first');
}
}
$('#utilitynav-phone.multi a').live('mouseover mouseout', function (event) {
if (event.type == 'mouseover') {
$('span.hoveroff', this).removeClass('hoveroff').addClass('hoveron');
$('#nav-utilitybtm li:not(#utilitynav-phone)').hide();
} else {
$('span.hoveron', this).removeClass('hoveron').addClass('hoveroff');
$('#nav-utilitybtm li').show();
}
});
/*=== CAPTURE ALL CLICK EVENTS ===*/
$(document).bind('click', function (e) { //bind click event to entire document
var clickedObj = $(e.target); //reference to the clicked object
//console.log('tag: '+clickedObj.get(0).tagName);
/*= OVERLAY LOGIC ==*/
if ($('#overlay').length == 0 || $('#blackout').length == 0) { //overlay is closed
if (!clickedObj.is('a')) { //not an anchor
}
}
/*= BLACKOUT LOGIC =*/
if ($('#blackout').length > 0) { //blackout exists
if (clickedObj.is('#blackout.hot')) { //is blackout with class hot
closeOverlay();
}
if (clickedObj.is('#blackout.preview')) {
closePreviewOverlay();
}
}
/*= QUICKLINKS LOGIC =*/
if (!clickedObj.is('ul#footer-lefttop li#quick-links a') && !clickedObj.is('#hero-btns a')) { //if not quick-links anchor and if not hero-btns anchor
if ($('ul#footer-lefttop li#quick-links a.on').length > 0) { //if quick-links is open
closeOverlayQuicklinks();
}
}
/*= CHECK FOR PRINT VIEW =*/
if (inPrintView == true) {
showBrowserView();
}
});
/* ===== CLICK/HOVER EVENTS - EXPANDABLE LISTS ===== */
$('.leftnav-expandable-list .btnToggle').live('click', function () {
var currClass = $(this).attr('class');
if (currClass == "btnToggle open") {
$(this).attr('class', 'btnToggle');
}
else {
$(this).addClass('open');
}
//$(this).parent().find('li.leftnav-li-hide').stop(true, true).toggle(1000);
$(this).parent().find('li.leftnav-li-hide').stop(true, true).toggle();
});
/*===== CLICK EVENT - TOP LEFT SAP LOGO =====*/
/* no longer need to capture
$('#header h1 a, #page h1 a').live('click', function () {
closeOverlay();
if ($('body#secondary').length > 0) { //if is secondary page (ie. byDesign)
window.location = '/';
}
});
*/
/*===== CLICK EVENT - EMPTY ANCHORS =====*/
$('a[href=""]').live('click', function () { return false; });
/*===== CLICK EVENT - CONTEXTUAL EMAIL LINK (OPENS CONTACT US TOP OVERLAY) =====*/
$('a.content-utility-email').live('click', function () {
$('A#utilitynav-contact').click();
return false;
});
/*===== CLICK EVENT - CLOSE OVERLAY BUTTON =====*/
$('#overlay a.btn-close-overlay, #roil_form_close').live('click', function () {
closeOverlay();
if ($(this).parent().attr('class') === "overlay-worldmap") {
$('#location-select').removeClass('on');
}
return false;
});
/*===== CLICK EVENT - WORLD MAP LINKS =====*/
if (userAgent != 'default') {
if ($('#worldmap').length > 0) {
$('#country-map area').each(function (e) {
imageMapID = $(this).attr('id');
$('#' + imageMapID).live('touchstart', function () {
mapSwitch($(this).attr('rel'));
});
});
$('#worldmap-left a').each(function (e) {
countryTitleID = $(this).attr('id');
$('#' + countryTitleID).live('touchstart', function () {
mapSwitch($(this).attr('rel'));
});
});
}
}
$('#worldmap-left a').live('click', function () {
if (($(this).attr('class')) !== 'on') {
var getRel = $(this).attr('rel');
$('#worldmaptitle-' + getRel).addClass('on', mapSwitch(getRel));
}
return false;
});
$('#worldmap-left a').live('mouseover mouseout', function (event) {
var getRel = $(this).attr('rel');
if (event.type === 'mouseover') {
$('#worldmap').prepend('
');
} else { $('#worldmap-hover-' + getRel).remove(); }
return false;
});
/*===== CLICK EVENT - UTILITY NAV =====*/
/*$('#utilitynav-locationselect, #utilitynav-buy, #utilitynav-myprofile, #utilitynav-contact').live('click', function () {
var el = $(this);
var getHref = $(el).attr('href');
//Modified hasedURL to get realtive path
getHref = getHashedURL(getHref);
var getId = $(el).attr('id'); // uses the elements id to pass as a class to the overlay
if ($(el).hasClass('on')) { $(el).removeClass('on'); closeOverlay(); }
else { $('#nav-utilitytop a.on').removeClass('on'); $(el).addClass('on'); location.hash = getHref + '?class=' + getId; }
return false;
});*/
/*===== CLICK EVENT - LOGIN CTA ON MY ACCOUNT PANEL =====*/
/*-- this content is now being loaded in an iframe
$('#btn-gotoaccount').live('click', function () {
openOverlay('/profile/registration.epx', 'utilitynav-reg');
return false;
});
*/
/*===== CLICK EVENTS - FOOTER LINKS: FOLLOW SAP, COMMUNITIES =====*/
$('#home #social-network, #home #footerlink-communities').live('click', function () {
getHref = ajaxHash = $(this).attr('href');
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('#nav-main a.on').removeClass('on');
$(this).addClass('on');
return false;
});
$('#home li.video > a').live('click', function () {
getHref = ajaxHash = $(this).attr('href');
location.hash = getHashedURL(getHref);
return false;
});
$('#home li.document > a').live('click', function () {
getHref = ajaxHash = $(this).attr('href');
location.hash = getHashedURL(getHref);
return false;
});
/*===== CLICK EVENT - MAIN NAV, NEWS FLYOUT =====*/
/* $('#home #nav-main a').live('click', function () {
if ($(this).parents('#nav-main').length > 0) {
$('#nav-main a.on').removeClass('on');
$(this).addClass('on');
getHref = ajaxHash = $(this).attr('href');
}
else { getHref = $(this).attr('href'); }
//Modified hasedURL to get realtive path
getHref = getHashedURL(getHref);
if ($('body#secondary').length > 0) {
if(getHref.indexOf("?">=0))
location.hash = getHref + '&class=byd-news-overlay';
else
location.hash = getHref + '?class=byd-news-overlay';
} else { location.hash = getHref; }
return false;
});*/
/*===== CLICK EVENTS - NEWS READER =======*/
/*
$('#subleft-listC .news-group a').live('click', function () {
getHref = $(this).attr('href');
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('#subleft-listC .news-group a').removeClass('on').parent().removeClass('on');
$(this).addClass('on').parent().addClass('on');
return false;
});
*/
/*===== CLICK EVENT - SUB NAV =====*/
$('#home #nav-sub a').live('click', function () {
getHref = ajaxHash = $(this).attr('href');
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('#nav-sub a.on').removeClass('on');
return false;
});
/*===== CLICK EVENT - LEFT NAV =====*/
$('#home #subleftcol a[rel="panel"]').live('click', function () {
getHref = ajaxHash = $(this).attr('href');
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('#subleftcol ul li a.on').removeClass('on');
$(this).addClass('on');
return false;
});
/*===== CLICK EVENT - LIST TOGGLES =====*/
$('.atoz-list dl').addClass('clearfix');
$('a.list-toggle', $('#subbottom')[0]).live('click', function () { if ($(this).parent().attr('class') === "on") { $(this).parent().removeClass('on'); } else { $(this).parent().addClass('on'); } return false; });
$('.atoz-list dl dt a').live('click', function () { if ($(this).attr('class') !== "on") { $(this).addClass('on').parent().parent().addClass('on'); } else { $(this).removeClass('on').parent().parent().removeClass('on'); } return false; }); //bugfix 1/10/11_sk
$('#subright-more-toggle a').live('click', function () { if ($(this).attr('class') !== "on") { $('#subright-top-flexible').attr('class', ''); $(this).addClass('on').html('Minimize -').parents('#subright').addClass('on'); } else { $('#subright-top-flexible').attr('class', currSubRghtTopFlexClass); $(this).removeClass('on').html('More +').parents('#subright').removeClass('on'); } return false; }); //revisited "more" toggle skiernan_1/5/11
$('a.expand-all', $('#subright-toggles')[0]).live('click', function () { $('#subright-listB li').addClass('on'); return false; });
$('a.close-all', $('#subright-toggles')[0]).live('click', function () { $('#subright-listB li').removeClass('on'); return false; });
$('a.expand-all', $('#atoz-toggle')[0]).live('click', function () { $('#atoz-list-wrapper li dl dt a').each(function () { $(this).addClass('on').parent().parent().addClass('on'); }); return false; });
$('a.close-all', $('#atoz-toggle')[0]).live('click', function () { $('#atoz-list-wrapper li dl dt a.on').removeClass('on').parent().parent().removeClass('on'); ; return false; });
/*===== CLICK EVENT - PAGINATION CONTROLS =======*/
if ($('body#home').length > 0) { //make sure we are in the new home page experience
$('.page-views a').live('click', function () {
getHref = $(this).attr('href');
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('.page-views a').removeClass('on');
$(this).addClass('on');
return false;
});
$('.page-selector a').live('click', function () {
getHref = $(this).attr('href');
if (getHref == '' || $(this).hasClass('on') == true || $(this).hasClass('disabled') == true) {
//do nothing
}
else {
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('.page-selector a').removeClass('on');
$(this).addClass('on');
}
return false;
});
}
else {
$('.page-views a').live('click', function () {
/*this hack is for search result pages... because even the disabled paginated number trigger
this function and hence load animation comes up.*/
if(!$('#searchResultContent').length){
showLoadAnim('subbottom');
}
});
$('.page-selector a').live('click', function () {
/*this hack is for search result pages... because even the disabled paginated number trigger
this function and hence load animation comes up.*/
if(!$('#searchResultContent').length && !$(this).hasClass('btn-prev-page disabled') && !$(this).hasClass('on')){
showLoadAnim('subbottom');
}
});
}
/*===== CLICK EVENTS - CUSTOMER TESTIMONIALS/CUSTOMER AT0Z =======*/
$('#home #form-customertestimonials-filter').live('submit', function (e) {
srchParam = 'Region=' + $('#filter-region').val() + '&Country=' + $('#filter-country').val() + '&Brochure=' + $('#Brochure').is(':checked') + '&Video=' + $('#Video').is(':checked');
location.hash = ajaxHash + '?' + srchParam;
e.preventDefault();
});
$('#home #atoz-menu a').live('click', function () {
if ($('#atoz-menu').hasClass('customerAZ')) { //if "customer testimonials a-z"
if ($(this).attr('class') != 'disabled') {
getHref = $(this).attr('href');
location.hash = getHref;
$('#atoz-menu a').removeClass('on');
$(this).addClass('on');
}
}
else { //not "customer testimonials a-z"
if ($(this).attr('class') != 'disabled') { //if anchor is not disabled
var letter = $(this).html().toLowerCase();
var pos = ($('#atoz-' + letter).position().top) + 170;
$('html').scrollTop(pos);
}
}
return false;
});
$('#home .a2z-moreless a').live('click', function (e) {
getHref = $(this).attr('href');
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
e.preventDefault();
});
$('#home #form-atoz-search').live('submit', function (e) {
getHref = $(this).attr('action');
srchParam = 'search=' + $('#atoz-input').val();
//Modified hasedURL to get realtive path
getHref = getHashedURL(getHref);
location.hash = getHref + '?' + srchParam;
e.preventDefault();
});
/*===== CLICK EVENT - MY SAP ACCOUNT EXPAND/EDIT TOGGLES =====*/
// 'Edit' link
$('a.editexpand').live('click', function () {
$(this).parent().parent().parent('.thicktopborder').addClass('on');
return false;
});
// 'Close' link
$('a.editclose').live('click', function () {
$(this).parent().parent().parent('.thicktopborder').removeClass('on');
return false;
});
// 'Cancel' link
$('a.cancellink').live('click', function () {
$(this).parent().parent('.thicktopborder').removeClass('on');
return false;
});
// 'Save' button
$('.axshawnbuttons a.btn-cta').live('click', function () {
$(this).parent().parent('.thicktopborder').removeClass('on');
return false;
});
/*===== CLICK EVENT - MY SAP ACCOUNT > MY SUBCRIPTIONS =====*/
var relatedChkbx; //global var use
$('.newslettertable a.infoicon').live('click', function () {
var el = $(this);
var jpgURL = $(el).attr('href');
var title = $(el).siblings('.NLTitle').html();
var pos = ($(el).position().top + 200);
relatedChkbx = $(el).parent().siblings('.col-one').children('input:first');
applyBlackout('newslettertable');
$('body').append('');
return false;
});
$('#subscribeNow').live('click', function () {
$(relatedChkbx).attr('checked', true);
closePreviewOverlay();
});
$('#myModalClose').live('click', function () {
closePreviewOverlay();
});
/*===== CLICK EVENT - BACK BUTTON (HISTORY.GO) =====*/
$('.backBtn').live('click', function (e) {
if (history.length >= 1) {
history.go(-1);
}
else { location.replace('/index.epx'); }
e.preventDefault();
});
/* By Gaurav Jasiwal.
* This is used for action on search button hit.
* */
function getPageLang(pagelang){
var lang;
if(pagelang && pagelang.indexOf("/")!=-1){
lang = pagelang.substring(pagelang.lastIndexOf("/") + 1, pagelang.length);
}else{
lang = "en_us";
}
return lang;
}
$('.resource-listsearch').live('click', function (e) {
var pagelanguage = getPageLang($('input#pageLanguage').val());
var searchURL = $(this).attr("data-source");
var searchType=document.getElementById("searchtype").value;
searchAjax(searchURL, pagelanguage, searchType, null);
e.preventDefault();
});
$("#searchresults-submit-click").click(function() {
searchHit($('#longsearchsite-input').val());
return false; // avoid to execute the actual submit of the form.
});
/*====== CAPTURE EVENT FOR SEARCH FILTER CLICKS =========*/
$('.dn-attr-v').live('click', function (e) {
var pagelanguage = getPageLang($('input#pageLanguage').val());
var searchType=document.getElementById("searchtype").value;
searchAjax($(this).attr('href'), pagelanguage, searchType, null);
e.preventDefault();
});
$('.page-selector > ul a').live('click',function(e){
var pagelanguage = getPageLang($('input#pageLanguage').val());
var searchType=document.getElementById("searchtype").value;
searchAjax($(this).attr('href'), pagelanguage, searchType, null);
e.preventDefault();
});
$('.list-selector_search > .page-selector .btn-next-page').live('click',function(e){
var pagelanguage = getPageLang($('input#pageLanguage').val());
var searchType=document.getElementById("searchtype").value;
searchAjax($(this).attr('href'), pagelanguage, searchType, null);
e.preventDefault();
});
$('.list-selector_search > .page-selector .btn-prev-page').live('click',function(e){
var pagelanguage = getPageLang($('input#pageLanguage').val());
var searchType=document.getElementById("searchtype").value;
searchAjax($(this).attr('href'), pagelanguage, searchType, null);
e.preventDefault();
});
$('.results-indicator > span a').live('click',function(e){
var pagelanguage = getPageLang($('input#pageLanguage').val());
var url = $(this).attr('href');
var searchType=document.getElementById("searchtype").value;
searchAjax(url, pagelanguage, searchType, null);
e.preventDefault();
});
function searhFromhistory(){
var pagelanguage = getPageLang($('input#pageLanguage').val());
var url = $(this).attr('href');
searchAjax(url, pagelanguage, 'Search History');
e.preventDefault();
}
/*====== SITE SEARCH INIT ======*/
$('#searchsite-input').live("focus", function () {
initInputs();
$(this).autocomplete({ //header site search input
minLength: 2,
delay: 0,
source: function (request, respond) {
get_suggestions(request.term, function (response) {
respond(eval(response))
});
},
minWidth: 146,
width: '100%',
zIndex: 9999,
select: function (event, ui) {
$('#searchsite-input').val(ui.item.value);
$('#headersearch-form').submit();
}
});
});
/*====== SITE LONG SEARCH INIT ======*/
$('#longsearchsite-input').live("focus", function () {
initInputs();
$(this).autocomplete({
minLength: 2,
delay: 0,
source: function (request, respond) {
get_suggestions(request.term, function (response) {
respond(eval(response))
});
},
minWidth: 246,
width: '100%',
zIndex: 9999,
select: function (event, ui) {
searchHit(ui.item.value);
}
});
});
/* UNCOMMENT FOR AUTOCOMPLETE */
$('#QueryText').autocomplete({
minLength: 2,
delay: 0,
source: function (request, respond) {
get_suggestions(request.term, function (response) {
respond(eval(response))
});
},
minWidth: 186,
width: '100%',
zIndex: 9999,
select: function (event, ui) {
$('#QueryText').val(ui.item.value);
$('#searchresults').submit();
}
});
/*==== INITIALIZE A TO Z PAGES =====*/
$('#atoz-menu a.disabled').each(function () {
letter = $(this).html().toLowerCase();
$('#atoz-' + letter).hide();
});
/*==== ByDESIGN - GUIDED TOUR =====*/
if ($('body#secondary').length > 0) { //make sure we are in the byd experience
$('#tour-launch').click(function (e) {
var getHref = $(this).attr('href');
//openOverlay(getHref, 'byd-tour');
location.hash = getHref + '?class=byd-tour';
$('html').scrollTop(0); //default scroll position back to top
e.preventDefault();
});
}
/*==== AJAX LOADING ANIMATIONS ====*/
$('#searchsite').submit(function (e) {
showLoadAnim('subbottom');
});
$('#searchresults').submit(function (e) {
showLoadAnim('subbottom');
});
/*==== INITIALIZE BYD TOUR ====*/
if ($('.tour_wrap').length > 0) {
initBYDtour();
}
//initialize leftnav expandable functionality
if ($('.leftnav-expandable-list').length > 0) {
if ($('.btnToggle').length == 0) {
$('.leftnav-expandable-list').each(function () {
var totalItems = $(this).find('li');
var linkArray = $(this).find('li a');
//determine whether to build a collapseable list
if (totalItems.length > 5) { //if there are more than 5 items in the list, apply a toggle button
$.each(totalItems, function (index, value) {
if (index > 4) {
$(this).addClass('leftnav-li-hide');
}
});
$(this).append('');
}
//determine whether the list should 'open' or stay 'collapsed' on pageload
$.each(linkArray, function (index, value) { //iterate thru anchors and look for the 'on' state
//console.log(index+' : '+value);
isOn = $(this).hasClass('on');
if (isOn == true) { //if 'on' state is present determine the index of that item in the array
if (index >= 5) { //if the 'on' anchor is 5 or greater... open the leftnav menu
$(this).parent().siblings('.btnToggle').trigger('click');
}
}
});
});
}
}
/*==== CUSTOMER TESTIMONIALS FILTER ====*/
$("#ct-filter-submit").click(function(){
var actionURL = document.location.href.replace(document.location.pathname,'').replace(document.location.search,'');
var urlPart = document.location.pathname.split(".");
var filterString = "";
var region = $("#filter-region").val();
var country = $("#filter-country").val();
var companysize = $("#filter-companysize").val();
if(region && $.trim(region).length > 0) {
filterString += "." + region;
}
if(country && $.trim(country).length > 0) {
filterString += "." + country;
}
if(companysize && $.trim(companysize).length > 0) {
filterString += "." + companysize;
}
actionURL += urlPart[0];
if (urlPart[1].match("^html")) {
// very unlikely
actionURL += filterString;
actionURL += ("." + urlPart[1]);
} else {
actionURL += ("." + urlPart[1]);
actionURL += filterString;
}
actionURL += ".html";
window.location.href = actionURL;
});
/*Check for Text Only View Cookie */
checkForTextOnly();
}); //end of $(window).load
$(window).resize(function() {
checkForTextOnly();
});
$(window).unload(function () {
if (typeof checkExitSurvey != "undefined")
checkExitSurvey();
});
/* ===== FUNCTIONS ========================================================================== */
/* ===== Detect User Agent ===== */
function detectUserAgent() {
if (uA.search('iphone') > -1) { userAgent = 'iphone'; $('body').addClass(userAgent); }
else if (uA.search('ipad') > -1) { userAgent = 'ipad'; $('body').addClass(userAgent); }
else if (uA.search('ipod') > -1) { userAgent = 'ipod'; $('body').addClass(userAgent); }
else if (uA.search('windows ce') > -1 || uA.search('windows phone') > -1) { userAgent = 'windows-mobile'; $('body').addClass(userAgent); }
else if (uA.search('blackberry') > -1) { userAgent = 'blackberry'; $('body').addClass(userAgent); }
else if (uA.search('palm') > -1) { userAgent = 'palm'; $('body').addClass(userAgent); }
else if (uA.search('android') > -1) {
if (uA.search('mobile') <=-1 ){
istablet=true;
}
userAgent = 'android'; $('body').addClass(userAgent); }
else { userAgent = 'default' }
}
/*==== AJAX LOADING ANIMATIONS ====*/
function showLoadAnim(targDiv) {
targDiv = '#' + targDiv;
if ($(targDiv).length > 0) {
$(targDiv).prepend('PROCESSING...
');
$('#XHR_request').fadeIn(500);
$('html').scrollTop(0); //default scroll position back to top
} else { $('body').prepend('PROCESSING...
'); }
}
function hideLoadAnim() {
$('#XHR_request').remove();
}
/*==== GET QUERYSTRING PARAM ======*/
function getParamByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
/* ===== MBOX DIVS ===== */
function mboxAJAXCreate() {
$('.mboxDefault').each(function () {
var mboxId = $(this).attr('id');
mboxDefine(mboxId, mboxId);
mboxUpdate(mboxId);
});
}
/*=== GET AJAX ===*/
function getAJAX(url_ref, div_ref) {
$.ajax({
type: 'GET',
url: url_ref,
global: false,
beforeSend: function (jqXHR, settings) {
showLoadAnim('subbottom');
if(typeof checkExitSurvey != "undefined")
checkExitSurvey();
if(referrer != '')
jqXHR.setRequestHeader('X-SAP-Referer', referrer);
referrer = 'http://' + location.host + location.hash.substring(1);
},
success: function (data) {
var sTitle = data.indexOf('') + 7; //find starting index for the title tag
var eTitle = data.indexOf(''); //find the ending index for the title tag
$('#nav-utilitytop a.on, #nav-main a.on, #footer a.on').removeClass('on'); //clear previous nav on-states
//getTitle = $(data).filter("title").text();
getTitle = data.substring(sTitle, eTitle); //extract substring of start/end indices for the tag
getContent = $(data).find(div_ref).html();
$('#overlay').fadeIn(500, function () {
$('#overlay').html(getContent).prepend('');
});
document.title = getTitle;
if ($('#blackout').length > 0) {
var class_ref = $('#overlay').attr('class');
if (class_ref.substr(0, 11) == 'utilitynav-') {
$('#footer').removeClass('footer-panel').css({ 'position': 'absolute', 'z-index': '70' });
} else { $('#footer').css({ 'position': 'relative' }); }
} else { $('#footer').addClass('footer-panel').css({ 'position': 'absolute' }); }
ajaxSuccess(data); //global functions for ajax callbacks
mboxAJAXCreate();
hideLoadAnim();
if (typeof change_phone != "undefined") change_phone(data);
if (typeof change_liveperson != "undefined") change_liveperson(data);
},
error: function (xhr, textStatus, errorThrown) {
alert(xhr.status + ': ' + xhr.statusText + '\nError Thrown: ' + errorThrown);
}
});
}
/*=== BLACKOUT REHEIGHT ===*/
function blackoutReheight() {
//var blackoutReheight = $('#page-content').height() + $('#header').height() + $('#footer').height() + 8;
$('#blackout').css('height', $(window).height());
}
/*=== AJAX SUCCESS CALLBACK FUNCTIONS ===*/
var currSubRghtTopFlexClass;
function ajaxSuccess(data) {
//initialize navigation on-states
if (ajaxHash.search(/\?/) != -1) { //check for existence of querystring
ajaxHash = ajaxHash.substring(0, ajaxHash.lastIndexOf('?')) //if found, strip off querystring
}
var ancURL = 'a[href="' + ajaxHash + '"]';
if (ancURL != 'a[href=""]') { //if targeted anchor is not an empty string
if ($(data).find(ancURL).length > 0) { //if current URL is equivalent to a navigation element on the served page then add class="on"
$(ancURL).each(function () { //iterate thru each found match (could be multiples href's {ie. main-nav and tabbed nav (ie. solutions and communities)} and we don't want to stop on first match )
if ($(this).attr('class') != 'on') {
$(this).addClass('on');
}
});
}
}
//highlight corresponding nav-main item
var targStr = ajaxHash.substring(1).split('/');
/* Commented by Inderjit, due to non usage of below lines. Defect - "MOWCMS-1922 Hard Coded Urls need to be updated due to new structure"
if ($('body#home').length > 0) { //confirm this is not a secondary page tempate
var navArray = $('#nav-main ul li a');
switch (targStr[0]) {
//header navigation
case 'countries': $('#utilitynav-locationselect').addClass('on'); break;
case 'buy-now': $('#utilitynav-buy').addClass('on'); break;
case 'profile': $('#utilitynav-myprofile').addClass('on'); break;
case 'contactsap': $('#utilitynav-contact').addClass('on'); break;
//main navigation
case 'solutions': $(navArray[0]).addClass('on'); break;
case 'services-support': $(navArray[1]).addClass('on'); break;
case 'about-sap': $(navArray[2]).addClass('on'); break;
case 'industries': $(navArray[3]).addClass('on'); break;
case 'customer-testimonials': $(navArray[4]).addClass('on'); break;
case 'partners': $(navArray[5]).addClass('on'); break;
case 'lob': $(navArray[6]).addClass('on'); break;
case 'training-education': $(navArray[7]).addClass('on'); break;
case 'events': $(navArray[8]).addClass('on'); break;
//footer navigation
case 'communities': $('#footerlink-communities').addClass('on'); break;
case 'social': $('#social-network').addClass('on'); break;
}
} */
if ($('body#secondary'.length > 0)) { //confirm we are in the secondary template (ie BYD)
//if the news reader overlay is open in BYD
if ($(data).find('.newsreader').length > 0) {
$('.page-views a').live('click', function () {
getHref = $(this).attr('href');
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('.page-views a').removeClass('on');
$(this).addClass('on');
return false;
});
$('.page-selector a').live('click', function () {
getHref = $(this).attr('href');
if (getHref == '' || $(this).hasClass('on') == true || $(this).hasClass('disabled') == true) {
//do nothing
}
else {
//Modified hasedURL to get realtive path
//location.hash = getHref;
location.hash = getHashedURL(getHref);
$('.page-selector a').removeClass('on');
$(this).addClass('on');
}
return false;
});
}
}
//if "A to Z" nav menu exists, hide disabled content blocks in "A to Z" list and change background
if ($(data).find('#atoz-menu').length > 0) {
$('#sub').addClass('nobkg');
$('#atoz-menu a.disabled').each(function () {
letter = $(this).html().toLowerCase();
$('#atoz-' + letter).hide();
});
}
else if ($(data).find('#sub').attr('class') == 'nobkg') { /* do nothing, leave class='nobkg' in tact */ }
else { $('#sub').removeClass('nobkg'); } //remove class='nobkg'
//move myprofile markup
var myProfileMenu = '#utilitynav-myprofile-menu';
if ($(myProfileMenu).length > 0) { moveMyProfile(); }
//init input fields
initInputs();
//initialize "more/minimize" link functionality
if ($('#subright').length > 0) { $('#subright').removeClass('on'); }
if ($(data).find('#subright-top-flexible').length > 0) { currSubRghtTopFlexClass = $('#subright-top-flexible').attr('class'); }
//initialize leftnav expandable functionality
if ($(data).find('.leftnav-expandable-list').length > 0) {
if ($('.btnToggle').length == 0) {
$('.leftnav-expandable-list').each(function () {
var totalItems = $(this).find('li');
var linkArray = $(this).find('li a');
//determine whether to build a collapseable list
if (totalItems.length > 5) { //if there are more than 5 items in the list, apply a toggle button
$.each(totalItems, function (index, value) {
if (index > 4) {
$(this).addClass('leftnav-li-hide');
}
});
$(this).append('');
}
//determine whether the list should 'open' or stay 'collapsed' on pageload
$.each(linkArray, function (index, value) { //iterate thru anchors and look for the 'on' state
//console.log(index+' : '+value);
isOn = $(this).hasClass('on');
if (isOn == true) { //if 'on' state is present determine the index of that item in the array
if (index >= 5) { //if the 'on' anchor is 5 or greater... open the leftnav menu
$(this).parent().siblings('.btnToggle').trigger('click');
}
}
});
});
}
}
//initialize UMP (universal media player) - removed 07.08.11 - *VS*
//if ($(data).find('.UMP_div').length > 0) { initUMP(); }
//Fire Rich Media's ajaxSuccess function - 07.08.11 - *VS*
rm_ajaxSuccess();
//initialize Events LeftNav Search Form
if ($('.searchevents').length > 0) {
initSearchEventsForm(); // initialize eventsLeftNav Search Form
if ($('.datepicker').length > 0) { initEventDatePicker(); } // initialize datepicker object
}
//initialize BYD TOUR
if ($('.tour_wrap').length > 0) {
initBYDtour();
}
} //end ajaxsuccess()
/*=== INIT - SEARCH INPUTS - HIDE AND SHOW LABEL APPROPRIATELY ===*/
function initInputs() {
var elmArr = $('.focusClear');
elmArr.each(function () {
$(this).focus('click', function () { $(this).siblings('label:first').hide(); });
$(this).blur(function () { if ($(this).attr('value') === "") { $(this).siblings('label:first').show(); } });
if ($(this).attr('value') !== "") { $(this).siblings('label:first').hide(); }
});
}
/*=== PRELOAD IMAGE FUNCTION ===*/
var cache = [];
function preload() {
var args_len = arguments.length;
for (var i = args_len; i--; ) {
var cacheImage = document.createElement('img');
cacheImage.src = arguments[i];
cache.push(cacheImage);
}
}
/*=== COUNTRY SELECTOR ===*/
// MAP HOVER
function areaEnter(getRel) {
if (userAgent == 'default') {
if ($('#worldmaptitle-' + getRel).attr('class') !== 'on') { $('#worldmaptitle-' + getRel).addClass('huvver'); }
$('#worldmap').prepend('');
}
}
function areaLeave(getRel) {
if (userAgent == 'default') {
if ($('#worldmaptitle-' + getRel).attr('class') !== 'on') { $('#worldmaptitle-' + getRel).removeClass('huvver'); }
$('#worldmap-hover-' + getRel).remove();
}
}
// MAP SWITCH
function mapSwitch(getRel) {
$('#worldlist-intro').hide();
$('#worldmap-right .worldlist').hide();
$('#worldlist-' + getRel).fadeIn(400);
$('#worldmap-left').css('background', 'url(/global/ui/images/backgrounds/bkg-worldmap-' + getRel + '-current.png) no-repeat 8px 10px');
$('#worldmap-left a.on, #worldmap-left area.on').removeClass('on');
$('#worldmaptitle-' + getRel).addClass('on');
if ($.browser.webkit) { $('area').focus(function () { $(this).blur(); }); }
}
/*=== OVERLAYS ===*/
// CLOSE PREVIEW OVERLAY
function closePreviewOverlay() {
$('#blackout').remove();
$('#previewContainer').remove();
}
// CLOSE OVERLAY
function closeOverlay() {
if ($('#overlay').length > 0) {
removeBlackout($('#overlay').attr('class'));
$('#overlay').fadeOut(500, function () { $('#overlay').remove(); });
$('#nav-main a.on, ul#nav-utilitytop li a').removeClass('on');
location.hash = '';
document.title = pgTitle;
//showHero();
if ($('#overlay').length != 0) {
//resumeHero();
}
$('#footer').removeClass('footer-panel').css({ 'position': 'absolute' });
$('#header,#footer').css('z-index', '70');
$('#nav-utilitytop a.on, #nav-utilitybtm a.on').removeClass('on');
return false;
}
}
// OPEN OVERLAY
function openOverlay(url_ref, class_ref) {
if ($('body#home').length > 0) { //is home experience
//pauseHero();
//hideHero();
if ($('#overlay').length > 0) { //overlay already open
if (class_ref.search('utilitynav-') > -1) { //if "utilitynav" is found
$('#overlay').remove(); //remove open overlay
$('body').prepend(''); //append new overlay to
}
$('#overlay').removeClass().addClass(class_ref); //change the class
} else { //overlay not already open
if (class_ref.search('utilitynav-') > -1) { //if "utilitynav" is found
$('body').prepend(''); //append overlay to
} else { $('#page-content').append(''); } //append overlay to #page-content
$('#overlay').addClass(class_ref); //add class to overlay
}
}
else { //is secondary page (ie. byDesign)
if ($('#overlay').length > 0) { //overlay already open
$('#overlay').removeClass().addClass(class_ref); //change the class
} else { //overlay not already open
if (class_ref.search('utilitynav-') > -1) { //if "utilitynav" is found
$('body').prepend(''); //append overlay to
}
else if (class_ref.search('byd-news-overlay') > -1) {
$('body').prepend(''); //append overlay to
}
else if (class_ref.search('byd-tour') > -1) {
$('body').prepend(''); //append overlay to
}
else { $('#page-content').append(''); } //append overlay to #page-content
$('#overlay').addClass(class_ref).css({ 'position': 'absolute', 'top': '120px' }); //add class to overlay
}
//if (url_ref.search('/news-reader/') > -1) { $('#overlay').addClass('byd-news-overlay'); }
}
getAJAX(url_ref, '#ajax-content-wrapper');
applyBlackout(class_ref);
}
// BLACKOUT
function applyBlackout(class_ref) {
if ($('#blackout').length == 0) {
$('body').prepend(''); //$('body#home').prepend('');
//$('#footer').addClass('footer-panel'); //commented out by skiernan @ 3/28/11 9:10am to fix floating footer when making a request from the home/landing page
}
if (class_ref.substr(0, 11) == 'utilitynav-') {
$('#blackout').css('z-index', '60').addClass('hot'); //class "hot" is the trigger used to make the overlay close onclick
$('#overlay').css('z-index', '100');
$('#footer').removeClass('footer-panel');
}
if (class_ref.substr(0) == 'utilitynav-locationselect') {
$('#overlay').css({ 'left': '50%', 'top': '50px', 'width': '950px', 'margin': '0 0 58px -475px' });
}
if (class_ref.substr(0) == 'utilitynav-buy') {
$('#overlay').css({ 'left': '50%', 'top': '50px', 'width': '950px', 'margin': '0 0 58px -475px' });
}
if ((class_ref.substr(0) == 'utilitynav-contact') || (class_ref.substr(0, 14) == 'utilitynav-reg')) {
$('#header,#footer').css('z-index', '50');
}
if (class_ref == 'newslettertable') {
$('#blackout').css('z-index', '60').addClass('preview'); //class "preview" is the trigger used to make the overlay close onclick
$('#header,#footer').css('z-index', '50');
}
if (class_ref.substr(0) == 'forceLogin') {
$('#blackout').css('z-index', '60');
$('#header,#footer').css('z-index', '50');
}
if (class_ref == 'registration') {
$('#blackout').css('z-index', '60');
$('#header,#footer').css('z-index', '50');
}
if (class_ref == 'byd-news-overlay' || class_ref == 'byd-tour') {
$('#overlay').css({ 'top': '50px', 'z-index': '70' });
$('#blackout').css('z-index', '60').addClass('hot');
}
$('#blackout').css({ 'width': ($(window).width()), 'height': ($(window).height()) }).fadeIn(500).fadeTo(100, 0.4);
}
function removeBlackout(class_ref) {
$('#blackout').fadeOut(500, function () { $('#blackout').remove(); });
return false;
}
/* no longer needed --sk 3/30
// SEARCH EVENTS
function searchEvents() {
$('#subright .subtab1').hide();
$('#subright .subtab2').show();
}
*/
/*=== SEARCH FILTERS ===*/
function updateFilter(url_ref, elemID) {
location.hash = url_ref;
$('#' + elemID).css('opacity', '0.3');
$.get(url_ref, function (data) {
getFilterHTML = $(data).find('#' + elemID).html();
$('#' + elemID).css('opacity', '1');
$('#' + elemID).html(getFilterHTML);
});
}
function clearSiteSearchFilters() { //used to uncheck all site-search filters
$('.srch_filter').attr('checked', false);
}
// ====== EVENTS SEARCH FORM FUNCTIONS ======== //
function initSearchEventsForm() {
//---- 'Focus Area' section
$('fieldset.radios input').each(function () {
if ($(this).is(':checked')) {
$(this).siblings('select').removeClass('disabled').attr('disabled', false);
}
});
$('fieldset.radios input').change(function () {
if ($(this).is(':checked')) {
$('fieldset.radios select').addClass('disabled').attr('disabled', true).val('');
$(this).siblings('select').removeClass('disabled').attr('disabled', false);
}
});
//---- 'Location' section
$('#selectregion').change(function () {
if ($('#selectregion option:selected').val() == '') {
$('#selectcountry').addClass('disabled').attr('disabled', true);
$('#selectstate').addClass('disabled').attr('disabled', true);
}
else { $('#selectcountry').removeClass('disabled').attr('disabled', false); }
});
$('#selectcountry').change(function () {
if ($('#selectcountry option:selected').val() == '') {
$('#selectstate').addClass('disabled').attr('disabled', true);
}
else { $('#selectstate').removeClass('disabled').attr('disabled', false); }
});
if ($('#selectregion').val() != '') {
$('#selectcountry').removeClass('disabled').attr('disabled', false);
if ($('#selectcountry').val() != '') {
$('#selectstate').removeClass('disabled').attr('disabled', false);
}
}
//---- 'Date' section
if ($('#event-startdate').val() != '') {
$('label[for="startdate"]').hide();
}
if ($('#event-enddate').val() != '') {
$('label[for="enddate"]').hide();
}
/* No longer a need for reset functionality. We now redirect back to the /events/index.epx page.
//---- 'Reset' button
$('.resetbtn').click(function () {
//-- reset 'Focus Area'
$('fieldset.radios input').attr('checked', false);
$('fieldset.radios select').addClass('disabled').attr('disabled', true).val('');
//-- reset 'Location'
$('#selectregion').val('');
$('#selectcountry').addClass('disabled').attr('disabled', true).val('');
$('#selectstate').addClass('disabled').attr('disabled', true).val('');
//-- reset 'Date'
$('#event-startdate').val('');
$('label[for="startdate"]').show();
$('#event-enddate').val('');
$('label[for="enddate"]').show();
//-- reset 'Type'
$('input[type=checkbox]').attr('checked', true);
});
*/
$('#events-submit').live('click', function (e) {
showLoadAnim('subbottom');
$('#eventssearch').submit();
e.preventDefault();
});
}
/*=== DATE/CALENDAR (requires jquery ui) ===*/
/*-- Initialize "EVENTS" date picker --*/
function initEventDatePicker() {
var dates = $("#event-startdate, #event-enddate").datepicker({
numberOfMonths: 2,
minDate: -365,
beforeShow: function (input, inst) { $(this).siblings('label:first').hide(); },
onSelect: function (selectedDate) {
$(this).siblings('label:first').hide();
var option = this.id == "event-startdate" ? "minDate" : "maxDate", instance = $(this).data('datepicker');
date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).datepicker('option', option, date);
},
onClose: function (dateText, inst) { if ($(this).val() == "") { $(this).siblings('label:first').show(); } }
});
}
// ====== UNIVERSAL MEDIA PLAYER ====== //
/*-- Open Video Overlay --*/
$('a[rel="ump"]').live('click', function () {
var getHref = $(this).attr('href'); location.hash = getHref; return false;
});
/*-- Initialize Universal Media Player --*/
function initUMP() {
if ($('.ump-asset').length == 0) { //write necessary UMP assets to the DOM
$('head').append('');
var script = document.createElement('script');
script.setAttribute('src', '#');
script.setAttribute('type', 'text/javascript');
script.setAttribute('data-main', 'utils/rm_initializer');
script.setAttribute('class', 'ump-asset');
document.getElementsByTagName('head')[0].appendChild(script);
}
else { //nessary UMP assets already exist, re-init the player
//UMP.setup();
UMP.reInit();
}
if ($('.chapter').length > 0) {
//set first chapter defaults
$('#video-left-col .chapter:first').css({ 'border-top': '1px solid #888' }).addClass('open');
$('#video-left-col .chapter:first .chapterLink a').addClass('on');
$('#video-left-col .chapter:first .chapterDetail').css({ 'display': 'block' });
/*-- Video Chapter Accordian --*/
$('.chapterLink a').click(function (e) {
var chapterDiv = $(this).parent().parent();
var chapterLink = $(this);
var chapterDetail = $(chapterDiv).find('.chapterDetail');
//reset all to default
$('.chapter').removeClass('open');
$('.chapterLink a').removeClass('on');
$('.chapterDetail').css('display', 'none');
//set clicked element to open
chapterLink.addClass('on');
$(chapterDiv).addClass('open');
chapterDetail.slideDown('fast');
//prevent link from being redirected
e.preventDefault();
});
}
}
/* ===== MY PROFILE MENU =============================================================================================== */
var myProfileMenu = '#utilitynav-myprofile-menu';
if ($(myProfileMenu).length > 0) { moveMyProfile(); }
function moveMyProfile() {
myProfileMarkup = '';
$(myProfileMenu).remove();
$('#page-content').append(myProfileMarkup);
}
// ====== CUSTOM OVERLAYS ============================================================================================== //
//-- added 031711 --sk
var fireCloseOverlay_tier2, fireCloseOverlay_tier3 = '';
var refreshPage = false;
// OPEN OVERLAY LAYER 2
$.extend({
openOverlay_tier2: function (url, classname, dialogURL, callback) {
$('#page-content').append('');
$('#overlay_tier2').addClass(classname);
$.get(url, function (data) {
getContent = $(data).find('#ajax-content-wrapper').html();
$('#overlay_tier2').fadeIn(500, function () { $('#overlay_tier2').html(getContent).prepend(''); }).after(function () { blackoutReheight(); });
if (typeof callback == 'function') {
callback.call(this, data);
}
});
applyBlackout(classname);
$('html').scrollTop(0); //default scroll position back to top
if (dialogURL != undefined && dialogURL != '') {
fireCloseOverlay_tier2 = 'closeTieredOverlay("overlay_tier2", "' + dialogURL + '")';
} else { fireCloseOverlay_tier2 = 'closeTieredOverlay("overlay_tier2")'; }
}
});
// OPEN OVERLAY LAYER 3
$.extend({
openOverlay_tier3: function (url, classname) {
$('#page-content').append('');
$('#overlay_tier3').addClass(classname);
$.get(url, function (data) {
getContent = $(data).find('#ajax-content-wrapper').html();
$('#overlay_tier3').fadeIn(500, function () { $('#overlay_tier3').html(getContent).prepend(''); }).after(function () { blackoutReheight(); });
if (typeof callback == 'function') {
callback.call(this, data);
}
});
applyBlackout(classname);
$('html').scrollTop(0); //default scroll position back to top
fireCloseOverlay_tier3 = 'closeTieredOverlay("overlay_tier3")';
}
});
//function test(data) { console.log($(data).find('#descriptionClose').html()); }
// CLOSE OVERLAY TIER
function closeTieredOverlay(elmID, dialogURL, refreshPage) {
if ($('#overlay_' + elmID).length > 0) {
if ($('#overlay_' + elmID).hasClass('confirm')) {
if (dialogURL != undefined) {
$.openOverlay_tier3(dialogURL, 'registration_overlay');
}
else { console.log('Missing Parameter: dialogURL is NOT defined'); }
}
else {
if ($('#overlay_tier3').length > 0) {
$('#overlay_' + elmID).fadeOut(500, function () { $('#overlay_' + elmID).remove(); });
}
else {
$('#overlay_' + elmID).fadeOut(500, function () { $('#overlay_' + elmID).remove(); });
$('#blackout').css('z-index', '10');
$('#header').css('z-index', '70');
$('#footer').css('z-index', '150');
}
}
if (refreshPage == true) { window.location.reload(); }
}
}
function closeAllTieredOverlays(refreshPage) {
$('#overlay_tier2').fadeOut(500, function () { $('#overlay_tier2').remove(); });
$('#overlay_tier3').fadeOut(500, function () { $('#overlay_tier3').remove(); });
$('#blackout').css('z-index', '10');
$('#header').css('z-index', '70');
$('#footer').css('z-index', '150');
if (refreshPage == true) { window.location.reload(); }
}
$('#overlay_tier2 a.btn-close-overlay').live('click', function () {
//console.log('fire... '+fireCloseOverlay_tier2);
eval(fireCloseOverlay_tier2);
return false;
});
$('#overlay_tier3 a.btn-close-overlay').live('click', function () {
//console.log('fire... '+fireCloseOverlay_tier3);
eval(fireCloseOverlay_tier3);
return false;
});
// ================ BYD GUIDED TOUR CONTROLS =============================== //
function initBYDtour() {
var option1 = getCookie('option1');
var select2 = getCookie('select2');
//== if cookie is already present, populate drop-downs
if (option1 != null) {
$('.tour_choice2 #option1').val(option1);
}
if (select2 != null) {
$('.tour_choice1 #select2').val(select2);
}
//== choice option (my company sells) > set cookie
$('#option1').change(function () { set_cookie('option1', $(this).val()); });
//== select2 option (I am in) > set cookie
$("#select2").change(function () { set_cookie('select2', $(this).val()); });
//== showhide 1
switch (option1) {
case 'choice1': $('#option1-' + option1).show(); break;
case 'choice2': $('#option1-' + option1).show(); break;
case 'choice3': $('#option1-' + option1).show(); break;
}
//== show hide 2
switch (select2) {
case 'select1': $('#select2-' + select2).show(); break;
case 'select2': $('#select2-' + select2).show(); break;
case 'select3': $('#select2-' + select2).show(); break;
case 'select4': $('#select2-' + select2).show(); break;
case 'select5': $('#select2-' + select2).show(); break;
case 'select6': $('#select2-' + select2).show(); break;
case 'select7': $('#select2-' + select2).show(); break;
case 'select8': $('#select2-' + select2).show(); break;
case 'select9': $('#select2-' + select2).show(); break;
}
//== capture button clicks
$('#tour-start').live('click', function (e) {
if ($('option[value=None]:selected').val() == "None") {
alert("please make a selection from both options");
}
else {
//Modified hasedURL to get realtive path
location.hash = getHashedURL($(this).attr('href')) + '?class=byd-tour';
//location.hash = $(this).attr('href') + '?class=byd-tour';
}
e.preventDefault();
});
$('.tour-next').live('click', function (e) {
var url_ref = $(this).attr('href');
//Modified hasedURL to get realtive path
url_ref = getHashedURL(url_ref);
location.hash = url_ref + '?class=byd-tour';
e.preventDefault();
});
$('#tour-close').live('click', function (e) {
closeOverlay();
e.preventDefault();
});
$('.tour_wrap .leave').live('click', function (e) {
closeOverlay();
//e.preventDefault();
});
$('.video .related-content a').live('click', function (e) {
var getAssetID = $(this).attr('rel');
var getVidPath = $(this).attr('href');
var parentUMP = $(this).parents('.video').find('.UMP_div');
$(parentUMP).attr('id', getAssetID).fadeOut('fast').html('\
\
- ' + getAssetID + '
\
- ' + getVidPath + '
\
- 488
\
- 294
\
\
').fadeIn('fast');
initUMP();
e.preventDefault();
});
//Fix for generated play button when multiple instances of the UMP exist on one page
if ($('.btnPlay').length > 1) { //if there is more than one play button rendered on the page
var getInlineStyles = $('#play').attr('style'); //get the inline styles of the first play button
$('.btnPlay').attr('style', getInlineStyles); //apply these same styles to additonal play buttons
}
}
/*==== CREATE EMAIL ====*/
function CreateMailMessage(subject, message) {
var lnk = "mailto:?";
(subject.length > 0) ? lnk += "subject=" + escape(subject) + "&" : lnk = lnk;
(message.length > 0) ? lnk += "body=" + escape(message) : lnk = lnk;
location.href = lnk;
}
//Copied code from footer.js >need to refactor js
$(document).ready(function () {
//FootConsole = new rmConsole('Foot_Console');
//FootConsole.log('Footer init...');
/*===== CLICK EVENT - FOOTER QUICKLINK =====*/
$('#quick-links a').bind('click', function () {
if ($(this).hasClass('on')) { closeOverlayQuicklinks(); }
else {
$('#quick-links ul').slideDown(300, function () { buildQLshadow(); }).children(':first').children('a').css('border', 'none');
$(this).parent().addClass('on');
$(this).addClass('on');
}
});
/*===== CLICK EVENT - QUICKLINK CHILDREN ANCHORS =====*/
$('#quick-links ul li a').bind('click', function () {
$('#QLshadow').remove();
closeOverlayQuicklinks();
});
/*===== FOOTER PRINT/TEXT CLICK EVENTS =====*/
var isTextView = $('#footer-textview');
var isPrintView = $('#footer-printview');
if (isTextView[0]) { $(isTextView).click(function () { showText(); }) }
if (isPrintView[0]) { $(isPrintView).click(function () { showPrint(); }) }
/*====TO LOAD CALENDAR JS====*/
if ($('.searchevents').length > 0) {
initSearchEventsForm(); // initialize eventsLeftNav Search Form
if ($('.datepicker').length > 0) { initEventDatePicker(); } // initialize datepicker object
}
if ($('.event-results').length > 0) { //if events search results page
$('.user-actions').hide(); //don't display save/share buttons
}
});
// CLOSE OVERLAY QUICKLINKS
function closeOverlayQuicklinks() {
if ($('#footer #quick-links.on').length > 0) {
removeQLshadow();
$('#quick-links ul').slideUp(300);
$('#quick-links.on').removeClass('on');
$('#quick-links a.on').removeClass('on');
}
}
// SHADOW EFFECTS
function buildQLshadow() {
$('#quick-links').prepend('');
$('#QLshadow').css({ 'width': ($('#quick-links ul').outerWidth() - 1), 'height': ($('#quick-links ul').outerHeight() - 1) });
}
function removeQLshadow() {
$('#QLshadow').remove();
}
// FOOTER TEXT AND PRINT LINKS
function showBrowserView() {
$('link[href="#"]').attr('media', 'print');
$('#BrowserView').delay(300).animate({ height: '0px' }, 400, function () { $('#BrowserView').remove(); });
inPrintView = false; //set global var to false
}
function CreateBrowserViewButton(clickFunc) {
if ($.browser.msie && $.browser.version == "6.0")
$('body').append("");
else
$('body').append("");
$('#BrowserView').delay(300).animate({ height: '23px' }, 400).click(clickFunc);
}
function showText() {
$("img").remove();
$('*').addClass('textOnlyView');
setTimeout(function () { killTheHero() }, 200);
CreateBrowserViewButton(function () { deleteCookie('SAP.TEXTONLY'); window.location.reload(); });
set_cookie('SAP.TEXTONLY', 'true');
}
function showPrint() {
$('link[href=""]').attr('media', 'all');
//pauseHero();
CreateBrowserViewButton(showBrowserView);
setTimeout(function () { inPrintView = true }, 1000); //set global var to true 1 second after click event
}
//Text View functions
function killTheHero() {
if (typeof hTimer !== 'undefined') {
if (hTimer !== null) {
hTimer.stop();
}
}
$('body').css({'background' : 'none'});
if (typeof rotationIntervalID !== "undefined") {
window.clearInterval(rotationIntervalID); //This is for smaller promorotations. please excuse my hack - VS 2013.7.17
}
}
function checkForTextOnly() {
var tV = get_cookie('SAP.TEXTONLY');
if (tV == "true") { showText(); }
}
$('#results-indicator.results-indicator > span a').live('click',function(e){});
function submitCustomerSearchForm(startPage,newestOnTop){
if (startPage==null && newestOnTop==null){
//Pick the author configured page size from Testimonial Search Component
$("#customersearch #pageSize").attr("value",$("#pageSizeConfigured").attr("value"))
$('#customersearch').submit();
} else {
var url = window.location.href;
if (startPage)
url = replaceOrAppendPattern(url,/&startPage=\d+/g,"&startPage="+startPage)
if (newestOnTop)
url = replaceOrAppendPattern(url,/&newestOnTop=\d+/g,"&newestOnTop="+startPage)
window.location = url;
}
}
function replaceOrAppendPattern(str,pattern,newStr){
return str.match(pattern) ? str.replace(pattern,newStr) : str + newStr;
}
function submitEventForm(startPage){
//alert("in submitEventFormSubmitting form"+ $('#eventsearch'));
if (startPage==null){
//Pick the author configured page size from Testimonial Search Component
$("#eventssearchform #pageSize").attr("value",$("#pageSizeConfigured").attr("value"))
$('#eventssearchform').submit();
} else {
var url = window.location.href;
if (startPage)
url = replaceOrAppendPattern(url,/&startPage=\d+/g,"&startPage="+startPage)
window.location = url;
}
}
function loadCountryCombo(){
var selectedRegion = $('#filter-region option:selected').val();
var firstOption = $('#filter-region option:first').val();
if (selectedRegion!=firstOption){
$.ajax({
type: "GET",
url: "",
data: { "filter-region" : selectedRegion },
dataType: "json"
}).done(function(reply) {
var allCountryOption = $("#filter-country option:first");
$("#filter-country").find("option").remove();
$("#filter-country").append(allCountryOption);
$.each(reply, function(key, value) {
$('#filter-country').append($('');
$("#selectcountry").append('');
$("#selectstate").append('');
$("#showinperson").attr("checked","checked");
$("#showonline").attr("checked","checked");
$("#sapevent").attr("checked","checked");
$("#sappartnerevent").attr("checked","checked");
$("#sappartnerevent").attr("checked","checked");
$('label[for="startdate"]').show();
$('label[for="enddate"]').show();
}
function loadStateCombo(){
var selectedCountry = $('#selectcountry').find("option:selected").val();
if(selectedCountry!='all-country'){
$.ajax({
type: "GET",
async: false,
url: "",
data: { "selectcountry" : selectedCountry },
dataType: "json"
}).done(function(reply) {
var allStateOption= $("#selectstate option[value='selectstate']");
$("#selectstate").find("option").remove();
$("#selectstate").append(allStateOption);
$("#selectstate option[value='all-state']").remove();
$("#selectstate").append('');
$.each(reply, function(key, value) {
$('#selectstate').append($('');
}
}
function loadEventCountryDropDown(){
var selectedRegion = $('#selectregion').find("option:selected").val();
if(selectedRegion!='all-region'){
$.ajax({
type: "GET",
async: false,
url: "",
data: { "selectregion" : selectedRegion },
dataType: "json"
}).done(function(reply) {
var allCountryOption = $("#selectcountry option[value='selectcountry']");
$("#selectcountry").find("option").remove();
$("#selectcountry").append(allCountryOption);
$("#selectcountry option[value='all-country']").remove();
$("#selectcountry").append('');
$.each(reply, function(key, value) {
$('#selectcountry').append($('');
}
}
function loadEventDropDown(){
var selectedRegion = $('#selectfocus').find("option:selected").val();
if(selectedRegion != 'events:corporate_events')
{
$("#selectconditional").removeAttr("disabled");
$.ajax({
type: "GET",
async: false,
url: "",
data: { "filter-region" : selectedRegion },
dataType: "json"
}).done(function(reply) {
var allCountryOption = $("#selectconditional option[value='selectconditional']");
$("#selectconditional").find("option").remove();
$("#selectconditional").append(allCountryOption);
$("#selectconditional").append('');
$.each(reply, function(key, value) {
$('#selectconditional').append($('');
$("#selectconditional").attr("disabled","disabled");
}}
function openPopup(url){
jQuery('#wcms_popup_window_normal').bPopup({
modalClose: false,
loadUrl: url,
escClose: true,
position: ['6%', '50%'],
content: 'iframe',
iframeid: 'modal-window',
follow: [false, false],
closeClass : 'b-close',
onOpen : function(){
$('#wcms_popup_window_normal iframe').css('width', '950px');
$('#wcms_popup_window_normal').css('margin-left', '-475px');
}
});
$("#modal-window").attr("style","width: 950px; height: 514px;");
$('').insertBefore('#modal-window');
}
function openPopupCJ(url){
jQuery('#wcms_popup_window_normal').bPopup({
modalClose: false,
loadUrl: url,
escClose: true,
position: [40, '16%'],
content: 'iframe',
iframeid: 'modal-window',
follow: [true, false],
closeClass : 'b-close',
scrollBar : true,
positionStyle: 'fixed',
iframeAttr:("scrolling='yes'"),
onClose : function(){
$("html, body").css('overflow-y', 'scroll');
$("html, body").css('overflow-x', 'hidden');
}
});
if ($.browser.msie ) {
$("#modal-window").attr("style","width: 956px; height: 670px;");
}
else
{
$("#modal-window").attr("style","width: 966px; height: 670px;");
}
$('').insertBefore('#modal-window');
}