//********************************************************************//
//*** Created by: ATI-SG (08/31/2000) ***//.
//*** 1. isBlank: Check if string is blank.
//*** 2. isDate: Check if string is formated date or not.
//*** 3. isInt: Check if string is number or not.
//*** 4. isEmail: Check if string a formated e-mail address or not.
//*** 5. isLength: Check if length string is less than or equal certain number of character.
//*** 6. confirmDelete: Check if user really want to delete a certain record.
//********************************************************************//
//**************************** CONSTANTS ***********************
var c_Null = " can not be null!"
var c_Delete = "Do you really want to delete this record?"
var c_InvalidEmail = "Invalid email, please try again!"
//**************************************************************
// Name: isBlank.
// Input: p_Str.
// Output: True/False.
// Usage: Use when you want to specify a string is blank string or not.
//**************************************************************
function isBlank(p_Str)
{
  var v_Len;
  if (p_Str == null)
    v_Len = 0;
  else
    v_Len = p_Str.length;
  if(!v_Len)
    return true;
  for (i=0; i<v_Len; i++)
  {
    if(p_Str.charAt(i)!= " ")
      return false;
  }
  return true;
}
//**************************************************************
// Name: isEmail.
// Input: p_Str.
// Output: True/False.
// Usage: Use when you want to specify a string is email address or not.
//**************************************************************
function isEmail(p_Str)
{
  var v_Len;
  if (p_Str == null)
    v_Len = 0;
  else
    v_Len = p_Str.length;
  //Check if blank
  if(!v_Len)
    return false;
  //Check if email
  if (p_Str.indexOf(' ') >= 0)
       return false;
  if (p_Str.indexOf('@') == -1)
    return false;
  if (p_Str.indexOf('.') == -1)
    return false;
  //if it is email
  return true;
}

//**************************************************************
// Name: isDayOMOY.
// Input: vDay,vMonth,vYear.
// Output: True/False.
// Usage: Use to specify valid day, month, year.
//**************************************************************

function isDayOMOY(vDay,vMonth,vYear)
{
  if(parseInt(vYear) < 1900)
    return false;
  if ((vDay<1)||(vMonth<1)||(vMonth>12)||(vYear<0))
    return false;
  if ((vMonth==1)||(vMonth==3)||(vMonth==5)||(vMonth==7)||(vMonth==8)||(vMonth==10)||(vMonth==12))
    if (vDay>31)
      return false;
  if ((vMonth==4)||(vMonth==6)||(vMonth==9)||(vMonth==11))
    if (vDay>30)
      return false;
  if (vMonth==2)
    if (vYear%4==0)
      return (vDay<=29);
    else
      return (vDay<=28);
  return true;
}

//**************************************************************
// Name: isDate.
// Input: str,mode.
//   + mode=1: date formated dd/mm/yyyy or dd/mm/yy.
//   + mode=2: date formated mm/dd/yyyy or mm/dd/yy.
// Output: True/False.
// Usage: Use to specify a valid date.
//**************************************************************

function isDate(str,mode)
{
  var vlen, i,vType, aDate;
  vType="/";
  aDate = str.split(vType);
  var alen ;
  alen= aDate.length;
  if (alen!=3)
    return false;
  if ((aDate[0].length!=1) && (aDate[0].length!=2))
    return false;
  if ((aDate[1].length!=1) && (aDate[1].length!=2))
    return false;
  if ((aDate[2].length!=2) && (aDate[2].length!=4))
    return false;
  for(i=0; i<alen; i++){
    if(isNaN(aDate[i]))
      return false;
  }
  if(mode==1)
    return(isDayOMOY(aDate[0],aDate[1],aDate[2]));
  else
    return(isDayOMOY(aDate[1],aDate[0],aDate[2]));
  return true;
}
//***************************************************************
//function check year must more than 1900						*	
//input value type date"mm/dd/yyyy"								*
//return value = "yyyy"											*
//if yyyy < 1900 then return false								*
//***************************************************************
function checkyear(vld){
	var str = vld
	var str1 = "/"
	var s = str.lastIndexOf(str1)
		aa =str.substring(s+1,str.length)
		if(aa < 1900)
		{
		return false;
		}else
		return true;
}	

