﻿if (typeof(awp_alterdata)=="undefined")
{
awp_alterdata=function()
{
 this.dateFixLength=function(adjLengh,theObj)
 {
	var tempd1=theObj;
	alert(tempd1.getFullYear());
 }
 this.stringFixLength1=function(theObj,adjLengh) 
 {
	return theObj.substr(0,adjLengh);
 }

 this.numberToString=function(theObj,theOption) 
 {
	var tempt1=theOption.split(",");
	var tempno=(parseInt(theObj)==NaN) ? 0 : parseInt(theObj);
	return ( tempno < tempt1.length) ? tempt1[tempno]:"";
 }


 this.make=function(theObj,lookatObj,objName,functionName)
 {
	var tempt1=document.getElementById(theObj);
	var tempt2=tempt1.getElementsByTagName(lookatObj);

	for (var tempi=0;tempi < tempt2.length;tempi++)
	{
		temps1=tempt2[tempi];
		if (objName=="" || objName == null || temps1.id.indexOf(objName) > -1)
		{

		 functionName2=(functionName==null)? temps1.getAttribute("functionname") : functionName;
		 if (functionName2!=null){

			var temps2=temps1.innerHTML;
			temps2=temps2.replace(/"/g,"\\\"");
			temps2=temps2.replace(/\n/g,"\\n");

			var tempa2="\"" + temps2 + "\"";

			for (var tempi2=5;tempi2 < arguments.length;tempi2++)
			{
				tempa2+=",\"" + arguments[tempi] + "\"";
			}
			for (var tempi2=1;tempi2 < 10;tempi2++)
			{
				tampa3=temps1.getAttribute("attribute" + tempi2);
				if (tampa3!=null && tampa3!=""){tempa2+=",\"" + tampa3 + "\"";}
				else{break;}
			}

			tempa2="return " + functionName2+ "(" + tempa2 + ")";
			var tempfunction=new Function (tempa2);
			temps1.innerHTML=tempfunction();
		 }
		}
	}
 }
}//awp_alterdata

awp_date10=function(theObj){
	var temp_alter=new awp_alterdata();
	temp_alter.dateFixLength(10,theObj);
}

awp_string10=function(theObj){
	var temp_alter=new awp_alterdata();
	return temp_alter.stringFixLength1(theObj,10);
}
awp_YesNo=function(theObj,theOption,theValue){
	var temp_alter=new awp_alterdata();
	if (theOption==null){theOption="否,是";}
	return temp_alter.numberToString(theValue,theOption);
}
awp_addOrderby=function(theObj,fftablemaker,theOrderName)
{
	return "<a href=\"javascript:" + fftablemaker +".dataXML='';" + fftablemaker +".dataXML_order=(" + fftablemaker +".dataXML_order=='"+theOrderName+"')?'"+theOrderName+" desc':'"+theOrderName+"';awp_tablemaker_makeorder('" + fftablemaker + "');\">" + theObj + "</a>";
}

//將西元年轉為民國年
awp_yearchange=function(theObj,ffvalue,fdate)
{
	var temps1=(fdate==null)?"yyyy-mm-dd":fdate;
	var tempd1=ffvalue;
	tempd1=tempd1.replace(/\//g,"-");	
	var tempd2=tempd1.split("-");
	if (tempd2.length >= 1){
		tempd2[0]=parseInt(tempd2[0])-1911;
		temps1=temps1.replace(/yyyy/,tempd2[0]);
	}
	if (tempd2.length >= 2){temps1=temps1.replace(/mm/,tempd2[1]);}
	if (tempd2.length >= 3){temps1=temps1.replace(/dd/,tempd2[2]);}

	return temps1;
}
}//typeof

