﻿var flag = 0 ;

function checknumber(source,base)
{
  var isnum=/(^\d+$)|(^\d+\.\d+$)/ ;
  if (!isnum.test(source.value) && source.value != "" )
   {
     source.value = base ;
     alert("數值欄位只能輸入數字 ! ") ;
     source.focus()	 ;
	}
  else if (source.value == "") source.value = base ;
}

function trim(data)
{
  var data;
  for (var begin=0; begin<data.length; begin++)
    if (data.charAt(begin) != " ") break;
  for (var end=data.length; end>0; end--)
    if (data.charAt(end-1) != " ") break;
  return data.slice( begin, end );
}

function OpenWindow(url,wID,hh,ww)
{
	var xLeft = (screen.width - hh)/2;
	var yTop = (screen.height - ww)/2;
	popupWin = window.open(url,wID,'width='+hh+',height='+ww+',scrollbars=no,left='+xLeft+',top='+yTop) ;
	popupWin.focus() ;
}

function checkid(Obj)
{
	id=Obj.value.toUpperCase();
	if( id.length<10 ) return false ;
	
	var Total = 0 ;
	switch (id.substring(0,1))
	{
		case "A" :
			Total = 1 ;
			break ;
		case "B" :
			Total = 10 ;
			break ;
		case "C" :
			Total = 19 ;
			break ;
		case "D" :
			Total = 28 ;
			break ;
		case "E" :
			Total = 37 ;
			break ;
		case "F" :
			Total = 46 ;
			break ;
		case "G" :
			Total = 55 ;
			break ;
		case "H" :
			Total = 64 ;
			break ;
		case "I" :
			Total = 39 ;
			break ;
		case "J" :
			Total = 73 ;
			break ;
		case "K" :
			Total = 82 ;
			break ;
		case "L" :
			Total = 2 ;
			break ;
		case "M" :
			Total = 11 ;
			break ;
		case "N" :
			Total = 20 ;
			break ;
		case "O" :
			Total = 48 ;
			break ;
		case "P" :
			Total = 29 ;
			break ;
		case "Q" :
			Total = 38 ;
			break ;
		case "R" :
			Total = 47 ;
			break ;
		case "S" :
			Total = 56 ;
			break ;
		case "T" :
			Total = 65 ;
			break ;
		case "U" :
			Total = 74 ;
			break ;
		case "V" :
			Total = 83 ;
			break ;
		case "W" :
			Total = 21 ;
			break ;
		case "X" :
			Total = 3 ;
			break ;
		case "Y" :
			Total = 12 ;
			break ;
		case "Z" :
			Total = 30 ;
			break ;
	}
	if (Total == 0) return false ;
	for (var i = 1 ; i < 9 ; i++)
	{
		if( parseInt(id.substring(i,i+1)) > 0 || id.substring(i,i+1)=='0') 
			Total = Total + parseInt(id.substring(i,i+1)) * (9-i) ;
		else return false ;
	}
	Total += parseInt(id.substring(9,10)) ;
    return  (Total % 10 == 0)  ;
}

function HaveEnglish(Str)
{
  for(var i = 0;i<Str.length;i++)
  {
    if(Str.charCodeAt(i)<255) return true;
  }
  return false ;
}

function dodiscountprint(did)
{
	var img = new Image();
	img.src = "../CoolponRoot.gif"
	if (did != "") OpenWindow("../discount_print_A4.aspx?did=" + did , "onlineprint",610,500)  ;
}

function doibonprint(did)
{
	if (did != "") OpenWindow("../discount_print_711.aspx?did=" + did , "onlineprint",830,630)  ;
}