﻿var tempID; 
var runID;
// Start Search Draw
function start (){
	document.all.results.innerHTML = "";
	drawResults(0);
}

// Initial Animation
function drawResults (loop){
	if (DL > 0){
		if (loop >= 1) {
			last = loop -1;
			document.all['R'+ last].style.backgroundColor=SCB(last);
		}

		if (loop < DL) {
			id = 'R'+loop;
			document.all.results.innerHTML += '<DIV ID="'+id+'" STYLE="position:relative; text-align: left; width: 400; height:25; background-color: #E6BF46; font-family: Verdana; font-size: 11px; overflow: hidden; z-index:1001"></DIV>';
			count = loop +1;
			setTimeout("drawResults(count)",20);

		} else {
			insertData(0);
			return(1);
		}
	} else {
		document.all.results.innerHTML += '<BR><CENTER>無資料!!</CENTER><BR><BR>';
	}
}

// Secondary anim + insert data
function insertData(loop){
	if (loop >= 1) {
		last = loop -1;
		document.all['R'+ last].style.backgroundColor=SCB(last);
	}

	if (loop < DL) {
		id = 'R'+loop;
		document.all[id].style.backgroundColor='#E6BF46';
		createShortResult(id,loop);
		count = loop +1;
		setTimeout("insertData(count)",20);

	} else {
		return(1);
	}
}

// Mini Search results 
function createShortResult(id,loop){
	detail = 'detail'+id;
	mini = 'mini'+id;
	document.all[id].innerHTML =	
		'<DIV ID="'+mini+'" STYLE="position:absolute; left:0; top:0; width:400; height:20; z-index:1010; text-align: left; cursor: help;" onmouseover="style.backgroundColor=\'#FEE9F2\'" onmouseout="style.backgroundColor=SCB(\''+loop+'\')" onclick="info(\''+loop+'\')">'+
			'<DIV STYLE="position:absolute: top:0; left:0; width:25;  z-index:1005;text-align: left; overflow:hidden;"><span class="second-l" valign="middle">'+ data[loop][0] +'.</span></DIV>' +
			'<DIV STYLE="position:absolute; top:0; left:25; width:195;  z-index:1005;text-align: left; overflow:hidden;"><font class="second-l" >'+ data[loop][1] +'</font></DIV>' +
			'<DIV STYLE="position:absolute; top:0; left:220; width:65;  z-index:1005; overflow:hidden;"><font class="second-l" color="#CC0000">'+ data[loop][2] +'</font></DIV>' +
			'<DIV STYLE="position:absolute; top:3; left:285; width:150;  z-index:1005;"><font class="small"  style="font-size: 12px; " color="#FF6600">'+ data[loop][3] +'</font></DIV>'+
		'</DIV>'+
		'<DIV ID="'+detail+'" STYLE="position:absolute; top:0; left:0; width:400;  z-index:1006;"></DIV>';
	
	return(1);
}
// 愛的鼓勵
function setCheer (intID){
	if(confirm("你要給本篇留言一個愛的鼓勵嗎？" )){
		frames["editFrame"].location.href="hot_frame.asp?cheerID=" + intID;
	 }
}