//**************************************************************
// Name: DelOnClick.
// Input: N/A.
// Output: True/False.
// Usage: Use when you want to delete a certain record.
//**************************************************************

function delOnClick() 
{
  var choose;
  choose = confirm("Do you really want to delete this record?");
  if (!choose)
  {
    return false;
  }
  return true;
}

//**************************************************************
// Name: IsInt.
// Input: num - num is a number or not.
// Output: True/False.
// Usage: Use when you want to specify an input whether a number or not.
//**************************************************************

function isInt(num) 
{
  var tempNum = new String(num);
  tempNum = allTrim(tempNum);
  var numLen = tempNum.length;
  if (numLen == 0) 
  {
    return true;
  }
  else 
  {
    var i = 0;
    for(i =0; i < numLen; i++)
    {
      if ((tempNum.substr(i,1) < "0")||(tempNum.substr(i,1) > "9"))
      {
        return false;
      }
    }
    return true;
  }
}

//**************************************************************
// Name: isLength.
// Input: str, length - is max length.
// Output: True/False.
// Usage: Use when you want to specify string length less than or equal length.
//**************************************************************

function isLength(str, l)
{
  if(str.length > l)
  {
    return false;
  }
  return true;
}

//**************************************************************
// Name: lTrim.
// Input: str.
// Output: String str without space in left hand.
// Usage: Use when you want to delete all space in left hand of string.
//**************************************************************

function lTrim(str)
{
  var strg,vlen;
  strg=str;
  vlen=strg.length;
  while((vlen>0)&&(strg.charAt(0)==" "))
  { 
    strg=strg.substr(1);
    vlen=strg.length;
  }
  return(strg);
}

//**************************************************************
// Name: rTrim.
// Input: str.
// Output: String str without space in right hand.
// Usage: Use when you want to delete all space in right hand of string.
//**************************************************************

function rTrim(str)
{
  var strg,vlen;
  strg=str;
  vlen=strg.length;
  while((vlen>0)&&(strg.charAt(vlen-1)==" "))
  { 
    strg=strg.substr(0,vlen-1);
    vlen=strg.length;
  }
  return(strg);
}

//**************************************************************
// Name: allTrim.
// Input: str.
// Output: String str without space in left & right hand.
// Usage: Use when you want to delete all space in left & right hand of string.
//**************************************************************

function allTrim(str)
{
  var strg;
  strg=lTrim(str);
  strg=rTrim(strg);
  return(strg);
}
//**************************************************************
function confirmDelete()
{
  var ok = window.confirm(c_Delete);
  if(ok)
  {
    return true;
  }
  else
  {
    return false;
  }
}
/*
function name: OpenFilewithnewWindow(strFileName, intWidth, intHeight)
Parameter: 
                  strFileName: It is name of file will be open.
                  intWidth: With of window 
                  intHeight: Height of window
***********************************************************************
*/
function OpenFilewithnewWindow(strFileName, intWidth, intHeight){
    if ((intWidth > 0) || (intHeight > 0)){
        intWidth = intWidth;
        intHeight = intHeight;
     }
     else
     {
       intWidth = 500;
       intHeight = 460;
    }
    
    NewWindow = window.open(strFileName, "WebWizard", "status=No,scrollbars=yes,resizable=yes,Left=0,Top=0, Width="+intWidth+", Height="+intHeight+"");
    NewWindow.focus();
    //NewWindow.resizeTo(intWidth, intHeight); Note: Both IE4 and NS4 are support for this propertis but it will be wink screen when execute this event
    
}

