function addBookmarkForBrowser(sTitle, sUrl)
{
  var userAgent = navigator.userAgent.toLowerCase();
  var browser = {
    version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
    safari: /webkit/.test( userAgent ),
    opera: /opera/.test( userAgent ),
    msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
    mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
  }

  if (browser.mozilla) {
    addBookmarkForBrowser = function(sTitle, sUrl) {
      window.sidebar.addPanel(sTitle, sUrl, "");
    }
  } else if (browser.msie) {
    addBookmarkForBrowser = function(sTitle, sUrl) {
      window.external.AddFavorite(sUrl, sTitle);
    }
  } else if (browser.safari) {
    addBookmarkForBrowser = function() {
      alert("do it yourself");
    }
  } else {
    addBookmarkForBrowser = function() {
      alert("do it yourself");
    }
  }
  return addBookmarkForBrowser(sTitle, sUrl);
}

var $jQuery = jQuery.noConflict();

// 頁面選單
swfobject.embedSWF('swf/icon.swf', 'icon', '1000', '92', '9', 'images/expressInstall.swf', {}, {quality: 'high', wmode: 'transparent', menu: false}, {});

// 頁面橫幅
if ($jQuery('#pFlash').get(0))
{
    swfobject.embedSWF('swf/pbanner.swf', 'pFlash', '1000', '195', '9', 'images/expressInstall.swf', {}, {quality: 'high', wmode: 'transparent', menu: false}, {});
}

if ($jQuery('#pGoods').get(0))
{
    swfobject.embedSWF('swf/goods.swf', 'pGoods', '492', '245', '9', 'images/expressInstall.swf', {}, {quality: 'high', wmode: 'transparent', menu: false}, {});
}

// 頁面廣告
if ($jQuery('#adv').get(0))
{
    swfobject.embedSWF('images/bcastr.swf?xml=cycle_image.php', 'adv', '250', '145', '9', 'images/expressInstall.swf', {}, {quality: 'high', wmode: 'transparent', menu: false}, {});
}

$jQuery(document).ready(function() {
  // 切換關鍵字背底圖
  var _kw = $jQuery('#s_keyword');
  _kw.focus(function() {
    $jQuery(this).removeClass('search');
  });
  _kw.blur(function() {
    if ($jQuery(this).val() == '') $jQuery(this).addClass('search');
  });
  
  // 切換按鈕樣式
  $jQuery('.ezpos').hover(
  function() {
      // 變換樣式
      _this = $jQuery(this).css('background-position', '0px -23px');
  },
  function() {
      // 變換樣式
      _this = $jQuery(this).css('background-position', '0px 0px');
  });

  // PNG 在 IE5.5 IE6 透明及滑鼠改變圖像
  $jQuery("img[src$=_out.png], input[src$=_out.png]")
    .ifixpng()
    .css({cursor: 'pointer'})
    .hover(
      function () {
        $jQuery(this).iunfixpng();
        var img_src = this.src;
        if (img_src != '_out.png') {
          var over_src = img_src.substring(0, img_src.lastIndexOf('_out.png')) + '_over.png';
          if (over_src != '_over.png') {
            $jQuery(this).attr('src', over_src).ifixpng();
          }
        }
      },
      function () {
        $jQuery(this).iunfixpng();
        var img_src = this.src;
        if (img_src != '_over.png') {
          var out_src = img_src.substring(0, img_src.lastIndexOf('_over.png')) + '_out.png';
          if (out_src != '_out.png') {
            $jQuery(this).attr('src', out_src).ifixpng();
          }
        }
      }
    );

  // 全部 PNG 在 IE5.5 IE6 透明
  $jQuery('img[src$=.png], input[src$=_out.png], .png').ifixpng().iunfixpng().ifixpng();

  // GIF 滑鼠改變圖像
  $jQuery("img[src$=_out.gif], input[src$=_out.gif]")
    .css({cursor: 'pointer'})
    .hover(
      function () {
        var img_src = this.src;
        if (img_src != '_out.gif') {
          var over_src = img_src.substring(0, img_src.lastIndexOf('_out.gif')) + '_over.gif';
          if (over_src != '_over.gif') {
            $jQuery(this).attr('src', over_src);
          }
        }
      },
      function () {
        var img_src = this.src;
        if (img_src != '_over.gif') {
          var out_src = img_src.substring(0, img_src.lastIndexOf('_over.gif')) + '_out.gif';
          if (out_src != '_out.gif') {
            $jQuery(this).attr('src', out_src);
          }
        }
      }
    );

  // JPG 滑鼠改變圖像
  $jQuery("img[src$=_out.jpg], input[src$=_out.jpg]")
    .css({cursor: 'pointer'})
    .hover(
      function () {
        var img_src = this.src;
        if (img_src != '_out.jpg') {
          var over_src = img_src.substring(0, img_src.lastIndexOf('_out.jpg')) + '_over.jpg';
          if (over_src != '_over.jpg') {
            $jQuery(this).attr('src', over_src);
          }
        }
      },
      function () {
        var img_src = this.src;
        if (img_src != '_over.jpg') {
          var out_src = img_src.substring(0, img_src.lastIndexOf('_over.jpg')) + '_out.jpg';
          if (out_src != '_out.jpg') {
            $jQuery(this).attr('src', out_src);
          }
        }
      }
    );
});
