// debugging  
function debug(loginfo) {
	if (window.console && window.console.log)  
		window.console.log(loginfo);  
}

function get(objectId){
	if(document.getElementById&&document.getElementById(objectId)){
		return document.getElementById(objectId);
	}else if(document.all&&document.all(objectId)){
		return document.all(objectId);
	}else if(document.layers&&document.layers[objectId]){
		return document.layers[objectId];
	}else{
		return false;
	}
}

//xmlHttpRequest = getXMLHttpRequest();
function getXMLHttpRequest(){
	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}else if (window.ActiveXObject){
		request = new ActiveXObject("Microsoft.XMLHTTP");
		if (!request){
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		return request;
	}
}

function AddHandler(hobj,e,pFn){
	if(hobj.addEventListener){hobj.addEventListener(e.substring(2),pFn,false);}
	else if(hobj.attachEvent){hobj.attachEvent(e,pFn);}
	else{var punk = hobj[e];if(punk == null){hobj[e] = pFn;} else {hobj[e] = function(){punk();pFn();}}}
}
function RemoveHandler(hobj,e,pFn){
	if(hobj.removeEventListener){hobj.removeEventListener(e.substring(2),pFn,false);}
	else if(hobj.detachEvent){hobj.detachEvent(e,pFn);
	}else{var punk=hobj[e];if(punk!=null){hobj[e]=null}}
}

//FCKeditor
//取得編輯器內的值
function getEditorHTMLContents(EditorName) { 
    var oEditor = window.FCKeditorAPI.GetInstance(EditorName); 
    return(oEditor.GetXHTML(true)); 
}
function getEditorTextContents(EditorName) {
var oEditor = window.FCKeditorAPI.GetInstance(EditorName);
return(oEditor.EditorDocument.body.innerText);
}
//清除編輯器內的值
function SetEditorContents(EditorName, ContentStr) {
var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
oEditor.SetHTML(ContentStr) ;
}


//取許標的座標
function getXY(){
	var x=0,y=0;
	var e=event;
  if(null==e)e=event;
  y=e.clientY?e.clientY+document.documentElement.scrollTop:e.pageY;
  x=e.clientX?e.clientX+document.documentElement.scrollLeft:e.pageX;
	return [x,y];
}
//取得某一元素的絕對位置
function getElementPos(obj){   
    var left = 0;   
    var top = 0;   
    if(obj.x){   
        left= obj.x;   
        top = obj.y;   
    }else if(obj.offsetParent){      
        while(obj.offsetParent){          
            left += obj.offsetLeft;   
            top  += obj.offsetTop;   
            obj = obj.offsetParent;   
        }    
    }   
    return [left,top];//返回一個數組
} 
//cookies 
function SetCookie(name,value,Days){
    //var Days = 30;
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name){
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;
 
}
function delCookie(name){
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}



