function LoadImages(id,src) 
{
if (id.getAttribute("loi") == null){
id.setAttribute("loi","1");
} else{
id.setAttribute("loi",eval(id.getAttribute("loi")) + 1);
}
if (eval(id.getAttribute("loi")) >= 2){
var width = src.substr(src.lastIndexOf("=") + 1,src.length - src.lastIndexOf("="));
 id.onerror = null;
 id.src = "/Images/NoImages/noimage_" + width + ".gif";
} else{
id.src = src;
}
}

function GetControlByName(id)
{
var prefix = document.getElementById("hidPrefix").value;
return document.getElementById(prefix + id);
}
/*Danh cho header-Tim kiem*/
function HideTextSearch(textSearch)
{ 
textSearch.value = "";
}
function ShowTextSearch(textSearch)
{
if (textSearch != null && textSearch.value.length == 0)
{
textSearch.value = "...điền từ khóa cần tìm";
}
}
function DoSearch(txt)
{
var keySearch=document.getElementById(txt).value;
if (document.all)
window.location = "/tim-kiem/"+keySearch+".htm";
else
window.location = "/tim-kiem/"+keySearch+".htm";
}

function doClickTimTin(buttonName,event,strKey)
{
var keySearch=strKey.value;
var key;
var url="/tim-kiem/"+keySearch+".htm";
if(window.event)
{
key = window.event.keyCode;
if (key == 13)
{
if(strKey!="")
{ 
document.location.href = url;
/*event.keyCode = 0;*/
return false;
}
else
{
alert("Bạn chưa nhập từ khóa tìm kiếm !");
return false;
}
}
}
else
{
key =event.which;;
if (key == 13)
{
if(strKey!="")
{
document.location.href = url;
return false;
}
else
{
alert("Bạn chưa nhập từ khóa tìm kiếm !");
return false;
}
}
}

}
var tii_isopera = typeof window.opera != 'undefined';

var tii_isie = typeof document.all != 'undefined'

 && !tii_isopera && navigator.vendor != 'KDE';

var tii_issafari = navigator.vendor == 'Apple Computer,Inc.';function tii_getTotalOffsetPosition (element,direction)
{
var pos = direction == 'x' ? element.offsetLeft:element.offsetTop;
var tmp = element.offsetParent;
while (tmp != null)
{
pos += direction == 'x' ? tmp.offsetLeft:tmp.offsetTop;
tmp = tmp.offsetParent;
}
return pos;
}

/* Stops the default action for the event,such as jumping to an anchor when clicking on a hyperlink */
function tii_stopDefaultAction (event)
{
event.returnValue = false;
if (typeof event.preventDefault != 'undefined')
{
event.preventDefault ();
}
}

/* Create a new element node with attributes */
function tii_dom_createElement (nodeName,attributes)
{
var isopera = typeof window.opera != 'undefined';
var isie = typeof document.all != 'undefined'
 && !isopera && navigator.vendor != 'KDE';

var newElement;
try
{
newElement = document.createElement (nodeName);
}
catch (error)
{
return null;
}

var attributesLength = attributes.length;
for (var i = 0;i < attributesLength;i++)
{
var attribute = attributes [i] [0];
var value = attributes [i] [1];
newElement.setAttribute (attribute,value);
switch (attribute)
{
case 'id':
newElement.id = value;
break;
case 'class':
if (isie)
{
newElement.setAttribute ('className',value);
}
newElement.className = value;
break;
case 'style':
newElement.style.cssText = newElement.style.cssText + ' ' + value;
break;
case 'for':
if (isie)
{
newElement.setAttribute ('htmlFor',value);
}
newElement.htmlFor = value;
}
}

return newElement;
}

/* Removes all the unwanted whitespace text nodes from inside the tree
 (including tabs,spaces,and line breaks between list items) */
function tii_dom_removeWhitespaceTextNodes (node)
{
for (var x = 0;x < node.childNodes.length;x++)
{
var child = node.childNodes [x];
if (child.nodeType == 3 && !/\S/.test (child.nodeValue))
{
node.removeChild (node.childNodes [x]);
x--;
}
if (child.nodeType == 1)
{
tii_dom_removeWhitespaceTextNodes (child);
}
}
}

