
function OpenDialog(fModal, sURL, lWidth, lHeight, lXPos, lYPos, sArguments) {
  var sFeatures;
  sFeatures = 'dialogHeight:' + lHeight + 'px;'
  sFeatures = sFeatures + 'dialogWidth:' + lWidth + 'px;'
  sFeatures = sFeatures + 'dialogTop:' + lXPos + 'px;'
  sFeatures = sFeatures + 'dialogLeft:' + lYPos + 'px;'
  sFeatures = sFeatures + 'edge: Raised; center: Yes; help: No; resizable: No; status: No;';

  if(fModal) return window.showModalDialog(sURL, sArguments, sFeatures);
  else return window.showModelessDialog(sURL, sArguments, sFeatures);
}
   
   function nextPage(form1,Page)
   {	  
	  form1.PageNo.value=Page;      
      form1.submit();
      return;
   }

   
	 function UpLoadFile(TempName,Field){

		var vReturnValue =OpenDialog(true,'UpLoad.asp?Folder=../goodsimage/&TempName='+TempName, '520', '300','','','');        
         if (typeof(vReturnValue) != 'undefined'){

			Field.value= vReturnValue;    
         }
}

function calendar(t) {
	sPath = "Include/calendar1.htm";
	strFeatures = "dialogWidth=206px;dialogHeight=208px;center=yes;help=no;status=no";
	st = t.value;
	if(st == "")
	  st = new Date();
	else
	  st = new Date();    //TransFromTWDate(st)
	sDate = showModalDialog(sPath,st,strFeatures);
	t.value = formatDate(sDate);
	
}

function PF_IsNull(Str)
{
 x='' + trim(Str)

 if(x=='')
 { return false; }
 else{return true; }
}

function TransFromTWDate(sDate) {
  var iTemp;
  iTemp = sDate.indexOf('/');
  return Number(sDate.substr(0, iTemp)) + 1911 + sDate.substr(iTemp);
}

function formatDate(sDate) {
	var sScrap = '';
	var dScrap = new Date(sDate);
	if (dScrap == 'NaN') return sScrap;

  return TransToTWDate(dScrap);
}

function TransToTWDate(sDate) {
	iDay = sDate.getDate();
	iMon = sDate.getMonth() + 1;
	iYea = sDate.getFullYear() ;
  if(iDay < 10) iDay = '0' + iDay;
  if(iMon < 10) iMon = '0' + iMon;

	return iYea + '/' + iMon + '/'  + iDay ;
}

function lTrim(str)
{
	if (typeof(str) != 'undefined'){
		if (str.charAt(0) == " ")
		{
			str = str.slice(1);
			str = lTrim(str);
		}
		return str;
	}
}


function rTrim(str)
{
var iLength;
	if (typeof(str) != 'undefined'){
		iLength = str.length;

			if (str.charAt(iLength - 1) == " ")
			{
				str = str.slice(0, iLength - 1);
				str = rTrim(str);
			}
			return str;
	}

}

function trim(str)
{
	return lTrim(rTrim(str));
}



function checkAll(field)
{
field.checked = true ;
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
field.checked = false ;
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

function openwin(p_Url,p_Name,p_Scroll,p_Height,p_Width,p_Top,p_Left)
{
	OrderWin = window.open(p_Url,p_Name,"toolbar=no,directories=no,menubar=no,resizable=yes,scrollbars="+ p_Scroll + ",height=" + p_Height + ",width=" + p_Width + ",top="+ p_Top + ",left=" + p_Left);
}

function resizeIframe() {    
    var i = parent.document.getElementById(window.name);    
    var iWidth = document.body.scrollWidth;    
    var iHeight = document.body.scrollHeight;    
    i.style.width = iWidth + 5 + "px";    
    i.style.height = iHeight + 5 + "px";    
 }    
