function EnBac_Widget()
{
    this.host = 'http://static.enbac.com/qcdantri';
    this.script_folder = this.host + '/';
	this.rand_limit = 4;

	this.Shuffle = function(v){
		for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
		return v;
	}
    this.toArray = function (o){
	var a = new Array();
	for (x in o){
	    a.push(o[x]);
	}
	return a;
    }
    this.CreateStyleSheet = function()
    {
       var css = '.qcst_content_css {color:#3b3b3b; font-size:12px;font-family:Arial, Helvetica, sans-serif;} .qcst_content_css a, .qcst_content_css a:link, .qcst_content_css a:visited{font-weight:bold;color:#3374b4;text-decoration:underline; font-size:12px;padding-bottom:7px;font-family:Arial, Helvetica, sans-serif;} .qcst_content_css a:hover{color:#ffcc00}.qcst_content_css strong{color:#dc0c0c; font-size:12px}';

		css += '.qcsantao_content a,.qcsantao_content a:link,.qcsantao_content a:visited {color:#3b3b3b;text-decoration:none;font-weight:normal}';
		css += '.qcsantao_content a:hover {text-decoration:underline;}';

		css += '.qcdt_bottom {height:18px; width:300px; padding-top:3px;font-family:Arial, Helvetica, sans-serif;} .qcdt_bottom a, .qcdt_bottom a:link, .qcdt_bottom a:visited {text-decoration:none;color:#d3e9ff; font-family:Arial, Helvetica, sans-serif; font-size:11px}.qcdt_bottom a:hover {text-decoration:none; color:#fcff00;font-family:Arial, Helvetica, sans-serif; font-size:11px}';
        var style = document.createElement('style');
        style.type = 'text/css';
        var head = document.getElementsByTagName('head')[0];
        head.appendChild(style);
        if(style.styleSheet)  // IE
            style.styleSheet.cssText = css;
        else  // other browserss
            style.appendChild(document.createTextNode(css));
    }

    this.InitScript = function()
    {
        this.CreateStyleSheet();
    }

    this.OnLoaded = function(data, methodName)
    {
        var json = eval(data);
        var output = '';
        var image_url = '';
	var item_per_page = 5;
	var url = window.location.href.toLowerCase();
	var allItems = new Array();
	
	if(json['VIP']){
	    allItems['VIP'] = this.toArray(json['VIP']);
	}
	if(json['NORMAL']){
	    allItems.NORMAL = this.toArray(json['NORMAL']);
	}
    if ( url.indexOf('static.enbac.com/') <= 0){
		if (allItems.NORMAL){
			allItems.NORMAL = this.Shuffle(allItems.NORMAL);
		}
		if (allItems.VIP){
			allItems.VIP = this.Shuffle(allItems.VIP);
		}
	}
	if (allItems.VIP){
	    allItems.Items = allItems.VIP.concat(allItems.NORMAL);
	}
	else{
	     allItems.Items = allItems.NORMAL;
	}
	allItems.Items.length = (this.rand_limit > allItems.Items.length  ) ? allItems.Items.length : this.rand_limit;
	allItems.Items = this.Shuffle(allItems.Items);
	for (var i = 0; i < allItems.Items.length; i++)
        {
	    var image_url = '';
	    var price_img = '';
            if (allItems.Items[i].images != '')
            {
		var temp_arr = new Array();
		var k = 0;
		for (var j in allItems.Items[i].images)
		{
		    temp_arr[k] = allItems.Items[i].images[j];
		    k++;
		}
		var ranNumImg= Math.floor(Math.random()*(temp_arr.length));
		image_url = this.script_folder+temp_arr[ranNumImg].src;
		price_img = temp_arr[ranNumImg].price;
		//alert(allItems.Items[i].images);
            }
            else
            {
		image_url = this.script_folder+'images/no-images-69x53.jpg';
            }
	    output += '<div style="height:15px"><span></span></div><div id="enbac_item_'+allItems.Items[i].id+'" style="background:#fff;margin:0;  padding:0;height:110px;overflow:hidden" align="left" class="qcst_content_css"><a href="'+this.host+'/click.php?id='+allItems.Items[i].id+'" target="_blank" style="border:none;margin:0;padding:0"><img src="'+image_url+'" width="110" height="80" border="0" alt="'+allItems.Items[i].Title+'" title="'+allItems.Items[i].Title+'" style="border:none;margin:0;padding:0; margin-left:5px;" align="right" /></a><div style="height:32px;overflow:hidden"><a href="'+this.host+'/click.php?id='+allItems.Items[i].id+'" target="_blank" style="border:none;margin:0;padding:0">'+allItems.Items[i].Title+'</a></div></br><div style="margin:8px 0"><strong>'+price_img+'</strong></div><div class="qcsantao_content"><a href="'+this.host+'/click.php?id='+allItems.Items[i].id+'" target="_blank" style="border:none;margin:0;padding:0">'+allItems.Items[i].Description+'</a></div></div></div><div style="height:15px"><span></span></div>';


	    try{
		document.getElementById('EnBac_QCsangtao_Oto_300_600_Item').innerHTML = output;
	    }
	    catch (e){
		    //Do nothing?
	    }
        }

    }

}
output = '<div align="center" style="width:300px; height:600px; border: 1px solid #3273b5;background-color:#ffffff"><div style="height:16px;"><a href="http://admicro.vn" target="_blank"><img src="http://static.enbac.com/qcdantri/images/top_ad_dantri_oto.gif" width="298" height="15" border="0" style="border:none;margin:0;padding:0" /></a></div>';

