//設定Cookie
function setCookie(name,value,expires,path,domain,secure)
{
  
  co_str=name + "=" + escape(value) +
         ((expires != null) ? ";expires=" + expires.toGMTString() : "") +
         ((path != null) ? ";path=" + path : "") +
         ((domain != null) ? ";domain=" + domain : "") +
         ((secure != null) ? ";secure" : "");
       
  document.cookie=co_str;
}


//讀取Cookie
function getCookie(key)
{
    begin = document.cookie.indexOf( key+"=" , 0 );
    if( begin == -1 )
    {
        return null;
    }
    begin += key.length + 1;

    end = document.cookie.indexOf( ";", begin );
    if( end == -1 )
    {
        end = document.cookie.length;
    }
    return unescape(document.cookie.substring( begin, end ));
}

//判斷是否為空白
function FormNeed(strFrm,strIpt,strTxt)
{
    Ipt=strIpt.split(",");
    Txt=strTxt.split(",");
    for (i=0; i<Ipt.length; i++)
    {
       switch (strFrm.elements[Ipt[i]].type)
       {
          case 'password':
          case 'text':
          case 'textarea':
             if (strFrm.elements[Ipt[i]].value=='')
             {
                alert("欄位["+Txt[i]+"]內容尚未填寫，請補齊！");
                return false;
             }
             break;
             
         case 'select-one':
             if (strFrm.elements[Ipt[i]].selectedIndex=='0')
             {
                alert("欄位["+Txt[i]+"]內容尚未填寫，請補齊！");
                return false;
             }
             break;
       }
    }
    
    return true;
}

//左方補零
function LeftZero(str,add,num)
{
    var Str_Ipt=str;
    
    for (i=Str_Ipt.length; i<num; i++)
       Str_Ipt=add+Str_Ipt;
    
    return Str_Ipt;
}

//檢查MAIL
function isEmail(elm)
{
   if (elm.value.indexOf("@") != "-1" &&
       elm.value.indexOf(".") != "-1" &&
       elm.value.value != "")
       
      return true;
  
   else
      return false;
}      