function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		layout_06_Button1_over = newImage("images/layout_06-Button1_over.jpg");
		layout_06_Button5_over = newImage("images/layout_06-Button5_over.jpg");
		layout_07_Button1_over = newImage("images/layout_07-Button1_over.jpg");
		layout_09_Button1_over = newImage("images/layout_09-Button1_over.jpg");
		layout_11_Button1_over = newImage("images/layout_11-Button1_over.jpg");
		layout_11_Button2_over = newImage("images/layout_11-Button2_over.jpg");
		layout_13_Button2_over = newImage("images/layout_13-Button2_over.jpg");
		layout_13_Button3_over = newImage("images/layout_13-Button3_over.jpg");
		layout_15_Button3_over = newImage("images/layout_15-Button3_over.jpg");
		layout_15_Button4_over = newImage("images/layout_15-Button4_over.jpg");
		layout_17_Button4_over = newImage("images/layout_17-Button4_over.jpg");
		layout_17_Button5_over = newImage("images/layout_17-Button5_over.jpg");
		layout_19_Button5_over = newImage("images/layout_19-Button5_over.jpg");
		layout_20_Button2_over = newImage("images/layout_20-Button2_over.jpg");
		layout_21_Button1_over = newImage("images/layout_21-Button1_over.jpg");
		layout_22_Button3_over = newImage("images/layout_22-Button3_over.jpg");
		layout_23_Button4_over = newImage("images/layout_23-Button4_over.jpg");
		layout_24_Button5_over = newImage("images/layout_24-Button5_over.jpg");
		preloadFlag = true;
	}
}


   function PopupPic(PicID) { 
     window.open('../viet/fullsizeimage.asp?ID=' + PicID,"","resizable=1,HEIGHT=200,WIDTH=200"); 
   } 

function delspace (str)
	{
		resStr = "" ;
		for (i=0; i < str.length; i ++)
			if (str.substr(i,1)!=" ") resStr += str.substr(i,1) ;
		return resStr;
	}
function delzero (str)
	{
		resStr = "" ;
		for (i=0; i < str.length; i ++)
			if (str.substr(i,1)!="0") break ;
		for (j=i; j < str.length; j ++)
			resStr += str.substr(j,1) ;
		if (resStr=="") resStr =0;
		return resStr;
	}

function ltrim (str)
	{
		resStr = "" ;
		for (i=0; i < str.length; i ++)
			if (str.substr(i,1)!=" ") break ;
		for (j=i; j < str.length; j ++)
			resStr += str.substr(j,1) ;
		return resStr;
	}

function rtrim (str)
	{
		resStr = "" ;
		for ( i = str.length-1;i>-1; i --)
			if (str.substr(i,1)!=" ") break ;
		for (j=i; j >-1; j --)
			resStr = str.substr(j,1) + resStr;
		return resStr;
	}

function trim (str)
	{
		return ltrim(rtrim(str));
	}

function ChkTextBox(Field, StrErr)
{
	if (trim(Field.value)=="") 
	{
		alert (StrErr);
		Field.focus()
		return false;			
	}
	//else return true
}
	
function isDigit(s)
{
	var test=""+s;
	if(test=="0"||test=="1"||test=="2"||test=="3"||test=="4"||test=="5"||test=="6"||test=="7"||test=="8"||test=="9")
		{
			return (true) ;
		}
	return (false);
}
	
function allDigit(s)
	{
		var test=""+s ;
		for (var k=0; k <test.length; k++)
		{
			var c=test.substring(k,k+1);
			if (isDigit(c)==false)
			{
				return (false);
			}
		}
		return (true);
	}
	
function isEmail(s)
	{
		var test=""+s ;
		for (var k=0; k <test.length; k++)
		{
			var c=test.substring(k,k+1);
			if (c=="@")
			{
				return (true);
			}
		}
		return (false);
	}

// Khong cuon duoc
function popupwin(StrURL,w,h) 
	{
		thewinwidth=w;
		thewinheight=h;
		thewinleft=(screen.width - thewinwidth)/2;
		thewintop=(screen.height- thewinheight)/2; 
		if (thewinleft<0) thewinleft=10;
		if (thewintop<0) thewintop=10;
		if ((thewinleft+thewinwidth)>screen.width) thewinleft=10;
		if ((thewintop+thewinheight)>screen.height) thewintop=10;  
		var newWin = window.open(StrURL, "prodmenu", "width="+thewinwidth+",height="+thewinheight+",scrollbars=0,menubar=0,toolbar=0,title=0,location=0,status=0,resizable=0,top="+thewintop+",left="+thewinleft+",screenX="+thewinleft+",screenY="+thewintop);
		//newWin.moveTo(thewinleft,thewintop);
	}

// Cuon duoc
function popupwins(StrURL,w,h) 
	{
		thewinwidth=w;
		thewinheight=h;
		thewinleft=(screen.width - thewinwidth)/2;
		thewintop=(screen.height- thewinheight)/2; 
		if (thewinleft<0) thewinleft=10;
		if (thewintop<0) thewintop=10;
		if ((thewinleft+thewinwidth)>screen.width) thewinleft=10;
		if ((thewintop+thewinheight)>screen.height) thewintop=10;  
		var newWin = window.open(StrURL, "prodmenu", "width="+thewinwidth+",height="+thewinheight+",scrollbars=1,menubar=0,toolbar=0,location=0,title=0,status=0,resizable=0,top="+thewintop+",left="+thewinleft+",screenX="+thewinleft+",screenY="+thewintop);
	  //newWin.moveTo(thewinleft,thewintop);
	}	

function PopupPic(sPicURL) 
	{ 
		window.open( "popup.htm?"+sPicURL, "", "resizable=1,HEIGHT=10,WIDTH=10"); 
	} 