// 圖片比例顯示
function DrawImage(ImgD, iwidth, iheight) {
	var image = new Image();
	image.src = ImgD.src;
	if (image.width > 0 && image.height > 0) {//圖片的長和寬都必需大於0
		if (image.width / image.height >= iwidth / iheight) {//長和寬大於指定的長和寬時縮小圖片
			if (image.width > iwidth) {
				ImgD.width = iwidth;
				ImgD.height = (image.height * iwidth) / image.width;
			} else {
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		} else {
			if (image.height > iheight) {
				ImgD.height = iheight;
				ImgD.width = (image.width * iheight) / image.height;
			} else {
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		}
	}
}
// 圖片比例顯示,特用於在div中無法居中對齊的時候
function DrawImage1(ImgD, iwidth, iheight , iDivHeight) {
	var image = new Image();
	image.src = ImgD.src;
	if (image.width > 0 && image.height > 0) {//圖片的長和寬都必需大於0
		if (image.width / image.height >= iwidth / iheight) {//長和寬大於指定的長和寬時縮小圖片
			if (image.width > iwidth) {
				ImgD.width = iwidth;
				ImgD.height = (image.height * iwidth) / image.width;
			} else {
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		} else {
			if (image.height > iheight) {
				ImgD.height = iheight;
				ImgD.width = (image.width * iheight) / image.height;
			} else {
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		}
		//ImgD.setAttribute("style","margin-top:" + (iDivHeight-ImgD.height)/2 + "px;");
		ImgD.style.margin=(iDivHeight-ImgD.height)/2 + "px 0 0 0";
	}
}

//驗讓是否有漢字
function checkchina(str){
  if(/[^\x00-\xff]/.test(str)){
		return true;
	}else{
		return false;
	}
}
//從左邊第一個開始取子字符串
function cutstring(str,cut_len){
    return str.substring(0,cut_len);
}
//返回字符的長度,一個漢字算2個字節數
function getstringlen(str,gbklen){
	str=ltrim(str);
	if(2==gbklen) {
    str=str.replace(/[^\x00-\xff]/g,'**');
	}
  return str.length;
}
//去兩邊的空格
function trim(str){
  return str.replace(/(^\s*)|(\s*$)/g,'');
}
//去左邊的空格
function ltrim(str){
  return str.replace(/(^\s*)/g,'');
}
//去右邊的空格
function rtrim(str){
  return str.replace(/(\s*$)/g,'');
}
//HTML過濾函數
function HTMLEncode(text){
	text = text.replace(/&/g, "&amp;");
	text = text.replace(/"/g, "&quot;");
	text = text.replace(/</g, "&lt;");
	text = text.replace(/>/g, "&gt;");
	text = text.replace(/'/g, "&#146;");
	return text ;
}

///驗證字符長度
function checklength(obj,num){
  var a=obj.value;
	len = getstringlen(a,2)
  if (a!=''&&len>num)
  {
    alert('String Length is not more than '+num);
	  obj.focus();
	  obj.select();
	  return false;
  }else{
    return true;
  }
}
//----------------------------------
//驗證http://url地址
//---------------------------------
function isHttpUrl(url){
	var Reg=/^http[s]*:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^\"\"])*$/;
	if(url==''){
		return true;
	}else{
		return Reg.test(url);
	}
}

/////////////////////////
//////驗證EMAIL//////////
/////////////////////////
function isEmail(sEmail){
	var regEx=/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	if (sEmail!=''){
    if(regEx.test(sEmail)){
      return true;
	  }else{
	    return false;		
    }
	}else{
		return true;
	}	
}

function checkEmail(obj){
	var regEx=/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	if (obj.value!=''){
    if(isEmail(obj.value)){
      return true;
	  }else{
      alert('電子郵箱格式不正確,請輸入正確的電子郵箱.');
	    obj.focus();
	    obj.select();
	    return false;		
    }
	}else{
		return true;
	}	
}
//驗證是不是一個數字
/// 1: 正整數 
/// 2: 非負整數（正整數 + 0)
/// 3: 非正整數（負整數 + 0）
/// 4: 負整數 
/// 5: 整數
/// 6: 非負浮點數（正浮點數 + 0）
/// 7: 正浮點數
/// 8: 非正浮點數（負浮點數 + 0)
/// 9: 負浮點數 
/// 10: 浮點數
function checkNum(obj,t){
	var regEx='',msg='';
	var a=parseInt(t);
	switch(a){
		case 1:
		  regEx=/^[0-9]*[1-9][0-9]*$/;
			msg='請輸入大於零的整數';
			break;
		case 2:
		  regEx=/^\d+$/;
			msg='請輸入大於等於零的整數';
			break;
		case 3:
		  regEx=/^((-\d+)|(0+))$/;
			msg='請輸入小於等於零的整數';
			break;
		case 4:
		  regEx=/^-[0-9]*[1-9][0-9]*$/;
			msg='請輸入小於零的整數';
			break;
		case 5:
		  regEx=/^-?\d+$/;
			msg='請輸入整數';
			break;
		case 6:
		  regEx=/^\d+(\.\d+)?$/;
			msg='請輸入大於等於零的數值';
			break;
		case 7:
		  regEx=/^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/;
			msg='請輸入大於零的數值';
			break;
		case 8:
		  regEx=/^((-\d+(\.\d+)?)|(0+(\.0+)?))$/;
			msg='請輸入小於等於零的數值';
			break;
		case 9:
		  regEx=/^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/;
			msg='請輸入小於零的數值';
		case 10:
		  regEx=/^(-?\d+)(\.\d+)?$/;
			msg='請輸入數值';
			break;
		default:
		  regEx='';
			break;
	}
	if (obj.value!='' && regEx!=''){
    if(regEx.test(obj.value)){
      return true;
	  }else{
      alert(msg);
	    obj.focus();
	    obj.select();
	    return false;		
    }
	}else{
		return true;
	}
}
function ChckNum(tempstr){
	ptempstr=new String("0123456789");
	for(i=0;i<tempstr.length;i++){
		if(ptempstr.indexOf(tempstr.charAt(i))==-1){
			return false;
		}
	}
	return true;
}
function ChkAbc(tempstr){
	ptempstr=new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
	for(i=0;i<tempstr.length;i++){
		if(ptempstr.indexOf(tempstr.charAt(i))==-1){
			return false;
		}
	}
	return true;
}

function ChkAbcNum(tempstr){
	ptempstr=new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
	for(i=0;i<tempstr.length;i++){
		if(ptempstr.indexOf(tempstr.charAt(i))==-1){
			return false;
		}
	}
	return true;
}

function isDate(sDate){
	var dateExp=/^([1-2]\d{3})[\/|\-](0?[1-9]|10|11|12)[\/|\-]([1-2]?[0-9]|0[1-9]|30|31)$/;
	if(dateExp.test(sDate)){
		return true;
	}else{
		return false;		
	}
}
//驗證日期
function CheckDate(obj){
	if(obj.value!=""){
		if(isDate(obj.value)){
			return true;
		}else{
      alert('Please input right Date,For example:2007/7/1 or 2008-7-1');
	    obj.focus();
	    obj.select();
	    return false;		
		}
	}else{
		return true;
	}
} 
function CheckUrl(obj){
	if(obj.value!=''){
		if(isHttpUrl(obj.value)){
			return true;
		}else{
			alert('請輸入合法的網址\n注意前面需加上http:// or https://');
			obj.focus();
			return false;
		}
	}else{
		return true;
	}
}
function CheckDateTime(dt) 
{
	if(dt!=""){
		//日期格式為2007/12/23 00:00 or 2007-12-23 00:00這個要考試到2月份的情況
		var dateExp=/^((((1[6-9]|[2-9]\d)\d{2})\/(0?[13578]|1[02])\/(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})\/(0?[13456789]|1[012])\/(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})\/0?2\/(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))\/0?2\/29)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$/;
		if(dateExp.test(dt)){
			return true;
		}else{
	    return false;		
		}
	}else{
		return true;
	}
} 


/////////////////////////////////////////////////
//////開啟一個新的窗口
/////////////////////////////////////////////////
function opencenterwin(page,winName,w,h){
  var sw = screen.availWidth;
  var sh = screen.availHeight;
  newwin=this.open(page,winName,["toolbar=0,menubar=0,location=0,scrollbars=0,resize=0,width="+w+",height="+h+",top="+((sh-h-20)*.5)+",left="+((sw-w-30)*.5)]);
}
function opencenterwin1(page,winName,w,h){
  var sw = screen.availWidth;
  var sh = screen.availHeight;
  newwin=this.open(page,winName,"toolbar=no,menubar=no,resiz=0,scrollbars=yes,width="+w+",height="+h+",top="+((sh-h-20)*.5)+",left="+((sw-w-30)*.5),false);
}
function openwin(page,winName,w,h)
{
	window.showModalDialog(page,winName,"DialogWidth:"+w+"px;DialogHeight:"+h+"px;help:no;status:no");
}
/////////////////////////////////////////////
//刪除記錄時的確認
/////////////////////////////////////////////
function onDelete(url){
  answer=confirm('確認刪除此記錄嗎？');
  if (answer)
  {
    location.href = url;
  }
}
function onDelete1(url,msg){
  answer=confirm(msg);
  if (answer){
    location.href = url;
  }
}
function onDelete2(url){
  location.href = url;
}
//////////////////////////////////////////////////
//返回至一頁面
/////////////////////////////////////////////////
function return_url(url){
	location.href = url;
}
////////////////////////////////////////////////
//計算兩個日期相差的天數
///////////////////////////////////////////////
function datediff(sDate1,sDate2){    //sDate1和sDate2是2006-12-18格式
 var aDate,oDate1,oDate2,iDays;
 if(sDate1.indexOf('-')!=-1){
   aDate=sDate1.split('-');
   oDate1=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);//轉換為12-18-2006格式 
 }else{
   aDate=sDate1.split('/');
   oDate1=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);//轉換為12-18-2006格式 
 }
 if(sDate2.indexOf('-')!=-1){
	 aDate=sDate2.split('-');  
   oDate2=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);
 }else{
   aDate=sDate2.split('/');  
   oDate2=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);
 }
 iDays=parseInt(Math.abs(oDate1-oDate2)/1000/60/60/24);    //把相差的ms轉換成天數
 return iDays;  
}
////////////////////////////////////////////////
//計算第一個日期是否在第二個日期前
///////////////////////////////////////////////
function datecomp(smallDate,bigDate){    //sDate1和sDate2是2006-12-18格式
  var aDate,oDate1,oDate2,iDays;
	if(smallDate.indexOf('-')!=-1){
  	aDate=smallDate.split('-');  
  	oDate1=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);//轉換為12-18-2006格式 
	}else{
  	aDate=smallDate.split('/');  
  	oDate1=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);//轉換為12-18-2006格式 
	}
	if(bigDate.indexOf('-')!=-1){
		aDate=bigDate.split('-'); 
    oDate2=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);  
	}else{
		aDate=bigDate.split('/'); 
    oDate2=new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]);  
	}
 iDays=parseInt((oDate2-oDate1)/1000/60/60/24);    //把相差的ms轉換成天數
 if (iDays>0 || iDays==0){
	 return true;
 }else{
	 return false;
 }
}  

