// JavaScript Document
var globalBanner; // this variable is useful for doSlideBanner function, please dont remove otherwise the function will not work
var theDivObjectName; // this variable is useful for doSlideBanner function, please dont remove otherwise the function will not work
var width_b;
var height_b;

var randomBannerIndex = null; // this variables useful for the
var the_items = new Array();
var the_times = new Array();

/*
 * OOP in Javascript
 * Popup Window
 */
var OpenWindow = function (url, name) 
{
	newwindow=window.open(url, name);
	/* 
	 * Open Popup
	 */
	if (window.focus) 
	{
		newwindow.focus();
	}
	/*
	 * Khi popup đang mở, nếu user click mở lần nữa thì active lại cửa sổ đã mở
	 */
	return true;
	/*
	 * Return false: Chỉ mở popup không thực thi link trong href.
	 */
}
/**

 */
function outputBanner(bannerArr, tableAttributes, tdAttributes, tdSpaceAttributes)
{
	var str = "";
	
	var bannerArrLength = bannerArr.length;
	
	if (bannerArrLength > 0)
	{
		str += "<table " + tableAttributes + ">";
	
		var i = 1;
		
		for (indexKey in bannerArr)
		{
			switch (bannerArr[indexKey][0])
			{
				case "1":
					// hinh gif
					str += "<tr>";
					str += "		<td " + tdAttributes + ">";
					
					if (bannerArr[indexKey][4] != "")
					{
						str += "			<a href='" + bannerArr[indexKey][4] + "' target='" + bannerArr[indexKey][5] + "'><img src='" + bannerArr[indexKey][3] + "' border='0' alt='" + bannerArr[indexKey][6] + "'></a>";
					}
					else
					{
						str += "			<img src='" + bannerArr[indexKey][3] + "' border='0' alt='" + bannerArr[indexKey][6] + "'>";
					}
					
					str += "		</td>";
					str += "</tr>";
					
					break;
				case "2":
					// hinh flash
					str += "<tr>";
					str += "		<td " + tdAttributes + ">";
					str += '			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"  width="' + bannerArr[indexKey][1] + '" height="' + bannerArr[indexKey][2] + '"><param name="movie" value="' + bannerArr[indexKey][3] + '?linkf=' + bannerArr[indexKey][4] + '"><param name="quality" value="high"><embed src="' + bannerArr[indexKey][3] + '?linkf=' + bannerArr[indexKey][4] + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + bannerArr[indexKey][1] + '" height="' + bannerArr[indexKey][2] + '"></embed></object>';
					str += "		</td>";
					str += "</tr>";
					
					break;
			}
			
			if ((tdSpaceAttributes != "") && (i < bannerArrLength))
			{
				str += "<tr>";
				str += "		<td " + tdSpaceAttributes + ">";
				str += "		</td>";
				str += "</tr>";
			}
			
			i++;
		}
		
		str += "</table>";
	}
	
	return str;
}

/**

 */
function makeADivObject(divName)
{
	document.write('<div id="' + divName + '"></div>');
}

/**

 */
function doSlideRandomBanner(bannerArr, tableAttributes, tdAttributes)
{
	globalBanner = bannerArr;
	
	theDivObjectName = "slide";
	
	makeADivObject(theDivObjectName);
	
	slideBanner(globalBanner, theDivObjectName, null, tableAttributes, tdAttributes);
	
	var timer = window.setInterval('slideBanner(globalBanner, theDivObjectName, null, \'' + tableAttributes + '\', \'' + tdAttributes + '\')', 10000);
}

/**

 */

var randomBannerIndex = null; // this variables useful for the

/**
function doSlideBanner(bannerArr, time_slide, divname, tableAttributes, tdAttributes)
 */

 