output += '<div align="center"><div id="EnBac_QCsangtao_Oto_300_600_Item" style="width:279px;margin:0;padding:0" align="center"></div></div>'

output += '<div class="qcdt_bottom" style="background:#2886e6;margin-top:3px" align="center"><a href="http://enbac.com/post_add.html" target="_blank"><img src="http://static.enbac.com/qcdantri/images/dantri_oto_160_ico.gif"  border="none" align="absbottom" style="border:none" /> Liên hệ quảng cáo</a></div></div>';



try{
	var url = window.location.href.toLowerCase();

	if ( url.indexOf('static.enbac.com/') > 0)
	{
		document.write('<div id="EnBac_QCsangtao_Oto_300_600_Content" style="width:300px; height:600px" align="left"></div>');
	}
    try{
        document.getElementById('EnBac_QCsangtao_Oto_300_600_Content').innerHTML = output;
    }
    catch (e){
				//Do nothing?
    }
}
catch (e){
				//Do nothing?
}

				try{
					var qcsangtao_dantri_oto_300_600 = new EnBac_Widget();
					qcsangtao_dantri_oto_300_600.InitScript();
					qcsangtao_dantri_oto_300_600.OnLoaded({"VIP":"","NORMAL":{"608":{"id":"608","Title":"KYLIN - GX668 kh\u1eb3ng \u0111\u1ecbnh 1 \u0111\u1eb3ng c\u1ea5p v\u00e0 1 th\u01b0\u01a1ng hi\u1ec7u","Content":"","Description":"Xe nh\u1eadp kh\u1ea9u nguy\u00ean chi\u1ebfc, nhi\u1ec1u m\u00e0u cho qu\u00fd kh\u00e1ch l\u1ef1a ch\u1ecdn<br \/>","Link":"http:\/\/otothegioi.vn\/?page=product&idp=219","start_time":"08-09-2009","images":{"1":{"src":"uploads\/4010569931.jpg","price":"otothegioi.vn"}}},"610":{"id":"610","Title":"S\u1ef1 tr\u1edf l\u1ea1i c\u1ee7a th\u01b0\u01a1ng hi\u1ec7u Mazda","Content":"","Description":"Xe nh\u1eadp kh\u1ea9u nguy\u00ean chi\u1ebfc , 5 ch\u1ed7 , m\u00e1y x\u0103ng 1.6L, \u0111\u00e8n g\u1ea7m, \u0111u\u00f4i c\u00e1, c\u1eeda n\u00f3c, g\u01b0\u01a1ng \u0111i\u1ec7n...","Link":"http:\/\/otothegioi.vn\/?page=product&idp=198","start_time":"08-09-2009","images":{"1":{"src":"uploads\/3379745719.jpg","price":"otothegioi.vn "}}},"611":{"id":"611","Title":"Nissan Teana 2010 - V\u1ec7 s\u0129 th\u00e9p b\u00ean b\u1ea1n ","Content":"","Description":"DVD, m\u00e0n h\u00ecnh Navigation, v\u00f4 l\u0103ng t\u00edch h\u1ee3p \u0111i\u1ec1u khi\u1ec3n, \u0111\u00e8n g\u00e2m, c\u1ea3m bi\u1ebfn, gh\u1ebf da, n\u1eb9p c\u1eeda inox, ch\u00eca kho\u00e1 th\u00f4ng minh","Link":"http:\/\/otothegioi.vn\/?page=product&idp=199","start_time":"08-09-2009","images":{"1":{"src":"uploads\/8710711934.jpg","price":"otothegioi.vn"}}},"612":{"id":"612","Title":"Camry 2.0 Ph\u00eda tr\u01b0\u1edbc l\u00e0 c\u1ee7a b\u1ea1n","Content":"","Description":"Gi\u00e1 t\u1ed1t nh\u1ea5t, giao h\u00e0ng \u0111\u00fang h\u1eb9n. Nh\u1eadn \u0111\u1eb7t h\u00e0ng t\u1ea5t c\u1ea3 c\u00e1c h\u00e3ng theo y\u00eau c\u1ea7u.","Link":"http:\/\/otothegioi.vn\/?page=product&idp=204","start_time":"08-09-2009","images":{"1":{"src":"uploads\/8496314843.jpg","price":"otothegioi.vn"}}},"613":{"id":"613","Title":"Toyota Corolla 1.8J","Content":"","Description":"Gh\u1ebf da, m\u00e2m \u0111\u00fac, \u0111\u00e8n g\u1ea7m, g\u01b0\u01a1ng g\u1eadp \u0111i\u00ean, DVD, k\u00ednh d\u00e1n 3M...Ngo\u00e0i ra, c\u00f2n r\u1ea5t nhi\u1ec1u m\u1eabu xe sang tr\u1ecdng kh\u00e1c","Link":"http:\/\/otothegioi.vn\/?page=product&idp=212","start_time":"08-09-2009","images":{"1":{"src":"uploads\/719664822.jpg","price":"otothegioi.vn"}}},"279":{"id":"279","Title":"Viet Auto Tr\u01b0\u1eddng Chinh - Khuy\u1ebfn m\u1ea1i l\u1edbn.","Content":"","Description":"Xe \u0111u\u1ee3c nh\u1eadp kh\u1ea9u nguy\u00ean chi\u1ebfc tr\u1ef1c ti\u1ebfp t\u1eeb c\u00e1c th\u1ecb tr\u01b0\u1eddng M\u1ef9, Nh\u1eadt, H\u00e0n Qu\u1ed1c, \u0110\u00e0i Loan, Trung \u0110\u00f4ng \u2026","Link":"http:\/\/vietauto.vn\/","start_time":"15-06-2009","images":{"1":{"src":"uploads\/3813596971.jpg","price":"1.667.660.000 VN\u0110"}}},"280":{"id":"280","Title":"Xe nh\u1eadp kh\u1ea9u gi\u00e1 c\u1ea3 c\u1ea1nh tranh","Content":"","Description":"V\u1edbi s\u1ef1 \u0111a d\u1ea1ng v\u1ec1 ch\u1ee7ng lo\u1ea1i, m\u00e0u s\u1eafc v\u00e0 c\u00e1c model m\u1edbi nh\u1ea5t c\u1ee7a nh\u1eefng h\u00e3ng xe n\u1ed5i ti\u1ebfng tr\u00ean th\u1ebf gi\u1edbi.","Link":"http:\/\/vietauto.vn\/","start_time":"15-06-2009","images":{"1":{"src":"uploads\/2250483963.jpg","price":"1.462.005.000 VN\u0110"}}},"281":{"id":"281","Title":"Trung t\u00e2m mua b\u00e1n \u00f4 t\u00f4 nh\u1eadp kh\u1ea9u","Content":"","Description":"Viet Auto Tr\u01b0\u1eddng Chinh cung c\u1ea5p t\u1edbi Qu\u00fd kh\u00e1ch h\u00e0ng nh\u1eefng chi\u1ebfc xe h\u01a1i v\u1edbi gi\u00e1 c\u1ea3 h\u1ee3p l\u00fd, d\u1ecbch v\u1ee5 ho\u00e0n h\u1ea3o ch\u1eafc ch\u1eafn s\u1ebd l\u00e0m h\u00e0i l\u00f2ng Qu\u00fd kh\u00e1ch h\u00e0ng. ","Link":"http:\/\/vietauto.vn\/","start_time":"15-06-2009","images":{"1":{"src":"uploads\/5824409254.jpg","price":"574.245.000 VN\u0110"}}},"282":{"id":"282","Title":"Nh\u00e0 nh\u1eadp kh\u1ea9u xe h\u01a1i chuy\u00ean nghi\u1ec7p ","Content":"","Description":"Viet Auto Tr\u01b0\u1eddng Chinh cung c\u1ea5p t\u1edbi Qu\u00fd kh\u00e1ch hang nh\u1eefng chi\u1ebfc xe h\u01a1i v\u1edbi gi\u00e1 c\u1ea3 h\u1ee3p l\u00fd, d\u1ecbch v\u1ee5 ho\u00e0n h\u1ea3o ch\u1eafc ch\u1eafn s\u1ebd l\u00e0m h\u00e0i l\u00f2ng Qu\u00fd kh\u00e1ch h\u00e0ng. ","Link":"http:\/\/vietauto.vn\/","start_time":"15-06-2009","images":{"1":{"src":"uploads\/6109348042.jpg","price":"1.082.650.000 VN\u0110"}}},"324":{"id":"324","Title":"Vietauto Tr\u01b0\u1eddng Chinh-Nh\u00e0 nh\u1eadp kh\u1ea9u xe h\u01a1i chuy\u00ean nghi\u1ec7p","Content":"","Description":"V\u1edbi s\u1ef1 \u0111a d\u1ea1ng v\u1ec1 ch\u1ee7ng lo\u1ea1i, m\u00e0u s\u1eafc v\u00e0 c\u00e1c model m\u1edbi nh\u1ea5t c\u1ee7a nh\u1eefng h\u00e3ng xe n\u1ed5i ti\u1ebfng tr\u00ean th\u1ebf gi\u1edbi.","Link":"http:\/\/vietauto.vn\/","start_time":"15-06-2009","images":{"1":{"src":"uploads\/2359682646.jpg","price":"880.800.000 VN\u0110"}}}}});
				}
				catch (e){
								//Do nothing?
				}