﻿var lastColor;
function DG_changeBackColor(row, highlight,bcolor)
{ 
			if (highlight)
			{//alert(bcolor);
				row.style.cursor = "pointer";
				lastColor = row.style.backgroundColor;
				row.style.backgroundColor = bcolor;
			}
			else
				row.style.backgroundColor = lastColor;
}
//function showWeather_Lucnv(value)
//{
//	if (value==1)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lblSonLa").value;
//	}
//	if (value==2)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lblHaiPhong").value;
//	}
//	if (value==3)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lblHaNoi").value;
//	}
//	if (value==4)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lblVinh").value;
//	}
//	if (value==5)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lbldaNang").value;
//	}
//	if (value==6)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lblNhaTrang").value;
//	}
//	if (value==7)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lblPleiku").value;
//	}
//	if (value==8)
//	{
//		document.getElementById("ctl00_AT_Content_Tygia1_lblInfo").innerHTML=document.getElementById("ctl00_AT_Content_Tygia1__lblTPHCM").value;
//	}
//}

function ShowForexRate(){
	var sHTML = '';
	sHTML = sHTML.concat('<div  style="margin-bottom:4px"><img src="http://amthucquehuong.com/Images/web/circle-chart.gif" /><b> Tỷ giá ngoại tệ </b></div>');
	sHTML = sHTML.concat('<div class="border" >');
	sHTML = sHTML.concat('<table border="0px" width="100%" cellpadding="2px" cellspacing="1px">');
	sHTML = sHTML.concat('	<tr>');
	sHTML = sHTML.concat('		<td class="border-bottom title-4" style="width: 60%;color:#EA8806">Mã NT</td>');
	sHTML = sHTML.concat('		<td class="border-bottom title-4" style="width: 40%;color:#EA8806">Giá Bán</td>');
	sHTML = sHTML.concat('	</tr>');
	for(var i=0;i<vForexs.length;i++){
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="border-bottom title-5" style="width: 60%;color:#D33225">').concat(vForexs[i]).concat('</td>');
		sHTML = sHTML.concat('		<td class="border-bottom title-5" style="width: 40%">').concat(vCosts[i]).concat('</td>');
		sHTML = sHTML.concat('	</tr>');
	}
	sHTML = sHTML.concat('</table>');
	sHTML = sHTML.concat('</div>');
	gmobj('eForex').innerHTML = sHTML;
}
function ShowWeatherBox(vId){
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) return;
	var sLink = '';
	sLink = '/Weather/';
	switch (parseInt(vId)){	    	
		case 1: sLink = sLink.concat('Sonla.xml');break;
		case 2: sLink = sLink.concat('Viettri.xml');break;
		case 3: sLink = sLink.concat('Haiphong.xml');break;
		case 4: sLink = sLink.concat('Hanoi.xml');break;
		case 5: sLink = sLink.concat('Vinh.xml');break;
		case 6: sLink = sLink.concat('Danang.xml');break;
		case 7: sLink = sLink.concat('Nhatrang.xml');break;
		case 8: sLink = sLink.concat('Pleicu.xml');break;		
		case 9: sLink = sLink.concat('HCM.xml');break;	
		default: sLink = sLink.concat('Hanoi.xml');break;
	}
	
	xmlHttp.open("GET", sLink, true);
    xmlHttp.onreadystatechange = function()
    {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
            {
               var xml = xmlHttp.responseXML;
               var vAdImg, vAdImg1, vAdImg2, vAdImg3, vAdImg4, vAdImg5, vWeather;
                vAdImg = xml.getElementsByTagName('AdImg').item(0).firstChild.nodeValue;
				vAdImg1 = xml.getElementsByTagName('AdImg1').item(0).firstChild.nodeValue;
				if(xml.getElementsByTagName('AdImg2').item(0).firstChild != null)
					vAdImg2 = xml.getElementsByTagName('AdImg2').item(0).firstChild.nodeValue;
				if(xml.getElementsByTagName('AdImg3').item(0).firstChild != null)
					vAdImg3 = xml.getElementsByTagName('AdImg3').item(0).firstChild.nodeValue;
				if(xml.getElementsByTagName('AdImg4').item(0).firstChild != null)
					vAdImg4 = xml.getElementsByTagName('AdImg4').item(0).firstChild.nodeValue;
				if(xml.getElementsByTagName('AdImg5').item(0).firstChild != null)
					vAdImg5 = xml.getElementsByTagName('AdImg5').item(0).firstChild.nodeValue;
				vWeather = xml.getElementsByTagName('Weather').item(0).firstChild.nodeValue;
				
				GetWeatherBox(vAdImg, vAdImg1, vAdImg2, vAdImg3, vAdImg4, vAdImg5, vWeather);	
            }
    }
    xmlHttp.send(null);    
}