function doSlideBanner(bannerArr, times, divname, tableAttributes, tdAttributes)
{
	this.globalBanner = "";
	
	if(bannerArr.length > 0)
	{
		for(i=0; i < bannerArr.length-1; i++)
		{	
			this.globalBanner += bannerArr[i] + ",";
		}
		this.globalBanner += bannerArr[i];
	}
	
	this.theDivObjectName = "slide" + divname + Math.round(Math.random() * Math.pow(10,Math.round(Math.random()*10)));
	
	the_times[theDivObjectName] = 0;
	
	 if(!times)
		times = 10000;
	 else
	 {
		if(isNaN(times))
			times = 10000;
	 }

	makeADivObject(this.theDivObjectName);
	
		
	doSlideBannerA1(this.globalBanner, this.theDivObjectName, tableAttributes, tdAttributes, times);
}

function doSlideBannerDiv(bannerArr, times, divname, tableAttributes, tdAttributes)
{
	this.globalBanner = "";
	
	if(bannerArr.length > 0)
	{
		for(i=0; i < bannerArr.length-1; i++)
		{	
			this.globalBanner += bannerArr[i] + ",";
		}
		this.globalBanner += bannerArr[i];
	}
	
	this.theDivObjectName = "slide" + divname + Math.round(Math.random() * Math.pow(10,Math.round(Math.random()*10)));
	
	the_times[theDivObjectName] = 0;
	
	 if(!times)
		times = 10000;
	 else
	 {
		if(isNaN(times))
			times = 10000;
	 }

	makeADivObject(this.theDivObjectName);
	
		
	doSlideBannerA1(this.globalBanner, this.theDivObjectName, tableAttributes, tdAttributes, times);
}

function doSlideBannerA1(bannerArr, theDivObjectName, tableAttributes, tdAttributes, times)
{
	if(the_items[theDivObjectName] != null)
	{
		window.clearInterval(the_items[theDivObjectName]);
		the_times[theDivObjectName] ++;
	}
		
	if(bannerArr.length != 0)
	{
		var arrTemp = new Array();
		arr 	= bannerArr.split(",");
		numArr 	= arr.length / 8;
		index	= 0;
		
		for(i = 0; i < numArr; i++)
		{
			arrTemp[i] = new Array();
			for(j = 0; j < 8; j++)
			{
				arrTemp[i][j] = arr[index];
				index++;
			}
		}
			
		var bannerArrLength = arrTemp.length;
		randomBannerIndex 	= the_times[theDivObjectName] % bannerArrLength;
		
		
		if(the_times[theDivObjectName] == bannerArr.length)
			the_times[theDivObjectName] = 0;		

		slideBanner(arrTemp, theDivObjectName, randomBannerIndex, tableAttributes, tdAttributes); //duoc
	}
	
	the_items[theDivObjectName] = window.setInterval('doSlideBannerA1(\''+ bannerArr +'\',\''+ theDivObjectName + '\',\'' + tableAttributes +'\', \''+ tdAttributes + '\',' + times + ')', 10000);			     

}
/**
function slideBanner(bannerArr, theDivObjectName, bannerIndex, tableAttributes, tdAttributes)
*/
function slideBanner(bannerArr, theDivObjectName, bannerIndex, tableAttributes, tdAttributes)
{	

	if(!bannerIndex)
		randomIndex = 0;
	else
		var randomIndex = bannerIndex;
	
	var theOutputString = "";

	switch (bannerArr[randomIndex][0])
	{
		case "99":
			// hinh gif
			//alert(bannerArr[0][4]);
			if (bannerArr[randomIndex][4] != "")
			{
				if (bannerArr[randomIndex][5] != "" && bannerArr[randomIndex][5] != "_blank")
				{
					theOutputString += "<a href='" + bannerArr[randomIndex][4] + "' target='" + bannerArr[randomIndex][5] + "' onclick='return OpenWindow(\"" + bannerArr[randomIndex][4] + "\",\"" + bannerArr[randomIndex][5] + "\")' ><img src='" + bannerArr[randomIndex][3] + "' border='0' alt='" + bannerArr[randomIndex][6]+"'></a>";
				}
				else
				{
					theOutputString += "<a href='" + bannerArr[randomIndex][4] + "' target='" + bannerArr[randomIndex][5] + "'><img src='" + bannerArr[randomIndex][3] + "' border='0' alt='" + bannerArr[randomIndex][6]+"' ></a>";		
				}
			}//end if
			else
			{
				theOutputString += "<img src='" + bannerArr[randomIndex][3] + "' border='0' alt='" + bannerArr[randomIndex][6]+"'>";
			}//end else
			break;
		case "103":
			// hinh flash
			theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + bannerArr[randomIndex][1] + '" height="' + bannerArr[randomIndex][2] + '"><param name="movie" value="' + bannerArr[randomIndex][3] + '?clicktag=' + bannerArr[randomIndex][4] + '"><param name="quality" value="high"><embed src="' + bannerArr[randomIndex][3] + '?clicktag=' + bannerArr[randomIndex][4] + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + bannerArr[randomIndex][1] + '" height="' + bannerArr[randomIndex][2] + '"></embed></object>';
		
			break;
	}//end switch	

	var theDivObject = document.getElementById(theDivObjectName);
	
	theDivObject.innerHTML = theOutputString;
}