////////////////////////////////////驗證是否符合給定的正則表達式/////
function check_code(reg_str,str){
  if (str!='' && reg_str!='' && str!=null && reg_str!=null){
		if(eval(reg_str).test(str)){
			return true;
		}else{
	    return false;		
		}
	}
}
///////////////////////////取文件的副檔名/////////////////////////////
function getfile_ext(file_str){
	var filename,ext;
	if(file_str!=''){
	  filename=file_str.split('.');
		ext=filename[1].toString().toLowerCase();
	}else{
		ext='';
	}
	return ext;
}
function chkFileExt(arg,fileList)
{
	if (arg!=''){
	  var file,fileExt,n;
		if((arg.indexOf("."))!=-1){
			n=arg.lastIndexOf(".")+1;
			fileExt=arg.substring(n,arg.length);
			if(fileList.indexOf(fileExt.toLowerCase())==-1){
				return false;
			}else{
				return true;
			}
		}else{
			return false;
		}
	}else{
	  return true;
	}
}
function getFileName(obj1,obj2){
	if(obj1.value!=''){
		var a,b,c,n;
		a=obj1.value;
		b=a.split('\\');
		c=b[b.length-1];
		n=c.lastIndexOf(".");
		obj2.value=c.substring(0,n);
	}
}
//player_flash
function player_flash(url,width,height){
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	if (is_ie) {
		document.write("<object classid=\"CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+width+"\" height=\""+height+"\"><param name=\"src\" value=\""+url+"\" /><param name=\"autostart\" value=\"true\" /><param name=\"loop\" value=\"true\" /><param name=\"quality\" value=\"high\" /></object>");
	} else {
		document.write("<object data=\""+url+"\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"><param name=\"autostart\" value=\"true\" /><param name=\"loop\" value=\"true\" /><param name=\"quality\" value=\"high\" /><EMBED src=\""+url+"\" quality=\"high\" width=\""+width+"\" height=\""+height+"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></object>");
	}
}