// Show extended info
function info (uin,show){
	
	
	id = 'R'+uin;
	detail = 'detail'+id;
	mini = 'mini'+id;
//	var DivHeight = 325  ;
	var DivHeight = document.all[id].offsetHeight+60; 

	if (tempID){		
			if(tempID != uin && show!=1){				 
				runID = tempID;
			//setTimeout("info (runID,1)",4000) ; 
			}
		}  

	if (show){
		 if(tempID == uin){tempID = 0;}
		infoResizeDown(id,DivHeight,uin);
		
		return(0);
	} else {
		tempID = uin;
		document.all[mini].style.visibility = 'hidden';

		document.all[id].style.border='E6BF46';
		document.all[id].style.borderStyle='solid'; 
		document.all[id].style.borderWidth = 1; 

		detail = 'detail'+id;
	 //	frames["editFrame"].location.href="hot_frame.asp?ID=" + data[uin][7]	;
		document.all[detail].innerHTML = ''+
			'<DIV style="position:absolute;width:100%;height:20;cursor:hand;background-color:#F4E7C1;z-index:2000" onclick="info(\''+uin+'\',1);">&nbsp;<font class="small" ><B>'+data[uin][0]+'</B>. <font class="second-l" >'+ data[uin][1] +'</font>'+
			'<DIV STYLE="position:absolute; left:380; width:50; z-index:1005; overflow:hidden;" ><img src="images/close.gif" alt="關閉"></DIV>' +
			'</DIV> '+
			'<DIV STYLE="position:absolute; top:25; left:5; width:150;  z-index:1005; overflow:hidden;"><font class="small" color="#1C91FF">作者：</font><font class="small" color="#000000">'+ data[uin][2] +'</font></DIV>' +
			'<DIV STYLE="visibility:hidden;position:absolute; top:45; left:5; width:400;  z-index:1005; overflow:hidden;"><font class="small" color="#CC0000">人氣點閱數：</font><font class="small" color="#000000">'+ data[uin][5] +'</font>　　<font class="small" color="#CC0000">本篇得到 </font><font class="small" color="#000000"> '+ data[uin][6] +' </font><font class="small" color="#CC0000"> 次愛的鼓勵</font>　　<font class="small" color="#C91FF" onclick="setCheer ('+ data[uin][7]+');" style="cursor:hand;">【給愛的鼓勵，Go!】</font></DIV>' +
			'<DIV STYLE="position:absolute;top:25;left:220;width:180 ;z-index:1005; overflow:hidden;" ><font class="small" color="#1C91FF">發表日期：</font><font class="small" color="#000000">'+ data[uin][3] +'</font></DIV>'+'</DIV>'+	

			'<div id="ListLayer" align="left"  style="top:45px;left:2px;width:394px;height:237px;z-index:3;position:absolute;overflow:auto;background-color:#fff9ee;border:1px solid #E6BF46;" >'+
			data[uin][4]+'</DIV> ' 
			  
			//'<DIV STYLE="position:absolute;top:280;height:20;left:285;width:100 ;z-index:1005; overflow:hidden;" ><font class="small" color="#CC0000">From：</font><font class="small" color="#999999">'+ data[uin][5] +'</font></DIV>'+'</DIV>';
			
			
			//' <DIV style="position:absolute;width:420;height:15;cursor:hand;background-color:#F4E7C1;z-index:2000" onclick="info(\''+uin+'\',1);">&nbsp;<font class="small" ><B>'+data[uin][0]+'.</B>'+
			//'<DIV STYLE="position:absolute; top:0; left:25; width:220;  z-index:1005;text-align: left; overflow:hidden;"><font class="second-l" >'+ data[uin][1] +'</font></DIV>' +
			//'<DIV STYLE="position:absolute; top:0; left:245; width:40;  z-index:1005; overflow:hidden;"><font class="second-l" color="#CC0000">'+ data[uin][2] +'</font></DIV>' +
			//'<DIV STYLE="position:absolute; top:3; left:285; width:100;  z-index:1005;"><font class="small" color="#FF6600">'+ data[uin][3] +'</font></DIV>'+
			//<DIV STYLE="position:absolute;top:0;left:285;width:150"><font class="small" >From:'+data[uin][5]+'</font></DIV>'+'</DIV>'+
			//'<DIV STYLE="position:absolute;top:35;width:400"><font class="small" >'+ data[uin][4]+'</font>'+
			//'</DIV> '+
			//document.all[detail].innerHTML = ' '+
			//'<DIV style="position:absolute;width:420;height:15;cursor:hand;background-color:#F4E7C1;z-index:2000" onclick="info(\''+uin+'\',1);">&nbsp;<font class="small" ><B>'+data[uin][0]+'.</B>'+
			//'</DIV> '+
			//'<div id="ListLayer" align="left"  style="position:absolute;width:120px;height:150px;z-index:3;left:20px;top:25px;overflow:auto;background-color:#fff9ee;border:1px solid #000000;" >'+
			//data[uin][4]+
			//'</DIV> ';	
		
		 		DivHeight = document.all[id].offsetHeight+60;

		
			 
		infoResizeUp(id,5,0,DivHeight);
			 
		
		return(1);
	}
	
}

// Odd \ even colors
function SCB(x){
	if (( x % 2 ) == 0){
		//return('#EBEBEB');
		return('#FFFFFF');
	} else {
		//return('#F4F4F4');
		return('#FFFFFF');
	}

}

// Animation of drop down of extended info
function infoResizeUp(id,by,speed,DivHeight){
	//var UID =  id.replace("R","")
//	var DivHeight = 325 ; // data[UID][4].length * 0.8; 
	if (by < DivHeight){
		count = by+28-speed;
		 
		if (speed <=10) speed2 = speed+2;
		document.all[id].style.height = count;
		setTimeout("infoResizeUp(id,count,speed2,DivHeight)",20);
	} else {
		
		document.all[id].style.height= DivHeight;
	}
	 
	return(1);
	
}

// Animation of drop back up of extended info
function infoResizeDown(id,by,uin){
	
	myUin = uin;
	if (by > 15){
		newBy = by - 10;
		document.all[id].style.height = by;
		setTimeout("infoResizeDown(id,newBy,myUin)",1);
	} else {
		document.all[id].style.height=25;
		document.all[id].style.borderWidth = 0; 
		createShortResult(id,uin);
		return(1);
	}
	 
}

// Minimize search reults ready for new data
function shrinkWrap (loop){
	if (loop != 0) {
		count = loop -1;
		id = 'R'+count;
		document.all[id].style.height=0;
		setTimeout("shrinkWrap(count)",20);
	
	} else {
		document.all.results.innerHTML = "";
		return(1);
	}
}

 
