
function VieTradeJson(InstanceName)
{
    this.host_img = "http://images.thuonghieuviet.com.vn";
    this.host =  'http://thuonghieuviet.com.vn/';
    this.script_folder= this.host +  '/www/vne';
    this.script_object = null;
    this.instance_name = InstanceName;
    
    this.CreateCssLink = function(href)
    {
        var css = document.createElement('link');
        css.type = 'text/css';
        css.rel = 'stylesheet';
        css.href = href;
        var head = document.getElementsByTagName('head')[0];
        head.appendChild(css);
    }
    this.LoadData = function()
    {
        var p = document.getElementById('hidCat_ID')
        if (p) p=p.value;
        this.CreateScriptObject(this.host + '/ProxyHandler.ashx?MethodName=VietTradeBaseHandler&CallBack=' + this.instance_name + '.OnLoaded&RequestType=json&p='+p);
    }
    
    this.InitScript = function()
    {
        this.CreateCssLink(this.script_folder + "/css/styles_vne.css");
        var output = '';
        output +='<div id="divTHVLogo"></div>';
        document.getElementById('divTHVLogo').innerHTML = output;
    }
    this.OnLoaded = function(data, methodName)
    {    
        var NewsData = eval(data);
        var output='';
        if (NewsData.VieTradeJson.VieTradeADV.length>0)
        {
            output +='<div class="vne_thuonghieuviet">';
            output +='<div class="vne_cntnt">';
            output +='<div class="vne_lft">'
            output +='<a class="vne_lnk" target="_blank" style="float:left; width:280px" href="http://www.thuonghieuviet.com.vn">Thương hiệu Việt Nam</a>';
            output +='<span style="color:#fff!important; float:left; padding-top:5px;">Chuyên trang thương hiệu của VnEconomy</span></div>';
            output +='<div class="vne_rght">';
            output +=' <table width="618" cellspacing="0" cellpadding="0" border="0">';
            output +='<tbody>';
            output +='<tr>';
            output +='<td>';
            output +='<marquee scrolldelay="5" onmouseout="this.start()" onmouseover="this.stop()" scrollamount="3">';
            for(var i=0 ; i <NewsData.VieTradeJson.VieTradeADV.length; i++)
            {
                output +='<a target="_blank" href="'  + NewsData.VieTradeJson.VieTradeADV[i].Page + '" title ="' + NewsData.VieTradeJson.VieTradeADV[i].Name+'"><img width="120" height="60" border="0" src="' + this.host_img + NewsData.VieTradeJson.VieTradeADV[i].Path + '"/></a>';
            }
            
            output +='</marquee>';
            output +='</td>';
            output +='</tr>';
            output +='</tbody>';
            output +='</table>';
            output +='</div>';
            output +='</div>';
            output +='</div>'
        }
        document.getElementById('divTHVLogo').innerHTML = output;
    }
    
    this.CreateScriptObject = function(src)
    {
        if (this.script_object != null)
	    {
		    this.RemoveScriptObject();
	    }
	    this.script_object = document.createElement('script');
        this.script_object.setAttribute('type','text/javascript');
        this.script_object.setAttribute('src', src);
        
        var head = document.getElementsByTagName('head')[0];
        head.appendChild(this.script_object);
    }

    this.RemoveScriptObject = function()
    {
	    this.script_object.parentNode.removeChild(this.script_object) ;
	    this.script_object = null ;
    }
}
if (document.getElementById('divTHVLogo'))
{
    var VieTradeADV = new VieTradeJson('VieTradeADV');
    VieTradeADV.InitScript();
    VieTradeADV.LoadData();
}
