/* 
 * Copyright (c) 2008 Infosys Technologies Limited
 */


// This file contains the logic specific to Intel's requirements for social
// bookmarking.

function launchWindow(url) {
  // disabling window launching sequence as we are opening up the window from
  // the link directly.
  // window.open(url);
}

function get_Variables(custom06) {
  var waVars = '';
  if(wa_custom01) {
    waVars = waVars + 'wa_custom01=' + wa_custom01 + '&';
  }

  if(wa_custom03) {
    waVars = waVars + 'wa_custom03=' + wa_custom03 + '&';
  }

  if(wa_custom05) {
    waVars = waVars + 'wa_custom05=' + wa_custom05 + '&';
  }

  // Add the custom 06 variable.
  waVars = waVars + 'wa_custom06=' + custom06 + '&';
  waVars = waVars + 'wa_events=se_cust12';

  return waVars;
}

function bookmarkthis(providerId, invoker) {
  if(providerId) {
    if ( "digg" == providerId) {
      digg_bookmark(invoker);
    } else if ( "delicious" == providerId ) {
      delicious_bookmark(invoker);
    } else if ("technoratti" == providerId ) {
      technoratti_bookmark(invoker);
    } else if ( "stumbleupon" == providerId ) {
      stumbleUpon_bookmark(invoker);
    } else if ( "xianguo" == providerId) {
      xianguo_bookmark(invoker);
    }
  }
}

function digg_bookmark(invoker) {
  var s='s_gs()';
  // Failsafe, check to see if the function has been defined or not.
  if(waCustomLink) {
    waCustomLink(invoker, "wiy digg icon", 'o', get_Variables('send to digg'));
  }
  var url = 'http://digg.com/submit?phase=2&url=' +
    encodeURIComponent(location.href) + '&title=' +
    encodeURIComponent(document.title) + '\'';
  
  launchWindow(url);
}

function delicious_bookmark(invoker) {
  var s='s_gs()';
  // Failsafe, check to see if the function has been defined or not.
  if(waCustomLink) {
    waCustomLink(invoker, "wiy del.ico.us icon", 'o', get_Variables('send to del.icio.us'));
  }

  var url = 'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=' +
    encodeURIComponent(location.href) + '&amp;title=' +
    encodeURIComponent(document.title) + '\'';
  
  launchWindow(url);
}

function technoratti_bookmark(invoker) {
  var s='s_gs()';
  // Failsafe, check to see if the function has been defined or not.
  if(waCustomLink) {
    waCustomLink(invoker, "wiy technoratti icon", 'o', get_Variables('send to technoratti'));
  }

  var url = 'http://technorati.com/faves/?add=' +
    encodeURIComponent(location.href) + '\'';
  
  launchWindow(url);
}

function stumbleUpon_bookmark(invoker) {
  var s='s_gs()';
  // Failsafe, check to see if the function has been defined or not.
  if(waCustomLink) {
    waCustomLink(invoker, "wiy stumbleupon icon", 'o', get_Variables('send to stumbleupon'));
  }

  var url = 'http://www.stumbleupon.com/submit?url=' +
    encodeURIComponent(location.href) + '&amp;title=' +
    encodeURIComponent(document.title) + '\'';
  
  launchWindow(url);
}

function xianguo_bookmark(invoker) {
  var s='s_gs()';
  // Failsafe, check to see if the function has been defined or not.
  if(waCustomLink) {
    waCustomLink(invoker, "wiy xianguo icon", 'o', get_Variables('send to xianguo'));
  }

  var url = 'http://www.xianguo.com/subscribe.php?url=' +
    encodeURIComponent(location.href) + '\' ';
  
  launchWindow(url);
}