//**************************************************************
//function line scroll
function scrollit_r2l(seed){ 	
	var msg="American Technologis-inc very happy service customer!";
	var out =" ";	
	 if (seed <=100 && seed > 0) {
                      for (c=0 ; c < seed ; c++) out+=" ";
                      out+=msg;
	    seed--;
	    var cmd="scrollit_r2l(" + seed + ")";
                      window.status=out;
	    timerTwo=window.setTimeout(cmd,100);
                  } else 
	      if (seed <= 0) { 
	         if (-seed < msg.length) {
	           out+=msg.substring(-seed,msg.length);
	           seed--;
	           var cmd="scrollit_r2l(" + seed + ")";
	           window.status=out;
	           timerTwo=window.setTimeout(cmd,100);
	        }
	        else { 
	           window.status=" ";
    	            timerTwo=window.setTimeout("scrollit_r2l(100)",75)

	       }
	     }
}

//end function line scroll

 function OpenWin_Detail(file_name, width, height)
 {
	MyWindow = window.open(file_name, "WebWizard", "status=No,scrollbars=yes,resizable=yes,Left=0,Top=0, Height=400, Width=600");
	MyWindow.focus();
	if ((width > 0) || (height > 0))
	  MyWindow.resizeTo(width, height);
 }
function OpenFileWithNewWindow(strFileName, intWidth, intHeight){
    if ((intWidth > 0) || (intHeight > 0)){
        intWidth = intWidth;
        intHeight = intHeight;
     }
     else
     {
       intWidth = 500;
       intHeight = 400;
    }
    NewWindow = window.open(strFileName, "WebWizard", "status=No,scrollbars=yes,resizable=yes,Left=0,Top=0, Width="+intWidth+", Height="+intHeight+"");
    NewWindow.focus();
    //NewWindow.resizeTo(intWidth, intHeight); Note: Both IE4 and NS4 are support for this propertis but it will be wink screen when execute this event
    
}
 