function GetWeatherBox(vImg, vImg1, vImg2, vImg3, vImg4, vImg5, vWeather){
	var sHTML = '';
	sHTML = sHTML.concat('<img src="http://amthucquehuong.com/Weather/').concat(vImg).concat('" class="img-weather" alt="" />&nbsp;');
	sHTML = sHTML.concat('<img src="http://amthucquehuong.com/Weather/').concat(vImg1).concat('" class="img-weather" alt="" />');
	if(vImg2!=null) sHTML = sHTML.concat('<img src="http://amthucquehuong.com/Weather/').concat(vImg2).concat('" class="img-weather" alt="" />');
	if(vImg3!=null) sHTML = sHTML.concat('<img src="http://amthucquehuong.com/Weather/').concat(vImg3).concat('" class="img-weather" alt="" />');
	if(vImg4!=null) sHTML = sHTML.concat('<img src="http://amthucquehuong.com/Weather/').concat(vImg4).concat('" class="img-weather" alt="" />');
	if(vImg5!=null) sHTML = sHTML.concat('<img src="http://amthucquehuong.com/Weather/').concat(vImg5).concat('" class="img-weather" alt="" />');
	sHTML = sHTML.concat('<img src="http://amthucquehuong.com/Weather/c.gif" class="img-weather" alt="" />');
	
	gmobj('img-Do').innerHTML = sHTML;
	gmobj('txt-Weather').innerHTML = vWeather;
}

function ScrollableTable (tableEl, tableHeight, tableWidth) {

	this.initIEengine = function () {

		this.containerEl.style.overflowY = 'auto';
		if (this.tableEl.parentElement.clientHeight - this.tableEl.offsetHeight < 0) {
			this.tableEl.style.width = this.newWidth - this.scrollWidth +'px';
		} else {
			this.containerEl.style.overflowY = 'hidden';
			this.tableEl.style.width = this.newWidth +'px';
		}

		if (this.thead) {
			var trs = this.thead.getElementsByTagName('tr');
			for (x=0; x<trs.length; x++) {
				trs[x].style.position ='relative';
				trs[x].style.setExpression("top",  "this.parentElement.parentElement.parentElement.scrollTop + 'px'");
			}
		}

		if (this.tfoot) {
			var trs = this.tfoot.getElementsByTagName('tr');
			for (x=0; x<trs.length; x++) {
				trs[x].style.position ='relative';
				trs[x].style.setExpression("bottom",  "(this.parentElement.parentElement.offsetHeight - this.parentElement.parentElement.parentElement.clientHeight - this.parentElement.parentElement.parentElement.scrollTop) + 'px'");
			}
		}

		eval("window.attachEvent('onresize', function () { document.getElementById('" + this.tableEl.id + "').style.visibility = 'hidden'; document.getElementById('" + this.tableEl.id + "').style.visibility = 'visible'; } )");
	};


	this.initFFengine = function () {
		this.containerEl.style.overflow = 'hidden';
		this.tableEl.style.width = this.newWidth + 'px';

		var headHeight = (this.thead) ? this.thead.clientHeight : 0;
		var footHeight = (this.tfoot) ? this.tfoot.clientHeight : 0;
		var bodyHeight = this.tbody.clientHeight;
		var trs = this.tbody.getElementsByTagName('tr');
		if (bodyHeight >= (this.newHeight - (headHeight + footHeight))) {
			this.tbody.style.overflow = '-moz-scrollbars-vertical';
			for (x=0; x<trs.length; x++) {
				var tds = trs[x].getElementsByTagName('td');
				tds[tds.length-1].style.paddingRight += this.scrollWidth + 'px';
			}
		} else {
			this.tbody.style.overflow = '-moz-scrollbars-none';
		}

		var cellSpacing = (this.tableEl.offsetHeight - (this.tbody.clientHeight + headHeight + footHeight)) / 4;
		this.tbody.style.height = (this.newHeight - (headHeight + cellSpacing * 2) - (footHeight + cellSpacing * 2)) + 'px';

	};

	this.tableEl = tableEl;
	this.scrollWidth = 20;

	this.originalHeight = this.tableEl.clientHeight;
	this.originalWidth = this.tableEl.clientWidth;

	this.newHeight = parseInt(tableHeight);
	this.newWidth = tableWidth ? parseInt(tableWidth) : this.originalWidth;

	this.tableEl.style.height = 'auto';
	this.tableEl.removeAttribute('height');

	this.containerEl = this.tableEl.parentNode.insertBefore(document.createElement('div'), this.tableEl);
	this.containerEl.appendChild(this.tableEl);
	this.containerEl.style.height = this.newHeight + 'px';
	this.containerEl.style.width = this.newWidth + 'px';


	var thead = this.tableEl.getElementsByTagName('thead');
	this.thead = (thead[0]) ? thead[0] : null;

	var tfoot = this.tableEl.getElementsByTagName('tfoot');
	this.tfoot = (tfoot[0]) ? tfoot[0] : null;

	var tbody = this.tableEl.getElementsByTagName('tbody');
	this.tbody = (tbody[0]) ? tbody[0] : null;

	if (!this.tbody) return;

	if (document.all && document.getElementById && !window.opera) this.initIEengine();
	if (!document.all && document.getElementById && !window.opera) this.initFFengine();


}