/* Adds a function for the window load event */
function tii_callFunctionOnWindowLoad (functionToCall)
{
if (typeof window.addEventListener != 'undefined')
{
window.addEventListener ('load',functionToCall,false);
}
else if (typeof document.addEventListener != 'undefined')
{
document.addEventListener ('load',functionToCall,false);
}
else if (typeof window.attachEvent != 'undefined')
{
window.attachEvent ('onload',functionToCall);
}
else
{
var oldFunctionToCall = window.onload;
if (typeof window.onload != 'function')
{
window.onload = functionToCall;
}
else
{
window.onload = function ()
{
oldFunctionToCall ();
functionToCall ();
};
}
}
}
function tii_callFunctionOnElementLoad (targetId,functionToCall)
{
var myArguments = arguments;
tii_callFunctionOnWindowLoad (function ()
{
window.loaded = true;
});
var targetElement = document.getElementById (targetId);
if (targetElement == null && !window.loaded)
{
var pollingInterval = setInterval (function ()
{
if (window.loaded)
{
clearInterval (pollingInterval);
}
targetElement = document.getElementById (targetId);
if (targetElement != null)
{
clearInterval (pollingInterval);
var argumentsTemp = new Array ();
var argumentsTempLength = myArguments.length - 2;
for (var i = 0;i < argumentsTempLength;i++)
{
argumentsTemp [i] = myArguments [i + 2];
}
functionToCall.apply (this,argumentsTemp);
}
},10);
}
}

/* Attaches an event handling function to the targetElement as soon as the targetElement is loaded
 (even if the document hasn't completely loaded yet). */
function tii_addEventHandlerOnElementLoad (targetId,eventType,functionToCall,bubbleEventUpDOMTree)
{
tii_callFunctionOnWindowLoad (function ()
{
window.loaded = true;
});
var targetElement = document.getElementById (targetId);
if (targetElement == null && !window.loaded)
{
var pollingInterval = setInterval (function ()
{
if (window.loaded)
{
clearInterval (pollingInterval);
}
targetElement = document.getElementById (targetId);
if (targetElement != null)
{
clearInterval (pollingInterval);
tii_addEventHandler (targetElement,eventType,functionToCall,bubbleEventUpDOMTree);
}
},10);
}
}

function tii_addEventHandler (targetElement,eventType,functionToCall,bubbleEventUpDOMTree)
{
if (!targetElement)
{
window.status = 'Warning:Tried to attach event to null object';
return false;
}
if (typeof targetElement.addEventListener != 'undefined')
{
targetElement.addEventListener (eventType,functionToCall,bubbleEventUpDOMTree);
}
else if (typeof targetElement.attachEvent != 'undefined')
{
targetElement.attachEvent ('on' + eventType,functionToCall);
}
else
{
eventType = 'on' + eventType;
if (typeof targetElement [eventType] == 'function')
{
var oldListener = targetElement [eventType];
targetElement [eventType] = function ()
{
oldListener ();
return functionToCall ();
}
}
else
{
targetElement [eventType] = functionToCall;
}
}

return true;
}

function tii_removeEventHandler (targetElement,eventType,functionToRemove,bubbleEventUpDOMTree)
{
if (typeof targetElement.removeEventListener != "undefined")
{
targetElement.removeEventListener (eventType,functionToRemove,bubbleEventUpDOMTree);
}
else if (typeof targetElement.detachEvent != "undefined")
{
targetElement.detachEvent ("on" + eventType,functionToRemove);
}
else
{
targetElement ["on" + eventType] = null;
}

return true;
}
function TiiAdConfig(sitename){
this.sitename= sitename;
this.cmSitename= sitename;

this.popups= true;
this.useBehaviorTracking= false;

this.setSitename= TiiAdConfigSetSitename;
this.setCmSitename= TiiAdConfigSetCmSitename;
this.setPopups= TiiAdConfigSetPopups;
this.setBehaviorTracking= TiiAdConfigSetBehaviorTracking;

this.useRevSciTracking = false;
this.setRevSciTracking = TiiAdConfigSetRevSciTracking;

this.useTacodaTracking = false;
this.setTacodaTracking = TiiAdConfigSetTacodaTracking;

}

function TiiAdConfigSetTacodaTracking(value){
this.useTacodaTracking = value;
}

function TiiAdConfigSetRevSciTracking(value){
this.useRevSciTracking = value;
}

function TiiAdConfigSetSitename(value){
this.sitename = value;
}