function Random(N) { return Math.floor(N*(Math.random()%1)) }
function Deal(N) { var J, K, Q = new Array(N)
  for (J=0; J<N; J++) { K = Random(J+1) ; Q[J] = Q[K] ; Q[K] = J }
  return Q }

//=================Banner QC khac====================
function BannerAD(bannerArr,tableAttributes, tdAttributes)
{
	//alert("so banner="+bannerArr.length);
	var bannerArrLength = bannerArr.length-1;
	
	var ranIn = new Array();
	ranIn = Deal(bannerArr.length);
	//alert("ran=" + ranIn);


	var theOutputString = "";
	
	if(bannerArr[0][7]==100)//TH random
	{		
			for(var i=0; i<=bannerArrLength; i++)
			{					
				switch (bannerArr[ranIn[i]][0])
				{
					case "99":
						//hinh gif
						if (bannerArr[ranIn[i]][4] != "")
						{
							if (bannerArr[ranIn[i]][5] != "" && bannerArr[ranIn[i]][5] != "_blank")
							{							
								theOutputString += "<tr><td class='" + tdAttributes + "'><a href='" + bannerArr[ranIn[i]][4] + "' target='" + bannerArr[ranIn[i]][5] + "' onclick='return OpenWindow(\"" + bannerArr[ranIn[i]][4] + "\",\"" + bannerArr[ranIn[i]][5] + "\")' ><img src='" + bannerArr[ranIn[i]][3] + "' border='0' alt='" + bannerArr[ranIn[i]][6] + "'></a></td></tr>";
							}
							else
							{
								theOutputString += "<tr><td class='" + tdAttributes + "'><a href='" + bannerArr[ranIn[i]][4] + "' target='" + bannerArr[ranIn[i]][5] + "'><img src='" + bannerArr[ranIn[i]][3] + "' border='0' alt='" + bannerArr[ranIn[i]][6] + "'></a></td></tr>";		
							}
						
						}
						else
						{
							theOutputString += "<tr><td class='" + tdAttributes + "'><img src='" + bannerArr[ranIn[i]][3] + "' border='0' alt='" + bannerArr[ranIn[i]][6] + "'></td></tr>";	
						}
						
						break;
					case "103":
						// hinh flash
						theOutputString += '<tr><td class="' + tdAttributes + '"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + bannerArr[ranIn[i]][1] + '" height="' + bannerArr[ranIn[i]][2] + '"><param name="movie" value="' + bannerArr[ranIn[i]][3] + '?clicktag=' + bannerArr[ranIn[i]][4] + '"><param name="quality" value="high"><embed src="' + bannerArr[ranIn[i]][3] + '?clicktag=' + bannerArr[ranIn[i]][4] + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + bannerArr[ranIn[i]][1] + '" height="' + bannerArr[ranIn[i]][2] + '"></embed></object></td></tr>';
			
						break;
				}//end switch
			}//end for
				
	}//end if(bannerArr[0][7]==1)//random
	else//norandom
	{		
		//theOutputString += "<table " + tableAttributes + ">";
		for(var i=0; i<=bannerArrLength; i++)
		{					
			
			switch (bannerArr[i][0])
			{
				case "99":
					//hinh gif
					if (bannerArr[i][4] != "")
					{
						if (bannerArr[i][5] != "" && bannerArr[i][5] != "_blank")
						{						
							theOutputString += "<tr><td class='" + tdAttributes + "'><a href='" + bannerArr[i][4] + "' target='" + bannerArr[i][5] + "' onclick='return OpenWindow(\"" + bannerArr[i][4] + "\",\"" + bannerArr[i][5] + "\")' ><img src='" + bannerArr[i][3] + "' border='0' alt='" + bannerArr[i][6] + "'></a></td></tr>";
						}
						else
						{
							theOutputString += "<tr><td class='" + tdAttributes + "'><a href='" + bannerArr[i][4] + "' target='" + bannerArr[i][5] + "'><img src='" + bannerArr[i][3] + "' border='0' alt='" + bannerArr[i][6] + "'></a></td></tr>";		
						}
					}
					else
					{
						theOutputString += "<tr><td class='" + tdAttributes + "'><img src='" + bannerArr[i][3] + "' border='0' alt='" + bannerArr[i][6] + "'></td></tr>";	
					}
					
					break;
				case "103":
					// hinh flash
					theOutputString += '<tr><td class="' + tdAttributes + '"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + bannerArr[i][1] + '" height="' + bannerArr[i][2] + '"><param name="movie" value="' + bannerArr[i][3] + '?clicktag=' + bannerArr[i][4] + '"><param name="quality" value="high"><embed src="' + bannerArr[i][3] + '?clicktag=' + bannerArr[i][4] + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + bannerArr[i][1] + '" height="' + bannerArr[i][2] + '"></embed></object></td></tr>';
					break;
			}//end switch
		}//end for
			
	}//else//norandom
	//alert(theOutputString);

	document.write(theOutputString);
}


