//+=========================Dreamweaver js函數====================================================
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-=========================Dreamweaver js函數====================================================
//=========================刪除確認====================================================
function del_confirm(){
	return confirm("您確定要刪除資料嗎??");
}
//=========================刪除確認====================================================
//=========================存取Cookie=================================================
function setCookie(name,value,daynum,path){
	 var str_time=new Date();
	 str_time.setTime(str_time.getTime()+24*60*60*1000*daynum);
	 document.cookie = name+"="+unescape(value)+"; expires="+str_time.toGMTString()+"; path="+path+";";
}
function getCookie(name){
	var cname = name + "=";
	if (document.cookie.length != 0){
		begin = document.cookie.indexOf(cname);
		if(begin != -1){
			begin += cname.length;
			end = document.cookie.indexOf(";", begin);
			if(end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
		}				
	}
	return "";	
}
//=========================存取Cookie=================================================
//=========================處理文字方塊輸入換空白=========================================
function textInputAutoNull(){
	$(":text,textarea").click(function(){ 
		if ($(this).val()==$(this).attr("alt")) $(this).val("");
	})
	$(":text,textarea").blur(function(){ 
		if ($(this).val()=="") $(this).val($(this).attr("alt"));
	})
}
//=========================處理文字方塊輸入換空白=========================================
//=========================欄位格式檢核====================================================
function check_basic_field(){ 	
	var arr_input=$("#form1 :input[validate]");
	for (var i=0;i<arr_input.length;i++){
		var obj_input=arr_input.eq(i);
		var arr_validate=obj_input.attr("validate").split(",");
		var str_name=obj_input.attr("alt").substring(5,obj_input.attr("alt").length-2);
		var str_value=$.trim(obj_input.val());
		for (var j=0;j<arr_validate.length;j++){
			switch (arr_validate[j]){
				case "row":
					str_name="第"+obj_input.parent().parent().attr("rowIndex")+"筆"+str_name;
					break;	
				case "null":				
					if (((str_value=="")||(str_value==obj_input.attr("alt")))&&(!obj_input.attr("vdnullold"))&&(obj_input.css("display")!="none")){						
						alert("["+str_name+"]請勿空白");return false;	
					}
					break;
				case "len":
					if ((str_value=="")||(str_value==obj_input.attr("alt"))) break;
					if (str_value.length>obj_input.attr("vdlength")){		
						alert("["+str_name+"]請勿超過"+obj_input.attr("vdlength")+"個字");return false;		
					}
					break;
				case "num":
					if ((str_value=="")||(str_value==obj_input.attr("alt"))) break;
					var arr_range=obj_input.attr("vdrange").split(",");
					if (!obj_input.attr("vddecimal")){
						if ((str_value<parseInt(arr_range[0],10))||(str_value>parseInt(arr_range[1],10))||(str_value!=parseInt(str_value,10))){
							alert("["+str_name+"]請輸入"+arr_range[0]+"~"+arr_range[1]+"的整數");return false;
						}	
					}else{
						if ((str_value<parseFloat(arr_range[0],10))||(str_value>parseFloat(arr_range[1],10))||(str_value!=parseFloat(str_value,10))){
							alert("["+str_name+"]請輸入"+arr_range[0]+"~"+arr_range[1]+"的數字");
						}
						if ((str_value.indexOf(".")>=0) && (str_value.match(new RegExp(".[0-9]{1,"+obj_input.attr("vddecimal")+"}$","i"))==null)){
							alert("["+str_name+"]請勿超過"+obj_input.attr("vddecimal")+"位小數");return false;
						}
					}	
					break;		
				case "reg":	
					if ((str_value=="")||(str_value==obj_input.attr("alt"))) break;
					if (str_value.match(new RegExp("^"+obj_input.attr("vdregular")+"$","i"))==null){
						alert("["+str_name+"]請使用正確格式");return false;
					}
					break;
				case "ext":		//?!asp$|php$ 不能為程式檔  //jpg$|gif$|bmp   必須為圖片檔	  
					if ((str_value=="")||(str_value==obj_input.attr("alt"))) break;
					if (str_value.match(new RegExp("[\.]("+obj_input.attr("vdregular")+")","i"))==null){
						alert("["+str_name+"]請勿上傳不合法的檔案");return false;
					}
					break;
				case "sub":		//vdsub="check_pw"
					if (errmsg=eval(obj_input.attr("vdsub")+"(obj_input)")){
						alert("["+str_name+"]"+errmsg);return false;
					}
					break;			
			} 
		}
	}
	//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	//處理表單提交disabled的控制項時值為NULL
	$("#form1 :disabled").removeAttr("disabled");
	//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	
	//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	//送出前若VALUE=ALT則VALUE設為空白
	SubmitClearInputAlt();
	//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	
	return true;
}

//=========================欄位格式檢核====================================================     
//===========================驗證身分證字號==========================
//檢查身分證字號
function check_pid(obj_id){
	errmsg="請使用正確格式";
	id=obj_id.value.toUpperCase();
	if (id.length != 10) return errmsg;

	if (isNaN(id.substr(1,9)) || (id.substr(0,1)<"A" ||id.substr(0,1)>"Z"))	return errmsg;

	var head="ABCDEFGHJKLMNPQRSTUVXYWZIO";
	id = (head.indexOf(id.substring(0,1))+10) +''+ id.substr(1,9)
	s =parseInt(id.substr(0,1)) + 
	parseInt(id.substr(1,1)) * 9 + 
	parseInt(id.substr(2,1)) * 8 + 
	parseInt(id.substr(3,1)) * 7 + 			
	parseInt(id.substr(4,1)) * 6 + 
	parseInt(id.substr(5,1)) * 5 + 
	parseInt(id.substr(6,1)) * 4 + 
	parseInt(id.substr(7,1)) * 3 + 
	parseInt(id.substr(8,1)) * 2 + 
	parseInt(id.substr(9,1)) + 
	parseInt(id.substr(10,1));

	//判斷是否可整除
	if ((s % 10) != 0) return errmsg;

	//身分證字號正確		
	return "";	  
}
//===========================驗證身分證字號==========================
//===========================檢查驗證碼==========================
function validateImageCodeCorrect(obj_inputcode){
	var errmsg="請和圖形驗證碼一致";
	var str_input=md5($.trim(obj_inputcode.val()).toUpperCase());
	var str_image=getCookie(obj_inputcode.attr("vdargs")); //vdargs存放Cookie名字
	return (str_input!=str_image)?errmsg:"";
}
//===========================檢查驗證碼==========================
//===========================檢查確認密碼==========================
//檢查確認密碼
function validateConfirmPasswordCorrect(obj_pw2){
	var errmsg="請和密碼一致";
	var str_pw=$.trim($("#"+obj_pw2.attr("vdargs")).val()) //vdargs存放密碼欄位名稱
	var str_pw2=$.trim(obj_pw2.val());
	return (str_pw2!=str_pw)?errmsg:""; 
}
//===========================檢查確認密碼==========================
//===========================檢查日期正確========================
function validateDateCorrect(obj_date){
	var errmsg="請使用正確日期";
	var str_date=$.trim(obj_date.val());
	//未填則跳過
	if (str_date=="") return "";	
	//格式檢查
	if(! str_date.match(/^([1-2]{1,1}[0-9]{3,3})-([0-1]{0,1}[0-9]{1,1})-([0-3]{0,1}[0-9]{1,1})$/)){
		return errmsg;
	}	
	//有效日期檢查
	var arr_date=str_date.split("-");
	var date= new Date(parseInt(arr_date[0],10),parseInt(arr_date[1],10)-1,parseInt(arr_date[2],10));	
	if(! ( (date.getFullYear()==parseFloat(arr_date[0])) && (date.getMonth()+1==parseFloat(arr_date[1])) && (date.getDate()==parseFloat(arr_date[2])) ) ){
		return errmsg;
	}
	return "";
}
//===========================檢查日期正確========================
//===========================送出表單時清空欄位提示字元========================
function SubmitClearInputAlt(){
	$("#form1 :input").each(function(){
		if ($.trim($(this).val())==$.trim($(this).attr("alt"))) $(this).val("");
	})
}
//===========================送出表單時清空欄位提示字元========================
//============================動態產生輸入附檔欄位==========================
function CreateSWFUpload(button_id,queue_limit,file_type,file_size_limit,session_id){
	//取得檔案型態
	var arr_type=new Array(new Array("all","mov","img","swf","pdf","doc"),new Array("*.*","*.flv;*.wmv","*.jpg;*.gif;*.png","*.swf;*.gif","*.pdf","*.doc"),new Array("All Files","Flash Video Files; Windows Media Files","JPG Image; GIF Image; PNG Image","Flash Player; GIF Image","Adobe Acrobat Document","Word Document"))
	type_num=$.inArray(file_type,arr_type[0]);		
	//設定參數
	var settings = {
		flash_url : "include/swfupload/swfupload.swf",
		flash9_url : "include/swfupload/swfupload_fp9.swf",
		upload_url: "admin/upload.php",
		file_post_name: "file_upload",
		post_params: {"PHPSESSID" : session_id},
		file_size_limit : file_size_limit,
		file_types : arr_type[1][type_num],
		file_types_description : arr_type[2][type_num],
		file_upload_limit : 0,
		file_queue_limit : queue_limit,
		debug: false,
		
		// Button settings
		button_image_url: "images/admin_attach_upload.png",
		button_placeholder_id: button_id,
		button_window_mode: "transparent",
		button_width: "40",
		button_height: "19",
			
		// The event handler functions are defined in handlers.js
		swfupload_preload_handler : preLoad,
		swfupload_load_failed_handler : loadFailed,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete
	};
	//建立物件
	var swfu = new SWFUpload(settings);
}
function CreateLinkDialog(){
	var dialog_html;
	dialog_html ="<div id=\"dialog_addlink\" title=\"請輸入連結網址,一次可新增1~3筆連結!!\" style=\"display:none;\" >";
	dialog_html+=	"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	dialog_html+=		"<tr><td>1.<input type=\"text\" name=\"txt_link1\" id=\"txt_link1\" size=\"50\" maxlength=\"200\"></td></tr>";
	dialog_html+=		"<tr><td>2.<input type=\"text\" name=\"txt_link2\" id=\"txt_link2\" size=\"50\" maxlength=\"200\"></td></tr>";
	dialog_html+=		"<tr><td>3.<input type=\"text\" name=\"txt_link3\" id=\"txt_link3\" size=\"50\" maxlength=\"200\"></td></tr>";
	dialog_html+=	"</table>";
	dialog_html+="</div>";
	$("body").append(dialog_html);
	$("#dialog_addlink").dialog({ autoOpen: false, modal: true, width:360, height:170,
		buttons: {'新增': function() {
				$("#dialog_addlink :text").each(function(){ 
					if ($.trim($(this).val())!=""){
						var result=$(this).val().match(/\w+(\.\w+)+/g);
						var title=(result)?result[0]:"";
						multiRowInsert("",title,"link",$(this).val());						
					}
					$(this).val("");  
				});													  
				$(this).dialog('close');
			}
		}
	});
	$("#btn_multi_addlink").click(function(){  $("#dialog_addlink").dialog("open"); });
}
function singleFileUpdate(swfid,title,path){
	var obj_hid=$("#"+swfid).next();
	var obj_link=$("#"+swfid).next().next();
	obj_hid.val(path);
	obj_link.attr("href",path).text(getFileTitleExtension(title,path));
}
//新增資料列
function multiRowInsert(sn,title,format,path){
	var rowsn, format, tr_html;
	rownum=$("#tab_multi tr").length+1;
	tr_html ="<tr>";
	tr_html+=	"<td class=\"attach_rowdel\" title=\"點擊刪除\">刪除</td>";	
	tr_html+=	"<td class=\"attach_rowsort\" title=\"拖曳排序\">排序</td>";
	tr_html+=	"<td>";
	tr_html+=		"<span id=\"lbl_multi_num\">"+ rownum +"</span>.";
	tr_html+=		"<input name=\hid_multi_sn[]\ type=\"hidden\" id=\"hid_multi_sn\" value=\""+ sn +"\">";
	tr_html+=		"<input name=\"hid_multi_format[]\" type=\"hidden\" id=\"hid_multi_format\" value=\""+ format +"\">";
	tr_html+=		"<input name=\"hid_multi_path[]\" type=\"hidden\" id=\"hid_multi_path\" value=\""+ path +"\">";
	tr_html+=	"</td>";
	tr_html+=	"<td><input name=\"txt_multi_title[]\" type=\"text\" id=\"txt_multi_title\" value=\""+ title +"\" size=\"30\" alt=\"--請輸入標題--\" validate=\"row,null,len\" vdlength=\"100\"></td>";
	tr_html+=	"<td><a href=\""+ path +"\" target=\"_blank\">"+ getFileTitleExtension(title,path) +"</a></td>";
	tr_html+="</tr>";
	$("#tab_multi").append(tr_html);
	$("#tab_multi").tableDnDUpdate();
}

//刪除資料列
function multiRowDelete(){
	//將SN放到delsn欄位記錄
	$("#hid_multi_delsn").val($("#hid_multi_delsn").val()+","+$(this).closest("tr").find("#hid_multi_sn").val());
	//刪除該列
	$(this).closest("tr").remove();
	//重排編號
	$("#tab_multi span[id='lbl_multi_num']").each(function(){ $(this).html($(this).closest("tr").attr("rowIndex")+1); });
}
//排序
function multiRowSort(){	
	//重排編號
	$("#tab_multi span[id='lbl_multi_num']").each(function(){ $(this).html($(this).closest("tr").attr("rowIndex")+1); });
}
//取得檔案的標題及副檔名顯示文字
function getFileTitleExtension(title,path){
	return ((title!="")?(title+"【"+path.substr(path.lastIndexOf(".")+1,path.length).toUpperCase()+"】"):(""));	
}
//============================動態產生輸入附檔欄位========================
//============================MD5編碼==========================
function MD5_rhex(num){
  var hex_chr = "0123456789abcdef";
  str = "";
  for(j = 0; j <= 3; j++)
    str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
           hex_chr.charAt((num >> (j * 8)) & 0x0F);
  return str;
}
//Convert a string to a sequence of 16-word blocks, stored as an array. Append padding bits and the length, as described in the MD5 standard.
function MD5_str2blks(str){
  nblk = ((str.length + 8) >> 6) + 1;
  blks = new Array(nblk * 16);
  for(i = 0; i < nblk * 16; i++) blks[i] = 0;
  for(i = 0; i < str.length; i++)
    blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
  blks[i >> 2] |= 0x80 << ((i % 4) * 8);
  blks[nblk * 16 - 2] = str.length * 8;
  return blks;
}
//Add integers, wrapping at 2^32. This uses 16-bit operations internally to work around bugs in some JS interpreters.
function MD5_add(x, y){
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}
//Bitwise rotate a 32-bit number to the left
function MD5_rol(num, cnt){
  return (num << cnt) | (num >>> (32 - cnt));
}
//These functions implement the basic operation for each round of the algorithm.
function MD5_cmn(q, a, b, x, s, t){
  return MD5_add(MD5_rol(MD5_add(MD5_add(a, q), MD5_add(x, t)), s), b);
}
function MD5_ff(a, b, c, d, x, s, t){
  return MD5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function MD5_gg(a, b, c, d, x, s, t){
  return MD5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function MD5_hh(a, b, c, d, x, s, t){
  return MD5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function MD5_ii(a, b, c, d, x, s, t){
  return MD5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
//Take a string and return the hex representation of its MD5.
function md5(str){
  x = MD5_str2blks(str);
  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;
 
  for(i = 0; i < x.length; i += 16){
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;

    a = MD5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = MD5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = MD5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = MD5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = MD5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = MD5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = MD5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = MD5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = MD5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = MD5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = MD5_ff(c, d, a, b, x[i+10], 17, -42063);
    b = MD5_ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = MD5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = MD5_ff(d, a, b, c, x[i+13], 12, -40341101);
    c = MD5_ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = MD5_ff(b, c, d, a, x[i+15], 22,  1236535329);    

    a = MD5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = MD5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = MD5_gg(c, d, a, b, x[i+11], 14,  643717713);
    b = MD5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = MD5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = MD5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = MD5_gg(c, d, a, b, x[i+15], 14, -660478335);
    b = MD5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = MD5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = MD5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = MD5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = MD5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = MD5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = MD5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = MD5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = MD5_gg(b, c, d, a, x[i+12], 20, -1926607734);
    
    a = MD5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = MD5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = MD5_hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = MD5_hh(b, c, d, a, x[i+14], 23, -35309556);
    a = MD5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = MD5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = MD5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = MD5_hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = MD5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = MD5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = MD5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = MD5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = MD5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = MD5_hh(d, a, b, c, x[i+12], 11, -421815835);
    c = MD5_hh(c, d, a, b, x[i+15], 16,  530742520);
    b = MD5_hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a = MD5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = MD5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = MD5_ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = MD5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = MD5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = MD5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = MD5_ii(c, d, a, b, x[i+10], 15, -1051523);
    b = MD5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = MD5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = MD5_ii(d, a, b, c, x[i+15], 10, -30611744);
    c = MD5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = MD5_ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = MD5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = MD5_ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = MD5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = MD5_ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a = MD5_add(a, olda);
    b = MD5_add(b, oldb);
    c = MD5_add(c, oldc);
    d = MD5_add(d, oldd);
  }
  return MD5_rhex(a) + MD5_rhex(b) + MD5_rhex(c) + MD5_rhex(d);
}	
//============================MD5編碼==========================

//★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
//★★★★★★★★★★★★★★★★★★★★　畫面特殊功能　★★★★★★★★★★★★★★★★★★★★
//★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//[後端網站連結]類型Select變更時,順序Textbox填入最大值
function weblinkChangeKindGetMaxsort(obj_kind){
	var sortvalue=$(obj_kind).find(":selected").attr("sortvalue");
   	$("#txt_sort").val(sortvalue);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//[後端選單維護]格式Select選單變時,處理內容值Tr變化
function menuChangeFormatUpdateValue(format){
	var trurlshow,txturlshow,txturlvalue,trpathshow,hidpathshow,hidpathvalue;
	if (format=="valueurl"){
		trurlshow="table-row"; txturlshow="inline"; txturlvalue=$("#txt_url").attr("default");
		trpathshow="none"; hidpathshow="none"; hidpathvalue="";
	}else if (format=="valuefile"){	
		trurlshow="none"; txturlshow="none"; txturlvalue="";
		trpathshow="table-row"; hidpathshow="inline"; hidpathvalue=$("#hid_path").attr("default");
	}else{
		trurlshow="none"; txturlshow="none"; txturlvalue="";
		trpathshow="none"; hidpathshow="none"; hidpathvalue="";
	}
	$("#tr_url").css("display",trurlshow);
	$("#txt_url").css("display",txturlshow);
	$("#txt_url").val(txturlvalue);
	$("#tr_path").css("display",trpathshow);
	$("#hid_path").css("display",hidpathshow);
	$("#hid_path").val(hidpathvalue);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//[後端檔案下載]類型Select變更時,處理檔案Tr變化
function dloadChangeKindUpdateFile(kind){
	var trpathshow,hidpathshow,hidpathvalue;
	if (kind=="檔案"){
		trpathshow="table-row"; hidpathshow="inline"; hidpathvalue=$("#hid_path").attr("default");
	}else{
		trpathshow="none"; hidpathshow="none"; hidpathvalue="";
	}
	$("#tr_path").css("display",trpathshow);
	$("#hid_path").css("display",hidpathshow);
	$("#hid_path").val(hidpathvalue);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//[後端資料下載維護]單位選單Select變更時,順序Textbox填入最大值
function ChangeOfficeGetMaxsort(ddl_office){
	var sortvalue=$(ddl_office).find(":selected").attr("sortvalue");
   	$("#txt_sort").val(sortvalue);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//[前端消息]開啟圖片影片視窗
function showImageMediaBox(){
	$("#tr_image a").each(function (){
		$(this).click(function (){ return false;});
		$(this).attr("rel","image").fancybox({
  			'titlePosition'	: 'inside',  
  			'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
					return "<span><div align=\"right\">"+(currentIndex+1)+"/"+currentArray.length+"</div>"+title.substr(0,title.lastIndexOf("【"))+"</span>";
			}						
  		});		
	});
									
	$("#tr_media a").each(function (index){
		var str_href,str_title,html_media;	
		str_href=$(this).attr("href");
		$("body").append("<div id=\"media"+index+"\"></div>");
		$(this).attr("href","#media"+index);
		$(this).click(function (){ return false;});
		html_media ="<object id=\"flowplayer\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"440\" height=\"330\">";
		html_media+=	"<param name=\"wmode\" value=\"transparent\">";
		html_media+=	"<param name=\"movie\" value=\"include/jquery/flowplayer/flowplayer.swf\" />"; 
		html_media+=	"<param name=\"flashvars\" value=\"config={'clip':'"+str_href+"'}\" />";
		html_media+=	"<embed type=\"application/x-shockwave-flash\" width=\"440\" height=\"330\" wmode=\"transparent\""; 
		html_media+=		"src=\"include/jquery/flowplayer/flowplayer.swf\"";
		html_media+=		"flashvars=\"config={'clip':'"+str_href+"'}\"/>";
		html_media+=		str_title;
		html_media+="</object>";		
		$(this).attr("rel","gallery").fancybox({
			'titlePosition'	: "inside",  
  			'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
					return "<span><div align=\"right\">"+(currentIndex+1)+"/"+currentArray.length+"</div>"+title.substr(0,title.lastIndexOf("【"))+"</span>";
			},									 
			'onStart'		: function() {						
				$("#media"+index).show();
				$("#media"+index).append(html_media);				
			},
			'onCleanup'		: function() {						
				$("#media"+index).hide();
				$("#media"+index).empty();
			}
		});			
	});
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
