﻿
imageRootPath='http://image.tintuconline.com.vn';mediaRootPath='http://media.tintuconline.com.vn';ajaxReqPath='http://ajax.tintuconline.com.vn';var goldPrice={};var exchangeRate={};exchangeRate.FORM = {};exchangeRate.FORM.ROWSET = {};exchangeRate.FORM.ROWSET.ROW = []; var stockInfo={};stockInfo.FORM = {};stockInfo.FORM.ROWSET = {};stockInfo.FORM.ROWSET.ROW = [];function getboxInfoGoldPrice(o){o.FORM.ROWSET.ROW.Buy=o.FORM.ROWSET.ROW.Buy.substr(0,5)+' tr';o.FORM.ROWSET.ROW.Sell=o.FORM.ROWSET.ROW.Sell.substr(0,5)+' tr';goldPrice=o.FORM.ROWSET.ROW;}
function getboxInfoExchange(o){exchangeRate=o;}
function getboxInfoStock(o){stockInfo=o;}
var homeBoxLoaded=false;function loadHomeBox(){if(homeBoxLoaded)return;var loading;$('#homeBoxHolder').each(function(){$(this).css('min-height',450);var T=$(this).offset().top;var L=$(this).offset().left;var H=$(this).height();var W=$(this).width();var E='<div class="loading1" style="top:'+T+'px;left:'+L+'px;width:'+W+'px;height:'+H+'px">&nbsp;</div>';loading=$(E).css({zIndex:1000001,opacity:0.5}).appendTo('body');});AP.Core.JS.AjaxManager.add({url:'/ajax/HomeBox/get.html',data:{rnd:getRND()},success:function(h){var html='';if(h&&h!='""'&&h!='null'){html=h.trim();}else{alert('Không lấy được dữ liệu! Hãy thử lại');loading.remove();return;};setDataHomeBox(html);loading.remove();},error:function(){loading.remove();}});function setDataHomeBox(html){$('#homeBoxHolder').css('min-height',0);homeBoxLoaded=true;$('#homeBoxHolder').html(html);AP.Core.JS.Initialization.call(initDynamicLead);AP.Core.JS.PopupLead.init('bestNews');AP.Core.JS.Initialization.call(initTopNews);AP.Core.JS.Initialization.call(initHomeAdv);try{AP.Core.JS.Initialization.call(bindGoldPrice);}catch(ex1){}
try{AP.Core.JS.Initialization.call(bindExchangeRate);}catch(ex2){}
try{AP.Core.JS.Initialization.call(bindStockInfo);}catch(ex3){}
AP.Core.JS.Initialization.call(initboxInfo);}
function initDynamicLead()
{AP.Core.JS.DynamicLead.GB=true;AP.Core.JS.DynamicLead.globalSlidePause=6.5;AP.Core.JS.DynamicLead.globalTitleTransition=1.4;AP.Core.JS.DynamicLead.init();}
function initTopNews()
{AP.Core.JS.DynamicTab.init({id:'topNews',ajaxRequest:'/ajax/TopNews/get.html',cache:true,action:AP.Core.JS.PopupLead.init,template:tplTopnews});}
function initboxInfo()
{AP.Core.JS.DynamicTab.init({id:'boxInfo',ajaxRequest:'/ajax/BoxInfo/get.html',cache:true,data:{ns:'boxInfo'}});}
function initHomeAdv()
{AP.Core.JS.PhotoSlide.init({id:'headAdv',autoStart:true,slidePause:12.0,direction:AP.Core.JS.PhotoSlide.Direction.Horizontal});}
function bindGoldPrice()
{var s='<ta'+'ble cellpadding="0" cellspacing="1" width="100%">'+'<t'+'r>'+'<t'+'d>Vàng-Mua</t'+'d>'+'<t'+'d align="right">{Buy}</t'+'d>'+'</t'+'r>'+'<t'+'r>'+'<t'+'d>Vàng-Bán</t'+'d>'+'<t'+'d align="right">{Sell}</t'+'d>'+'</t'+'r>'+'</tab'+'le>';var t=new AP.Core.JS.Template({id:'boxInfoGoldPrice',template:s});t.overwrite('boxInfoGoldPrice',goldPrice);}
function bindExchangeRate()
{var s='<sp'+'an class="label name">{MoneyCode}</sp'+'an><sp'+'an class="label price">{Sell}</sp'+'an>';var t=new AP.Core.JS.Template({id:'boxInfoExchange',template:s});var tb=new AP.Core.JS.Template({id:'boxInfoExchangeFoo',template:'<b'+'r class="clear" />'});for(var i=0;i<exchangeRate.FORM.ROWSET.ROW.length;i++)
{exchangeRate.FORM.ROWSET.ROW[i].Sell=exchangeRate.FORM.ROWSET.ROW[i].Sell.substr(0,exchangeRate.FORM.ROWSET.ROW[i].Sell.length-3);t.append('boxInfoExchange',exchangeRate.FORM.ROWSET.ROW[i]);}
tb.append('boxInfoExchange',{});}
function bindStockInfo()
{var s='<sp'+'an class="stk_name">{name}</sp'+'an>'+'<sp'+'an class="stk_image"><i'+'mg height="9" width="9" src="/Images/{status}.gif" alt="" title="" /></sp'+'an>'+'<sp'+'an class="stk_price">{price}</sp'+'an>'+'<sp'+'an class="stk_price stk_price1">{diff}</sp'+'an>';var t=new AP.Core.JS.Template({id:'boxInfoStock',template:s});var tb=new AP.Core.JS.Template({id:'boxInfoStockFoo',template:'<b'+'r class="clear" />'});for(var i=0;i<stockInfo.FORM.ROWSET.ROW.length;i++)
{t.append('boxInfoStock',stockInfo.FORM.ROWSET.ROW[i]);}
tb.append('boxInfoStock',{});}}
function showHomeBox(){$('#btnShowHomeBox').hide();var hId=homeBoxLoaded?'#homeBox':'#homeBoxHolder';$('#homeBoxMini').hide(function(){$(hId).show(function(){$('#btnHideHomeBox').show();loadHomeBox();});});}
function closeHomeBox(){$('#btnHideHomeBox').hide();var hId=homeBoxLoaded?'#homeBox':'#homeBoxHolder';$(hId).slideUp(1500,function(){$('#homeBoxMini').slideDown(500,function(){$('#btnShowHomeBox').show();});});}
function submitSimpleSearch(f){var frm=$(f);var kw=$('.searchttol-text',frm).val();if(!kw||kw=='Từ khoá'){alert('Bạn hãy nhập từ cần tìm!!!');}
else{}}
function submitSearch(){var keyword=$('#txtKeyword').val().trim();var exactWord=$('#chkExactWord:checked').size();var findTitle=$('#chkFindTitle:checked').size();var category=$('#ddlCategory').val();var objSearch=AP.Core.JS.DynamicTab.items.get('searchResult');AP.Core.JS.DynamicTab.clearCache(objSearch);AP.Core.JS.DynamicTab.setData(objSearch,{kw:keyword,ew:exactWord,ft:findTitle,cat:category});AP.Core.JS.DynamicTab.goFirst(objSearch);}
AP.Core.JS.Initialization.add(AP.Core.JS.PopupLead.init);
function initLink(){var rnd=0.8;$('a').each(function(){var href=this.href;if(href&&href.indexOf('/vn/')>-1&&Math.random()<rnd){href=href.replace('/vn/','/vi/');$(this).click(function(){pageTracker._trackPageview(href);});}});}AP.Core.JS.Initialization.add(initLink);
function focusComment(){$('#sendername').focus();}
function randomNumber(n){if(!n||n<=0)n=1;return Math.floor(Math.random()*n);}
function getRND(){var d=new Date();randomstr=new String(Math.random());randomstr=randomstr.substring(1,8);return d.format('yyyymmddHHMMssl')+randomstr;}
function pollVote(ev){var frm=$('#frmPoll');var act=frm.attr('action');var url=act+'&'+getRND();if($(':radio:checked',frm).length==0){alert('Ban phai chon cau tra loi');$(':radio',frm).focus();}else{if($.browser.version=='6.0'){window.open(url);}else{url+='&pollValue='+$(':radio:checked',frm).val();$('#popSurvey-content').html('<ifr'+'ame src="'+url+'" width="100%" frameborder="0" scrolling="auto" height="270"></ifr'+'ame>');AP.Core.JS.Popup.show(ev,'popSurvey');}}}
function pollResult(ev){var frm=$('#frmPoll');var act=frm.attr('action');var p=act.indexOf('ReceiveSurvey.aspx');if(p>-1){var url=act.replace('ReceiveSurvey.aspx','SurveyResult.aspx');if($.browser.version=='6.0'){window.open(url);}else{$('#popSurvey-content').html('<ifr'+'ame src="'+url+'" width="100%" frameborder="0" scrolling="auto" height="270"></ifr'+'ame>');AP.Core.JS.Popup.show(ev,'popSurvey');}}}
function showSendNews(ev,cate)
{if(!cate||cate=='')cate='tinbandoc';var url=sendNewsUrl+cate;if($.browser.version=='6.0'){window.open(url);}else{$('#popSendNews-content').html('<ifr'+'ame src="'+url+'" width="100%" frameborder="0" scrolling="no" height="500"></ifr'+'ame>');AP.Core.JS.Popup.show(ev,'popSendNews');}}
AP.Core.JS.PopupLead.items = [];