function BannerAD1(bannerArr1,tableAttributes1, tdAttributes1)
{
	var theOutputString = "";
	var bannerArrLength = bannerArr1.length;
	//alert(bannerArrLength);
	var ranInd = new Array();
	ranInd = Deal(bannerArr1.length);
	//alert("ran=" + ranInd);
	for(var i=0; i<bannerArrLength; i++)
	{				
		theOutputString += "<table " + tableAttributes1 + ">";	
		theOutputString += "	<tr>";
		theOutputString += "		<td class='" + tdAttributes1 + "'>";
		switch (bannerArr1[ranInd[i]][0])
		{
			case "99":
				//hinh gif
				if (bannerArr1[ranInd[i]][4] != "")
				{
					if (bannerArr1[ranInd[i]][5] != "" && bannerArr1[ranInd[i]][5] != "_blank")
					{							
						theOutputString += "<a href='" + bannerArr1[ranInd[i]][4] + "' target='" + bannerArr1[ranInd[i]][5] + "' onclick='return OpenWindow(\"" + bannerArr1[ranInd[i]][4] + "\",\"" + bannerArr1[ranInd[i]][5] + "\")' ><img src='" + bannerArr1[ranInd[i]][3] + "' border='0' alt='" + bannerArr1[ranInd[i]][6] + "' ></a>";
					}
					else
					{
						theOutputString += "<a href='" + bannerArr1[ranInd[i]][4] + "' target='" + bannerArr1[ranInd[i]][5] + "'><img src='" + bannerArr1[ranInd[i]][3] + "' border='0' alt='" + bannerArr1[ranInd[i]][6] + "' ></a>";		
					}
				
				}
				else
				{
					theOutputString += "<img src='" + bannerArr1[ranInd[i]][3] + "' border='0' alt='" + bannerArr1[ranInd[i]][6] + "'>";	
				}
				
				break;
			case "103":
				// hinh flash
				theOutputString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + bannerArr1[ranInd[i]][1] + '" height="' + bannerArr1[ranInd[i]][2] + '"><param name="movie" value="' + bannerArr1[ranInd[i]][3] + '?clicktag=' + bannerArr1[ranInd[i]][4] + '"><param name="quality" value="high"><embed src="' + bannerArr1[ranInd[i]][3] + '?clicktag=' + bannerArr1[ranInd[i]][4] + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + bannerArr1[ranInd[i]][1] + '" height="' + bannerArr1[ranInd[i]][2] + '"></embed></object>';
	
				break;
		}//end switch
		theOutputString += "		</td>";
		theOutputString += "	</tr>";
		theOutputString += "</table>";
		theOutputString += "<div style='height:"+ (parseInt(bannerArr1[ranInd[i]][2]) + 9) + "px;'></div>";
	}//end for
	
	document.write(theOutputString);
}


