var cssdropdown={
disappeardelay: 250,
disablemenuclick: false,
enableswipe: 1,
enableiframeshim: 1,

dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10)
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)"
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-30 /*15*/: window.pageXOffset+window.innerWidth-30 /*15*/
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure)
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null)
this.dropmenuobj.style.visibility="hidden"
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick}
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
this.positionshim()
}
},

positionshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined"){
if (this.dropmenuobj.style.visibility=="visible"){
this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
this.shimobject.style.left=this.dropmenuobj.style.left
this.shimobject.style.top=this.dropmenuobj.style.top
}
this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
}
},

hideshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined")
this.shimobject.style.display='none'
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay)
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
if (window.createPopup && !window.XmlHttpRequest){
document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
this.shimobject=document.getElementById("iframeshim")
}
}
}
// ===================================================================
// Author: Matt Kruse <matt@ajaxtoolbox.com>
// WWW: http://www.AjaxToolbox.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

function AjaxRequest(){var req =new Object();
req.timeout =null;
req.generateUniqueUrl =true;
req.url =window.location.href;
req.method ="GET";
req.async =true;
req.username =null;
req.password =null;
req.parameters =new Object();
req.requestIndex =AjaxRequest.numAjaxRequests++;
req.responseReceived =false;
req.groupName =null;
req.queryString ="";
req.responseText =null;
req.responseXML =null;
req.status =null;
req.statusText =null;
req.aborted =false;
req.xmlHttpRequest =null;
req.onTimeout=null;
req.onLoading=null;
req.onLoaded=null;
req.onInteractive=null;
req.onComplete=null;
req.onSuccess=null;
req.onError=null;
req.onGroupBegin=null;
req.onGroupEnd=null;
req.xmlHttpRequest =AjaxRequest.getXmlHttpRequest();
if(req.xmlHttpRequest==null){return null;}req.xmlHttpRequest.onreadystatechange =
function(){if(req==null || req.xmlHttpRequest==null){return;}if(req.xmlHttpRequest.readyState==1){req.onLoadingInternal(req);}if(req.xmlHttpRequest.readyState==2){req.onLoadedInternal(req);}if(req.xmlHttpRequest.readyState==3){req.onInteractiveInternal(req);}if(req.xmlHttpRequest.readyState==4){req.onCompleteInternal(req);}};
req.onLoadingInternalHandled=false;
req.onLoadedInternalHandled=false;
req.onInteractiveInternalHandled=false;
req.onCompleteInternalHandled=false;
req.onLoadingInternal=
function(){if(req.onLoadingInternalHandled){return;}AjaxRequest.numActiveAjaxRequests++;
if(AjaxRequest.numActiveAjaxRequests==1 && typeof(window['AjaxRequestBegin'])=="function"){AjaxRequestBegin();}if(req.groupName!=null){if(typeof(AjaxRequest.numActiveAjaxGroupRequests[req.groupName])=="undefined"){AjaxRequest.numActiveAjaxGroupRequests[req.groupName] =0;}AjaxRequest.numActiveAjaxGroupRequests[req.groupName]++;
if(AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function"){req.onGroupBegin(req.groupName);}}if(typeof(req.onLoading)=="function"){req.onLoading(req);}req.onLoadingInternalHandled=true;};
req.onLoadedInternal=
function(){if(req.onLoadedInternalHandled){return;}if(typeof(req.onLoaded)=="function"){req.onLoaded(req);}req.onLoadedInternalHandled=true;};
req.onInteractiveInternal=
function(){if(req.onInteractiveInternalHandled){return;}if(typeof(req.onInteractive)=="function"){req.onInteractive(req);}req.onInteractiveInternalHandled=true;};
req.onCompleteInternal=
function(){if(req.onCompleteInternalHandled || req.aborted){return;}req.onCompleteInternalHandled=true;
AjaxRequest.numActiveAjaxRequests--;
if(AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function"){AjaxRequestEnd(req.groupName);}if(req.groupName!=null){AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
if(AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function"){req.onGroupEnd(req.groupName);}}req.responseReceived =true;
req.status =req.xmlHttpRequest.status;
req.statusText =req.xmlHttpRequest.statusText;
req.responseText =req.xmlHttpRequest.responseText;
req.responseXML =req.xmlHttpRequest.responseXML;
if(typeof(req.onComplete)=="function"){req.onComplete(req);}if(req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function"){req.onSuccess(req);}else if(typeof(req.onError)=="function"){req.onError(req);}delete req.xmlHttpRequest['onreadystatechange'];
req.xmlHttpRequest =null;};
req.onTimeoutInternal=
function(){if(req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled){req.aborted =true;
req.xmlHttpRequest.abort();
AjaxRequest.numActiveAjaxRequests--;
if(AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function"){AjaxRequestEnd(req.groupName);}if(req.groupName!=null){AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
if(AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function"){req.onGroupEnd(req.groupName);}}if(typeof(req.onTimeout)=="function"){req.onTimeout(req);}delete req.xmlHttpRequest['onreadystatechange'];
req.xmlHttpRequest =null;}};
req.process =
function(){if(req.xmlHttpRequest!=null){if(req.generateUniqueUrl && req.method=="GET"){req.parameters["AjaxRequestUniqueId"] =new Date().getTime() + "" + req.requestIndex;}var content =null;
for(var i in req.parameters){if(req.queryString.length>0){req.queryString +="&";}req.queryString +=encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);}if(req.method=="GET"){if(req.queryString.length>0){req.url +=((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;}}req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
if(req.method=="POST"){if(typeof(req.xmlHttpRequest.setRequestHeader)!="undefined"){req.xmlHttpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');}content =req.queryString;}if(req.timeout>0){setTimeout(req.onTimeoutInternal,req.timeout);}req.xmlHttpRequest.send(content);}};
req.handleArguments =
function(args){for(var i in args){if(typeof(req[i])=="undefined"){req.parameters[i] =args[i];}else{req[i] =args[i];}}};
req.getAllResponseHeaders =
function(){if(req.xmlHttpRequest!=null){if(req.responseReceived){return req.xmlHttpRequest.getAllResponseHeaders();}alert("Cannot getAllResponseHeaders because a response has not yet been received");}};
req.getResponseHeader =
function(headerName){if(req.xmlHttpRequest!=null){if(req.responseReceived){return req.xmlHttpRequest.getResponseHeader(headerName);}alert("Cannot getResponseHeader because a response has not yet been received");}};
return req;}AjaxRequest.getXmlHttpRequest =function(){if(window.XMLHttpRequest){return new XMLHttpRequest();}else if(window.ActiveXObject){/*@cc_on @*/
/*@if(@_jscript_version >=5)
try{return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(E){return null;}}@end @*/}else{return null;}};
AjaxRequest.isActive =function(){return(AjaxRequest.numActiveAjaxRequests>0);};
AjaxRequest.get =function(args){AjaxRequest.doRequest("GET",args);};
AjaxRequest.post =function(args){AjaxRequest.doRequest("POST",args);};
AjaxRequest.doRequest =function(method,args){if(typeof(args)!="undefined" && args!=null){var myRequest =new AjaxRequest();
myRequest.method =method;
myRequest.handleArguments(args);
myRequest.process();}};
AjaxRequest.submit =function(theform, args){var myRequest =new AjaxRequest();
if(myRequest==null){return false;}var serializedForm =AjaxRequest.serializeForm(theform);
myRequest.method =theform.method.toUpperCase();
myRequest.url =theform.action;
myRequest.handleArguments(args);
myRequest.queryString =serializedForm;
myRequest.process();
return true;};
AjaxRequest.serializeForm =function(theform){var els =theform.elements;
var len =els.length;
var queryString ="";
this.addField =
function(name,value){if(queryString.length>0){queryString +="&";}queryString +=encodeURIComponent(name) + "=" + encodeURIComponent(value);};
for(var i=0;i<len;i++){var el =els[i];
if(!el.disabled){switch(el.type){case 'text': case 'password': case 'hidden': case 'textarea':
this.addField(el.name,el.value);
break;
case 'select-one':
if(el.selectedIndex>=0){this.addField(el.name,el.options[el.selectedIndex].value);}break;
case 'select-multiple':
for(var j=0;j<el.options.length;j++){if(el.options[j].selected){this.addField(el.name,el.options[j].value);}}break;
case 'checkbox': case 'radio':
if(el.checked){this.addField(el.name,el.value);}break;}}}return queryString;};
AjaxRequest.numActiveAjaxRequests =0;
AjaxRequest.numActiveAjaxGroupRequests =new Object();
AjaxRequest.numAjaxRequests =0;

//-----------------------
var iMaxTS=5,iMaxTBS=3;
var iReadStep=0;
var sLoDID=',';
var iDelay=200;
var iDisplayCateNo=0;
var iTSTimer=0;
var iTSCount,iTSCur,iTSFading,iTSPrev=0,iTSNext=0,iTSFastMove=0;
var iFadeDelay=50;
var iBoxCount=0;

function getNodeValue(o){
	try	{
		return o.item(0).firstChild.nodeValue;
	}
	catch(err) {
		return '';
	}
	// if (o.item(0)){
		// if (o.item(0).firstChild){
			// return o.item(0).firstChild.nodeValue;
		// }
		// else{
			// return '';
		// }
	// }
	// else{
		// return '';
	// }
}

function displayid(id,add){
	if (typeof(add)=='undefined') add=true;
	if (sLoDID.indexOf(id)<=0){
		if (add) sLoDID=sLoDID.concat(id).concat(',');
		//sLoDID=sLoDID.concat(id).concat(',');
		return true;
	}
	else{
		return false;
	}
}

function showtopstoryitem(sNameTS,sPathTS,arItemTS){
	iTSCount = arItemTS.length-1;
	var sHTML='';
	sHTML=sHTML.concat('<div style="position:relative;width:360px;height:265px;">');
	sHTML=sHTML.concat('	<div style="left:0px;top:0px;width:360px;height:3px;" class="HomeTopStoryBorder"></div>');
	sHTML=sHTML.concat('	<div style="left:0px;top:262px;width:360px;height:3px;" class="HomeTopStoryBorder"></div>');
	sHTML=sHTML.concat('	<div style="left:0px;top:3px;width:3px;height:259px;" class="HomeTopStoryBorder"></div>');
	sHTML=sHTML.concat('	<div style="left:357;top:3px;width:3px;height:259px;" class="HomeTopStoryBorder"></div>');
	for (var i=0;i<=iTSCount;i++){
		sHTML=sHTML.concat('	<div id="divTopStory').concat(i).concat('" onmousemove="cleartopstorycounter();" style="overflow:hidden;position:absolute;').concat(iif(i==0,'left:0px','left:-1000px')).concat(';top:0px;width:360px;height:265px;">');
		sHTML=sHTML.concat('		<a href="').concat(arItemTS[i][1]).concat('"><img border="0" src="').concat(arItemTS[i][1]).concat(arItemTS[i][4]).concat('" width="360" height="265"></a>');
		sHTML=sHTML.concat('	</div>');
		sHTML=sHTML.concat('	<div id="divTopStoryLayer').concat(i).concat('" onmousemove="cleartopstorycounter();" style="').concat(iif(i==0,'left:0px','left:-1000px')).concat(';top:200px;width:360px;height:65px;" class="HomeTopStoryColorLayer"></div>');
		sHTML=sHTML.concat('	<div id="divTopStoryTitle').concat(i).concat('" onmousemove="cleartopstorycounter();" style="').concat(iif(i==0,'left:0px','left:-1000px')).concat(';top:200px;width:360px;height:65px;" class="HomeTopStoryColorLayerContent">');
		sHTML=sHTML.concat('		<div style="left:7px;top:4px;width:355px;height:18px;" class="HomeTopStoryTitle" onclick="window.location=\'').concat(arItemTS[i][1]).concat('\'">').concat(arItemTS[i][2]).concat('</div>');
		sHTML=sHTML.concat('		<div style="left:8px;top:5px;width:355px;height:18px;" class="HomeTopStoryTitleShadow">').concat(arItemTS[i][2]).concat('</div>');
		sHTML=sHTML.concat('		<div style="left:8px;top:28px;width:340px;height:18px;" class="HomeTopStoryLead">').concat(arItemTS[i][3]);
		if (arItemTS[i][7]>0){
			sHTML = sHTML.concat('<img src="/Images/Video.gif" hspace=2>');
		}
		if (arItemTS[i][8]>0){
			sHTML = sHTML.concat('<img src="/Images/Photo.gif" hspace=2>');
		}
		if (arItemTS[i][9]>0){
			sHTML = sHTML.concat('<img src="/Images/Story.gif" hspace=2>');
		}
		sHTML = sHTML.concat('		</div>');
		sHTML=sHTML.concat('	</div>');
	}
	sHTML=sHTML.concat('<div style="left:332px;top:244px;width:40px;height:32px;" class="HomeTopStoryColorLayerSubImage">');
	sHTML=sHTML.concat('<img id="imgTSPrev" src="/Images/TopStory/Prev2.gif" hspace="2" vspace="0" onmouseover="iTSPrev=1;this.src=\'/Images/TopStory/Prev.gif\'" onmouseout="iTSPrev=0;this.src=\'/Images/TopStory/Prev2.gif\'" style="cursor:pointer" onclick="changetopstory(-1,false);">');
	sHTML=sHTML.concat('<img id="imgTSNext" src="/Images/TopStory/Next2.gif" hspace="2" vspace="0" onmouseover="iTSNext=1;this.src=\'/Images/TopStory/Next.gif\'" onmouseout="iTSNext=0;if (!iTSFading) this.src=\'/Images/TopStory/Next2.gif\'" style="cursor:pointer" onclick="changetopstory(1,false);">');
	sHTML=sHTML.concat('</div>');
	sHTML=sHTML.concat('</div>');
	gmobj('tdTS').innerHTML=sHTML;
	iTSCur=0;
	setInterval(function(){topstorycounter();},100)
}

function changetopstory(direction,fade){
	var iTop, iBot;
	var oTop, oBot, oTopLayer, oBotLayer, oTopTitle, oBotTitle;
	iTop=iTSCur;
	iBot=iTop+direction;
	if (iBot<0) iBot=iTSCount;
	if (iBot>iTSCount) iBot=0;
	oTop = 'divTopStory'+iTop;
	oBot = 'divTopStory'+iBot;
	oTopLayer = 'divTopStoryLayer'+iTop;
	oBotLayer = 'divTopStoryLayer'+iBot;
	oTopTitle = 'divTopStoryTitle'+iTop;
	oBotTitle = 'divTopStoryTitle'+iBot;
	if (iTSFading==1){
		gmobj('divTopStory'+(iTop+1)).style.left='-1000px';
		gmobj('divTopStoryLayer'+(iTop+1)).style.left='-1000px';
		gmobj('divTopStoryTitle'+(iTop+1)).style.left='-1000px';
		outdirectionimage();
		iTSFading=0;
	}
	iTSTimer=0;
	if (!fade){
		iTSFastMove=1;
		changeOpac(100,oBot);
		changeOpac(40,oBotLayer);
		changeOpac(100,oBotTitle);
		gmobj(oTop).style.zIndex=1;
		gmobj(oBot).style.zIndex=2;
		gmobj(oBot).style.left='0px';
		gmobj(oTop).style.left='-1000px';
		gmobj(oBotLayer).style.left='0px';
		gmobj(oTopLayer).style.left='-1000px';
		gmobj(oBotTitle).style.left='0px';
		gmobj(oTopTitle).style.left='-1000px';
		iTSFading=0;
		iTSCur=iBot;
	}
	else{
		iTSFastMove=0;
		changeOpac(100,oBot);
		changeOpac(0,oBotLayer);
		changeOpac(0,oBotTitle);
		gmobj(oTop).style.zIndex=2;
		gmobj(oBot).style.zIndex=1;
		gmobj(oBot).style.left='0px';
		gmobj(oBotLayer).style.left='0px';
		gmobj(oBotTitle).style.left='0px';
		iTSFading=1;
		changingdirectionimage(direction);
		changingtopstory(iTop,iBot,0,100);
	}
}

function changingtopstory(iTop,iBot,iStep,iCurOpac){
	var oTop, oBot, oTopLayer, oBotLayer, oTopTitle, oBotTitle;
	oTop = 'divTopStory'+iTop;
	oBot = 'divTopStory'+iBot;
	oTopLayer = 'divTopStoryLayer'+iTop;
	oBotLayer = 'divTopStoryLayer'+iBot;
	oTopTitle = 'divTopStoryTitle'+iTop;
	oBotTitle = 'divTopStoryTitle'+iBot;
	if (iTSFading==1){
		if (iStep==0){
			if (iCurOpac>=0){
				changeOpac(iCurOpac,oTopTitle);
				changeOpac(iCurOpac*40/100,oTopLayer);
				iCurOpac-=5;
				setTimeout(function(){changingtopstory(iTop,iBot,0,iCurOpac)},iFadeDelay);
			}
			else{
				setTimeout(function(){changingtopstory(iTop,iBot,1,100)},1000);
			}
		}
		else if (iStep==1){
			if (iCurOpac>=0){
				changeOpac(iCurOpac,oTop);
				iCurOpac-=5;
				setTimeout(function(){changingtopstory(iTop,iBot,1,iCurOpac)},iFadeDelay);
			}
			else{
				iTSCur=iBot;
				gmobj(oTop).style.left='-1000px';
				gmobj(oTopLayer).style.left='-1000px';
				gmobj(oTopTitle).style.left='-1000px';
				setTimeout(function(){changingtopstory(iTop,iBot,2,0)},100);
			}
		}
		else if (iStep==2){
			if (iCurOpac<=100){
				changeOpac(iCurOpac,oBotTitle);
				changeOpac(iCurOpac*40/100,oBotLayer);
				iCurOpac+=5;
				setTimeout(function(){changingtopstory(iTop,iBot,2,iCurOpac)},iFadeDelay);
			}
			else{
				outdirectionimage();
				iTSFading=0;
				iTSTimer=0;
			}
		}
	}
	else if (iStep<2 && iTSFastMove==0) {
		gmobj(oBot).style.left='-1000px';
		gmobj(oBotLayer).style.left='-1000px';
		gmobj(oBotTitle).style.left='-1000px';
		outdirectionimage();
		iTSFading=0;
		iTSTimer=0;
	}
}

function changingdirectionimage(direction){
	if (direction>0) gmobj('imgTSNext').src="/Images/TopStory/Next.gif"
	else gmobj('imgTSPrev').src="/Images/TopStory/Prev.gif"
}

function outdirectionimage(){
	if (iTSNext==0) gmobj('imgTSNext').src="/Images/TopStory/Next2.gif"
	if (iTSPrev==0) gmobj('imgTSPrev').src="/Images/TopStory/Prev2.gif"
}

function topstorycounter(){
	iTSTimer++;
	if (iTSTimer>70) {
		iTSTimer=0;
		changetopstory(1,true);
	}
}

function cleartopstorycounter(){
	changeOpac(100,'divTopStory'+iTSCur);
	changeOpac(40,'divTopStoryLayer'+iTSCur);
	changeOpac(100,'divTopStoryTitle'+iTSCur);
	iTSFading=0;
	iTSTimer=0;
}

function changeOpac(opacity, id) {
	gmobj(id).style.opacity = (opacity / 100);
	gmobj(id).style.MozOpacity = (opacity / 100);
	gmobj(id).style.KhtmlOpacity = (opacity / 100);
	gmobj(id).style.filter = "alpha(opacity=" + opacity + ")";
}

function showtopboxitem(sFolder,sName,sPath,arItem,index){
	var sHTML='';
	sHTML=sHTML.concat('<Table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%">');
	sHTML=sHTML.concat('	<tr>');
	sHTML=sHTML.concat('		<td height="100%" valign="top">');
	sHTML=sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
	sHTML=sHTML.concat('				<tr>');
	sHTML=sHTML.concat('					<td background="/Images/TopBox/TopBackground.gif" height=4></td>');
	sHTML=sHTML.concat('				</tr>');
	sHTML=sHTML.concat('				<tr>');
	sHTML=sHTML.concat('					<td align="center" style="padding-top:0;">');
	sHTML=sHTML.concat('						<Table align="center" border=0 cellspacing=1 cellpadding=0 width="92%">');
	sHTML=sHTML.concat('							<tr>');
	sHTML=sHTML.concat('								<td>');
	sHTML=sHTML.concat('									<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
	sHTML=sHTML.concat('										<tr>');
	sHTML=sHTML.concat('											<td><a href="').concat(sPath).concat('"><img border="0" src="/Images/TopBox/').concat(sFolder).concat('.gif"></a></td>');
	sHTML=sHTML.concat('											<td width="100%" style="background-image:url(/Images/TopBox/HeaderDot.gif);background-position: 2px 9px; background-repeat: repeat-x;"></td>');
	sHTML=sHTML.concat('										</tr>');
	sHTML=sHTML.concat('									</Table>');
	sHTML=sHTML.concat('								</td>');
	sHTML=sHTML.concat('							</tr>');
	if (arItem[index][5]!=''){
		sHTML=sHTML.concat('							<tr>');
		sHTML=sHTML.concat('								<td align=center>');
		//sHTML=sHTML.concat('									<Table border=0 cellspacing=0 cellpadding=1 bgcolor="#626262">');
		//sHTML=sHTML.concat('										<tr><td><a href="').concat(arItem[index][1]).concat('"><img border=0 width=150 height=110 src="').concat(arItem[index][1]).concat(arItem[index][5]).concat('"></a></td></tr>');
		//sHTML=sHTML.concat('									</Table>');
		sHTML=sHTML.concat('<a href="').concat(arItem[index][1]).concat('"><img border=0 width=150 height=110 src="').concat(arItem[index][1]).concat(arItem[index][5]).concat('"></a>');
		sHTML=sHTML.concat('								</td>');
		sHTML=sHTML.concat('							</tr>');
	}
	sHTML=sHTML.concat('							<tr>');
	sHTML=sHTML.concat('								<td style="padding-left:3px;padding-right:3px;"><a class="HomeNormal Bold Black" href="').concat(arItem[index][1]).concat('">').concat(arItem[index][2]).concat('</a></td>');
	sHTML=sHTML.concat('							</tr>');
	sHTML=sHTML.concat('							<tr>');
	sHTML=sHTML.concat('								<td class="Small" style="padding-left:3px;padding-right:3px;">');
	sHTML=sHTML.concat('									').concat(arItem[index][3]);
	if (arItem[index][7]>0){
		sHTML = sHTML.concat('<img src="/Images/Video.gif" hspace=2>');
	}
	if (arItem[index][8]>0){
		sHTML = sHTML.concat('<img src="/Images/Photo.gif" hspace=2>');
	}
	if (arItem[index][9]>0){
		sHTML = sHTML.concat('<img src="/Images/Story.gif" hspace=2>');
	}
	sHTML=sHTML.concat('								</td>');
	sHTML=sHTML.concat('							</tr>');
	sHTML=sHTML.concat('						</Table>');
	sHTML=sHTML.concat('					</td>');
	sHTML=sHTML.concat('				</tr>');
	sHTML=sHTML.concat('			</Table>');
	sHTML=sHTML.concat('		</td>');
	sHTML=sHTML.concat('	</tr>');
	sHTML=sHTML.concat('	<tr>');
	sHTML=sHTML.concat('		<td style="padding-bottom:4;" align="right">');

	sHTML=sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0 height="20px" width="100%" bgcolor="#c8d77d">');
	sHTML=sHTML.concat('				<tr>');
	sHTML=sHTML.concat('					<td>');
	sHTML=sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0 align=right>');
	sHTML=sHTML.concat('				<tr>');
	if (index==0){
		sHTML=sHTML.concat('					<td style="padding-left:5;padding-right:5;"><img src="/Images/TopBox/Prev2.gif"></td>');
	}
	else{
		sHTML=sHTML.concat('					<td style="padding-left:5;padding-right:5;">');
		sHTML=sHTML.concat('<img src="/Images/TopBox/Prev.gif" style="cursor:pointer;" ');
		sHTML=sHTML.concat('onclick="showtopboxitem(sId').concat(sFolder).concat(',sName').concat(sFolder).concat(',sPath').concat(sFolder).concat(',arItem').concat(sFolder).concat(',').concat(index-1).concat(')"');
		sHTML=sHTML.concat('></td>');
	}
	if (index>=arItem.length-1){
		sHTML=sHTML.concat('					<td style="padding-left:5;padding-right:5;"><img src="/Images/TopBox/Next2.gif"></td>');
	}
	else{
		sHTML=sHTML.concat('					<td style="padding-left:5;padding-right:5;">');
		sHTML=sHTML.concat('<img src="/Images/TopBox/Next.gif" style="cursor:pointer;" ');
		sHTML=sHTML.concat('onclick="showtopboxitem(sId').concat(sFolder).concat(',sName').concat(sFolder).concat(',sPath').concat(sFolder).concat(',arItem').concat(sFolder).concat(',').concat(index+1).concat(')"');
		sHTML=sHTML.concat('></td>');
	}
	sHTML=sHTML.concat('				</tr>');
	sHTML=sHTML.concat('			</Table>');
	sHTML=sHTML.concat('					</td>');
	sHTML=sHTML.concat('				</tr>');
	sHTML=sHTML.concat('			</Table>');
	sHTML=sHTML.concat('		</td>');
	sHTML=sHTML.concat('	</tr>');
	sHTML=sHTML.concat('</Table>');
	gmobj('tdTopBox'+sFolder).innerHTML=sHTML;
}

function showhomefolderitem(sFolder){
		if (iReadStep<2 || (sFolder==1001 && iBoxCount<19)) {
	//if (iReadStep<2) {
		setTimeout(function(){showhomefolderitem(sFolder);},iDelay);
		return;
	}
	var sId, sName, sPath;
	var arItem = new Array();
	var arSub = new Array();
	var sLink = '/ListFile/'.concat(sFolder).concat('.xml');
	var sHTML;
	var iMaxItem;
	switch (parseInt(sFolder)){
		case 15: case 16: case 25: iMaxItem = 1; break;
		case 21: iMaxItem = 2;break;
		case 1001: iMaxItem = 7;break;
		default: iMaxItem = 3;
	}
	AjaxRequest.get(
		{
	    'url':sLink
	    ,'onSuccess':function(req){
	    	if (req.responseXML.getElementsByTagName('Folder').length>0){
	    		with(req.responseXML.getElementsByTagName('Folder').item(0)){
					sId = getNodeValue(getElementsByTagName('fID'));
					sName = toUpper(getNodeValue(getElementsByTagName('fName')));
					sPath = getNodeValue(getElementsByTagName('fPath'));
	    		}
	    	}
	    	var iCount=0;
	    	for (var i=0;i<req.responseXML.getElementsByTagName('Item').length;i++){
	    		with(req.responseXML.getElementsByTagName('Item').item(i)){
	    			if (iCount<iMaxItem){
		    			var sTemp = getNodeValue(getElementsByTagName('sID'));
		    			if (sTemp!='' && displayid(sTemp)){
			    			arItem[iCount] = new Array(10);
							arItem[iCount][0] = getNodeValue(getElementsByTagName('sID'));
							arItem[iCount][1] = getNodeValue(getElementsByTagName('sPath'));
							arItem[iCount][2] = getNodeValue(getElementsByTagName('sTitle'));
							arItem[iCount][3] = getNodeValue(getElementsByTagName('sLead'));
							arItem[iCount][4] = getNodeValue(getElementsByTagName('sImageTopStory'));
							//if (arItem[iCount][4]=='') arItem[iCount][4] = getNodeValue(getElementsByTagName('sImageTopStory'));
							arItem[iCount][5] = getNodeValue(getElementsByTagName('sImageHome'));
							if (arItem[iCount][5]=='') {
								arItem[iCount][5] = getNodeValue(getElementsByTagName('sTopImage'));
							}
							else{
								if (iCount>0){
									arItem[iCount][5] = arItem[iCount][5].concat('.thumb95x67.ns.jpg');
								}
							}
							arItem[iCount][6] = getNodeValue(getElementsByTagName('sImageFolder'));
							if (arItem[iCount][6]=='') arItem[iCount][6] = getNodeValue(getElementsByTagName('sTopImage'));
							arItem[iCount][7] = getNodeValue(getElementsByTagName('sHasVideo'));
							arItem[iCount][8] = getNodeValue(getElementsByTagName('sHasPhoto'));
							arItem[iCount][9] = getNodeValue(getElementsByTagName('sHasStory'));
							arSub[iCount] = new Array(5);
							for (var j=0;j<getElementsByTagName('Comment').length;j++){							
								with (getElementsByTagName('Comment').item(j)){
									arSub[iCount][j] = new Array(5);
									arSub[iCount][j][0] = getNodeValue(getElementsByTagName('sID'));
									arSub[iCount][j][1] = getNodeValue(getElementsByTagName('sPath'));
									arSub[iCount][j][2] = getNodeValue(getElementsByTagName('sTitle'));
								}
							}
							iCount++;
						}
					}
	    		}
	    	}
	    	switch (parseInt(sFolder)){
	    		case 15: case 16: case 25: sHTML = getentertainmenthomefolder(sId,sName,sPath,arItem); break;
	    		case 18: case 28: sHTML = getposterhomefolder(sId,sName,sPath,arItem); break;
	    		case 21: sHTML = getforumhomefolder(sId,sName,sPath,arItem,arSub);break;
	    		case 1001: sHTML = gethotnewshomefolder(sId,sName,sPath,arItem);break;
	    		default: sHTML = getnormalhomefolder(sId,sName,sPath,arItem);
	    	}
			gmobj('tdHomeFolder'+sFolder).innerHTML=sHTML;
			iBoxCount++;
			iTSTimer=0;
	    }
	    ,'onError':function(req){
			gmobj('tdHomeFolder'.concat(sFolder)).innerHTML=req.statusText;
			iBoxCount++;
			iTSTimer=0;
			}
		}
	)
}

function getposterhomefolder(sId,sName,sPath,arItem){
	var sHTML = '';
	var iCount=0, i=0;
	sHTML = sHTML.concat('<Table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%">');
	sHTML = sHTML.concat('<tr>');
	if (arItem.length>0){
		sHTML = sHTML.concat('	<td bgcolor="#9e1617" valign="top">');
		sHTML = sHTML.concat('		<Table border=0 cellspacing=0 cellpadding=5 width="100%">');
		sHTML = sHTML.concat('			<tr>');
		sHTML = sHTML.concat('				<td>');
		sHTML = sHTML.concat('					<Table border=0 cellspacing=3 cellpadding=0 bgcolor="#FFFFFF">');
		sHTML = sHTML.concat('						<tr>');
		sHTML = sHTML.concat('							<td><a href="').concat(arItem[i][1]).concat('"><img border=0 height="120" width="170" src="').concat(arItem[i][1]).concat(arItem[i][5]).concat('"></a></td>');
		sHTML = sHTML.concat('						</tr>');
		sHTML = sHTML.concat('					</Table>');
		sHTML = sHTML.concat('				</td>');
		sHTML = sHTML.concat('			</tr>');
		sHTML = sHTML.concat('			<tr>');
		sHTML = sHTML.concat('				<td>');
		sHTML = sHTML.concat('					<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
		sHTML = sHTML.concat('						<tr>');
		sHTML = sHTML.concat('							<td rowspan=2 valign="top" style="padding-right:5px;"><img src="/Images/Poster/Photo.gif"></td>');
		sHTML = sHTML.concat('							<td><a class="HomeNormal White" href="').concat(arItem[i][1]).concat('"><b>').concat(arItem[i][2]).concat('</b></a></td>');
		sHTML = sHTML.concat('						</tr>');
		sHTML = sHTML.concat('						<tr>');
		sHTML = sHTML.concat('							<td class="Small White">').concat(arItem[i][3]).concat('</td>');
		sHTML = sHTML.concat('						</tr>');
		sHTML = sHTML.concat('					</Table>');
		sHTML = sHTML.concat('				</td>');
		sHTML = sHTML.concat('			</tr>');
		sHTML = sHTML.concat('		</Table>');
		sHTML = sHTML.concat('	</td>');
	}
	i=1;
	if (arItem.length>1){
		sHTML = sHTML.concat('	<td width="1" bgcolor="#b13e3f"></td>');
		sHTML = sHTML.concat('	<td bgcolor="#861213" align="center" valign="top" style="padding-left:6px;padding-right:7px;padding-top:5px;">');
		sHTML = sHTML.concat('		<Table border=0 cellspacing=0 cellpadding=0 width="90%">');
		while (i<arItem.length){
			sHTML = sHTML.concat('			<tr>');
			sHTML = sHTML.concat('				<td>');
			sHTML = sHTML.concat('					<Table border=0 cellspacing=3 cellpadding=0 bgcolor="#FFFFFF">');
			sHTML = sHTML.concat('						<tr>');
			sHTML = sHTML.concat('							<td><a href="').concat(arItem[i][1]).concat('"><img border=0 height="67" width="95" src="').concat(arItem[i][1]).concat(arItem[i][5]).concat('"></a></td>');
			sHTML = sHTML.concat('						</tr>');
			sHTML = sHTML.concat('					</Table>');
			sHTML = sHTML.concat('				</td>');
			sHTML = sHTML.concat('			</tr>');
			sHTML = sHTML.concat('			<tr>');
			sHTML = sHTML.concat('				<td style="padding-top:3px;padding-bottom:3px;"><a class="Smaller Pink" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></td>');
			sHTML = sHTML.concat('			</tr>');
			i++;
		}
		sHTML = sHTML.concat('		</Table>');
		sHTML = sHTML.concat('	</td>');
	}
	sHTML = sHTML.concat('</tr>');
	sHTML = sHTML.concat('</Table>');
	return sHTML;
}

function gethotnewshomefolder(sId,sName,sPath,arItem){
	var sHTML = '';
	var iCount=0, i=0;
	sHTML = sHTML.concat('<Table border=0 cellspacing=3 cellpadding=0 width="98%" align="center">');
	while (i<arItem.length){
		if (i==0) {
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td colspan="3" width="100%">');
			sHTML = sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
			sHTML = sHTML.concat('				<tr>');
			if (arItem[i][6]!=''){
				sHTML = sHTML.concat('		<td style="padding-right:4px;" width="10" valign="top">');
				sHTML = sHTML.concat('			<Table border=0 cellspacing=1 cellpadding=2 bgcolor="#c1c1c1">');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td bgcolor="#FFFFFF"><a href="').concat(arItem[i][1]).concat('"><img border=0 width=95 height=80 src="').concat(arItem[i][1]).concat(arItem[i][6]).concat('"></a></td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('			</Table>');
				sHTML = sHTML.concat('		</td>');
			}
			sHTML = sHTML.concat('		<td valign="top" width="100%">');
			sHTML = sHTML.concat('			<Table border=0 cellspacing=2 cellpadding=0 width="100%">');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td style="padding-top:2px;padding-bottom:2px;"><a class="HomeHotNews Bold Red" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></td>');
			sHTML = sHTML.concat('				</tr>');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td class="HomeNormal Black">').concat(arItem[i][3]).concat('</td>');
			sHTML = sHTML.concat('				</tr>');
			if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
				sHTML = sHTML.concat('<tr>');
				sHTML = sHTML.concat('	<td>');
				sHTML = sHTML.concat('		<Table border=0 cellspacing=1 cellpadding=0 align="right">');
				sHTML = sHTML.concat('			<tr>');
				if (arItem[i][7]>0){
					sHTML = sHTML.concat('				<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
				}
				if (arItem[i][8]>0){
					sHTML = sHTML.concat('				<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
				}
				if (arItem[i][9]>0){
					sHTML = sHTML.concat('				<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
				}
				sHTML = sHTML.concat('			</tr>');
				sHTML = sHTML.concat('		</Table>');
				sHTML = sHTML.concat('	</td>');
				sHTML = sHTML.concat('</tr>');
			}
			sHTML = sHTML.concat('			</Table>');
			sHTML = sHTML.concat('		</td>');
			sHTML = sHTML.concat('	</tr>');
			sHTML = sHTML.concat('	</Table>');
		}
		else {
			sHTML = sHTML.concat('	<tr><td colspan="3" height="1" background="/Images/HotNews/HotlineSep.gif"></td></tr>');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td width="1" style="padding-right:3px;"><img src="/Images/HotNews/Dot.gif"></td>');
			sHTML = sHTML.concat('		<td width="100%"><a class="Small Black" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></td>');
			if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
				sHTML = sHTML.concat('	<td>');
				sHTML = sHTML.concat('		<Table border=0 cellspacing=1 cellpadding=0 align="right">');
				sHTML = sHTML.concat('			<tr>');
				if (arItem[i][7]>0){
					sHTML = sHTML.concat('				<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
				}
				if (arItem[i][8]>0){
					sHTML = sHTML.concat('				<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
				}
				if (arItem[i][9]>0){
					sHTML = sHTML.concat('				<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
				}
				sHTML = sHTML.concat('			</tr>');
				sHTML = sHTML.concat('		</Table>');
				sHTML = sHTML.concat('	</td>');
			}
			else{
				sHTML = sHTML.concat('<td></td>');
			}
			sHTML = sHTML.concat('	</tr>');
		}
		i++;
	}
	sHTML = sHTML.concat('</Table>');
	return sHTML;
}

function getforumhomefolder(sId,sName,sPath,arItem,arSub){
	var sHTML = '';
	var iCount=0, i=0, j=0;
	while (i<arItem.length){
		if (i==0){
			sHTML = sHTML.concat('<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
		}
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td align=center>');
		sHTML = sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0 width="95%">');
		sHTML = sHTML.concat('				<tr>');
		sHTML = sHTML.concat('					<td rowspan="3" valign="top" style="padding-top:4;padding-left:3;padding-right:6;"><img src="/Images/Forum/Dot.gif"></td>');
		sHTML = sHTML.concat('					<td><a class="HomeNormal Bold Grey2" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></td>');
		sHTML = sHTML.concat('				</tr>');
		sHTML = sHTML.concat('				<tr>');
		sHTML = sHTML.concat('					<td class="HomeNormal Black" style="padding-top:3;padding-bottom:3;">').concat(arItem[i][3]).concat('</td>');
		sHTML = sHTML.concat('				</tr>');
		sHTML = sHTML.concat('				<tr>');
		sHTML = sHTML.concat('					<td>');
		sHTML = sHTML.concat('						<Table border=0 cellspacing=2 cellpadding=0 width="100%">');
		for (j=0;j<4;j++){
			if (!(typeof(arSub[i][j])=='undefined')){
				sHTML = sHTML.concat('							<tr>');
				sHTML = sHTML.concat('								<td valign="top" style="padding-top:3;padding-right:3;"><img src="/Images/Forum/Doc.gif"></td>');
				sHTML = sHTML.concat('								<td><a class="HomeNormal Black" href="').concat(arSub[i][j][1]).concat('">').concat(arSub[i][j][2]).concat('</a></td>');
				sHTML = sHTML.concat('							</tr>');
			}
		}
		sHTML = sHTML.concat('						</Table>');
		sHTML = sHTML.concat('					</td>');
		sHTML = sHTML.concat('				</tr>');
		sHTML = sHTML.concat('			</Table>');
		
		sHTML = sHTML.concat('		</td>');
		sHTML = sHTML.concat('	</tr>');
		
		if (i<arItem.length-1){
			sHTML = sHTML.concat('	<tr><td height=5></td></tr>');
			sHTML = sHTML.concat('	<tr><td height=1 bgcolor="white"></td></tr>');
		}
		sHTML = sHTML.concat('	<tr><td height=5></td></tr>');
		i++;
	}
	sHTML = sHTML.concat('</Table>');
	return sHTML;
}

function getentertainmenthomefolder(sId,sName,sPath,arItem){
	var sHTML = '';
	var iCount=0, i=0;
	while (i<arItem.length){
		if (i==0){
			sHTML = sHTML.concat('<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
			sHTML = sHTML.concat('	<tr>');
			if (arItem[i][6]!='' && sId==16){
				sHTML = sHTML.concat('		<td style="padding-left:5px;padding-top:5;" width="10" valign="top">');
				sHTML = sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0>');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td>');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=2 bgcolor="#c1c1c1">');
				sHTML = sHTML.concat('							<tr>');
				sHTML = sHTML.concat('								<td bgcolor="#FFFFFF"><a href="').concat(arItem[i][1]).concat('"><img border=0 width=95 height=80 src="').concat(arItem[i][1]).concat(arItem[i][6]).concat('"></a></td>');
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('					<td background="/Images/LeftBox/ShadowRight.gif" valign="top"><img src="/Images/LeftBox/ShadowTopRight.gif"></td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td colspan=2>');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=0 cellpadding=0>');
				sHTML = sHTML.concat('							<tr>');
				sHTML = sHTML.concat('								<td width=1><img src="/Images/LeftBox/ShadowBottomLeft.gif"></td>');
				sHTML = sHTML.concat('								<td width="100%" background="/Images/LeftBox/ShadowBottom.gif"></td>');
				sHTML = sHTML.concat('								<td width=1><img src="/Images/LeftBox/ShadowBottomRight.gif"></td>');
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('			</Table>');
				sHTML = sHTML.concat('		</td>');
			}
			if (arItem[i][6]!=''){
				sHTML = sHTML.concat('		<td valign="top" style="padding-left:5px;padding-top:10px;">');
			}
			else{
				sHTML = sHTML.concat('		<td style="padding-left:5px;padding-top:5px;padding-bottom:5px;">');
			}
			sHTML = sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td style="padding-bottom:3px;"><a class="HomeFolder Green2" href="').concat(sPath).concat('">').concat(sName).concat('</a></td>');
			sHTML = sHTML.concat('				</tr>');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td height="1" background="/Images/LeftBox/DotSepWhite.gif"></td>');
			sHTML = sHTML.concat('				</tr>');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td style="padding-top:3px;padding-bottom:3px;"><a class="HomeNormal Bold White" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></td>');
			sHTML = sHTML.concat('				</tr>');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td class="Small White">').concat(arItem[i][3]).concat('</td>');
			sHTML = sHTML.concat('				</tr>');
			if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td valign="top" style="padding-right:2;">');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=0 align="right">');
				sHTML = sHTML.concat('							<tr>');
				if (arItem[i][7]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
				}
				if (arItem[i][8]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
				}
				if (arItem[i][9]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
				}
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('				</tr>');
			}
			sHTML = sHTML.concat('			</Table>');
			sHTML = sHTML.concat('		</td>');
			if (arItem[i][6]!='' && sId!=16){
				sHTML = sHTML.concat('		<td style="padding-right:5px;padding-top:5;" width="10" valign="top">');
				sHTML = sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0>');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td>');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=2 bgcolor="#c1c1c1">');
				sHTML = sHTML.concat('							<tr>');
				sHTML = sHTML.concat('								<td bgcolor="#FFFFFF"><a href="').concat(arItem[i][1]).concat('"><img border=0 width=95 height=80 src="').concat(arItem[i][1]).concat(arItem[i][6]).concat('"></a></td>');
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('					<td background="/Images/LeftBox/ShadowRight.gif" valign="top"><img src="/Images/LeftBox/ShadowTopRight.gif"></td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td colspan=2>');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=0 cellpadding=0>');
				sHTML = sHTML.concat('							<tr>');
				sHTML = sHTML.concat('								<td width=1><img src="/Images/LeftBox/ShadowBottomLeft.gif"></td>');
				sHTML = sHTML.concat('								<td width="100%" background="/Images/LeftBox/ShadowBottom.gif"></td>');
				sHTML = sHTML.concat('								<td width=1><img src="/Images/LeftBox/ShadowBottomRight.gif"></td>');
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('			</Table>');
				sHTML = sHTML.concat('		</td>');
			}
			sHTML = sHTML.concat('	</tr>');
			sHTML = sHTML.concat('</Table>');
		}
		i++;
	}
	return sHTML;
}

function getnormalhomefolder(sId,sName,sPath,arItem){
	var sHTML = '';
	var iCount=0, i=0;
	while (i<arItem.length){
		if (i==0){
			sHTML = sHTML.concat('<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
			sHTML = sHTML.concat('	<tr style="background-image:url(/Images/NewsBox/Background.jpg);background-position: right 11px; background-repeat: repeat-x;">');
			if (arItem[i][6]!=''){
				sHTML = sHTML.concat('		<td valign="top" style="padding-top:4px;">');
				sHTML = sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0>');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td>');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=2 bgcolor="#c1c1c1">');
				sHTML = sHTML.concat('							<tr>');
				sHTML = sHTML.concat('								<td bgcolor="#FFFFFF"><a href="').concat(arItem[i][1]).concat('"><img border=0 width=95 height=80 src="').concat(arItem[i][1]).concat(arItem[i][6]).concat('"></a></td>');
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('					<td background="/Images/NewsBox/ShadowRight.gif" valign="top"><img src="/Images/NewsBox/ShadowTopRight.gif"></td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td colspan=2>');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=0 cellpadding=0>');
				sHTML = sHTML.concat('							<tr>');
				sHTML = sHTML.concat('								<td width=1><img src="/Images/NewsBox/ShadowBottomLeft.gif"></td>');
				sHTML = sHTML.concat('								<td width="100%" background="/Images/NewsBox/ShadowBottom.gif"></td>');
				sHTML = sHTML.concat('								<td width=1><img src="/Images/NewsBox/ShadowBottomRight.gif"></td>');
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td colspan=2><img src="/Images/White.gif" height="3" width="9"></td>');
				sHTML = sHTML.concat('				</tr>');
				sHTML = sHTML.concat('			</Table>');
				sHTML = sHTML.concat('		</td>');
			}
			if (arItem[i][6]!=''){
				sHTML = sHTML.concat('		<td valign="top" height="105px" width="100%">');
			}
			else{
				sHTML = sHTML.concat('		<td valign="top" height="105px" width="100%" style="padding-left:3px;">');
			}
			sHTML = sHTML.concat('			<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td valign="top" height="88px">');
			sHTML = sHTML.concat('						<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
			// sHTML = sHTML.concat('							<tr>');
			// sHTML = sHTML.concat('								<td>');
			// sHTML = sHTML.concat('									<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
			// sHTML = sHTML.concat('										<tr>');
			// sHTML = sHTML.concat('											<td width="100%" style="background-image:url(/Images/NewsBox/HeaderDot.gif);background-position: 2px 9px; background-repeat: repeat-x;"></td>');
			// sHTML = sHTML.concat('											<td style="padding-left:1px;" nowrap><a class="HomeFolder DarkBlue" href="').concat(sPath).concat('">').concat(sName).concat('</a></td>');
			// sHTML = sHTML.concat('										</tr>');
			// sHTML = sHTML.concat('									</Table>');
			// sHTML = sHTML.concat('								</td>');
			// sHTML = sHTML.concat('							</tr>');
			sHTML = sHTML.concat('							<tr>');
			sHTML = sHTML.concat('								<td nowrap align="right"><a class="HomeFolder DarkBlue" href="').concat(sPath).concat('">').concat(sName).concat('</a></td>');
			sHTML = sHTML.concat('							</tr>');
			sHTML = sHTML.concat('							<tr>');
			sHTML = sHTML.concat('								<td style="padding:3;"><a class="HomeNormal Bold DarkGrey" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></td>');
			sHTML = sHTML.concat('							</tr>');
			sHTML = sHTML.concat('							<tr>');
			sHTML = sHTML.concat('								<td style="padding-left:3;padding-right:3;" class="Small Black">').concat(arItem[i][3]).concat('</td>');
			sHTML = sHTML.concat('							</tr>');
			sHTML = sHTML.concat('						</Table>');
			sHTML = sHTML.concat('					</td>');
			sHTML = sHTML.concat('				</tr>');
			if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td valign="top" style="padding-right:2;">');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=0 align="right">');
				sHTML = sHTML.concat('							<tr>');
				if (arItem[i][7]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
				}
				if (arItem[i][8]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
				}
				if (arItem[i][9]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
				}
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('				</tr>');
			}
			sHTML = sHTML.concat('			</Table>');
			sHTML = sHTML.concat('		</td>');
			sHTML = sHTML.concat('	</tr>');
			sHTML = sHTML.concat('</Table>');
		}
		else{
			sHTML = sHTML.concat('<Table border=0 cellspacing=2 cellpadding=0 width="100%">');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td width=10><img src="/Images/Footer/Bullet.gif"></td>');
			sHTML = sHTML.concat('		<td width="100%" style="padding-left:3;"><a class="HomeNormal Grey" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</td>');
			if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
				sHTML = sHTML.concat('		<td width=10>');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=0 align="right">');
				sHTML = sHTML.concat('							<tr>');
				if (arItem[i][7]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
				}
				if (arItem[i][8]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
				}
				if (arItem[i][9]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
				}
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('		</td>');
			}
			sHTML = sHTML.concat('	</tr>');
			sHTML = sHTML.concat('</Table>');
		}
		i++;
	}
	return sHTML;
}

function displaylistcategory(face, loc){
	var sHTML='';
	var arSplit = ''.concat(loc).split(',');
	for (var i=0; i<arSplit.length;i++){
		if (parseInt(arSplit[i])>0){
			iDisplayCateNo++;
			sHTML = '';
			sHTML = sHTML.concat('<Table border=0 cellpadding=0 cellspacing=0 width="100%">');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td style="padding-top:5px;" id="tdCate').concat(iDisplayCateNo).concat('">');
			sHTML = sHTML.concat('		</td>');
			sHTML = sHTML.concat('	</tr>');
			sHTML = sHTML.concat('</Table>');
			document.write(sHTML);
			displaycategory(face,parseInt(arSplit[i]),'tdCate'.concat(iDisplayCateNo));
		}
	}
}

function displaycategory(face,id,objreturn){
	var sId, sName, sPath;
	var arItem = new Array();
	var sLink = '/ListFile/'.concat(id).concat('.xml');
	var sHTML;
	var iMaxItem=0;
	switch (face){
		case 2: iMaxItem=2; break;
		default: iMaxItem=1; break;
	}
	AjaxRequest.get(
		{
	    'url':sLink
	    ,'onSuccess':function(req){
	    	if (req.responseXML.getElementsByTagName('Folder').length>0){
	    		with(req.responseXML.getElementsByTagName('Folder').item(0)){
					sId = getNodeValue(getElementsByTagName('fID'));
					sName = toUpper(getNodeValue(getElementsByTagName('fName')));
					sPath = getNodeValue(getElementsByTagName('fPath'));					
	    		}
	    	}
	    	var iCount=0;
	    	for (var i=0;i<req.responseXML.getElementsByTagName('Item').length;i++){
	    		with(req.responseXML.getElementsByTagName('Item').item(i)){
	    			if (iCount<iMaxItem){
		    			var sTemp = getNodeValue(getElementsByTagName('sID'));
		    			if (sTemp!='' && displayid(sTemp)){
			    			arItem[iCount] = new Array(10);
							arItem[iCount][0] = getNodeValue(getElementsByTagName('sID'));
							arItem[iCount][1] = getNodeValue(getElementsByTagName('sPath'));
							arItem[iCount][2] = getNodeValue(getElementsByTagName('sTitle'));
							arItem[iCount][3] = getNodeValue(getElementsByTagName('sLead'));
							arItem[iCount][4] = getNodeValue(getElementsByTagName('sImageTopStory'));
							arItem[iCount][5] = getNodeValue(getElementsByTagName('sImageHome'));
							arItem[iCount][6] = getNodeValue(getElementsByTagName('sImageFolder'));
							arItem[iCount][7] = parseInt(getNodeValue(getElementsByTagName('sHasVideo')));
							arItem[iCount][8] = getNodeValue(getElementsByTagName('sHasPhoto'));
							arItem[iCount][9] = getNodeValue(getElementsByTagName('sHasStory'));
							iCount++;
						}
					}
	    		}
	    	}
			
			//////////////////////////////////////////////////////
			if(RelatedFolder==28) 
			{
			
				//return;
			}
			//alert(sPath);
			//////////////////////////////////////////////////////
			
	    	switch (face){
	    		case 1: gmobj(objreturn).innerHTML = getlefttopboxcategory(sId,sName,sPath,arItem);break;
	    		case 2: gmobj(objreturn).innerHTML = getleftbottomboxcategory(sId,sName,sPath,arItem);break;
	    		case 3: gmobj(objreturn).innerHTML = getcentercategory(sId,sName,sPath,arItem);break;
	    	}
	    }
	    ,'onError':function(req){gmobj('tdHomeFolder'.concat(sFolder)).innerHTML=req.statusText;}
		}
	)
}

function getlefttopboxcategory(sId,sName,sPath,arItem){
	var sHTML = '';
	var iCount=0, i=0;
	while (i<arItem.length){
		sHTML = sHTML.concat('<Table border=0 cellpadding=0 cellspacing=0 width="100%" style="background: url(/images/sd/SD01.png) no-repeat; background-position:0 11">');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td>');
		sHTML = sHTML.concat('			<Table border=0 cellpadding=0 cellspacing=0 width="100%">');
		sHTML = sHTML.concat('				<tr>');
		sHTML = sHTML.concat('					<td nowrap><a class="HomeFolder DarkBlue" href="').concat(sPath).concat('">').concat(sName).concat('</a></td>');
		sHTML = sHTML.concat('					<td style="background-image: url(/Images/NewsBox/HeaderDot.gif); background-position: 2px 9px; background-repeat: repeat-x;" width="100%"></td>');
		sHTML = sHTML.concat('				</tr>');
		sHTML = sHTML.concat('			</Table>');
		sHTML = sHTML.concat('		</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td>');
		sHTML = sHTML.concat('			<Table border=0 cellpadding=0 cellspacing=0 width="100%">');
		sHTML = sHTML.concat('				<tr>');
		sHTML = sHTML.concat('					<td style="padding-top:4;padding-bottom:2;">');
		if(IsStarTeenFolder()) 
		{
			sHTML = sHTML.concat( ShowPhoto(arItem[i][1], arItem[i][5], 170, 120, 1, '#606060',0,'',0).replace(/align=left/, "align=center") );
			sHTML = sHTML.concat('					</td>');
			sHTML = sHTML.concat('				</tr>	');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td style="padding:0 4 2 4;" bgcolor="#e0e0e0">');
			sHTML = sHTML.concat('				<a class="HomeNormal Bold Black" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a>');
		}
		else
		{
			sHTML = sHTML.concat('						<a class="HomeNormal Bold Black" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a>');
		}
		sHTML = sHTML.concat('					</td>');
		sHTML = sHTML.concat('				</tr>	');
		sHTML = sHTML.concat('				<tr>');
		sHTML = sHTML.concat('					<td>');
		sHTML = sHTML.concat('						<Table border=0 cellpadding=0 cellspacing=0 width="100%">');
		sHTML = sHTML.concat('							<tr>');
		if (arItem[i][6]!=''&&(!IsStarTeenFolder)){
			sHTML = sHTML.concat('								<td valign="top" style="padding-right:3;">');
			sHTML = sHTML.concat('									<Table border=0 cellspacing=2 cellpadding=0 bgcolor="#FFFFFF">');
			sHTML = sHTML.concat('										<tr><td><a href="').concat(arItem[i][1]).concat('"><img border=0 width=65 height=55 src="').concat(arItem[i][1]).concat(arItem[i][6]).concat('"></a></td></tr>');
			sHTML = sHTML.concat('									</Table>');
			sHTML = sHTML.concat('								</td>');
		}
		sHTML = sHTML.concat('								<td valign="top">');
		sHTML = sHTML.concat('									<Table border=0 cellspacing=0 cellpadding=0 width="100%">');
		sHTML = sHTML.concat('										<tr><td class="HomeNormal Black" '+(IsStarTeenFolder()?' style="padding:0 4 0 4" bgcolor="#e0e0e0" ':'')+'>').concat(arItem[i][3]).concat('</td></tr>');
		if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td valign="top" style="padding-right:2;">');
			sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=0 align="right">');
			sHTML = sHTML.concat('							<tr>');
			if (arItem[i][7]>0){
				sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
			}
			if (arItem[i][8]>0){
				sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
			}
			if (arItem[i][9]>0){
				sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
			}
			sHTML = sHTML.concat('							</tr>');
			sHTML = sHTML.concat('						</Table>');
			sHTML = sHTML.concat('					</td>');
			sHTML = sHTML.concat('				</tr>');
		}
		sHTML = sHTML.concat('									</table>');
		sHTML = sHTML.concat('								</td>');
		sHTML = sHTML.concat('							</tr>');
		sHTML = sHTML.concat('						</Table>');
		sHTML = sHTML.concat('					</td>');
		sHTML = sHTML.concat('				</tr>	');
		sHTML = sHTML.concat('			</Table>');
		sHTML = sHTML.concat('		</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('</Table>');
		i++;
	}
	return sHTML;
}

function getleftbottomboxcategory(sId,sName,sPath,arItem){
	var sHTML = '';
	var iCount=0, i=0;
	while (i<arItem.length){
		if (i==0){
			sHTML = sHTML.concat('<Table border=0 cellpadding=0 cellspacing=0 width="100%" style="background: url(/images/sd/SD05.gif) no-repeat; background-position:0 12">');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td>');
			sHTML = sHTML.concat('			<Table border=0 cellpadding=0 cellspacing=0 width="100%">');
			sHTML = sHTML.concat('				<tr>');
			sHTML = sHTML.concat('					<td nowrap><a class="HomeFolder LightGreen" href="').concat(sPath).concat('">').concat(sName).concat('</a></td>');
			sHTML = sHTML.concat('					<td style="background-image: url(/Images/LeftBox/DotSepWhite.gif); background-position: 2px 9px; background-repeat: repeat-x;" width="100%"></td>');
			sHTML = sHTML.concat('				</tr>');
			sHTML = sHTML.concat('			</Table>');
			sHTML = sHTML.concat('		</td>');
			sHTML = sHTML.concat('	</tr>');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td>');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td style="padding-top:4;">');
			if(IsStarTeenFolder()) 
			{
				sHTML = sHTML.concat( ShowPhoto(arItem[i][1], arItem[i][5], 170, 120, 1, '#606060',0,'',0).replace(/align=left/, "align=center") );
				sHTML = sHTML.concat('					</td>');
				sHTML = sHTML.concat('				</tr>	');
				sHTML = sHTML.concat('				<tr>');
				sHTML = sHTML.concat('					<td style="padding:0 4 2 4;">');
				sHTML = sHTML.concat('		<p class="NoMargin"><a class="HomeNormal Bold White" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></p>');
				i=arItem.length-1
			}
			else
			{
				if (arItem[i][6]!=''){
					sHTML = sHTML.concat('		').concat(ShowPhoto(arItem[i][1],arItem[i][6].concat('.thumb65x55.ns.jpg'), 65, 55, 1, "#d7d7d8", 1, "#ffffff",'padding-top:3px;padding-right:4px;'));
				}		
				sHTML = sHTML.concat('		<p class="NoMargin" style="padding-top:3px;"><a class="HomeNormal Bold White" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></p>');
			}
		
			//sHTML = sHTML.concat('		<p class="NoMargin"><a class="HomeNormal Bold White" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></p>');
			sHTML = sHTML.concat('		<p class="NoMargin Small White" style="padding-top:3px;">').concat(arItem[i][3]).concat('</p>');
			if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
				sHTML = sHTML.concat('				<p class="NoMargin" align="right">');
				sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=0 align="right">');
				sHTML = sHTML.concat('							<tr>');
				if (arItem[i][7]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
				}
				if (arItem[i][8]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
				}
				if (arItem[i][9]>0){
					sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
				}
				sHTML = sHTML.concat('							</tr>');
				sHTML = sHTML.concat('						</Table>');
				sHTML = sHTML.concat('				</p>');
			}
			sHTML = sHTML.concat('		</td>');
			sHTML = sHTML.concat('	</tr>');
			sHTML = sHTML.concat('</Table>');
		}
		else{
			sHTML = sHTML.concat('<Table border=0 cellpadding=0 cellspacing=0 width="100%">');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('		<td width="100%" valign="top" class="HomeNormal LightBlue" style="padding-top:2px;"><font size="2">&#9642;</font>&nbsp;<a class="HomeNormal LBlue2 Bold" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></td>');
			sHTML = sHTML.concat('	<tr>');
			sHTML = sHTML.concat('</Table>');
		}
		i++;
	}
	return sHTML;
}

function getcentercategory(sId,sName,sPath,arItem){
	var sHTML = '';
	var iCount=0, i=0;
	while (i<arItem.length){
		sHTML = sHTML.concat('<Table border=0 cellpadding=0 cellspacing=0 width="100%" style="background: url(/images/sd/SD04.gif) no-repeat; background-position:0 11">');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td>');
		sHTML = sHTML.concat('			<Table border=0 cellpadding=0 cellspacing=0 width="100%">');
		sHTML = sHTML.concat('				<tr>');
		sHTML = sHTML.concat('					<td nowrap><a class="HomeFolder DBlue4" href="').concat(sPath).concat('">').concat(sName).concat('</a></td>');
		sHTML = sHTML.concat('					<td style="background-image: url(/Images/NewsBox/HeaderDot.gif); background-position: 2px 9px; background-repeat: repeat-x;" width="100%"></td>');
		sHTML = sHTML.concat('				</tr>');
		sHTML = sHTML.concat('			</Table>');
		sHTML = sHTML.concat('		</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td style="padding-top:4;">');
		if (arItem[i][6]!=''){
			sHTML = sHTML.concat('		').concat(ShowPhoto(arItem[i][1],arItem[i][6], 65, 55, 1, "#d7d7d8", 1, "#ffffff",'padding-top:3px;padding-right:4px;'));
		}
		sHTML = sHTML.concat('		<p class="NoMargin" style="margin-top:2px"><a class="HomeNormal Bold Black" href="').concat(arItem[i][1]).concat('">').concat(arItem[i][2]).concat('</a></p>');
		sHTML = sHTML.concat('		<p class="NoMargin Small" style="margin-top:4px">').concat(arItem[i][3]).concat('</p>');
		if ((arItem[i][7]+arItem[i][8]+arItem[i][9])>0){
			sHTML = sHTML.concat('				<p class="NoMargin" align="right">');
			sHTML = sHTML.concat('						<Table border=0 cellspacing=1 cellpadding=0 align="right">');
			sHTML = sHTML.concat('							<tr>');
			if (arItem[i][7]>0){
				sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Video.gif"></td>');
			}
			if (arItem[i][8]>0){
				sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Photo.gif"></td>');
			}
			if (arItem[i][9]>0){
				sHTML = sHTML.concat('								<td style="padding-left:2;padding-right:2;"><img src="/Images/Story.gif"></td>');
			}
			sHTML = sHTML.concat('							</tr>');
			sHTML = sHTML.concat('						</Table>');
			sHTML = sHTML.concat('				</p>');
		}
		if (sId==26 || sId==27 || sId==38){
			sHTML = sHTML.concat('				<p class="NoMargin">');
			sHTML = sHTML.concat('					<Table border=0 cellspacing=1 cellpadding=0>');
			sHTML = sHTML.concat('						<tr>');
			sHTML = sHTML.concat('							<td style="padding-right:2;"><a href="http://srv.ngoisao.net/user/Contribution/?f=').concat(sId).concat('" hidefocus><img src="/images/pen2.gif" border=0></a></td>');
			sHTML = sHTML.concat('							<td><a href="http://srv.ngoisao.net/user/Contribution/?f=').concat(sId).concat('" class="Contribution" hidefocus>');
			if (sId==26) sHTML=sHTML.concat('B&#7841;n c&#243; th&#7875; t&#226;m s&#7921; t&#7841;i &#273;&#226;y');
			if (sId==27) sHTML=sHTML.concat('Vi&#7871;t cho ng&#432;&#7901;i y&#234;u d&#7845;u');
			if (sId==38) sHTML=sHTML.concat('&#272;&#7863;t c&#226;u h&#7887;i t&#7841;i &#273;&#226;y');
			sHTML = sHTML.concat('</a></td>');
			sHTML = sHTML.concat('						</tr>');
			sHTML = sHTML.concat('					</Table>');
			sHTML = sHTML.concat('				</p>');
		}
		sHTML = sHTML.concat('		</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('</Table>');
		i++;
	}
	return sHTML;
}


function ShowPhoto(vPath, vFile, vWidth, vHeight, vOutBorderWidth, vOutBorderColor, vInBorderWidth, vInBorderColor, vPaddingRight){
	if (typeof(vInBorderWidth)=='undefined'){
		return '<table align=left cellspacing=0 cellpadding='+vOutBorderWidth+' bgcolor="'+vOutBorderColor+'" width="'+vWidth+vOutBorderWidth+'"><tr><td class="LoadBox">'+GetPhoto(vPath, vFile, vWidth, vHeight)+'</td></tr></table>';
	}
	else if (typeof(vPaddingRight)=='undefined'){
		return '<table align=left cellspacing="'+vOutBorderWidth+'" cellpadding="'+vInBorderWidth+'" border="0" bgcolor="'+vOutBorderColor+'"><tr><td bgcolor="'+vInBorderColor+'">'+GetPhoto(vPath, vFile, vWidth, vHeight)+'</td></tr></table>';
	}
	else{
		return '<table align=left cellspacing="0" cellpadding="0" border="0"><tr><td style="'+vPaddingRight+'"><table align=left cellspacing="'+vOutBorderWidth+'" cellpadding="'+vInBorderWidth+'" border="0" bgcolor="'+vOutBorderColor+'"><tr><td bgcolor="'+vInBorderColor+'">'+GetPhoto(vPath, vFile, vWidth, vHeight)+'</td></tr></table></td></tr></table>';
	}
}

function GetPhoto(vPath, vFile, vWidth, vHeight){
	return '<a href="'+vPath+'" hidefocus><img src="'+vPath+vFile+'" border=0 width="'+vWidth+'" height="'+vHeight+'"></a>';
}

function AddBreak (vHeight)
{
	return '<table border=0 cellpadding=0 cellspacing=0><tr><td height='+vHeight+'></td></tr></table>'
}

function DisplayFolderSub(id)
{
	displaylistcategory(3,id);
}

function IsStarTeenFolder()
{
	if(RelatedFolder==28||RelatedFolder==31||RelatedFolder==32||RelatedFolder==33||RelatedFolder==34)	return true; else return false;
}

//------------------------------- NewsPanel --------------------------------
function NewsPanelHeader()
{
	var HTML  = '';
	HTML += '<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" id="table_BT">';
	HTML += '<tr>';
	HTML += '	<td><img width="3" height="3" alt="" src="/images/BG/RB/LT.gif"/></td>';
	HTML += '	<td width="100%" height="3" background="/images/BG/RB/T.gif" alt=""/>';
	HTML += '	<td><img width="3" height="3" alt="" src="/images/BG/RB/RT.gif"/></td>';
	HTML += '</tr>';
	return HTML;
}

function NewsPanelHR()
{
	var HTML   = '';
	HTML  += '<tr>';
	HTML  += '	<td width="3" height="4" background="/images/bg/BGBRL.gif"/>';
	HTML  += '	<td height="4" background="/images/bg/RB/BGM.gif"/>';
	HTML  += '	<td width="3" height="4" background="/images/bg/BGBRR.gif"/>';
	HTML  += '</tr>';
	return HTML;
}

function NewsPanelFooter()
{
	var HTML  = '';
	HTML += '<tr>';
	HTML += '	<td><img width="3" height="3" alt="" src="/images/BG/RB/LB.gif"/></td>';
	HTML += '	<td width="100%" height="3" background="/images/BG/RB/B.gif" alt=""/>';
	HTML += '	<td><img width="3" height="3" alt="" src="/images/BG/RB/RB.gif"/></td>';
	HTML += '</tr>';
	HTML += '</table>';
	return HTML;
}

function NewsPanelItem(vPath,vTitle,vShortLead,vImage,vImageWidth,vImageHeight)
{
	var HTML  = '';
	HTML += '<tr>';
	HTML += '	<td style="border-left: 1px solid rgb(167, 168, 175); border-right: 1px solid rgb(167, 168, 175); padding: 4px 8px; background: rgb(238, 241, 245) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" colspan="3">';
	HTML += '		<table width="100%" cellspacing="0" cellpadding="0" border="0">';
	HTML += '		<tr>';
	if(vImage!='')
	{
	HTML += '			<td class="Right Top">';
	HTML += '				<table cellspacing="1" cellpadding="1" border="0" bgcolor="#d4d4d4" align="left"><tr><td bgcolor="#ffffff"><a hidefocus="" href="'+vPath+'"><img width="'+vImageWidth+'" height="'+vImageHeight+'" border="0" src="'+vPath+vImage+'.thumb'+vImageWidth+'x'+vImageHeight+'.ns.jpg"/></a></td></tr></table>';
	HTML += '			</td>';
	HTML += '			<td width="8"/>';
	}
	HTML += '			<td valign="top">';
	HTML += '				<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">';
	HTML += '				<tr><td colspan="4"><a class="HomeNormal Bold DRed" href="'+vPath+'">'+vTitle+'</a></td></tr>';
	HTML += '				<tr><td class="Small Justify" colspan="4">'+vShortLead+'</td></tr>';
	HTML += '				</table>';
	HTML += '			</td>';
	HTML += '		</tr>';
	HTML += '		</table>';
	HTML += '	</td>';
	HTML += '</tr>';	
	
	return HTML;
}

function NewsPanelHTML(id,arItem)
{
	var HTML = '';
	var i=0;

	HTML += NewsPanelHeader();
	while (i<arItem.length)
	{
		if(i>0)	HTML += NewsPanelHR();
		switch(id)
		{
		case 18:
			HTML += NewsPanelItem(arItem[i][1],arItem[i][2],arItem[i][3],arItem[i][5],95,67); break;
		default:
			HTML += NewsPanelItem(arItem[i][1],arItem[i][2],arItem[i][3],arItem[i][6],65,55); break;
		}		
		i++;
	}
	HTML += NewsPanelFooter();
	return HTML;
}

function ShowNewsPanel(id,max)
{
	var iMaxItem=max;
	var arItem = new Array();
	
	AjaxRequest.get
	(
		{
	    'url':'/ListFile/NewsPanel('+id+').xml'
	    ,'onSuccess':function(req)
		{
	    	if (req.responseXML.getElementsByTagName('Folder').length>0)
			{
	    		with(req.responseXML.getElementsByTagName('Folder').item(0))
				{
					sId = getNodeValue(getElementsByTagName('fID'));
	    		}
	    	}
	    	var iCount=0;
	    	for (var i=0;i<req.responseXML.getElementsByTagName('Item').length;i++)
			{
	    		with(req.responseXML.getElementsByTagName('Item').item(i))
				{
	    			if (iCount<iMaxItem)
					{
		    			var sTemp = getNodeValue(getElementsByTagName('sID'));
		    			if (sTemp!='' && displayid(sTemp))
						{
			    			arItem[iCount] = new Array(10);
							arItem[iCount][0] = getNodeValue(getElementsByTagName('sID'));
							arItem[iCount][1] = getNodeValue(getElementsByTagName('sPath'));
							arItem[iCount][2] = getNodeValue(getElementsByTagName('sTitle'));
							arItem[iCount][3] = getNodeValue(getElementsByTagName('sShortLead'));
							arItem[iCount][4] = getNodeValue(getElementsByTagName('sImageTopStory'));
							arItem[iCount][5] = getNodeValue(getElementsByTagName('sImageHome'));
							arItem[iCount][6] = getNodeValue(getElementsByTagName('sImageFolder'));
							arItem[iCount][7] = getNodeValue(getElementsByTagName('sHasVideo'));
							arItem[iCount][8] = getNodeValue(getElementsByTagName('sHasPhoto'));
							arItem[iCount][9] = getNodeValue(getElementsByTagName('sHasStory'));
							iCount++;
						}
					}
	    		}
	    	}
			
			gmobj('tdNewsPanel').innerHTML = (NewsPanelHTML(id,arItem));
	    	}
	    }
	    
	)
}
//------------------------------- /NewsPanel --------------------------------


























//General
//for example: instead of each module writing out script found in moduleMaxMin_OnClick have the functionality cached
//

var DNN_COL_DELIMITER = String.fromCharCode(16);
var DNN_ROW_DELIMITER = String.fromCharCode(15);
var __dnn_m_bPageLoaded = false;

window.onload = __dnn_Page_OnLoad;

function __dnn_ClientAPIEnabled()
{
	return typeof(dnn) != 'undefined';
}


function __dnn_Page_OnLoad()
{
	if (__dnn_ClientAPIEnabled())
	{
		var sLoadHandlers = dnn.getVar('__dnn_pageload');
		if (sLoadHandlers != null)
			eval(sLoadHandlers);
		
		dnn.dom.attachEvent(window, 'onscroll', __dnn_bodyscroll);
	}
	__dnn_m_bPageLoaded = true;
}

function __dnn_KeyDown(iKeyCode, sFunc, e)
{
	if (e == null)
		e = window.event;

	if (e.keyCode == iKeyCode)
	{
		eval(unescape(sFunc));
		return false;
	}
}

function __dnn_bodyscroll() 
{
	var oF=document.forms[0];	
	if (__dnn_ClientAPIEnabled() && __dnn_m_bPageLoaded)
		oF.ScrollTop.value=document.documentElement.scrollTop ? document.documentElement.scrollTop : dnn.dom.getByTagName("body")[0].scrollTop;
}

function __dnn_setScrollTop(iTop)
{
	if (__dnn_ClientAPIEnabled())
	{
		if (iTop == null)
			iTop = document.forms[0].ScrollTop.value;
	
		var sID = dnn.getVar('ScrollToControl');
		if (sID != null && sID.length > 0)
		{
			var oCtl = dnn.dom.getById(sID);
			if (oCtl != null)
			{
				iTop = dnn.dom.positioning.elementTop(oCtl);
				dnn.setVar('ScrollToControl', '');
			}
		}
		window.scrollTo(0, iTop);
	}
}

//Focus logic
function __dnn_SetInitialFocus(sID)
{
	var oCtl = dnn.dom.getById(sID);	
	if (oCtl != null && __dnn_CanReceiveFocus(oCtl))
		oCtl.focus();
}	

function __dnn_CanReceiveFocus(e)
{
	//probably should call getComputedStyle for classes that cause item to be hidden
	if (e.style.display != 'none' && e.tabIndex > -1 && e.disabled == false && e.style.visible != 'hidden')
	{
		var eParent = e.parentElement;
		while (eParent != null && eParent.tagName != 'BODY')
		{
			if (eParent.style.display == 'none' || eParent.disabled || eParent.style.visible == 'hidden')
				return false;
			eParent = eParent.parentElement;
		}
		return true;
	}
	else
		return false;
}

//Max/Min Script
function __dnn_ContainerMaxMin_OnClick(oLnk, sContentID)
{
	var oContent = dnn.dom.getById(sContentID);
	if (oContent != null)
	{
		var oBtn = oLnk.childNodes[0];
		var sContainerID = oLnk.getAttribute('containerid');
		var sCookieID = oLnk.getAttribute('cookieid');
		var sCurrentFile = oBtn.src.toLowerCase().substr(oBtn.src.lastIndexOf('/'));
		var sMaxFile;
		var sMaxIcon;
		var sMinIcon;

		if (dnn.getVar('min_icon_' + sContainerID))
			sMinIcon = dnn.getVar('min_icon_' + sContainerID);
		else
			sMinIcon = dnn.getVar('min_icon');

		if (dnn.getVar('max_icon_' + sContainerID))
			sMaxIcon = dnn.getVar('max_icon_' + sContainerID);
		else
			sMaxIcon = dnn.getVar('max_icon');

		sMaxFile = sMaxIcon.toLowerCase().substr(sMaxIcon.lastIndexOf('/'));

		var iNum = 5;
		if (oLnk.getAttribute('animf') != null)
			iNum = new Number(oLnk.getAttribute('animf'));
			
		if (sCurrentFile == sMaxFile)
		{
			oBtn.src = sMinIcon;				
			//oContent.style.display = '';
			dnn.dom.expandElement(oContent, iNum);
			oBtn.title = dnn.getVar('min_text');
			if (sCookieID != null)
			{
				if (dnn.getVar('__dnn_' + sContainerID + ':defminimized') == 'true')
					dnn.dom.setCookie(sCookieID, 'true', 365);
				else
					dnn.dom.deleteCookie(sCookieID);
			}
			else
				dnn.setVar('__dnn_' + sContainerID + '_Visible', 'true');
		}
		else
		{
			oBtn.src = sMaxIcon;				
			//oContent.style.display = 'none';
			dnn.dom.collapseElement(oContent, iNum);
			oBtn.title = dnn.getVar('max_text');
			if (sCookieID != null)
			{
				if (dnn.getVar('__dnn_' + sContainerID + ':defminimized') == 'true')
					dnn.dom.deleteCookie(sCookieID);
				else
					dnn.dom.setCookie(sCookieID, 'false', 365);				
			}
			else
				dnn.setVar('__dnn_' + sContainerID + '_Visible', 'false');			
		}
		
		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

function __dnn_Help_OnClick(sHelpID)
{
	var oHelp = dnn.dom.getById(sHelpID);
	if (oHelp != null)
	{
		if (oHelp.style.display == 'none')
			oHelp.style.display = '';
		else
			oHelp.style.display = 'none';

		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

function __dnn_SectionMaxMin(oBtn, sContentID)
{
	var oContent = dnn.dom.getById(sContentID);
	if (oContent != null)
	{
		var sMaxIcon = oBtn.getAttribute('max_icon');
		var sMinIcon = oBtn.getAttribute('min_icon');
		var bCallback = oBtn.getAttribute('userctr') != null;
		var sVal;
		if (oContent.style.display == 'none')
		{
			oBtn.src = sMinIcon;				
			oContent.style.display = '';
			if (bCallback)
			    sVal = 'True';
			else
			    dnn.setVar(oBtn.id + ':exp', 1);
		}
		else
		{
			oBtn.src = sMaxIcon;				
			oContent.style.display = 'none';
			if (bCallback)
			    sVal = 'False';
			else
                dnn.setVar(oBtn.id + ':exp', 0);
		}
		if (bCallback)
		    dnncore.setUserProp(oBtn.getAttribute('userctr'), oBtn.getAttribute('userkey'), sVal, null);
		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

//Drag N Drop
function __dnn_enableDragDrop()
{
	var aryConts = dnn.getVar('__dnn_dragDrop').split(";");	
	var aryTitles;

	for (var i=0; i < aryConts.length; i++)
	{
		aryTitles = aryConts[i].split(" ");
		if (aryTitles[0].length > 0)
		{			
			var oCtr = dnn.dom.getById(aryTitles[0]);
			var oTitle = dnn.dom.getById(aryTitles[1]);
			if (oCtr != null && oTitle != null)
			{
				oCtr.setAttribute('moduleid', aryTitles[2]);
				dnn.dom.positioning.enableDragAndDrop(oCtr, oTitle, '__dnn_dragComplete()', '__dnn_dragOver()');
			}	
		}
	}
}

var __dnn_oPrevSelPane;
var __dnn_oPrevSelModule;
var __dnn_dragEventCount=0;
function __dnn_dragOver()
{
	__dnn_dragEventCount++;
	if (__dnn_dragEventCount % 75 != 0)	//only calculate position every 75 events
		return;
	
	var oCont = dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);

	var oPane = __dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);
		
	if (__dnn_oPrevSelPane != null)	//reset previous pane's border
		__dnn_oPrevSelPane.pane.style.border = __dnn_oPrevSelPane.origBorder;

	if (oPane != null)
	{		
		__dnn_oPrevSelPane = oPane;
		oPane.pane.style.border = '4px double ' + DNN_HIGHLIGHT_COLOR;
		var iIndex = __dnn_getPaneControlIndex(oCont, oPane);

		var oPrevCtl;
		var oNextCtl;
		for (var i=0; i<oPane.controls.length; i++)
		{
			if (iIndex > i && oPane.controls[i].id != oCont.id)
				oPrevCtl = oPane.controls[i];
			if (iIndex <= i && oPane.controls[i].id != oCont.id)
			{
				oNextCtl = oPane.controls[i];
				break;
			}
		}			
		
		if (__dnn_oPrevSelModule != null)
			dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border = __dnn_oPrevSelModule.origBorder;
			

		if (oNextCtl != null)
		{
			__dnn_oPrevSelModule = oNextCtl;
			dnn.dom.getNonTextNode(oNextCtl.control).style.borderTop = '5px groove ' + DNN_HIGHLIGHT_COLOR;
		}
		else if (oPrevCtl != null)
		{
			__dnn_oPrevSelModule = oPrevCtl;
			dnn.dom.getNonTextNode(oPrevCtl.control).style.borderBottom = '5px groove ' + DNN_HIGHLIGHT_COLOR;
		}
	}
}

function __dnn_dragComplete()
{
	var oCtl = dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);
	var sModuleID = oCtl.getAttribute('moduleid');
	
	if (__dnn_oPrevSelPane != null)
		__dnn_oPrevSelPane.pane.style.border = __dnn_oPrevSelPane.origBorder;

	if (__dnn_oPrevSelModule != null)
		dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border = __dnn_oPrevSelModule.origBorder;
		
	var oPane = __dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);
	var iIndex;
	if (oPane == null)
	{
		var oPanes = __dnn_Panes();
		for (var i=0; i<oPanes.length; i++)
		{
			if (oPanes[i].id == oCtl.parentNode.id)
				oPane = oPanes[i];
		}
	}	
	if (oPane != null)
	{
		iIndex = __dnn_getPaneControlIndex(oCtl, oPane);
		__dnn_MoveToPane(oPane, oCtl, iIndex);

		dnn.callPostBack('MoveToPane', 'moduleid=' + sModuleID, 'pane=' + oPane.paneName, 'order=' + iIndex * 2); 
	}
}

function __dnn_MoveToPane(oPane, oCtl, iIndex)
{

	if (oPane != null)
	{
		var aryCtls = new Array();
		for (var i=iIndex; i<oPane.controls.length; i++)
		{
			if (oPane.controls[i].control.id != oCtl.id)
				aryCtls[aryCtls.length] = oPane.controls[i].control;

			dnn.dom.removeChild(oPane.controls[i].control);
		}
		dnn.dom.appendChild(oPane.pane, oCtl);
		oCtl.style.top=0;
		oCtl.style.left=0;
		oCtl.style.position = 'relative';
		for (var i=0; i<aryCtls.length; i++)
		{
			dnn.dom.appendChild(oPane.pane, aryCtls[i]);
		}
		__dnn_RefreshPanes();
	}
	else
	{
		oCtl.style.top=0;
		oCtl.style.left=0;
		oCtl.style.position = 'relative';
	}
}

function __dnn_RefreshPanes()
{
	var aryPanes = dnn.getVar('__dnn_Panes').split(';');
	var aryPaneNames = dnn.getVar('__dnn_PaneNames').split(';');
	__dnn_m_aryPanes = new Array();
	for (var i=0; i<aryPanes.length; i++)
	{
		if (aryPanes[i].length > 0)
			__dnn_m_aryPanes[__dnn_m_aryPanes.length] = new __dnn_Pane(dnn.dom.getById(aryPanes[i]), aryPaneNames[i]);
	}
}

var __dnn_m_aryPanes;
var __dnn_m_aryModules;
function __dnn_Panes()
{
	if (__dnn_m_aryPanes == null)
	{
		__dnn_m_aryPanes = new Array();
		__dnn_RefreshPanes();
	}
	return __dnn_m_aryPanes;
}

function __dnn_Modules(sModuleID)
{
	if (__dnn_m_aryModules == null)
		__dnn_RefreshPanes();
	
	return __dnn_m_aryModules[sModuleID];
}

function __dnn_getMostSelectedPane(oContent)
{
	var oCDims = new dnn.dom.positioning.dims(oContent);
	var iTopScore=0;
	var iScore;
	var oTopPane;
	for (var i=0; i<__dnn_Panes().length; i++)
	{
		var oPane = __dnn_Panes()[i];
		var oPDims = new dnn.dom.positioning.dims(oPane.pane);
		iScore = dnn.dom.positioning.elementOverlapScore(oPDims, oCDims);
		
		if (iScore > iTopScore)
		{
			iTopScore = iScore;
			oTopPane = oPane;
		}
	}
	return oTopPane;
}

function __dnn_getPaneControlIndex(oContent, oPane)
{
	if (oPane == null)
		return;
	var oCDims = new dnn.dom.positioning.dims(oContent);
	var oCtl;
	if (oPane.controls.length == 0)
		return 0;
	for (var i=0; i<oPane.controls.length; i++)
	{
		oCtl = oPane.controls[i];
		var oIDims = new dnn.dom.positioning.dims(oCtl.control);
		if (oCDims.t < oIDims.t)
			return oCtl.index;
	}
	if (oCtl != null)
		return oCtl.index+1;
	else
		return 0;
}

//Objects
function __dnn_Pane(ctl, sPaneName)
{
	this.pane = ctl;
	this.id = ctl.id;
	this.controls = new Array();
	this.origBorder = ctl.style.border;
	this.paneName = sPaneName;
	
	var iIndex = 0;
	var strModuleOrder='';
	for (var i=0; i<ctl.childNodes.length; i++)
	{
		var oNode = ctl.childNodes[i];
		if (dnn.dom.isNonTextNode(oNode))	
		{
			if (__dnn_m_aryModules == null)
				__dnn_m_aryModules = new Array();

			//if (oNode.tagName == 'A' && oNode.childNodes.length > 0)
			//	oNode = oNode.childNodes[0];	//DNN now embeds anchor tag 
				
			var sModuleID = oNode.getAttribute('moduleid');
			if (sModuleID != null && sModuleID.length > 0)
			{
				strModuleOrder += sModuleID + '~';
				this.controls[this.controls.length] = new __dnn_PaneControl(oNode, iIndex);
				__dnn_m_aryModules[sModuleID] = oNode.id;
				iIndex+=1;
			}
		}
	}
	this.moduleOrder = strModuleOrder;

}

function __dnn_PaneControl(ctl, iIndex)
{
	this.control = ctl;
	this.id = ctl.id;
	this.index = iIndex;
	this.origBorder = ctl.style.border;
	
}

//move towards dnncore ns.  right now only for personalization
function __dnncore()
{
    this.GetUserVal = 0;
    this.SetUserVal = 1;
}

__dnncore.prototype = {
getUserProp: function(sNameCtr, sKey, pFunc) {
    this._doUserCallBack(dnncore.GetUserVal, sNameCtr, sKey, null, new dnncore.UserPropArgs(sNameCtr, sKey, pFunc));
},

setUserProp: function(sNameCtr, sKey, sVal, pFunc) {
    this._doUserCallBack(dnncore.SetUserVal, sNameCtr, sKey, sVal, new dnncore.UserPropArgs(sNameCtr, sKey, pFunc));
},

_doUserCallBack: function(iType, sNameCtr, sKey, sVal, pFunc) {
    if (dnn && dnn.xmlhttp)
    {
        var sPack = iType + COL_DELIMITER + sNameCtr + COL_DELIMITER + sKey + COL_DELIMITER + sVal;
        dnn.xmlhttp.doCallBack('__Page',sPack,dnncore._callBackSuccess,pFunc,dnncore._callBackFail,null,true,null,0);
    }
    else
        alert('Client Personalization not enabled');
},

_callBackSuccess: function (result, ctx, req) {
    if (ctx.pFunc)
        ctx.pFunc(ctx.namingCtr, ctx.key, result);
},

_callBackFail: function (result, ctx) {
	window.status = result;
}
}

__dnncore.prototype.UserPropArgs = function(sNameCtr, sKey, pFunc)
{
    this.namingCtr = sNameCtr;
	this.key = sKey;
	this.pFunc = pFunc;
}

var dnncore = new __dnncore();
