﻿/* IE6訊息提示，設置對話框全局默認配置，樣式設定*/
(function($, window, artDialog, undefined) {
	
	var config = artDialog.defaults;
	
	config['skin'] = 'default'; // black , green ,default
	config['path'] = 'plugins/artDialog';
	
	config['drag'] = true;
	config['showTemp'] = 100000;
	
	config['title'] = '網頁訊息';
	config['okVal'] = '確定';
	config['cancelVal'] = '取消';
	
	var link = document.createElement('link');
	link.rel = 'stylesheet';
	link.href = config['path'] + '/skins/' + config['skin'] + '.css';
	document.getElementsByTagName('head')[0].appendChild(link);
	
	artDialog.IE6A = function (options) {
		
		var opt = options || {},
			api;
		
		var config = {
			title: false,
			fixed: true,
			lock: true,
			padding: 0,
			opacity: .7
		};
		
		for (var i in opt) {
			if (config[i] === undefined) config[i] = opt[i];
		};
		
		return artDialog(config);
	}
	
	artDialog.IE6B = function (options) {
		
		var opt = options || {},
			api, aConfig, hide, wrap, top,
			duration = 800;
				
		var config = {
			id: 'Notice',
			left: '100%',
			top: '100%',
			padding: 0,
			fixed: true,
			title: false,
			drag: false,
			resize: false,
			follow: null,
			lock: false,
			init: function(here) {
				api = this;
				aConfig = api.config;
				wrap = api.DOM.wrap;
				top = parseInt(wrap[0].style.top);
				hide = top + wrap[0].offsetHeight;
				
				wrap.css('top', hide + 'px')
					.animate({top: top + 'px'}, duration, function() {
						opt.init && opt.init.call(api, here);
					});
			},
			close: function(here){
				wrap.animate({top: hide + 'px'}, duration, function() {
					opt.close && opt.close.call(this, here);
					aConfig.close = $.noop;
					api.close();
				});
				
				return false;
			}
		};	
		
		for (var i in opt) {
			if (config[i] === undefined) config[i] = opt[i];
		};
		
		return artDialog(config);
	};	
})(window.jQuery || window.art, this, this.artDialog);

jQuery(document).ready(function() {	

  var ctrlDown = false;
  var ctrlKey = 17, cKey = 67, xKey = 68;
  
  /* 鎖右鍵 */
  jQuery(document).bind("contextmenu",function(e) {
    alert('請尊重智慧產權！');
    return false;
  });
  
  /* 鎖拖曳 */
  jQuery(document).bind("dragstart",function(e) {
    return false;
  });

  /* 鎖反白 */
  jQuery(document).bind("selectstart", function(e){ return false; });
  
  /* 鎖反白 for FireFox*/
	jQuery('body').css('-moz-user-select','none');
  
  /* 取得 Ctrl 鍵點擊狀態 */
  jQuery(document).keydown(function(e) {
      if (e.keyCode == ctrlKey) { ctrlDown = true; }
  }).keyup(function(e) {
      if (e.keyCode == ctrlKey) { ctrlDown = false; }
  });
  jQuery(document).keydown(function(e) {
      /* 鎖 ctrl + c */
      if (ctrlDown && (e.keyCode == cKey)) { return false; }
      /* 鎖 ctrl + x */
      if (ctrlDown && (e.keyCode == xKey)) { return false; }
  });

	if (jQuery('div.iSWF605')[0]) {
		swfobject.embedSWF('themes/default/images/index.swf', 'indSwf', '1000', '605', '10', 'images/expressInstall.swf', {}, {menu: false, wmode: 'transparent'}, {});
		swffit.fit("indSwf");
	}
	else if (jQuery('div.pSWF325')[0]) {
		swfobject.embedSWF('themes/default/images/banner1.swf', 'banSwf', '1000', '325', '10', 'images/expressInstall.swf', {}, {menu: false, wmode: 'transparent'}, {});
		swffit.fit("banSwf");
	}
 
  // 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);
          }
        }
      }
    );
		

	// IE6 彈跳訊息
	if ((jQuery.browser.msie && jQuery.browser.version <= 6) && jQuery.cookie("IE6") == null) {
		jQuery.dialog.IE6B({
			content: jQuery('#domMessage')[0],
			time: 5,
			init: function(here){
				var api = this;
				jQuery('#domMessage input[type="button"]').click(function() {
					api.close();
				});
				jQuery.cookie("IE6", 1, { expires: 1}); 
			}
		});
	}

})
// 防止按右鍵機制
.bind("contextmenu", function(e) {
	//alert('請尊重智慧產權！');
	//return false;
});

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);
}