/**

 */
function displayRandomBanner(bannerArr, tableAttributes, tdAttributes, tdSpaceAttributes)
{	
	bannerArr = randomArray(bannerArr);
	
	var outputedBanner = outputBanner(bannerArr, tableAttributes, tdAttributes, tdSpaceAttributes);
	
	document.write(outputedBanner);
}

/**

 */
function displayBanner(bannerArr, tableAttributes, tdAttributes, tdSpaceAttributes)
{	
	var outputedBanner = outputBanner(bannerArr, tableAttributes, tdAttributes, tdSpaceAttributes);
	
	document.write(outputedBanner);
}

/**

 */
function displayFloatBanner(floatBannerArr, handSide)
{

	str = "";
	
	if (floatBannerArr.length > 0)
	{

		switch (handSide)
		{
			case "left":
				str += '<div id="divAdLeft" style="left: -110px; width: 108px; position: absolute; top: 103px" align="right">';
				
				for (keyIndex in floatBannerArr)
				{
					if (floatBannerArr[keyIndex][4] != "")
					{
						str += "<a href='" + floatBannerArr[keyIndex][4] + "' target='" + floatBannerArr[keyIndex][5] + "'><img src='" + floatBannerArr[keyIndex][3] + "' border='0' alt='" + floatBannerArr[keyIndex][6] + "'></a><br>";
					}
					else
					{
						str += "<img src='" + floatBannerArr[keyIndex][3] + "' border='0' alt='" + floatBannerArr[keyIndex][6] + "'><br>";
					}
				}
				
				str += "</div>";
				break;
			case "right":

				str += '<div id=divAdRight style="right: -110px; width: 96px; position: absolute; top: 103px; padding-left: 3px;">';
				
				for (keyIndex in floatBannerArr)
				{
					if (floatBannerArr[keyIndex][4] != "")
					{
						str += "<a href='" + floatBannerArr[keyIndex][4] + "' target='" + floatBannerArr[keyIndex][5] + "'><img src='" + floatBannerArr[keyIndex][3] + "' border='0' alt='" + floatBannerArr[keyIndex][6] + "'></a><br>";
					}
					else
					{
						str += "<img src='" + floatBannerArr[keyIndex][3] + "' border='0' alt='" + floatBannerArr[keyIndex][6] + "'><br>";
					}
				}
				
				str += "</div>";
				break;
		}
	}
	
	document.write(str);
	
	switch (handSide)
	{
		case "left":
			ShowAdDiv("divAdLeft", handSide);
			break;
		case "right":
			ShowAdDiv("divAdRight", handSide);
			break;
	}
}

/**

 */
function ShowAdDiv(theBannerDivID, handSide)
{
	var theBannerDivObject = document.getElementById(theBannerDivID);
	
	if (document.body.clientWidth < 980)
	{
		theBannerDivObject.style.left = -110;
	}
	else
	{
		switch (handSide)
		{
			case "left":
				theBannerDivObject.style.left = 0;
				
				FloatTopDiv2(theBannerDivID);
				break;
			case "right":
				theBannerDivObject.style.left = document.body.clientWidth - 110;
				FloatTopDiv(theBannerDivID);
				break;
		}
	}
}

