/* *
 * 顯示載入信息
 */
function showLoader()
{
  $jQuery('#loader').show();
}

/* *
 * 隱藏載入信息
 */
function hideLoader()
{
  $jQuery('#loader').hide();
}

document.getCookie = function(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");

  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0])
      return decodeURIComponent(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

document.setCookie = function(sName, sValue, sExpires)
{
  var sCookie = sName + "=" + encodeURIComponent(sValue);
  if (sExpires != null)
  {
    sCookie += "; expires=" + sExpires;
  }

  document.cookie = sCookie;
}

document.removeCookie = function(sName, sValue)
{
  document.cookie = sName + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

function checkHTMLTag(checkObj,alertMsg)
{
  var checkStr = checkObj.value;
  var counts = 0;
  for(i = 0;i < checkStr.length; i++)
  {
    if(checkStr.charAt(i) == '<')
    {
      counts = 1;
      continue;
    }
    if(counts>=1&&checkStr.charAt(i) != '>')
    {
      counts++;
    }
    if(checkStr.charAt(i) == '>')
    {
      if(counts > 1)
      {
        alert(alertMsg + "若要使用\"<\" \">\"符號，建議您使用全形或以其他符號代替，謝謝。");
        checkObj.focus();
        return false;
      }
      else
      {
        counts=0;
      }
    }
  }
  return true;
}

function getUrlParam(param)   {
  var sURL = document.URL.toString();
  var arrURLParams = sURL.split("&");
  var arrParamNames = new Array(arrURLParams.length);
  var arrParamValues = new Array(arrURLParams.length);
  var i = 0;
  for (i=0; i < arrURLParams.length; i++) {
    var sParam =  arrURLParams[i].split("=");
    arrParamNames[i] = sParam[0];
    if (sParam[1] != "")
      arrParamValues[i] = unescape(sParam[1]);
    else
      arrParamValues[i] = "";
  }
  for (i=0; i < arrURLParams.length; i++) {
    if (arrParamNames[i] == param) {
      return arrParamValues[i]
    }
  }
  return "";
}

//if (navigator.appName.indexOf("Internet Explorer") != -1) document.onmousedown = noSourceExplorer;
//function noSourceExplorer()
//{ if (event.button == 2 | event.button == 3) alert("對不起喔 …… 請不要再按右鍵咯，謝謝您啊！"); }

function addBookmarkForBrowser(sTitle, sUrl)
{
	if (window.sidebar && window.sidebar.addPanel) {
		addBookmarkForBrowser = function(sTitle, sUrl) {
			window.sidebar.addPanel(sTitle, sUrl, "");
		}
	} else if (window.external) {
		addBookmarkForBrowser = function(sTitle, sUrl) {
			window.external.AddFavorite(sUrl, sTitle);
		}
	} else {
		addBookmarkForBrowser = function() {
			alert("do it yourself");
		}
	}
	return addBookmarkForBrowser(sTitle, sUrl);
}

$jQuery(document).ready(function() {
  // PNG 在 IE5.5 IE6 透明及滑鼠改變圖像
  $jQuery("img[src$=_out.png]")
		.ifixpng()
    .css({cursor: 'pointer'})
    .hover(
      function () {
        $jQuery(this).iunfixpng();
				var over_src = this.src.substring(0, this.src.lastIndexOf('_out.png')) + '_over.png';
				$jQuery(this).attr('src', over_src).ifixpng();
      },
      function () {
        $jQuery(this).iunfixpng();
				var out_src = this.src.substring(0, this.src.lastIndexOf('_over.png')) + '_out.png';
        $jQuery(this).attr('src', out_src).ifixpng();
      }
    );	
  
	// 全部 PNG 在 IE5.5 IE6 透明
  $jQuery('img[src$=.png]').ifixpng().iunfixpng().ifixpng();
	
	// GIF JPG 滑鼠改變圖像
  $jQuery("img[src$=_out.gif], img[src$=_out.jpg], input[src$=_out.gif], input[src$=_out.jpg]")
    .css({cursor: 'pointer'})
    .hover(
      function () {
        var over_src = this.src.substring(0, this.src.lastIndexOf('_out' + this.src.substring(this.src.lastIndexOf('.')))) + '_over' + this.src.substring(this.src.lastIndexOf('.'));
        $jQuery(this).attr('src', over_src);
      },
      function () {
       var out_src = this.src.substring(0, this.src.lastIndexOf('_over' + this.src.substring(this.src.lastIndexOf('.')))) + '_out' + this.src.substring(this.src.lastIndexOf('.'));
        $jQuery(this).attr('src', out_src);
      }
    );
});
