﻿var objRelated;
var iTimeout=99;
var aFlag=true;
var queryCount = 0;
var queryArray = new Array();
var arrActor = new Array(), cntActor=0;
var arrDirector = new Array(), cntDirector=0;
var arrProduce = new Array(), cntProduce=0;
var arrScenario = new Array(), cntScenario=0;
var arrGenre = new Array(), cntGenre=0;
var lShowCount = 0;
var lShowId = new Array();

function gmobj(o){
	if(document.getElementById){
		m=document.getElementById(o);
	}
	else if(document.all){
		m=document.all[o];
	}else if(document.layers){
		m=document[o];
	}
	return m;
}
function getNodeValue(o){
	if (o.item(0)){
		if (o.item(0).firstChild){
			return o.item(0).firstChild.nodeValue;
		}
		else{
			return '';
		}
	}
	else{
		return '';
	}
}	

function gPBI(s){
	var t = parseInt(s).toString(16).toUpperCase();
	return '/XML/'.concat(t.substring(0,2)).concat('/').concat(t.substring(2,4)).concat('/').concat(t.substring(4,6)).concat('/').concat(t.substring(6,8))
}

function addListShow(q){
	lShowCount += 1;
	lShowId[lShowCount] = q;
}

function inListShow(q){
	for (var iItem=1;iItem<=lShowCount;iItem++){
		if (lShowId[iItem]==q){
			return true;
		}
	}
	return false;
}
/**/

function addQuery(q){
	queryCount += 1;
	queryArray[queryCount] = q;
}

function runQuery(){
	var qItem;
	for(qItem=1;qItem<=queryCount;qItem++){
		window.setTimeout(queryArray[qItem],qItem*10);
	}
}

function loadRelatedXMLDoc(url, callbackFunction, desc, QUERY_STRING) {
	aFlag=false;
	if(desc) window.status = desc;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        objRelated = new XMLHttpRequest();
		objRelated.onreadystatechange =	function(){
										// only if req shows "complete"
										if (objRelated.readyState == 4) {
											eval(callbackFunction);
										}
									}
		if(QUERY_STRING){
		    objRelated.open("POST", url, true);
			objRelated.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			objRelated.send(QUERY_STRING);
		}
        else{
	        objRelated.open("GET", url, true);
	        objRelated.send(null);
	    }
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        objRelated = new ActiveXObject("Microsoft.XMLHTTP");
        if (objRelated) {
        	objRelated.onreadystatechange =	function(){
											// only if req shows "complete"
											if (objRelated.readyState == 4) {
												eval(callbackFunction);
											}
										}
			if(QUERY_STRING){
			    objRelated.open("POST", url, true);
				objRelated.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				objRelated.send(QUERY_STRING);
			}
			else{
			    objRelated.open("GET", url, true);
			    objRelated.send(null);
			}
        }
    }
}

function imageShow(path,filename,border){
	var color, sHTML;
	switch (border){
		case 1: {color='#FFFFFF'; break;}
		case 2: {color='#000000'; break;}
	}
	sHTML = '<table align=left cellspacing=0 cellpadding=1 bgcolor="' + color + '"><tr><td class=""LoadBox"">';
	if (path!=''){
		sHTML += '<a href="' + path + '">';
	}
	sHTML += '<img src="' + path + filename + '" border=0 hidefocus>';
	if (path!=''){
		sHTML += '</a>';
	}
	sHTML += '</td></tr></table>';
	return sHTML;
}


//---------------------------------------------------------------------------------------

function openVote(id){
	vHeight = 100;
	vWidth = 220;
	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	//newwin = open('http://srv.phimanh.net/Vote/?Id=' + id, '_blank', winDef);
	newwin = open('/Service/Point/?Id=' + id, '_blank', winDef);
}

function viewFilm(id){
	window.location = 'http://srv.phimanh.net/ViewFilm/?Id=' + id;
}

//---------------------------------------------------------------------------------------

function getFilmVote() 
{
	var c = objRelated.responseXML.getElementsByTagName('s').length;
	var sp;
	if(c)
	{
		for(var i=0; i<c; i++)	
		{
			with(objRelated.responseXML.getElementsByTagName('s').item(i))
			{
				sp = getAttribute('sp');
			}
			document.getElementById("tdVoteStar").innerHTML = getHTMLFilmVote(sp);
		}
	}
	window.status="";
	aFlag=true;
}

function getHTMLFilmVote(iPoint)
{	
	var rPoint = Math.floor(iPoint);
	var uPoint = Math.round((iPoint - rPoint) * 100);
	//alert(rPoint + "_" + uPoint)
	var iShown = 0;
	var HTML = ''
	HTML = '<Table border=0 cellspacing=0 cellpadding=0 width="10" align=center style="padding-top:2;">';
	HTML += '<tr><td align=center>';
	for (i = 1; i < rPoint + 1; i++){HTML += '<img src=\"/Images/Vote/Star07.gif\"  border=0>'; iShown = i;}
	if (uPoint > 0 && uPoint < 21){HTML += '<img src=\"/Images/Vote/Star02.gif\"  border=0>'; iShown++;} 
	if (uPoint > 20 && uPoint < 41){HTML += '<img src=\"/Images/Vote/Star03.gif\"  border=0>'; iShown++;}
	if (uPoint > 40 && uPoint < 61){HTML += '<img src=\"/Images/Vote/Star04.gif\"  border=0>'; iShown++;}
	if (uPoint > 60 && uPoint < 81){HTML += '<img src=\"/Images/Vote/Star05.gif\"  border=0>'; iShown++;}
	if (uPoint > 80 && uPoint < 100){HTML += '<img src=\"/Images/Vote/Star06.gif\"  border=0>'; iShown++;}
	for (i = iShown; i < 5; i++){HTML += '<img src=\"/Images/Vote/Star01.gif\"  border=0>';}
	HTML += '</td></tr></Table>';
	return HTML;
}

function showFilmVote(){
	if(aFlag){
		loadRelatedXMLDoc('/User/Vote/getVote.Asp?ExLocalID=' + escape(iSID), 'getFilmVote()', 'Loading Vote Point...');
	}
	else{
		window.setTimeout('showFilmVote(' + iSID + ')',iTimeout);
	}
}


//---------------------------------------------------------------------------------------

function getDirector(url){
	/*var i=1;
	while (objRelated.responseXML.getElementsByTagName('Item'+i).length>0)
	{
		with(objRelated.responseXML.getElementsByTagName('Item'+i).item(0)){
			cntDirector++;
			arrDirector[cntDirector] = new Array(6);
			arrDirector[cntDirector][0] = getElementsByTagName('sID').item(0).firstChild.nodeValue;
			arrDirector[cntDirector][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
			arrDirector[cntDirector][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
			arrDirector[cntDirector][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
			//if (getElementsByTagName('sLongLead')) 
			//	if (getElementsByTagName('sLongLead').item(0))
			//		if (getElementsByTagName('sLongLead').item(0).firstChild)
			//			{arrDirector[cntDirector][4]=getElementsByTagName('sLongLead').item(0).firstChild.nodeValue}
			//arrDirector[cntDirector][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
		}
		i++;
	}
	window.status="";
	aFlag=true;
	window.setTimeout('checkDirector(1)',iTimeout);*/	
	var i=1;
	 AjaxRequest.get(
		{
		'url':url
		,'onSuccess':function(req){			
			while (req.responseXML.getElementsByTagName('Item'+i).length>0){
				with(req.responseXML.getElementsByTagName('Item'+i).item(0)){	
					cntDirector ++;
					arrDirector[cntDirector] = new Array(6);
					arrDirector[cntDirector][0] = getNodeValue(getElementsByTagName('sID'));
					arrDirector[cntDirector][1] = getNodeValue(getElementsByTagName('sPath'));
					arrDirector[cntDirector][2] = getNodeValue(getElementsByTagName('sTitle'));
					arrDirector[cntDirector][3] = getNodeValue(getElementsByTagName('sLead'));					
				}	
				i++;				
			}
			parseDirector();
		}
		,'onError':function(req){}
		}
	)	
	window.status="";
	aFlag=true;
	window.setTimeout('checkDirector(1)',iTimeout);
}