function TiiAdConfigSetCmSitename(value){
this.cmSitename = value;
}

function TiiAdConfigSetPopups(value){
this.popups = value;
}

function TiiAdConfigSetBehaviorTracking(value){
this.useBehaviorTracking = value;
}

function TiiAdFactory(){
var first = arguments[0];

if (typeof(first) == "string"){
this.sitename= first;
this.cmSitename= first;

} else if (typeof(first) == "object"){
this.config= first;
this.sitename= first.sitename;
this.cmSitename= first.cmSitename;
}

if (TiiAd_isSecure()){
this.adServer= "https://ad.doubleclick.net/";
} else{
this.adServer= "http://ad.doubleclick.net/";
}

this.randomNumber= TiiAdsGetRandomNumber();
this.tileCounter= 1;
this.params= new Array();
this.zone= "";
this.dcopt= false;
this.behaviorTracked = false;

if (arguments.length == 2){
this.zone = arguments[1];
}

this.createAd= TiiAdFactoryCreateAd;
this.getAd= TiiAdFactoryGetAd;
this.getCmAd= TiiAdFactoryGetCmAd;
this.getMultiAd= TiiAdFactoryGetMultiAd;
this.getTransitionalAd= TiiAdFactoryGetTransitionalAd;
this.setArticleId= TiiAdFactorySetArticleId;
this.setChannel= TiiAdFactorySetChannel;
this.setChannelPage= TiiAdFactorySetChannelPage;
this.setContentPage= TiiAdFactorySetContentPage;
this.setContentType= TiiAdFactorySetContentType;
this.setPackageId= TiiAdFactorySetPackageId;
this.setParam= TiiAdFactorySetParam;
this.setSubchannel= TiiAdFactorySetSubchannel;
this.setZone= TiiAdFactorySetZone;
this.trackBehaviour= TiiAdTrackBehavior;

if (this.config.useBehaviorTracking || this.config.useRevSciTracking){
var revSciSegments = TiiAdGetRevSciSegments();
this.setParam("rsseg",revSciSegments)
}

if (this.config.useTacodaTracking){
var tacodaSegments = TiiAdGetTacodaSegments();
this.setParam("tcseg",tacodaSegments)
}

}

function TiiAdTrackRevSci(){
if (typeof(DM_tag) == "function" && typeof(s_time) == "object"){
rsCategory = s_time.channel + " > " + s_time.prop16 + " > " + s_time.prop11;
DM_cat(rsCategory);
DM_tag();
}
}


function TiiAdFactorySetParam(key,value){
if (typeof(value) == "object"){
this.params[key] = value;
} else{
if (value.toString() != ""){
this.params[key] = value;
}
}
}

function TiiAdFactoryCreateAd(){
var width,height,zone,ad;

if (arguments.length == 2){
width = arguments[0];
height = arguments[1];

} else{
width = arguments[0];
height = arguments[1];
zone = arguments[2];

}

ad = new TiiAd(this,width,height,this.tileCounter);

if (null != zone){
ad.setZone(zone);
}

for (var key in this.params){
ad.setParam(key,this.params[key]);
}

ad.setParam("sz",width + "x" + height);

var paths = window.location.pathname.split("/");
paths = paths.slice(1,paths.length - 1);
ad.setParam("path",paths);

ad.setParam("dcove","d");

if (TiiAdsIsTestMode()){
ad.setParam("test",1);
}

if (this.config.useBehaviorTracking && this.behaviorTracked == false){
this.trackBehaviour();
}

this.tileCounter++;

return ad;
}

function TiiAdFactoryGetAd(){
var width,height,zone,ad;

if (arguments.length == 2){
width = arguments[0];
height = arguments[1];

ad = this.createAd(width,height);

} else{
width = arguments[0];
height = arguments[1];
zone = arguments[2];

ad = this.createAd(width,height,zone);
}

if (this.dcopt == false){
ad.setParam("dcopt","ist");
this.dcopt = true;
}

return ad;
}

function TiiAdFactoryGetCmAd(width,height,position,type){
ad = this.createAd(width,height);
ad.setParam("cmpos",position);
ad.setParam("cmtyp",type);
ad.sitename = this.cmSitename;

return ad;
}

function TiiAdFactoryGetTransitionalAd(){
ad = this.getAd(0,0);
return ad;
}

