function SelectStatus(el,o)
{
	if($(el).attr("checked")==true)
	{
		$('#'+o).val(parseInt($('#'+o).val())+1);
	
	}
	else
	{
		$('#'+o).val(parseInt($('#'+o).val())-1);
	}
}
function AddFilesTr(o,filenum,filetitle,txttitle,filetype)
{
	var n = parseInt($('#'+filenum).val());		
	var x=$('#'+o).append('<div class="TB-upfile"> <table cellpadding="0" cellspacing="0"> <tr><th width="55">上傳檔案 :</th><td><input type="file"  name="'+filetitle+n+'" id='+filetitle+n+' onchange="checkFile(\''+filetype+'\',this);" size="38" style="width:300px;" /></td></tr> <tr> <th>顯示名稱 :</th><td><input type="text" name='+txttitle+n+' id='+txttitle+n+' class="tf" style="width:200px;" /></td> </tr></table></div>');	
	$('#'+filenum).val(n+1);
	
}

function RemoveTr(o)
{
	$("#"+o).children().get(0).remove();
}
function OrderEpaper(t)
	{
		var email=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
		var a = $('#memail').val();
		if(a=='')
		{
			alert('請輸入郵件地址');
			return false;
		}
		else if(!email.test(a))
		{
			$('#memail').focus();
			alert('Email填寫錯誤');
			return false;
		}
		$.ajax({
			type:'post',
			url:'joinepaper.php',
			data:'email='+a+'&action='+t,
			success:function(b){
				if (b==1)
				{
					alert('訂閱操作成功');
					$('#memail').val('');
					$('#epaperForm').hide();
				}
				else if (b==3)
				{
					alert('取消訂閱操作成功');
					$('#memail').val('');
					$('#epaperForm').hide();
				}
				else if (b==2)
				{
					alert('您已訂閱');
				}
				else if(b==4){
					alert('請選登入');
				}
			}
		
		});
		return false;
	}
	function setupShadowbox() {

    Shadowbox.setup("a.mustang-gallery", {
        gallery:        "mustang",
        continuous:     true,
        counterType:    "skip"
    });

}
function checkTwID(id){  
    var city = new Array(  
         1,10,19,28,37,46,55,64,39,73,82, 2,11,  
        20,48,29,38,47,56,65,74,83,21, 3,12,30  
    )  
    id = id.toUpperCase();   
    if (id.search(/^[A-Z](1|2)\d{8}$/i) == -1) {    
        return false;
    } else {  
        id = id.split('');  
        var total = city[id[0].charCodeAt(0)-65];  
        for(var i=1; i<=8; i++){  
            total += eval(id[i]) * (9 - i);  
        }  
        total += eval(id[9]);  
        return ((total%10 == 0 ));  
    }  
}