/******************************************************************
js查看圖片
<div id="ViewImageDiv" style="position:absolute;z-index:1;display:none;"></div>
onmouseover="ViewPaperImage(this,true,image);" 
onmouseout="ViewPaperImage(this,false,image);
******************************************************************/
function ViewPaperImage(obj,ViewBoolean,image_src){
	var pos = getElementPos(obj); 
	var image = new Image();
	image.src = image_src;
	//alert(image.width);
	var x=pos[0]-image.width-30;
	var y=pos[1]-2;
	var s='';
	if(ViewBoolean){
		s+='<img src="'+image_src+'" style="border:10px #eee solid;filter:progid:DXImageTransform.Microsoft.Shadow(Color=#333333,Direction=120,strength=3);" />';
		get('ViewPaperImageDiv').innerHTML=s;
		get('ViewPaperImageDiv').style.display='';
		get('ViewPaperImageDiv').style.left=x;
		get('ViewPaperImageDiv').style.top=y;
	}else{
		get('ViewPaperImageDiv').style.display='none';
	}
}

/******************************************************************
js查看圖片
<div id="ViewImageDiv" style="position:absolute;z-index:1;display:none;"></div>
onmouseover="ViewImage(this,true,image);" 
onmouseout="ViewImage(this,false,image);
******************************************************************/
function ViewImage(obj,ViewBoolean,image_src){
	if(ViewBoolean){
		var offsetWidth=document.body.offsetWidth/2;
		var pos = getElementPos(obj);
		var x=pos[0];
		var y=pos[1];
		var image = new Image();
		image.src = image_src;
		
		if(x>offsetWidth){
			x=x-image.width-30;
		}else{
			x=x+30;
		}
		var s='';
		s+='<img src="'+image_src+'" style="border:10px #ccc solid;" />';
		get('ViewImageDiv').innerHTML=s;
		get('ViewImageDiv').style.display='';
		get('ViewImageDiv').style.left=x;
		get('ViewImageDiv').style.top=y;
	}else{
		get('ViewImageDiv').style.display='none';
	}
}
function ViewImage1(obj,ViewBoolean,image_src,iWidth,iHeight){
	if(ViewBoolean){
		var offsetWidth=document.body.offsetWidth/2;
		var pos = getElementPos(obj);
		var x=pos[0];
		var y=pos[1];
		if(x>offsetWidth){
			x=x-iWidth-30;
		}else{
			x=x+30;
		}
		var s='';
		s+='<img src="'+image_src+'" style="border:10px #ccc solid;" width="'+iWidth+'" height="'+iHeight+'" />';
		get('ViewImageDiv').innerHTML=s;
		get('ViewImageDiv').style.display='';
		get('ViewImageDiv').style.left=x;
		get('ViewImageDiv').style.top=y;
	}else{
		get('ViewImageDiv').style.display='none';
	}
}