function TiiAdFactoryGetMultiAd(sizes){
var width = sizes[0].split("x")[0];
var height = sizes[0].split("x")[1];
var ad = this.getAd(width,height);
var sizeValue = sizes.join(",");
ad.setParam("sz",sizeValue);

return ad;
}

function TiiAdFactorySetArticleId(articleId){
this.setParam("aid",articleId);
}

function TiiAdFactorySetChannel(channel){
this.setParam("ch",channel);
}

function TiiAdFactorySetPackageId(packageId){
this.setParam("pid",packageId);
}

function TiiAdFactorySetSubchannel(subchannel){
this.setParam("sch",subchannel);
}

function TiiAdFactorySetContentPage(){
this.setParam("ptype","content");
}

function TiiAdFactorySetChannelPage(){
this.setParam("ptype","channel");
}

function TiiAdFactorySetContentType(ctype){
this.setParam("ctype",ctype);
}

function TiiAdFactorySetZone(zone){
this.zone = zone;
}

function TiiAd(factory,width,height,tileNumber){
this.tileNumber= tileNumber;
this.width= width;
this.height= height;
this.params= new Array();

// Methods
this.setParam= TiiAdFactorySetParam;
this.setMagicNumber= TiiAdSetMagicNumber;
this.setPosition= TiiAdSetPosition;
this.setZone= TiiAdSetZone;
this.write= TiiAdWrite;

// Private Methods
this._formatParams= TiiAd_formatParams;
this._getAdParams= TiiAd_getAdParams;
this._getAdTag= TiiAd_getAdTag;
this._getAdUrl= TiiAd_getAdUrl;
this._getImageUrl= TiiAd_getImageUrl;
this._getClickUrl= TiiAd_getClickUrl;
this._getDebugHtml= TiiAd_getDebugHtml;
this._getSecureAdTag= TiiAd_getSecureAdTag;

// Copy factory settings
this.randomNumber= factory.randomNumber;
this.adServer= factory.adServer;
this.tileNumber= factory.tileCounter;
this.zone= factory.zone;
this.sitename= factory.sitename;
this.config= factory.config;
}

function TiiAdSetMagicNumber(mn){
this.setParam("mn",mn);
}

function TiiAdSetPosition(pos){
this.setParam("pos",pos);
}

function TiiAdSetZone(zone){
this.zone = zone;
}

function TiiAdWrite(){
if (TiiAdsIsDebugMode()){
document.write(this._getDebugHtml() + "<br/>");
}

document.write(this._getAdTag());
}

function TiiAd_formatParams(){
var adParams = "";
for (var key in this.params){
var value = this.params[key];

if (typeof(value) == "function"){
continue;
}

if (typeof(value) == "string" || typeof(value) == "number"){
adParams += ";" + key + "=" + escape(value).toLowerCase();
} else{
for (var i = 0;i < value.length;i++){
if (value[i] != ""){
adParams += ";" + key + "=" + escape(value[i]).toLowerCase();
}
}
}
}

return adParams;
}

function TiiAd_getAdParams(){
var adParams= this._formatParams();
var tileParam= ";tile=" + this.tileNumber;

var secureParam = "";
if (TiiAd_isSecure()){
secureParam = ";sec=1";
}

var puParam = "";
if (!this.config.popups){
puParam = ";pu=0";
}

var ordParam= ";ord=" + this.randomNumber;
var rhost= document.referrer.split("/")[2];
var rhostParam= "";
if (typeof(rhost) != "undefined") rhostParam= ";rhost=" + rhost;
var pageParam= ";pgurl=" + escape(document.location);

return this.sitename + "/" + this.zone.toLowerCase() + adParams + pageParam + rhostParam + tileParam + puParam + secureParam + ordParam + "?";
}

function TiiAd_getAdTag(){
var adTag;
if (TiiAd_isSecure()){
adTag = this._getSecureAdTag();
} else{
adTag = '<scr' + 'ipt type="text/javascript" src="' + this._getAdUrl() + '"></scr' + 'ipt>';
}

return adTag;
}

function TiiAd_getSecureAdTag(){
return '<a href="' + this._getClickUrl() + '" target="_blank"><img src="' + this._getImageUrl() + '" width="' + this.width + '" height="' + this.height + '" border="0" /></a>';
}