function headerSeaSaigon(){
document.write(" <TABLE align=center border='0' cellPadding=0 cellSpacing=0 width='780'>");
  document.write("<TR>");
    document.write("<td width='94'><map name='FPMap10'>");
      document.write("<area href='index.htm' shape='rect' coords='9, 36, 53, 59'></map><img border='0' src='images/Banner/ban-01.jpg' usemap='#FPMap10' alt='Home page' width='94' height='77'></td>");
    document.write("<td width='116'><img border='0' src='images/Banner/ban-02.jpg' width='116' height='77'></td>");
    document.write("<td width='355'><map name='FPMap1'>");
      document.write("<area href='index.htm' shape='rect' coords='1, 6, 45, 73'></map><img border='0' src='images/Banner/ban-03.gif' usemap='#FPMap1' width='355' height='77'></td>");
    document.write("<td width='118'><img border='0' src='images/Banner/ban-04.jpg' width='118' height='77'></td>");
    document.write("<td width='97' background='images/Banner/ban-05.jpg'>");
      document.write("<p align='right'><span style='position: absolute; left: 692; top: 27'><a href="+'Javascript:OpenFileWithNewWindow('+'"flash/index.php"'+','+'780'+','+'480'+')'+"><img border='0' src='images/Banner/flash.gif' width='150' height='50'></a></span>&nbsp;</td> ");
    document.write("</TR>");
  /*document.write("<TR>");
    document.write("<TD colspan='5' width='780' height='30' background='images/Banner/bg-text.gif' align='middle'>");
    document.write("<font face='arial' color='#ffffff' size='2'><A class ='cssMenuHeader' href='aboutus.htm'>");
    document.write("About Us</a>&nbsp;|| &nbsp; <A class ='cssMenuHeader' href='whatwedo.htm'>What We Do</a> &nbsp;|| &nbsp;<A class ='cssMenuHeader' href='Organization_Chart.htm'>Organization Chart</a> &nbsp;||&nbsp;");
    document.write("<A class ='cssMenuHeader' href='Mainproducts.htm'>Main Products</a> &nbsp;||&nbsp; <A class ='cssMenuHeader' href='import-export.asp'>Import -Export</a> &nbsp;||&nbsp;<A class ='cssMenuHeader' href='Services.htm'>Services</a>&nbsp;||&nbsp;<A class ='cssMenuHeader' href='News.htm'>");
    document.write("News</a>&nbsp;|| &nbsp;<A class ='cssMenuHeader' href='ContactUs.htm'>Contact Us</a> &nbsp;||&nbsp; <A class ='cssMenuHeader' href='SiteMap.htm'>Site Map</a>&nbsp;");
    document.write("</font>");
    document.write("</TD>");
    document.write("</TR>");*/
document.write("</TABLE>");
}
function headerSeaSaigonAdmin(){
document.write(" <TABLE align=center border='0' cellPadding=0 cellSpacing=0 width='780'>");
  document.write("<TR>");
    document.write("<td width='94'><map name='FPMap0'>");
      document.write("<area href='../index.htm' shape='rect' coords='9, 36, 53, 59'></map><img border='0' src='../images/Banner/ban-01.jpg' usemap='#FPMap0' alt='Home page' width='94' height='77'></td>");
    document.write("<td width='116'><img border='0' src='../images/Banner/ban-02.jpg' width='116' height='77'></td>");
    document.write("<td width='355'><map name='FPMap1'>");
      document.write("<area href='../index.htm' shape='rect' coords='1, 6, 45, 73'></map><img border='0' src='../images/Banner/ban-03.gif' usemap='#FPMap1' width='355' height='77'></td>");
    document.write("<td width='118'><img border='0' src='../images/Banner/ban-04.jpg' width='118' height='77'></td>");
    document.write("<td width='97' background='../images/Banner/ban-05.jpg'>");
      document.write("<p align='right'><span style='position: absolute; left: 692; top: 27'><a href='../flash/index.php'><img border='0' src='../images/Banner/flash.gif' width='150' height='50'></a></span>&nbsp;</td> ");
      
    document.write("</TR>");
  document.write("<TR>");
    document.write("<TD colspan='5' width='780' height='30' background='../images/Banner/bg-text.gif' align='middle'>");
    document.write("<font face='arial' color='#ccffff' size='2'><A class ='cssMenuHeader' href='company_profile.asp'>");
    document.write("<font face='arial' color='#ccffff' size='2'>Profile</font></a>&nbsp;&nbsp;|| &nbsp;&nbsp; <A class ='cssMenuHeader' href='List_Category.asp'><font face='arial' color='#ccffff' size='2'>Categories</font></a>&nbsp; &nbsp;|| &nbsp;&nbsp;<A class ='cssMenuHeader' href='Products_admin_show.asp'><font face='arial' color='#ccffff' size='2'>Products</font></a>&nbsp; &nbsp;||&nbsp;&nbsp;");
    document.write("<A class ='cssMenuHeader' href='List_Order.asp'><font face='arial' color='#ccffff' size='2'>Order</font></a> &nbsp;&nbsp;||&nbsp;&nbsp; <A class ='cssMenuHeader' href='Auto_Respond_Manager.asp'><font face='arial' color='#ccffff' size='2'>Respond Info</font></a> &nbsp;&nbsp;||&nbsp;&nbsp;");
    document.write("<A class ='cssMenuHeader' href='Feedback_Manager.asp'><font face='arial' color='#ccffff' size='2'>Feedback</font></a>&nbsp;&nbsp;|| &nbsp;&nbsp <A class ='cssMenuHeader' href='Hit-Counter.asp'><font face='arial' color='#ccffff' size='2'>Hit Counter</font></a>&nbsp;&nbsp;");
    document.write("</font>");
    document.write("</TD>");
    document.write("</TR>");
document.write("</TABLE>");
}