/******************************************************************
javascript取屏幕信息的一些对象 
******************************************************************/
function DisplayScreenInfo()
{
	var bodyWidth           =document.body.clientWidth;      //网页可见区域宽
	var bodyHeight          =document.body.clientHeight;     //网页可见区域高
	var bodyWidthWithBorder =document.body.offsetWidth;      //网页可见区域宽(包括边线的宽)
	var bodyHeightWithBorder=document.body.offsetHeight;     //网页可见区域高(包括边线的宽)
	var bodyWidthWithScroll =document.body.scrollWidth;      //网页正文全文宽
	var bodyHeightWithScroll=document.body.scrollHeight;     //网页正文全文高     
	var bodyTopHeight       =document.body.scrollTop;        //网页被卷去的上边距
	var bodyLeftWidth       =document.body.scrollLeft;       //网页被卷去的左边距
	var windowTopHeight     =window.screenTop;               //网页正文部分上边距
	var windowLeftWidth     =window.screenLeft;              //网页正文部分左边距 
	var screenHeight        =window.screen.height;           //屏幕分辨率的高
	var screenWidth         =window.screen.width;            //屏幕分辨率的宽
	var screenAvailHeight   =window.screen.availHeight;      //屏幕可用工作区高度 
	var screenAvailWidth    =window.screen.availWidth;       //屏幕可用工作区宽度
	
	var Str="";
	Str+="网页可见区域宽:"+bodyWidth+"px\n";
	Str+="网页可见区域高:"+bodyHeight+"px\n";
	Str+="网页可见区域宽(包括边线的宽):"+bodyWidthWithBorder+"px\n";
	Str+="网页可见区域高(包括边线的宽):"+bodyHeightWithBorder+"px\n";
	Str+="网页正文全文宽:"+bodyWidthWithScroll+"px\n";
	Str+="网页正文全文高:"+bodyHeightWithScroll+"px\n";
	Str+="网页被卷去的上边距:"+bodyTopHeight+"px\n";
	Str+="网页被卷去的左边距:"+bodyLeftWidth+"px\n";
	Str+="网页正文部分上边距:"+windowTopHeight+"px\n";
	Str+="网页正文部分左边距:"+windowLeftWidth+"px\n";
	Str+="屏幕分辨率的高:"+screenHeight+"px\n";
	Str+="屏幕分辨率的宽:"+screenWidth+"px\n";
	Str+="屏幕可用工作区高度:"+screenAvailHeight+"px\n";
	Str+="屏幕可用工作区宽度:"+screenAvailWidth+"px\n";
	alert(Str);
 }