function TiiAd_getAdUrl(){
return this.adServer + "adj/" + this._getAdParams();
}

function TiiAd_getImageUrl(){
return this.adServer + "ad/" + this._getAdParams();
}

function TiiAd_getClickUrl(){
return this.adServer + "jump/" + this._getAdParams();
}

function TiiAd_getDebugHtml(){
var output = '<input style="font-family:courier new;font-size:small;width:' + this.width + 'px;margin:0;padding:0" value="' + this._getAdUrl() + '"/>';

return output;
}


function TiiAdsIsDebugMode(){
return window.location.search.indexOf("debugads") >= 0;
}

function TiiAdsIsTestMode(){
return window.location.search.indexOf("testads") >= 0;
}

function TiiAdsGetRandomNumber(){
return Math.ceil(1+1E12*Math.random());
}

function TiiAd_isSecure(){
return (document.location.protocol == "https:");
}

function TiiAdTrackBehavior(){
if (typeof(DM_tag) == "function" && typeof(s_time) == "object"){
rsCategory = s_time.channel + " > " + s_time.prop16 + " > " + s_time.prop11;
DM_cat(rsCategory);
DM_tag();
this.behaviorTracked = true;
}
}

function TiiAdGetTacodaSegments(){

var tcd_segs = [];
var segs_beg = document.cookie.indexOf('AxData=');
if (segs_beg >= 0){
segs_beg = document.cookie.indexOf('=',segs_beg)+1;

if (segs_beg > 0){
var segs_end = document.cookie.indexOf(';',segs_beg);
if (segs_end == -1) segs_end=document.cookie.length;
tcd_segs=document.cookie.substring(segs_beg,segs_end);
if(tcd_segs.length <=0 ){
var retVal = new Array();
return retVal;
}



tcd_segs = tcd_segs.split("#");
if(tcd_segs[1].indexOf("|") > 0){
tcd_segs = tcd_segs[1].split("|");
} else{
tcd_segs = tcd_segs[1];
return tcd_segs;
}
var segLen = "",segArr = new Array()
segLen = tcd_segs.length;
var segs = new Array();
for (var i = 0;i < segLen;i++){
segs[i] = tcd_segs[i];
}
return segs;
} 
} 
var retVal = new Array();
return retVal;
}

function TiiAdGetRevSciSegments(){
var rsi_segs = [];
var segs_beg = document.cookie.indexOf('rsi_segs=');
if (segs_beg >= 0){
segs_beg = document.cookie.indexOf('=',segs_beg)+1;
if (segs_beg > 0){
var segs_end = document.cookie.indexOf(';',segs_beg);
if (segs_end == -1) segs_end=document.cookie.length;
rsi_segs=document.cookie.substring(segs_beg,segs_end).split('|');
}
}

var segLen = 20
var segQS = "",segArr = new Array()

if (rsi_segs.length < segLen){
segLen = rsi_segs.length
}

var segs = new Array();
for (var i = 0;i < segLen;i++){
segArr = rsi_segs[i].split("_")
if (segArr.length > 1){
segs[i] = segArr[1];
segQS += ("rsi" + "=" + segArr[1] + ";")
}
}

return segs;
}

function tiiAdSetType(){}
function tiiAdSetTarget(){}
function tiiHtmlAdWH(mn,width,height){
adFactory.getAd(width,height).write();
}
/* Attaching event handlers to elements */
var clickToggle = true;
tii_addEventHandlerOnElementLoad ('bubbleLink','mouseover',function (event){displayBubble(event);},false);
tii_addEventHandlerOnElementLoad ('bubbleLink','mouseout',function (event){hideBubble(event);},false);
tii_addEventHandlerOnElementLoad ('bubbleLink','keypress' ,function (event){displayBubble(event);},false);
tii_addEventHandlerOnElementLoad ('bubbleLink','blur',function (event){hideBubble(event);},false);

/* Thought Bubble for The Ag */
function displayBubble(event){

bubLink = document.getElementById('bubbleLink');
bub = document.getElementById('bubble');
var bubPos = new Array(2);
bubPos = findPos(bubLink);

/*Check for IE */
if (tii_isie) 
{
bub.style.left = (parseInt(bubPos[0]) - 162).toString() + 'px';
bub.style.top = (parseInt(bubPos[1]) +25).toString() + 'px';
}
else
{
bub.style.left = (parseInt(bubPos[0]) - 176).toString() + 'px';
bub.style.top = (parseInt(bubPos[1]) +26).toString() + 'px';
}

/* Display the bubble */
bub.style.display = 'block';
clickToggle = false;
}