/**

 */
function FloatTopDiv2(leftFloatBanner)
{
	startX2 = document.body.clientWidth - 1004, startY2 = 131;
	var ns2 = (navigator.appName.indexOf("Netscape") != -1);
	var d2 = document;
		
	if (document.body.clientWidth < 980) startX2 = -110;
	
	function ml2(id)
	{
		var el2=d2.getElementById?d2.getElementById(id):d2.all?d2.all[id]:d2.layers[id];
		
		if(d2.layers)el2.style=el2;
		
		el2.sP = function(x,y)
		{
			this.style.left=x;
			this.style.top=y;
		};
		
		el2.x = startX2;
		el2.y = startY2;
		
		return el2;
	}
	
	window.stayTopLeft2=function()
	{
		if (document.body.clientWidth < 980)
		{
			ftlObj2.x = - 115;ftlObj2.y = 0;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
		}
		else
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY2 = ns2 ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY2 = ns2 ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop > 131){startY2 = 3} else {startY2 = 131};

			if (document.body.clientWidth >= 1024)
			{
				ftlObj2.x =  0;ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			else
			{		
				ftlObj2.x  = startX2;
				ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;
				ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
		}
		
		setTimeout("stayTopLeft2()", 1);
	}
	
	ftlObj2 = ml2(leftFloatBanner);
	stayTopLeft2();		
}

/**

 */
/**

 */
function FloatTopDiv(rightFloatBanner)
{
	startX = document.body.clientWidth - 110, startY = 103;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
		
	if (document.body.clientWidth < 980)
	{
		startX = -110;
	}
	
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if (d.layers)
		{
			el.style=el;
		}
		
		el.sP = function(x,y)
		{
			this.style.left=x;
			this.style.top=y;
		};
		
		el.x = startX;
		el.y = startY;
		
		return el;
	}
	
	window.stayTopLeft=function()
	{		
		if (document.body.clientWidth < 980)
		{
			ftlObj.x = - 115;ftlObj.y = 0;	ftlObj.sP(ftlObj.x, ftlObj.y);
		}			
		else
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY = ns ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY = ns ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop > 103){startY = 17} else {startY = 103};

			if (document.body.clientWidth >= 1024)
			{
				ftlObj.x = document.body.clientWidth - 110;ftlObj.y += (pY + startY - ftlObj.y)/32;ftlObj.sP(ftlObj.x, ftlObj.y);
			}
			else
			{			
				ftlObj.x  = startX;
				ftlObj.y += (pY + startY - ftlObj.y)/32;
				ftlObj.sP(ftlObj.x, ftlObj.y);
			}
		}
		
		setTimeout("stayTopLeft()", 1);
	}
	
	ftlObj = ml(rightFloatBanner);
	
	stayTopLeft();
}

function getRandom(theNumber)
{
	return Math.round(Math.random() * theNumber);
}

function createNumRand(num) {
	rate = 1;
	while(num > 1) {
		rate *= 10;
		num /= 10;
	}
	num *= rate;
	return (Math.floor(Math.random()*rate)%num);
}

function createNumRandArr(num) {
	rate = 1;
	while(num > 1) {
		rate *= 10;
		num /= 10;
	}
	num *= rate;
	return (Math.floor((Math.random()*rate)%num));
}

function randomArray(max) {
	finalArray = new Array();
	i = 0;
	while(i < max)
	{
		num = createNumRandArr(max);
		if(!searchIn(finalArray, num))
		{	finalArray[i] = num;
			i++;
		}
	}
	return finalArray;
}
function searchIn(arr, num) {
	if(arr.length > 0) len = arr.length;
	else 
		return false;
	for(i=0; i < len; i++) {
		if(arr[i] == num)
			return true; //tim thay
	}
	return false;//khong tim thay
}