/*-----------------------------------------------------------------*/
Date.prototype.format = function(format) {
	var returnStr = '';
	var replace = Date.replaceChars;
	for (var i = 0; i < format.length; i++) {
		var curChar = format.charAt(i);
		if (replace[curChar]) {
			returnStr += replace[curChar].call(this);
		} else {
			returnStr += curChar;
		}
	}
	return returnStr;
};
Date.replaceChars = {
	shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
	longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
	shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
	longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
	
	// Day
	d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
	D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
	j: function() { return this.getDate(); },
	l: function() { return Date.replaceChars.longDays[this.getDay()]; },
	N: function() { return this.getDay() + 1; },
	S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
	w: function() { return this.getDay(); },
	z: function() { return "Not Yet Supported"; },
	// Week
	W: function() { return "Not Yet Supported"; },
	// Month
	F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
	m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); },
	M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
	n: function() { return this.getMonth() + 1; },
	t: function() { return "Not Yet Supported"; },
	// Year
	L: function() { return (((this.getFullYear()%4==0)&&(this.getFullYear()%100 != 0)) || (this.getFullYear()%400==0)) ? '1' : '0'; },
	o: function() { return "Not Supported"; },
	Y: function() { return this.getFullYear(); },
	y: function() { return ('' + this.getFullYear()).substr(2); },
	// Time
	a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
	A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
	B: function() { return "Not Yet Supported"; },
	g: function() { return this.getHours() % 12 || 12; },
	G: function() { return this.getHours(); },
	h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
	H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
	i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
	s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
	// Timezone
	e: function() { return "Not Yet Supported"; },
	I: function() { return "Not Supported"; },
	O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; },
	P: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':' + (Math.abs(this.getTimezoneOffset() % 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() % 60)); },
	T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;},
	Z: function() { return -this.getTimezoneOffset() * 60; },
	// Full Date/Time
	c: function() { return this.format("Y-m-d") + "T" + this.format("H:i:sP"); },
	r: function() { return this.toString(); },
	U: function() { return this.getTime() / 1000; }
}