/* Hides the bubble */
function hideBubble(event){
/*alert ('test');*/
var bub = document.getElementById('bubble');
bub.style.display = 'none';
clickToggle = true;
}

/* Finds the position of an element on the page */
function findPos(obj){
var curleft = curtop = 0;
if (obj.offsetParent){
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent){
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}

/* Begin TimeStamp function */
function renderTimestamp(year,month,day,hour,minutes,seconds) 
{
var aYear = new String(year);
var aMonth = new String(month);
var aDay = new String(day);
var aHour = new String(hour);
var aMinutes = new String(minutes);
var aSeconds = new String(seconds);
articleUTC = Date.UTC(aYear,aMonth,aDay,aHour,aMinutes,aSeconds);

/* this is EST timezone offset of 5 hours = 300 minutes
all Time articles are published in EST */
articleTZOffsetMS = 300 * 60 * 1000 ;
articleCorrectedMS = articleUTC + articleTZOffsetMS;

localDate = new Date();
localYear = localDate.getFullYear();
localMonth = localDate.getMonth();
localDay = localDate.getDate();
localHour = localDate.getHours();
localMinutes = localDate.getMinutes();
localSeconds = localDate.getSeconds();
localTZOffset = localDate.getTimezoneOffset();
//localTZOffsetMS = localTZOffset * 1000* 60;
localTZOffsetMS = 300 * 1000* 60;localUTC = Date.UTC(localYear,localMonth,localDay,localHour,localMinutes,localSeconds);

localCorrectedMS = localUTC + localTZOffsetMS;

// calculate how many minutes between article utc and user utc 
minuteDifferential = (localCorrectedMS - articleCorrectedMS)/(1000 * 60);
ageInMinutes = Math.round(minuteDifferential);
 
 if (ageInMinutes < 0){ ageInMinutes = 0;} 

if ( ageInMinutes < 15 ){
document.write("<span>UPDATED:</span> "+ ageInMinutes +" minutes ago");
} else{
if (hour >= 12){
if (hour != 12){aHour = aHour - 12;} 
ampm = "PM";
} else{
ampm = "AM";
}
if (aMinutes < 10){aMinutes = "0" + aMinutes} 
document.write("<span>UPDATED:</span> "+ aHour+":" + aMinutes + ampm + " ET");
}
}
/* End TimeStamp function */
/* Begin Main story module */
var currPic=0;
var timer1,timer2;
var paused = true;
var opacity = 100;
var msDivs = new Array(5);
var msButtons = new Array(5);
var msWrap;
var button;
var position;
var currPosition;

function initPageComponents(){
 /*Used to load all components on the page */
 msDivs[0] = document.getElementById('mainStory1');
 msDivs[1] = document.getElementById('mainStory2');
 msDivs[2] = document.getElementById('mainStory3');
 msDivs[3] = document.getElementById('mainStory4');
 msDivs[4] = document.getElementById('mainStory5');
 msButtons[0] = document.getElementById('a1');
 msButtons[1] = document.getElementById('a2');
 msButtons[2] = document.getElementById('a3');
 msButtons[3] = document.getElementById('a4');
 msButtons[4] = document.getElementById('a5');
 msWrap = document.getElementById('mainStoryWrap');
 initPausePlayEvents();
 var breakingNews = document.getElementById('breakingNewsImg');
 if (breakingNews == null)
{
paused = false;
timer1=setTimeout('timedStory()',5000);
 }
 doImageSwap();
}

function initPausePlayEvents(){
 /* add Event Handlers for the Photo Module */
 if (!document.getElementById || !document.getElementsByTagName){
return true;
 }
 /* checks for Javascript operability*/ 

 /*get all the links in the photo module*/
 var topStories = document.getElementById('topStories');
 var links = topStories.getElementsByTagName('a');

 for (i=0;i < links.length;i++){
if (links.item(i).id.substring(0,1) == 'a'){
 //filter the links for those that have a class name beginnig with 'a'
 //add the doNumber event handler for the number links
 links.item(i).href='javascript:void(0)';
 tii_addEventHandler (links [i],'click',function (event)
{
doNumber (event);
 },false);
}
 }
 
 var playLink = document.getElementById('playLink');

 //add the doButton event handler for the play pause button 
 tii_addEventHandler ( playLink ,'click',function (event)
{
doButton (event);
 },false);
}

/* helper function to deal specifically with images and the cross-browser differences in opacity handling */
function fader(opac){
 if (msWrap.style.MozOpacity!=null){
/* Mozilla's pre-CSS3 proprietary rule */ 
msWrap.style.MozOpacity = (opac/100) - .001;
 } else if (msWrap.style.opac!=null){
/* CSS3 compatible */
msWrap.style.opacity = (opac/100) - .001;
 } else if (msWrap.style.filter!=null){
/* IE's proprietary filter */ 
 if (opac==100){
msWrap.style.filter = "none;";
 } else{
msWrap.style.filter = "alpha(opacity="+opac+");";
}
 }
}

function change(num,step){
 /*fadeOut*/
 if (step == 1){
opacity -= 10;
if (opacity > 0){
 fader(opacity);
 timer2=setTimeout('change(' + num + ',1)',50);
}
else{ 
 change(num,2);
}
 }
 /*change picture*/
 else if (step == 2){
currPic = num;
msDivs[0].style.display = (num == 0 ? "block":"none");
msDivs[1].style.display = (num == 1 ? "block":"none");
msDivs[2].style.display = (num == 2 ? "block":"none");
msDivs[3].style.display = (num == 3 ? "block":"none");
msDivs[4].style.display = (num == 4 ? "block":"none");
msButtons[0].className = (num == 0 ? "on":"off");
msButtons[1].className = (num == 1 ? "on":"off");
msButtons[2].className = (num == 2 ? "on":"off");
msButtons[3].className = (num == 3 ? "on":"off");
msButtons[4].className = (num == 4 ? "on":"off");
change(num,3);
 }
 /*fadeIn*/
 else if (step == 3){ 
opacity += 10;
if (opacity <= 100){
 fader(opacity);
 timer2=setTimeout('change(' + num + ',3)',50);
}
 }
}

/* change picture,wait 5 seconds,repeat */
function timedStory() 
{
 if (currPic<4)
{
 currPic++;
 change(currPic,1);
 timer1=setTimeout('timedStory()',5000);
 }
 else
{
currPic=0;
change(currPic,1);
 timer1=setTimeout('timedStory()',5000);
 currPic++;
/*
currPic=0;
clearTimeout(timer1);
change(currPic,1);
paused = true;
doImageSwap();*/
 }
}
/* executed when the play pause button is selected */
function doButton(event){
 paused = !paused;
 doImageSwap();
 if (paused){
/* stop the image loop */
clearTimeout(timer1);
 }
 else{ 
/* restart the image loop */
timedStory();
 }
}


/*executed when a number link is selected */
function doNumber (event){
 var eventSource = typeof event.target != 'undefined' ? event.target:window.event.srcElement;
 /*get the number portion of the class name of the event source */ 
 currPic = eventSource.id.substring(1,2) - 1;
 paused = true;
 doImageSwap();
 clearTimeout(timer1);
 clearTimeout(timer2);
 change(currPic,1);

} 

/* swap the play pause button image */
function doImageSwap(){
 var button = document.getElementById('playLink');
 if (!tii_isie){
var imageFile = paused ? "Images/Home_Slide_Show/btn_play.gif":"Images/Home_Slide_Show/btn_pause.gif";
button.style.background= "url("+imageFile+") 0px 0px no-repeat";
 }else{
/*Use an image sprite to deplete the image flickering in IE */
button.style.backgroundImage= "url(/Images/Home_Slide_Show/btn_playpause.gif)";
position = paused ? "-16 px":"0 px";/* change the image source */
try{
document.execCommand('BackgroundImageCache',false,true);
} catch(e){}

/* if paused and play is not displayed */
if (paused == true && currPosition != "-16 px"){
button.style.backgroundPositionY=position;
}
/* if playing and paused is not displayed */
if (paused != true && currPosition != "0 px"){
button.style.backgroundPositionY=position;
 }
 currPosition = position;
 }
}
/* End Main story module */
/* Initialization and Unobtrusive Javascript Calls */
tii_callFunctionOnElementLoad('playLink',initPageComponents);/**
 * SWFObject v1.5:Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