function getDirectorNewInfo(iDirector) 
{
	if (objRelated.responseXML) {
		if (objRelated.responseXML.getElementsByTagName('Item1').length>0)
		{
			with(objRelated.responseXML.getElementsByTagName('Item1').item(0)){
				arrDirector[iDirector][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
				arrDirector[iDirector][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
				arrDirector[iDirector][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
				//arrActor[iDirector][4] = getElementsByTagName('sLongLead').item(0).firstChild.nodeValue;
				//arrActor[iDirector][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
			}
		}
	}
	window.status="";
	aFlag=true;

	if (iDirector<cntDirector){
		window.setTimeout('checkDirector(' + (iDirector+1) + ')',iTimeout);
	}
	else{
		window.setTimeout('parseDirector()',iTimeout);
	}
}

function checkDirector(iDirector){
	if(aFlag){
		loadRelatedXMLDoc(gPBI(arrDirector[iDirector][0]).concat('/Info.xml'), 'getDirectorNewInfo(' + iDirector + ')', 'Checking Director...');
	}
	else{
		window.setTimeout('checkDirector(' + iDirector + ')',iTimeout);
	}	
}

function parseDirector(){
	var i=1;
	var HTML='', SameHTML='';
	SameHTML += '<Table cellspacing=0 cellpadding=0 width="100%" bgcolor="#1e3354">';
	while (i<=cntDirector)
	{
		sPath = arrDirector[i][1];
		sTitle = arrDirector[i][2];
		sLead = arrDirector[i][3];
		sLongLead = arrDirector[i][4];
		sTopImage = arrDirector[i][5];
		if (i>1){
			HTML += ', ';
		}
		if (sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
			HTML += '<a class="TopStoryNormal" href="' + sPath + '">' + sTitle + '</a>';
		}
		else{
			HTML += sTitle;
		}
		SameHTML += '<tr>';
		SameHTML += '	<td style="padding-top:1;padding-left:5;" width=15><img id="imgSameDirector' + i + '" src="/Images/tree1.gif" style="cursor:pointer;" onclick="showSameDirector(' + i + ');"></td>';
		SameHTML += '	<td class="Other2" style="padding:3;cursor:pointer;" onclick="showSameDirector(' + i + ');">' + sTitle + '</td>';
		SameHTML += '</tr>';
		SameHTML += '<tr><td></td><td id="tdSameDirector' + i + '"></td></tr>';
		i++;
	}
	SameHTML += '</Table>';
	if(document.getElementById("tdDirector")){document.getElementById("tdDirector").innerHTML = HTML;}
	if(document.getElementById("tdSameDirector")){document.getElementById("tdSameDirector").innerHTML = SameHTML;}
}

function showDirector(){
	if(aFlag){
		//loadRelatedXMLDoc(gPBI(iSID).concat('/FS1.xml'), 'getDirector()', 'Loading Director...');
		getDirector(gPBI(iSID).concat('/FS1.xml'));
	}
	else{
		//window.setTimeout('showDirector()',iTimeout);
	}	
}


//---------------------------------------------------------------------------------------


function getActor(url){
	/*try
	{
		var i=1;
		while (objRelated.responseXML.getElementsByTagName('Item'+i).length>0)
		{
			with(objRelated.responseXML.getElementsByTagName('Item'+i).item(0)){
				cntActor++;
				arrActor[cntActor] = new Array(6);
				if ((getElementsByTagName('sID').item(0) != null) && (getElementsByTagName('sID').item(0).firstChild != null))
					arrActor[cntActor][0] = getElementsByTagName('sID').item(0).firstChild.nodeValue;
				if ((getElementsByTagName('sPath').item(0) != null) && (getElementsByTagName('sPath').item(0).firstChild != null))
					arrActor[cntActor][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
				if ((getElementsByTagName('sTitle').item(0) != null) && (getElementsByTagName('sTitle').item(0).firstChild != null))
					arrActor[cntActor][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
				if ((getElementsByTagName('sLead').item(0) != null) && (getElementsByTagName('sLead').item(0).firstChild != null))
					arrActor[cntActor][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
				if ((getElementsByTagName('sLongLead').item(0) != null) && (getElementsByTagName('sLongLead').item(0).firstChild != null))
					arrActor[cntActor][4] = getElementsByTagName('sLongLead').item(0).firstChild.nodeValue;
				if ((getElementsByTagName('sTopImage').item(0) != null) && (getElementsByTagName('sTopImage').item(0).firstChild != null))
					arrActor[cntActor][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
			}
			i++;
		}
		window.status="";
		aFlag=true;
		window.setTimeout('checkActor(1)',iTimeout);
	}
	catch(err){}*/
	var j = 1;
	 AjaxRequest.get(
		{
		'url':url
		,'onSuccess':function(req){			
			while (req.responseXML.getElementsByTagName('Item'+j).length>0){				
				with(req.responseXML.getElementsByTagName('Item' + j).item(0)){	
					cntActor++;
					arrActor[cntActor] = new Array(6);
					if(getNodeValue(getElementsByTagName('sID'))!=null){arrActor[cntActor][0] = getNodeValue(getElementsByTagName('sID'));}
					if(getNodeValue(getElementsByTagName('sPath'))!=null){arrActor[cntActor][1] = getNodeValue(getElementsByTagName('sPath'));}
					if(getNodeValue(getElementsByTagName('sTitle'))!=null){arrActor[cntActor][2] = getNodeValue(getElementsByTagName('sTitle'));}
					if(getNodeValue(getElementsByTagName('sLead'))!=null){arrActor[cntActor][3] = getNodeValue(getElementsByTagName('sLead'));}
					if(getNodeValue(getElementsByTagName('sLongLead'))!=null){arrActor[cntActor][4] = getNodeValue(getElementsByTagName('sLongLead'));}
					if(getNodeValue(getElementsByTagName('sTopImage'))!=null){arrActor[cntActor][5] = getNodeValue(getElementsByTagName('sTopImage'));}						
					
				}	
				j++;				
			}
			parseActor();
		}
		,'onError':function(req){}
		}
	)	
	window.status="";
	aFlag=true;
	window.setTimeout('checkActor(1)',iTimeout);
}

function getActorNewInfo(iActor) 
{
	try
	{
		if (objRelated.responseXML) {
			if (objRelated.responseXML.getElementsByTagName('Item1').length>0)
			{
				with(objRelated.responseXML.getElementsByTagName('Item1').item(0)){
					if ((getElementsByTagName('sPath').item(0) != null) && (getElementsByTagName('sPath').item(0).firstChild != null))
						arrActor[iActor][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
					if ((getElementsByTagName('sTitle').item(0) != null) && (getElementsByTagName('sTitle').item(0).firstChild != null))
						arrActor[iActor][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
					if ((getElementsByTagName('sLead').item(0) != null) && (getElementsByTagName('sLead').item(0).firstChild != null))
						arrActor[iActor][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
					if ((getElementsByTagName('sLongLead').item(0) != null) && (getElementsByTagName('sLongLead').item(0).firstChild != null))
						arrActor[iActor][4] = getElementsByTagName('sLongLead').item(0).firstChild.nodeValue;
					if ((getElementsByTagName('sTopImage').item(0) != null) && (getElementsByTagName('sTopImage').item(0).firstChild != null))	
						arrActor[iActor][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
				}
			}
		}
		window.status="";
		aFlag=true;

		if (iActor<cntActor){
			window.setTimeout('checkActor(' + (iActor+1) + ')',iTimeout);
		}
		else{
			window.setTimeout('parseActor()',iTimeout);
		}
	}
	catch(err){}
}

function checkActor(iActor){
	if(aFlag){
		loadRelatedXMLDoc(gPBI(arrActor[iActor][0]).concat('/Info.xml'), 'getActorNewInfo(' + iActor + ')', 'Checking Actor...');
	}
	else{
		window.setTimeout('checkActor(' + iActor + ')',iTimeout);
	}	
}

function parseActor(){
	var i=1;
	var HTMLActor='', HTMLMain='', SameHTML='';
	SameHTML += '<Table cellspacing=0 cellpadding=0 width="100%" bgcolor="#1e3354">';
	while (i<=cntActor)
	{
		sPath = arrActor[i][1];
		sTitle = arrActor[i][2];
		sLead = arrActor[i][3];
		sLongLead = arrActor[i][4];
		sTopImage = arrActor[i][5];
		if (i>1){
			HTMLActor = HTMLActor + ', ';
		}
		if (sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
			HTMLActor = HTMLActor + '<a class="TopStoryNormal" href="' + sPath + '">' + sTitle + '</a>';
		}
		else{
			HTMLActor = HTMLActor + sTitle;
		}
		SameHTML += '<tr>';
		SameHTML += '	<td style="padding-top:1;padding-left:5;" width=15><img id="imgSameActor' + i + '" src="/Images/tree1.gif" style="cursor:pointer;" onclick="showSameActor(' + i + ');"></td>';
		SameHTML += '	<td class="Other2" style="padding:3;cursor:pointer;" onclick="showSameActor(' + i + ');">' + sTitle + '</td>';
		SameHTML += '</tr>';
		SameHTML += '<tr><td></td><td id="tdSameActor' + i + '"></td></tr>';
		if (i==1 && sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
			HTMLMain = HTMLMain + '<Table border=0 cellspacing=0 cellpadding=0 width="100%">'; 
			HTMLMain = HTMLMain + '	<tr><td height=5></td></tr>'; 
			HTMLMain = HTMLMain + '	<tr>'; 
			HTMLMain = HTMLMain + '	<td class="TopStoryContent">Di&#7877;n vi&#234;n ch&#237;nh:</td>'; 
			HTMLMain = HTMLMain + '	</tr>'; 
			HTMLMain = HTMLMain + '	<tr><td height=5></td></tr>'; 
			HTMLMain = HTMLMain + '	<tr>'; 
			HTMLMain = HTMLMain + '		<td>'; 
			HTMLMain = HTMLMain + '			<Table border=0 cellspacing=0 cellpadding=0 width="100%" valign=top>';
			HTMLMain = HTMLMain + '				<tr>';
			HTMLMain = HTMLMain + '					<td rowspan=3 style="padding-right:5;" width=100 height=10 valign=top>';
			if (sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
				HTMLMain = HTMLMain + imageShow(sPath, sTopImage,1);
			}
			else{
				HTMLMain = HTMLMain + imageShow('',sPath + sTopImage,1);
			}
			HTMLMain = HTMLMain + '					</td>';
			HTMLMain = HTMLMain + '					<td height=10 class="TopStoryOption">';
			if (sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
				HTMLMain = HTMLMain + '<a href="' + sPath + '" class="TopStoryOption">' + sTitle + '</a>';
			}
			else{
				HTMLMain = HTMLMain + sTitle;
			}
			HTMLMain = HTMLMain + '					</td>';
			HTMLMain = HTMLMain + '				<tr><td height=5></td></tr>';
			HTMLMain = HTMLMain + '				</tr>';
			HTMLMain = HTMLMain + '					<td valign=top height=80 class="TopStoryLead">';
			if (sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
				HTMLMain = HTMLMain + '<a href="' + sPath + '" class="TopStoryLead">' + ReplaceAll(sLongLead,'""','"') + '</a>';
			}
			else{
				HTMLMain = HTMLMain + ReplaceAll(sLongLead,'""','"');
			}
			HTMLMain = HTMLMain + '					</td>';
			HTMLMain = HTMLMain + '				</tr>';
			HTMLMain = HTMLMain + '			</table>';
			HTMLMain = HTMLMain + '		</td>';
			HTMLMain = HTMLMain + '	</tr>';
			HTMLMain = HTMLMain + '</table>';
		}
		i++;
	}
	SameHTML += '</Table>';
	if(document.getElementById("tdActor")){document.getElementById("tdActor").innerHTML = HTMLActor;}
	if(document.getElementById("tdMainActor")){document.getElementById("tdMainActor").innerHTML = HTMLMain;}
	if(document.getElementById("tdSameActor")){document.getElementById("tdSameActor").innerHTML = SameHTML;}
}

function showActor(){
	if(aFlag){
		//loadRelatedXMLDoc(gPBI(iSID).concat('/FS2.xml'), 'getActor()', 'Loading Actor...');
		getActor(gPBI(iSID).concat('/FS2.xml'));
	}
	else{
		window.setTimeout('showActor()',iTimeout);
	}	
}


//---------------------------------------------------------------------------------------


function getProduce(url){
	/*var i=1;
	while (objRelated.responseXML.getElementsByTagName('Item'+i).length>0)
	{
		with(objRelated.responseXML.getElementsByTagName('Item'+i).item(0)){
			cntProduce++;
			arrProduce[cntProduce] = new Array(6);
			arrProduce[cntProduce][0] = getElementsByTagName('sID').item(0).firstChild.nodeValue;
			arrProduce[cntProduce][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
			arrProduce[cntProduce][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
			arrProduce[cntProduce][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
			//if (getElementsByTagName('sLongLead')) 
			//	if (getElementsByTagName('sLongLead').item(0))
			//		if (getElementsByTagName('sLongLead').item(0).firstChild)
			//			{arrProduce[cntProduce][4]=getElementsByTagName('sLongLead').item(0).firstChild.nodeValue}
			//arrProduce[cntProduce][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
		}
		i++;
	}
	window.status="";
	aFlag=true;
	window.setTimeout('checkProduce(1)',iTimeout);*/
	
	var i=1;
	 AjaxRequest.get(
		{
		'url':url
		,'onSuccess':function(req){			
			while (req.responseXML.getElementsByTagName('Item'+i).length>0){
				with(req.responseXML.getElementsByTagName('Item'+i).item(0)){	
					cntProduce ++;
					arrProduce[cntProduce] = new Array(6);
					arrProduce[cntProduce][0] = getNodeValue(getElementsByTagName('sID'));
					arrProduce[cntProduce][1] = getNodeValue(getElementsByTagName('sPath'));
					arrProduce[cntProduce][2] = getNodeValue(getElementsByTagName('sTitle'));
					arrProduce[cntProduce][3] = getNodeValue(getElementsByTagName('sLead'));					
				}	
				i++;				
			}
			parseProduce();
		}
		,'onError':function(req){}
		}
	)	
	window.status="";
	aFlag=true;
	window.setTimeout('checkProduce(1)',iTimeout);
}

function getProduceNewInfo(iProduce) 
{
	if (objRelated.responseXML) {
		if (objRelated.responseXML.getElementsByTagName('Item1').length>0)
		{
			with(objRelated.responseXML.getElementsByTagName('Item1').item(0)){
				arrProduce[iProduce][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
				arrProduce[iProduce][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
				arrProduce[iProduce][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
				//arrProduce[iProduce][4] = getElementsByTagName('sLongLead').item(0).firstChild.nodeValue;
				//arrProduce[iProduce][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
			}
		}
	}
	window.status="";
	aFlag=true;

	if (iProduce<cntProduce){
		window.setTimeout('checkProduce(' + (iProduce+1) + ')',iTimeout);
	}
	else{
		window.setTimeout('parseProduce()',iTimeout);
	}
}

function checkProduce(iProduce){
	if(aFlag){
		loadRelatedXMLDoc(gPBI(arrProduce[iProduce][0]).concat('/Info.xml'), 'getProduceNewInfo(' + iProduce + ')', 'Checking Produce...');
	}
	else{
		window.setTimeout('checkProduce(' + iProduce + ')',iTimeout);
	}	
}

function parseProduce(){
	var i=1;
	var HTML='', SameHTML='';
	SameHTML += '<Table cellspacing=0 cellpadding=0 width="100%" bgcolor="#1e3354">';
	while (i<=cntProduce)
	{
		sPath = arrProduce[i][1];
		sTitle = arrProduce[i][2];
		sLead = arrProduce[i][3];
		sLongLead = arrProduce[i][4];
		sTopImage = arrProduce[i][5];
		if (i>1){
			HTML += ', ';
		}
		if (sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
			HTML += '<a class="TopStoryNormal" href="' + sPath + '">' + sTitle + '</a>';
		}
		else{
			HTML += sTitle;
		}
		SameHTML += '<tr>';
		SameHTML += '	<td style="padding-top:1;padding-left:5;" width=15><img id="imgSameProduce' + i + '" src="/Images/tree1.gif" style="cursor:pointer;" onclick="showSameProduce(' + i + ');"></td>';
		SameHTML += '	<td class="Other2" style="padding:3;cursor:pointer;" onclick="showSameProduce(' + i + ');">' + sTitle + '</td>';
		SameHTML += '</tr>';
		SameHTML += '<tr><td></td><td id="tdSameProduce' + i + '"></td></tr>';
		i++;
	}
	SameHTML += '</Table>';
	if(document.getElementById("tdProduce")){document.getElementById("tdProduce").innerHTML = HTML;}
	if(document.getElementById("tdSameProduce")){document.getElementById("tdSameProduce").innerHTML = SameHTML;}
}

function showProduce(){
	if(aFlag){
		//loadRelatedXMLDoc(gPBI(iSID).concat('/FS3.xml'), 'getProduce()', 'Loading Produce...');
		getProduce(gPBI(iSID).concat('/FS3.xml'));
	}
	else{
		window.setTimeout('showProduce()',iTimeout);
	}	
}


//---------------------------------------------------------------------------------------


function getScenario(url){
	/*var i=1;
	while (objRelated.responseXML.getElementsByTagName('Item'+i).length>0)
	{
		with(objRelated.responseXML.getElementsByTagName('Item'+i).item(0)){
			cntScenario++;
			arrScenario[cntScenario] = new Array(6);
			arrScenario[cntScenario][0] = getElementsByTagName('sID').item(0).firstChild.nodeValue;
			arrScenario[cntScenario][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
			arrScenario[cntScenario][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
			arrScenario[cntScenario][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
			//if (getElementsByTagName('sLongLead')) 
			//	if (getElementsByTagName('sLongLead').item(0))
			//		if (getElementsByTagName('sLongLead').item(0).firstChild)
			//			{arrScenario[cntScenario][4]=getElementsByTagName('sLongLead').item(0).firstChild.nodeValue}
			//arrScenario[cntScenario][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
		}
		i++;
	}
	window.status="";
	aFlag=true;
	window.setTimeout('checkScenario(1)',iTimeout);*/
	
	var i=1;
	 AjaxRequest.get(
		{
		'url':url
		,'onSuccess':function(req){			
			while (req.responseXML.getElementsByTagName('Item'+i).length>0){
				with(req.responseXML.getElementsByTagName('Item'+i).item(0)){	
					cntScenario ++;
					arrScenario[cntScenario] = new Array(6);
					arrScenario[cntScenario][0] = getNodeValue(getElementsByTagName('sID'));
					arrScenario[cntScenario][1] = getNodeValue(getElementsByTagName('sPath'));
					arrScenario[cntScenario][2] = getNodeValue(getElementsByTagName('sTitle'));
					arrScenario[cntScenario][3] = getNodeValue(getElementsByTagName('sLead'));					
				}	
				i++;				
			}
			parseScenario();
		}
		,'onError':function(req){}
		}
	)
	window.status="";
	aFlag=true;
	window.setTimeout('checkScenario(1)',iTimeout);	
}

function getScenarioNewInfo(iScenario) 
{
	if (objRelated.responseXML) {
		if (objRelated.responseXML.getElementsByTagName('Item1').length>0)
		{
			with(objRelated.responseXML.getElementsByTagName('Item1').item(0)){
				arrScenario[iScenario][1] = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
				arrScenario[iScenario][2] = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
				arrScenario[iScenario][3] = getElementsByTagName('sLead').item(0).firstChild.nodeValue;
				//arrScenario[iScenario][4] = getElementsByTagName('sLongLead').item(0).firstChild.nodeValue;
				//arrScenario[iScenario][5] = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
			}
		}
	}
	window.status="";
	aFlag=true;

	if (iScenario<cntScenario){
		window.setTimeout('checkScenario(' + (iScenario+1) + ')',iTimeout);
	}
	else{
		window.setTimeout('parseScenario()',iTimeout);
	}
}

function checkScenario(iScenario){
	if(aFlag){
		loadRelatedXMLDoc(gPBI(arrScenario[iScenario][0]).concat('/Info.xml'), 'getScenarioNewInfo(' + iScenario + ')', 'Checking Scenario...');
	}
	else{
		window.setTimeout('checkScenario(' + iScenario + ')',iTimeout);
	}	
}

function parseScenario(){
	var i=1;
	var HTML='', SameHTML='';
	SameHTML += '<Table cellspacing=0 cellpadding=0 width="100%" bgcolor="#1e3354">';
	while (i<=cntScenario)
	{
		sPath = arrScenario[i][1];
		sTitle = arrScenario[i][2];
		sLead = arrScenario[i][3];
		sLongLead = arrScenario[i][4];
		sTopImage = arrScenario[i][5];
		if (i>1){
			HTML += ', ';
		}
		if (sLead!='Nolink' && sLead!='No link' && sLead!='Đang cập nhật'){
			HTML += '<a class="TopStoryNormal" href="' + sPath + '">' + sTitle + '</a>';
		}
		else{
			HTML += sTitle;
		}
		SameHTML += '<tr>';
		SameHTML += '	<td style="padding-top:1;padding-left:5;" width=15><img id="imgSameScenario' + i + '" src="/Images/tree1.gif" style="cursor:pointer;" onclick="showSameScenario(' + i + ');"></td>';
		SameHTML += '	<td class="Other2" style="padding:3;cursor:pointer;" onclick="showSameScenario(' + i + ');">' + sTitle + '</td>';
		SameHTML += '</tr>';
		SameHTML += '<tr><td></td><td id="tdSameScenario' + i + '"></td></tr>';
		i++;
	}
	SameHTML += '</Table>';
	if(document.getElementById("tdScenario")){document.getElementById("tdScenario").innerHTML = HTML;}
	if(document.getElementById("tdSameScenario")){document.getElementById("tdSameScenario").innerHTML = SameHTML;}
}

function showScenario(){
	if(aFlag){
		//loadRelatedXMLDoc(gPBI(iSID).concat('/FS4.xml'), 'getScenario()', 'Loading Scenario...');
		getScenario(gPBI(iSID).concat('/FS4.xml'))
	}
	else{
		window.setTimeout('showScenario()',iTimeout);
	}	
}


//---------------------------------------------------------------------------------------


function getGenre(url){
	var i=0;
	var HTML='', SameHTML='';
	SameHTML += '<Table cellspacing=0 cellpadding=0 width="100%" bgcolor="#1e3354">';
	AjaxRequest.get(
		{
		'url':url
		,'onSuccess':function(req){			
			while (req.responseXML.getElementsByTagName('Item'+i).length>0){
				with(req.responseXML.getElementsByTagName('Item'+i).item(0)){						
					sFolder = getNodeValue(getElementsByTagName('fID'));
					sTitle = getNodeValue(getElementsByTagName('fName'));
					sPath = getNodeValue(getElementsByTagName('fPath'));					
					cntGenre++;
					arrGenre[cntGenre] = new Array(3);
					arrGenre[cntGenre][0] = sFolder;
					arrGenre[cntGenre][1] = sTitle;
					arrGenre[cntGenre][2] = sPath;					
					if (i>0){
						HTML += ', ';
					}
					HTML += '<a class="TopStoryGenre" href="' + sPath + '">'; 
					HTML += sTitle + '</a>';
					SameHTML += '<tr>';
					SameHTML += '	<td style="padding-top:1;padding-left:5;" width=15><img id="imgSameGenre' + cntGenre + '" src="/Images/tree1.gif" style="cursor:pointer;" onclick="showSameGenre(' + cntGenre + ');"></td>';
					SameHTML += '	<td class="Other2" style="padding:3;cursor:pointer;" onclick="showSameGenre(' + cntGenre + ');">' + sTitle + '</td>';
					SameHTML += '	<td class="Other2" style="padding:3;font-weight:normal;">';
					SameHTML += '(Phim năm ';
					var thedate = new Date( );
					for (var j=thedate.getUTCFullYear();j>thedate.getUTCFullYear()-3;j--){
						SameHTML += '<b><a class="Other3" href="/ListSame/?t=1&i=' + sFolder + '&y=' + j + '">' + j + '</a></b>, ';
					}
					SameHTML += '<b><a class="Other3" href="/ListSame/?t=1&i=' + sFolder + '">...</a></b>';
					SameHTML += ')</td>';
					SameHTML += '</tr>';
					SameHTML += '<tr><td></td><td colspan=2 id="tdSameGenre' + cntGenre + '"></td></tr>';
				}
				i++;
			}
			SameHTML += '</Table>';
			if(document.getElementById("tdGenre")){document.getElementById("tdGenre").innerHTML = HTML;}
			if(document.getElementById("tdSameGenre")){document.getElementById("tdSameGenre").innerHTML = SameHTML;}
		}
		,'onError':function(req){}
		}
	)
	
	window.status="";
	aFlag=true;
}

function showGenre(){
	if(aFlag){
		//loadRelatedXMLDoc(gPBI(iSID).concat('/FS5.xml'), 'getGenre()', 'Loading Genre...');
		getGenre(gPBI(iSID).concat('/FS5.xml'));
	}
	else{
		window.setTimeout('showGenre()',iTimeout);
	}	
}



//---------------------------------------------------------------------------------------

function getSameDirector(index){
	var sp,st,ss,i;
	var HTML='';
	HTML += '<Table cellspacing=0 cellpadding=1 width="100%">';
	if(objRelated.responseXML && objRelated.responseXML.getElementsByTagName('s').length){
		for(i=0; i<objRelated.responseXML.getElementsByTagName('s').length; i++){
			with(objRelated.responseXML.getElementsByTagName('s').item(i)){
				st = getAttribute('st');
				sp = getAttribute('sp');
				if (getAttribute('ss')) {ss=getAttribute('ss')}else{ss=''};
			}
			HTML += '<tr>';
			HTML += '	<td style="padding-left:2;" class="Other3">• <a class="Other3" href="' + sp + '">' + st;
			if (ss!='') HTML += ' (' + ss + ')';
			HTML += '</td>'
			HTML += '</tr>';			
		}
	}
	else{
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(Kh&#244;ng c&#243; th&#244;ng tin)</td>';
		HTML += '</tr>';
	}
	if (i>1){
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(<a class="Other3" href="/ListSame/?t=2&i=' + arrDirector[index][0] + '">Xem tất phim của đạo diễn ' + arrDirector[index][2] + '</a>)';
		HTML += '</td>';
		HTML += '</tr>';
	}
	HTML += '</Table>';
	if(document.getElementById("tdSameDirector"+index)){document.getElementById("tdSameDirector"+index).innerHTML = HTML;}
	window.status="";
	aFlag=true;	
}

function showSameDirector(index){
	if(sId<=0){return;}
	if (document.getElementById("tdSameDirector"+index).innerHTML==''){
		if(aFlag){
			document.getElementById('imgSameDirector'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameDirector'+index).innerHTML = '<img src="/Images/loading.gif">'
			loadRelatedXMLDoc(gPBI(arrDirector[index][0]).concat('/DirectorFL.xml'), 'getSameDirector(' + index + ')', 'Loading Director Related...');
		}
		else{
			window.setTimeout('showSameDirector(' + index + ')',iTimeout);
		}
	}
	else{
		if (document.getElementById('tdSameDirector'+index).style.display==''){
			document.getElementById('imgSameDirector'+index).src='/Images/tree1.gif';
			document.getElementById('tdSameDirector'+index).style.display='none';
		}
		else{
			document.getElementById('imgSameDirector'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameDirector'+index).style.display='';
		}
	}
}


//---------------------------------------------------------------------------------------

function getSameActor(index){
	var sp,st,ss,i;
	var HTML='';
	HTML += '<Table cellspacing=0 cellpadding=1 width="100%">';
	if(objRelated.responseXML && objRelated.responseXML.getElementsByTagName('s').length){
		for(i=0; i<objRelated.responseXML.getElementsByTagName('s').length; i++){
			with(objRelated.responseXML.getElementsByTagName('s').item(i)){
				st = getAttribute('st');
				sp = getAttribute('sp');
				if (getAttribute('ss')) {ss=getAttribute('ss')}else{ss=''};
			}
			HTML += '<tr>';
			HTML += '	<td style="padding-left:2;" class="Other3">• <a class="Other3" href="' + sp + '">' + st;
			if (ss!='') HTML += ' (' + ss + ')';
			HTML += '</td>'
			HTML += '</tr>';			
		}
	}
	else{
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(Kh&#244;ng c&#243; th&#244;ng tin)</td>';
		HTML += '</tr>';
	}
	if (i>1){
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(<a class="Other3" href="/ListSame/?t=3&i=' + arrActor[index][0] + '">Xem tất phim của diễn viên ' + arrActor[index][2] + '</a>)';
		HTML += '</td>';
		HTML += '</tr>';
	}
	HTML += '</Table>';
	if(document.getElementById("tdSameActor"+index)){document.getElementById("tdSameActor"+index).innerHTML = HTML;}
	window.status="";
	aFlag=true;	
}

function showSameActor(index){
	if(sId<=0){return;}
	if (document.getElementById("tdSameActor"+index).innerHTML==''){
		if(aFlag){
			document.getElementById('imgSameActor'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameActor'+index).innerHTML = '<img src="/Images/loading.gif">'
			loadRelatedXMLDoc(gPBI(arrActor[index][0]).concat('/ActorFL.xml'), 'getSameActor(' + index + ')', 'Loading Actor Related...');
		}
		else{
			window.setTimeout('showSameActor(' + index + ')',iTimeout);
		}
	}
	else{
		if (document.getElementById('tdSameActor'+index).style.display==''){
			document.getElementById('imgSameActor'+index).src='/Images/tree1.gif';
			document.getElementById('tdSameActor'+index).style.display='none';
		}
		else{
			document.getElementById('imgSameActor'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameActor'+index).style.display='';
		}
	}
}


//---------------------------------------------------------------------------------------

function getSameScenario(index){
	var sp,st,ss, i;
	var HTML='';
	HTML += '<Table cellspacing=0 cellpadding=1 width="100%">';
	if(objRelated.responseXML && objRelated.responseXML.getElementsByTagName('s').length){
		for(i=0; i<objRelated.responseXML.getElementsByTagName('s').length; i++){
			with(objRelated.responseXML.getElementsByTagName('s').item(i)){
				st = getAttribute('st');
				sp = getAttribute('sp');
				if (getAttribute('ss')) {ss=getAttribute('ss')}else{ss=''};
			}
			HTML += '<tr>';
			HTML += '	<td style="padding-left:2;" class="Other3">• <a class="Other3" href="' + sp + '">' + st;
			if (ss!='') HTML += ' (' + ss + ')';
			HTML += '</td>'
			HTML += '</tr>';			
		}
	}
	else{
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(Kh&#244;ng c&#243; th&#244;ng tin)</td>';
		HTML += '</tr>';
	}
	if (i>1){
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(<a class="Other3" href="/ListSame/?t=5&i=' + arrScenario[index][0] + '">Xem tất phim do ' + arrScenario[index][2] + ' viết kịch bản</a>)';
		HTML += '</td>';
		HTML += '</tr>';
	}
	HTML += '</Table>';
	if(document.getElementById("tdSameScenario"+index)){document.getElementById("tdSameScenario"+index).innerHTML = HTML;}
	window.status="";
	aFlag=true;	
}

function showSameScenario(index){
	if(sId<=0){return;}
	if (document.getElementById("tdSameScenario"+index).innerHTML==''){
		if(aFlag){
			document.getElementById('imgSameScenario'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameScenario'+index).innerHTML = '<img src="/Images/loading.gif">'
			loadRelatedXMLDoc(gPBI(arrScenario[index][0]).concat('/ScenarioFL.xml'), 'getSameScenario(' + index + ')', 'Loading Scenario Related...');
		}
		else{
			window.setTimeout('showSameScenario(' + index + ')',iTimeout);
		}
	}
	else{
		if (document.getElementById('tdSameScenario'+index).style.display==''){
			document.getElementById('imgSameScenario'+index).src='/Images/tree1.gif';
			document.getElementById('tdSameScenario'+index).style.display='none';
		}
		else{
			document.getElementById('imgSameScenario'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameScenario'+index).style.display='';
		}
	}
}


//---------------------------------------------------------------------------------------

function getSameProduce(index){
	var sp,st,ss, i;
	var HTML='';
	HTML += '<Table cellspacing=0 cellpadding=1 width="100%">';
	if(objRelated.responseXML && objRelated.responseXML.getElementsByTagName('s').length){
		for(i=0; i<objRelated.responseXML.getElementsByTagName('s').length; i++){
			with(objRelated.responseXML.getElementsByTagName('s').item(i)){
				st = getAttribute('st');
				sp = getAttribute('sp');
				if (getAttribute('ss')) {ss=getAttribute('ss')}else{ss=''};
			}
			HTML += '<tr>';
			HTML += '<tr>';
			HTML += '	<td style="padding-left:2;" class="Other3">• <a class="Other3" href="' + sp + '">' + st;
			if (ss!='') HTML += ' (' + ss + ')';
			HTML += '</td>'
			HTML += '</tr>';			
		}
	}
	else{
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(Kh&#244;ng c&#243; th&#244;ng tin)</td>';
		HTML += '</tr>';
	}
	if (i>1){
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(<a class="Other3" href="/ListSame/?t=4&i=' + arrProduce[index][0] + '">Xem tất phim do ' + arrProduce[index][2] + ' sản xuất</a>)';
		HTML += '</td>';
		HTML += '</tr>';
	}
	HTML += '</Table>';
	if(document.getElementById("tdSameProduce"+index)){document.getElementById("tdSameProduce"+index).innerHTML = HTML;}
	window.status="";
	aFlag=true;	
}

function showSameProduce(index){
	if(sId<=0){return;}
	if (document.getElementById("tdSameProduce"+index).innerHTML==''){
		if(aFlag){
			document.getElementById('imgSameProduce'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameProduce'+index).innerHTML = '<img src="/Images/loading.gif">'
			loadRelatedXMLDoc(gPBI(arrProduce[index][0]).concat('/ProduceFL.xml'), 'getSameProduce(' + index + ')', 'Loading Produce Related...');
		}
		else{
			window.setTimeout('showSameProduce(' + index + ')',iTimeout);
		}
	}
	else{
		if (document.getElementById('tdSameProduce'+index).style.display==''){
			document.getElementById('imgSameProduce'+index).src='/Images/tree1.gif';
			document.getElementById('tdSameProduce'+index).style.display='none';
		}
		else{
			document.getElementById('imgSameProduce'+index).src='/Images/tree2.gif';
			document.getElementById('tdSameProduce'+index).style.display='';
		}
	}
}


//---------------------------------------------------------------------------------------

function getSameGenre(iGenre){
	var c = objRelated.responseXML.getElementsByTagName('s').length;
	var sp,st,ss;
	var HTML='';
	HTML += '<Table cellspacing=0 cellpadding=1 width="100%">';
	if(c){
		for(var i=0; i<c; i++){
			with(objRelated.responseXML.getElementsByTagName('s').item(i)){
				st = getAttribute('st');
				sp = getAttribute('sp');
				if (getAttribute('ss')) {ss=getAttribute('ss')}else{ss=''};
				if (getAttribute('sr')) {sr=getAttribute('sr')}else{sr=''};
			}
			HTML += '<tr>';
			HTML += '	<td style="padding-left:2;" class="Other3">• <a class="Other3" href="' + sp + '">' + st
			if (ss!='') HTML += ' (' + ss + ')';
			HTML += '</a>'
			//if (sr!='') HTML += ' - ' + sr;
			HTML += '</td>';
			HTML += '</tr>';			
		}
	}
	else{
		HTML += '<tr>';
		HTML += '	<td style="padding-left:2;" class="Other3">(Kh&#244;ng c&#243; th&#244;ng tin)</td>';
		HTML += '</tr>';
	}
	/*
	HTML += '<tr>';
	HTML += '	<td style="padding-left:2;" class="Other3">(Xem tất phim <b><a class="Other3" href="' + arrGenre[iGenre][2] + '">' + arrGenre[iGenre][1] + '</a></b> trong năm ';
	var thedate = new Date( );
	for (var i=thedate.getYear();i>thedate.getYear()-3;i--){
		HTML += '<b><a class="Other3" href="/ListSame/?t=1&i=' + arrGenre[iGenre][0] + '&y=' + i + '">' + i + '</a></b>, ';
	}
	HTML += '<b><a class="Other3" href="/ListSame/?t=1&i=' + arrGenre[iGenre][0] + '">...</a></b>';
	HTML += ')</td>';
	HTML += '</tr>';
	*/
	HTML += '</Table>';
	if(document.getElementById("tdSameGenre"+iGenre)){document.getElementById("tdSameGenre"+iGenre).innerHTML = HTML;}
	window.status="";
	aFlag=true;	
}

function showSameGenre(iGenre){
	if(iSID<=1000000000){return;}
	if (document.getElementById("tdSameGenre"+iGenre).innerHTML==''){
		if(aFlag){
			document.getElementById('imgSameGenre'+iGenre).src='/Images/tree2.gif';
			document.getElementById('tdSameGenre'+iGenre).innerHTML = '<img src="/Images/loading.gif">'
			loadRelatedXMLDoc('/User/Related/getRelated.Asp?ExID=' + escape(iSID) + '&ExF=' + arrGenre[iGenre][0], 'getSameGenre(' + iGenre + ')', 'Loading Film Related...');
		}
		else{
			window.setTimeout('showSameGenre(' + iGenre + ')',iTimeout);
		}
	}
	else{
		if (document.getElementById('tdSameGenre'+iGenre).style.display==''){
			document.getElementById('imgSameGenre'+iGenre).src='/Images/tree1.gif';
			document.getElementById('tdSameGenre'+iGenre).style.display='none';
		}
		else{
			document.getElementById('imgSameGenre'+iGenre).src='/Images/tree2.gif';
			document.getElementById('tdSameGenre'+iGenre).style.display='';
		}
	}
}


//---------------------------------------------------------------------------------------

function getTopView(item){
	var i=1,j=1;
	var HTML='';
	
		AjaxRequest.get(
		{
		'url':'/ListFile/TopView.xml'
		,'onSuccess':function(req){	
		
			while (req.responseXML.getElementsByTagName('Item'+i).length>0 && j<=item)
			{
				with(req.responseXML.getElementsByTagName('Item'+i).item(0)){
					sId = getNodeValue(getElementsByTagName('sID'));
					sTitle = getNodeValue(getElementsByTagName('sTitle'));
					sPath = getNodeValue(getElementsByTagName('sPath'));
					sSubTitle='';
					if (getElementsByTagName('sSubTitle')) 
						if (getElementsByTagName('sSubTitle').item(0))
							if (getElementsByTagName('sSubTitle').item(0).firstChild)
								{sSubTitle=getNodeValue(getElementsByTagName('sSubTitle'))}
					if (getElementsByTagName('sRelease').item(0).firstChild){
						sRelease = getNodeValue(getElementsByTagName('sRelease'));
					}
					else{
						sRelease = '';
					}
					sTopImage = getNodeValue(getElementsByTagName('sTopImage'));
					if (!inListShow(sId)){
						j++;
						addListShow(sId);
						HTML += '<Table width="120" cellpadding=0 cellspacing=0>'; 
						HTML += '	<tr>'; 
						HTML += '		<td width="120">'; 
						HTML += '			<table cellpadding=0 cellspacing=0 width="120">'; 
						HTML += '				<tr><td style="padding-top:5;padding-bottom:5;" align=center class="TopViewTitle">' + sRelease + '</td></tr>'; 
						HTML += '				<tr>'; 
						HTML += '					<td><table cellpadding=0 cellspacing=0><tr><td width="21"><img src="/Images/TopView/topleft.jpg" border=0></td><td width="100%"></td><td width="21"><img src="/Images/TopView/topright.jpg" border=0></td></tr></table></td>'; 
						HTML += '				</tr>'; 
						HTML += '				<tr>'; 
						HTML += '					<td>'; 
						HTML += '						<table cellpadding=0 cellspacing=0 width="120">'; 
						HTML += '							<tr>'; 
						HTML += '								<td width="2" height="100%" background="/Images/TopView/bg_top.gif"></td>'; 
						HTML += '								<td width="116" style="padding-top:10;padding-bottom:9;" align=center>'; 
						HTML += '									<Table cellpadding=0 cellspacing=0>'; 
						HTML += '										<tr>'; 
						HTML += '											<td>' + imageShow(sPath,sTopImage,2) + '</a></td>'; 
						HTML += '										</tr>'; 
						HTML += '									</Table>'; 
						HTML += '								</td> '; 
						HTML += '								<td width="2" height="100%" background="/Images/TopView/bg_top_right.gif"></td>'; 
						HTML += '							</tr>'; 
						HTML += '						</table>'; 
						HTML += '					</td>'; 
						HTML += '				</tr>'; 
						HTML += '				<tr>'; 
						HTML += '					<td><table cellpadding=0 cellspacing=0><tr><td width="21"><img src="/Images/TopView/bottomleft.jpg" border=0></td><td width="100%"></td><td width="21"><img src="/Images/TopView/bottomright.jpg" border=0></td></tr></table></td>'; 
						HTML += '				</tr>'; 
						HTML += '				<tr><td style="padding-top:5;" align=center><a href="' + sPath + '" class="TopViewTitle">' + toUpper(sTitle) + '</a></td></tr>'; 
						if (sSubTitle!='')	HTML += '				<tr><td style="padding-top:2;" align=center><a href="' + sPath + '" class="TopViewSubTitle">(' + sSubTitle + ')</a></td></tr>'; 
						HTML += '				<tr height="18"><td></td></tr>'; 
						HTML += '			</Table>'; 
						HTML += '		</td>'; 
						HTML += '	</tr>'; 
						HTML += '</Table>'; 
					}
				}
				i++;
			}			
			if(document.getElementById("tdTopView")){document.getElementById("tdTopView").innerHTML = HTML;}
		}
		,'onError':function(req){}
		}
	)
	//====================================	
	window.status="";
	aFlag=true;
}

function showTopView(fId,item){
	if(aFlag){
		//loadRelatedXMLDoc('/ListFile/TopView.xml', 'getTopView(' + item + ')', 'Loading Top View...');
		getTopView(item);
	}
	else{
		window.setTimeout('showTopView(' + fId + ',' + item + ')',iTimeout);
	}	
}

//---------------------------------------------------------------------------------------

function getTopReady(item){
	var i=1,j=1;
	var HTML='';
	while (objRelated.responseXML.getElementsByTagName('Item'+i).length>0 && j<=item)
	{
		with(objRelated.responseXML.getElementsByTagName('Item'+i).item(0)){
			sId = getElementsByTagName('sID').item(0).firstChild.nodeValue;
			sTitle = getElementsByTagName('sTitle').item(0).firstChild.nodeValue;
			sPath = getElementsByTagName('sPath').item(0).firstChild.nodeValue;
			if (getElementsByTagName('sRelease').item(0).firstChild){
				sRelease = getElementsByTagName('sRelease').item(0).firstChild.nodeValue;
			}
			else{
				sRelease = '';
			}
			sTopImage = getElementsByTagName('sTopImage').item(0).firstChild.nodeValue;
			if (!inListShow(sId)){
				j++;
				addListShow(sId);
				HTML += '<Table width="120" cellpadding=0 cellspacing=0>'; 
				HTML += '	<tr>'; 
				HTML += '		<td width="120">'; 
				HTML += '			<table cellpadding=0 cellspacing=0 width="120">'; 
				HTML += '				<tr><td style="padding-top:5;padding-bottom:5;" align=center class="TopViewTitle">' + sRelease + '</td></tr>'; 
				HTML += '				<tr>'; 
				HTML += '					<td><table cellpadding=0 cellspacing=0><tr><td width="21"><img src="/Images/TopView/topleft.jpg" border=0></td><td width="100%"></td><td width="21"><img src="/Images/TopView/topright.jpg" border=0></td></tr></table></td>'; 
				HTML += '				</tr>'; 
				HTML += '				<tr>'; 
				HTML += '					<td>'; 
				HTML += '						<table cellpadding=0 cellspacing=0 width="120">'; 
				HTML += '							<tr>'; 
				HTML += '								<td width="2" height="100%" background="/Images/TopView/bg_top.gif"></td>'; 
				HTML += '								<td width="116" style="padding-top:10;padding-bottom:9;" align=center>'; 
				HTML += '									<Table cellpadding=0 cellspacing=0>'; 
				HTML += '										<tr>'; 
				HTML += '											<td>' + imageShow(sPath,sTopImage,2) + '</a></td>'; 
				HTML += '										</tr>'; 
				HTML += '									</Table>'; 
				HTML += '								</td> '; 
				HTML += '								<td width="2" height="100%" background="/Images/TopView/bg_top_right.gif"></td>'; 
				HTML += '							</tr>'; 
				HTML += '						</table>'; 
				HTML += '					</td>'; 
				HTML += '				</tr>'; 
				HTML += '				<tr>'; 
				HTML += '					<td><table cellpadding=0 cellspacing=0><tr><td width="21"><img src="/Images/TopView/bottomleft.jpg" border=0></td><td width="100%"></td><td width="21"><img src="/Images/TopView/bottomright.jpg" border=0></td></tr></table></td>'; 
				HTML += '				</tr>'; 
				HTML += '				<tr><td style="padding-top:5;" align=center><a href="' + sPath + '" class="TopViewTitle">' + toUpper(sTitle) + '</a></td></tr>'; 
				HTML += '				<tr height="18"><td></td></tr>'; 
				HTML += '			</Table>'; 
				HTML += '		</td>'; 
				HTML += '	</tr>'; 
				HTML += '</Table>'; 
			}
		}
		i++;
	}
	if(document.getElementById("tdTopReady")){document.getElementById("tdTopReady").innerHTML = HTML;}
	window.status="";
	aFlag=true;
}

function showTopReady(fId,item){
	if(aFlag){
		loadRelatedXMLDoc('/ListFile/TopReady.xml', 'getTopReady(' + item + ')', 'Loading Top Ready...');
	}
	else{
		window.setTimeout('showTopReady(' + fId + ',' + item + ')',iTimeout);
	}	
}


//---------------------------------------------------------------------------------------

function getComment(path) 
{
	var sc, sl;
	if(objRelated.responseXML && objRelated.responseXML.getElementsByTagName('s').length)
	{
		for(var i=0; i<objRelated.responseXML.getElementsByTagName('s').length; i++)	
		{
			with(objRelated.responseXML.getElementsByTagName('s').item(i))
			{
				sc = getElementsByTagName('c').item(0).firstChild.nodeValue;
				sl = getElementsByTagName('l').item(0).firstChild.nodeValue
			}
			mnuComment[i]='<a href="' + sl + '" target="_blank">' + sc + '</a>'
		}
		//if(document.getElementById("tdComment")){document.getElementById("tdComment").innerHTML = '<table cellspacing=2 cellpadding=0 border=0><tr><td align=center><img src="/Images/Comment.gif" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, mnuComment, \'\')" onMouseout="delayhidemenu()"></td></tr><tr><td><img src="/Images/shadow.gif"></td></tr></table>'};
		if(document.getElementById("tdComment")){document.getElementById("tdComment").innerHTML = '<table cellspacing=2 cellpadding=0 border=0><tr><td align=center><img src="/Images/Comment.gif" onMouseover="dropdownmenu(this, event, mnuComment, \'\')" onMouseout="delayhidemenu()"></td></tr><tr><td><img src="/Images/shadow.gif"></td></tr></table>'};
	}
	else{
		if(document.getElementById("tdComment")){document.getElementById("tdComment").innerHTML = ''};
	}
	window.status="";
	aFlag=true;
}

function showComment(){
	if(aFlag){
		loadRelatedXMLDoc(gPBI(iSID).concat('/Comment.xml'), 'getComment()', 'Loading Comment...');
	}
	else{
		window.setTimeout('showComment()',iTimeout);
	}	
}


//---------------------------------------------------------------------------------------

function getActorFilm(){
	var sp,st,ss;
	var HTML='';
	HTML += '<ul>';
	if(objRelated.responseXML && objRelated.responseXML.getElementsByTagName('s').length){
		for(var i=0; i<objRelated.responseXML.getElementsByTagName('s').length; i++){
			with(objRelated.responseXML.getElementsByTagName('s').item(i)){
				st = getAttribute('st');
				sp = getAttribute('sp');
				if (getAttribute('ss')) {ss=getAttribute('ss')}else{ss=''};
			}
			HTML += '<li><a class="Other4" href="' + sp + '">' + st;
			if (ss!='') HTML += ' (' + ss + ')';
			HTML += '</a></li>';			
		}
	}
	else{
		HTML += '<li>(Kh&#244;ng c&#243; th&#244;ng tin)</li>';			
	}
	HTML += '</ul>';
	if(document.getElementById("tdActorFilm")){document.getElementById("tdActorFilm").innerHTML = HTML;}
	window.status="";
	aFlag=true;	
}

function showActorFilm(){
	if (document.getElementById("tdActorFilm").innerHTML==''){
		if(aFlag){
			document.getElementById('tdActorFilm').innerHTML = '<img src="/Images/loading.gif">';
			loadRelatedXMLDoc(gPBI(iSID).concat('/ActorFL.xml'), 'getActorFilm()', 'Loading Film Related...');
		}
		else{
			window.setTimeout('showActorFilm()',iTimeout);
		}
	}
}


//---------------------------------------------------------------------------------------



function toUpper(sInput){
	sInput=sInput.toUpperCase()
	var sOutput='',sTemp;
	var i=0, j=0;
	for (var i=0;i<sInput.length;i++){
		if (sInput.charAt(i)+sInput.charAt(i+1)=='&#'){
			sTemp=sInput.substring(i+2,sInput.length);
			j=sTemp.indexOf(';');
			if (j>4){
				sOutput+=sInput.charAt(i);					
			}
			else{
				sTemp=sTemp.substring(0,j)
				switch(sTemp){
					case '225': {sOutput+='&#193;';break;}		//a'
					case '224': {sOutput+='&#192;';break;}		//a`
					case '7843': {sOutput+='&#7842;';break;}	//a?
					case '227': {sOutput+='&#195;';break;}		//a~
					case '7841': {sOutput+='&#7840;';break;}	//a.
					case '226': {sOutput+='&#194;';break;}		//a^
					case '7845': {sOutput+='&#7844;';break;}	//a^'
					case '7847': {sOutput+='&#7846;';break;}	//a^`
					case '7849': {sOutput+='&#7848;';break;}	//a^?
					case '7851': {sOutput+='&#7850;';break;}	//a^~
					case '7853': {sOutput+='&#7852;';break;}	//a^.
					case '259': {sOutput+='&#258;';break;}		//a(
					case '7855': {sOutput+='&#7854;';break;}	//a('
					case '7857': {sOutput+='&#7856;';break;}	//a(`
					case '7859': {sOutput+='&#7858;';break;}	//a(?
					case '7861': {sOutput+='&#7860;';break;}	//a(~
					case '7863': {sOutput+='&#7862;';break;}	//a(.
					case '273': {sOutput+='&#272;';break;}		//dd
					case '233': {sOutput+='&#201;';break;}		//e'
					case '232': {sOutput+='&#200;';break;}		//e`
					case '7867': {sOutput+='&#7866;';break;}	//e?
					case '7869': {sOutput+='&#7868;';break;}	//e~
					case '7865': {sOutput+='&#7864;';break;}	//e.
					case '234': {sOutput+='&#202;';break;}		//e^
					case '7871': {sOutput+='&#7870;';break;}	//e^'
					case '7873': {sOutput+='&#7872;';break;}	//e^`
					case '7875': {sOutput+='&#7874;';break;}	//e^?
					case '7877': {sOutput+='&#7876;';break;}	//e^~
					case '7879': {sOutput+='&#7878;';break;}	//e^.
					case '237': {sOutput+='&#205;';break;}		//i'
					case '236': {sOutput+='&#204;';break;}		//i`
					case '7881': {sOutput+='&#7880;';break;}	//i?
					case '297': {sOutput+='&#296;';break;}		//i~
					case '7883': {sOutput+='&#7882;';break;}	//i.
					case '243': {sOutput+='&#211;';break;}		//o'
					case '242': {sOutput+='&#210;';break;}		//i`
					case '7887': {sOutput+='&#7886;';break;}	//o?
					case '245': {sOutput+='&#213;';break;}		//o~
					case '7885': {sOutput+='&#7884;';break;}	//o.
					case '244': {sOutput+='&#212;';break;}		//o^
					case '7889': {sOutput+='&#7888;';break;}	//o^'
					case '7891': {sOutput+='&#7890;';break;}	//o^`
					case '7893': {sOutput+='&#7892;';break;}	//o^?
					case '7895': {sOutput+='&#7894;';break;}	//o^~
					case '7897': {sOutput+='&#7896;';break;}	//o^.
					case '417': {sOutput+='&#416;';break;}		//o*
					case '7899': {sOutput+='&#7898;';break;}	//o*'
					case '7901': {sOutput+='&#7900;';break;}	//o*`
					case '7903': {sOutput+='&#7902;';break;}	//o*?
					case '7905': {sOutput+='&#7904;';break;}	//o*~
					case '7907': {sOutput+='&#7906;';break;}	//o*.
					case '250': {sOutput+='&#218;';break;}		//u'
					case '249': {sOutput+='&#217;';break;}		//u`
					case '7911': {sOutput+='&#7910;';break;}	//u?
					case '361': {sOutput+='&#360;';break;}		//u~
					case '7909': {sOutput+='&#7908;';break;}	//u.
					case '432': {sOutput+='&#431;';break;}		//u*
					case '7913': {sOutput+='&#7912;';break;}	//u*'
					case '7915': {sOutput+='&#7914;';break;}	//u*`
					case '7917': {sOutput+='&#7916;';break;}	//u*?
					case '7919': {sOutput+='&#7918;';break;}	//u*~
					case '7921': {sOutput+='&#7920;';break;}	//u*.
					case '253': {sOutput+='&#221;';break;}		//y'
					case '7923': {sOutput+='&#7922;';break;}	//y`
					case '7927': {sOutput+='&#7926;';break;}	//y?
					case '7929': {sOutput+='&#7928;';break;}	//y~
					case '7925': {sOutput+='&#7924;';break;}	//y.
					default: {sOutput+='&#'+sTemp+';';break;}
				}
				i+=j+2;
			}
		}
		else{
			sOutput+=sInput.charAt(i);
		}
	}
	return sOutput;
}
