var btnCount = 5;
var staCount = 2;
var btnImages = new Array();
function btnMouseOut(img)
{
	document.images[img].src = btnImages[img.substring(img.indexOf('mbtn')+4,img.length)][0].src;
};
function btnMouseOver(img)
{
	document.images[img].src = btnImages[img.substring(img.indexOf('mbtn')+4,img.length)][1].src;
};
function btnMouseDown(img)
{
//	document.images[img].src = btnImages[img.substring(img.indexOf('mbtn')+4,img.length)][2].src;
};
var timerID = null;
var timerOn = false;
var timeCount = 1000;
var mnuCount = 1;
function showLayer(btntd,btnmnu,bdir,mdir,mpos,xoffset,yoffset)
{
	var td,layer,imgs;
	if (btnmnu==0) return;
	td = document.getElementById(btntd);
	layer = document.getElementById(btnmnu);
	for (i=0; i<2; i++) {
	  imgs = document.getElementById('mm'+i);
	  if (parent.document.getElementById("XHPlayer").RecordType == i) 
      imgs.border = "3px";
	  else
	    imgs.border = "0";
	}		
	if (bdir==0)
	{
		switch(mpos)
		{
			case 0:
			layer.style.left = xoffset;
			break;
			case 1:
			layer.style.left = td.offsetWidth/2 + xoffset;
			break;
			case 2:
			layer.style.left = td.offsetWidth+xoffset;
			break;
		}
		if (mdir==0)
			layer.style.top = td.offsetHeight+yoffset;
		else
			layer.style.top = -layer.offsetHeight-yoffset;
	}
	else
	{
		switch(mpos)
		{
			case 0:
			layer.style.top = yoffset;
			break;
			case 1:
			layer.style.top = td.offsetHeight/2 + yoffset;
			break;
			case 2:
			layer.style.top = td.offsetHeight+yoffset;
			break;
		}
		if (mdir==0)
			layer.style.left = td.offsetWidth+xoffset;
		else
			layer.style.left = -layer.offsetWidth-xoffset;
	}
	layer.style.visibility = "visible";
};
function hideLayer(btnmnu)
{
	var layer;
	if (btnmnu==0) return;
	layer = document.getElementById(btnmnu);
	layer.style.visibility = "hidden";
};
function hideAllLayers()
{
	for (i=0; i<mnuCount; i++)
		hideLayer("mbtn_mnu"+i);
};
function startTime()
{
	if (timerOn == false)
	{
 		timerID=setTimeout( "hideAllLayers()" , timeCount);
 		timerOn = true;
 	}
};
function stopTime()
{
	if (timerOn)
	{
 		clearTimeout(timerID);
 		timerID = null;
 		timerOn = false;
 	}
};
function get_menu_tb_css(iMIndex,bTbAutosize,iTbWidth,iTbHeight,bTbBgColor,TbBgColor,bTbBgImage,strTbBgImage,bTbBrSetParts,iTbBrSize,TbBrColor,strTbBrStyle,bTbBrLeft,iTbBrSizeLeft,TbBrColorLeft,strTbBrStyleLeft,bTbBrRight,iTbBrSizeRight,TbBrColorRight,strTbBrStyleRight,bTbBrTop,iTbBrSizeTop,TbBrColorTop,strTbBrStyleTop,bTbBrBottom,iTbBrSizeBottom,TbBrColorBottom,strTbBrStyleBottom,imgFolder)
{
str=".mnu"+iMIndex+"_tb {";
if(!bTbAutosize)
	str+="width:"+iTbWidth+"px;height:"+iTbHeight+"px;";
if(bTbBgColor)
	str+="background-color:#"+TbBgColor+";";
if(bTbBgImage)
	str+="background-image:url("+imgFolder+"/"+strTbBgImage+");"
if(!bTbBrSetParts)
	str+="border:"+iTbBrSize+"px #"+TbBrColor+" "+strTbBrStyle+";";
else{
	if(bTbBrLeft) str+="border-left:"+iTbBrSizeLeft+"px #"+TbBrColorLeft+" "+strTbBrStyleLeft+";";
	if(bTbBrRight) str+="border-right:"+iTbBrSizeRight+"px #"+TbBrColorRight+" "+strTbBrStyleRight+";";
	if(bTbBrTop) str+="border-top:"+iTbBrSizeTop+"px #"+TbBrColorTop+" "+strTbBrStyleTop+";";
	if(bTbBrBottom) str+="border-bottom:"+iTbBrSizeBottom+"px #"+TbBrColorBottom+" "+strTbBrStyleBottom+";";
};
str+="} ";
return str;
};
function get_menu_line_css(iMIndex,SeperateColor)
{
str=".mnu"+iMIndex+"_line {height:0px;background-color:#"+SeperateColor+"} ";
return str;
};
function get_menu_td_css(bNormal,iMIndex,iTdIndex,strTdHorizontal,strTdVertical,iTdPadding,fcolor,ffamily,fsize,fitalic,fbold,funderline,iTdBrSize,TdBrColor,strTdBrStyle,bTdBgColor,TdBgColor,bTdBgImage,strTdBgImage,imgFolder)
{
var sLink;
sLink="{display:block;";
sLink+="text-align:"+strTdHorizontal+";vertical-align:"+strTdVertical+";padding:"+iTdPadding+";";
sLink+="color:#"+fcolor+";font-family:"+ffamily+";font-size:"+fsize+";";
if(fitalic) sLink+="font-style:italic;"; else sLink+="font-style:normal;";
if(fbold) sLink+="font-weight:bold;"; else sLink+="font-weight:normal;";
if(funderline) sLink+="text-decoration:underline;"; else sLink+="text-decoration:none;";
sLink+="border:"+iTdBrSize+"px #"+TdBrColor+" "+strTdBrStyle+";";
if(bTdBgColor) sLink+="background-color:#"+TdBgColor+";";
if(bTdBgImage) sLink+="background-image:url("+imgFolder+"/"+strTdBgImage+");";
sLink+="} ";
if(bNormal) str=".mnu"+iMIndex+"_td"+iTdIndex+" a:link "+sLink+".mnu"+iMIndex+"_td"+iTdIndex+" a:visited "+sLink;
else str=".mnu"+iMIndex+"_td"+iTdIndex+" a:hover "+sLink+".mnu"+iMIndex+"_td"+iTdIndex+" a:active "+sLink;
return str;
};
function get_menu_tb_td(iMIndex,iTdIndex,bSetAsDivision,strTdLink,strTdTarget,strTdIcon,strTdText,iTdIconAlign,imgFolder)
{
if(bSetAsDivision) {
	str="<tr><td class=\"mnu"+iMIndex+"_line\"></td></tr>";
	return str;
};
str="<tr><td nowrap valign=\"center\" class=\"mnu"+iMIndex+"_td"+iTdIndex+"\" onClick=\""+strTdLink+"\" >";
str+="<a href=\"#\">";
//str+="<a href=\""+"\"";
//if(strTdTarget.length>0) str+=" target=\""+strTdTarget+"\"";
//str+=">";
id = "mm"+iTdIndex;
if(strTdIcon.length>0){
if(iTdIconAlign==0) str+="<img  id=\""+id+"\" src=\""+imgFolder+"/"+strTdIcon+"\" border=\"0\">   "+strTdText;
else if(iTdIconAlign==1) str+=strTdText+"<img id=\""+id+"\" src=\""+imgFolder+"/"+strTdIcon+"\" border=\"0\">";
else if(iTdIconAlign==2) str+="<img id=\""+id+"\" src=\""+imgFolder+"/"+strTdIcon+"\" border=\"0\"><br>"+strTdText;
else if(iTdIconAlign==3) str+=strTdText+"<br><img id=\""+id+"\" src=\""+imgFolder+"/"+strTdIcon+"\" border=\"0\">";
}
else str+=strTdText;
str+="</a></td></tr>";
return str;
};
function get_menu(iMIndex,imgFolder)
{
str="<div style=\"position:relative;\">";
str+="<div id=\"mbtn_mnu"+iMIndex+"\" style=\"position:absolute;visibility:hidden;z-index:100;\">";
if(iMIndex==0) {
str+="<style type=\"text/css\">";
str+=get_menu_tb_css(0,true,"0","0",true,"FFFFFF",false,"",false,"1","C0C0C0","solid",false,"0","FFFFFF","solid",false,"0","FFFFFF","solid",false,"0","FFFFFF","solid",false,"0","FFFFFF","solid",imgFolder);
str+=get_menu_line_css(0,"C0C0C0");
str+=get_menu_td_css(true,0,0,"Left","Middle","5","808080","Arial","12",false,false,false,"0","000000","solid",false,"FFFFFF",false,"",imgFolder);
str+=get_menu_td_css(false,0,0,"Left","Middle","5","000000","Arial","12",false,false,false,"0","000000","solid",true,"C0C0C0",false,"",imgFolder);
str+=get_menu_td_css(true,0,1,"Left","Middle","5","808080","Arial","12",false,false,false,"0","000000","solid",false,"FFFFFF",false,"",imgFolder);
str+=get_menu_td_css(false,0,1,"Left","Middle","5","000000","Arial","12",false,false,false,"0","000000","solid",true,"C0C0C0",false,"",imgFolder);
str+="</style>";
str+="<table class=\"mnu"+iMIndex+"_tb\" cellspacing=\"2\" cellpadding=\"0\" onMouseOver=\"stopTime();\" onMouseOut=\"startTime();\">";str+=get_menu_tb_td(0,0,false,"ChangeRecordType(0)","","normal-recording.gif","Normal Recordings",0,imgFolder);
str+=get_menu_tb_td(0,1,false,"ChangeRecordType(1)","","event-recording.gif","Event Recordings",0,imgFolder);
str+="</table>";
};
str+="</div></div>";
return str;
};
function get_menutd(iIndex,iMIndex,bOver,bdir,mdir,mpos,xoffset,yoffset,iWidth,iHeight,sHint,sLink,sTarget,imgFolder) {
str="<td style=\"padding-right:0px\" id=\"mbtn_td"+iIndex+"\">";
str+=get_menu(iMIndex,imgFolder);
str+="<a ";
if (bOver)
	str+="onMouseOver=\"btnMouseOver('mbtn"+iIndex+"');hideAllLayers();"
else
	str+="onMouseOver=\"btnMouseOver('mbtn"+iIndex+"');hideAllLayers();\" onclick=\"";
str+="showLayer('mbtn_td"+iIndex+"','mbtn_mnu"+iMIndex+"',"+bdir+","+mdir+","+mpos+","+xoffset+","+yoffset+");stopTime();\"";
str+=" onMouseOut=\"btnMouseOut('mbtn"+iIndex+"');startTime();\" onMouseDown=\"btnMouseDown('mbtn"+iIndex+"');\" href=\""+sLink+"\"";
if (sTarget.length >0)
	str+=" target=\""+sTarget+"\"";
str+=">";
str+="<img src=\""+imgFolder+"/mbtn"+iIndex+"_0.gif\" name=mbtn"+iIndex+" border=0 width=\""+iWidth+"\" height=\""+iHeight+"\" alt=\""+sHint+"\">";
str+="</a></td>";
return str;
};
function gen_td(iIndex,bOver,sLink,sTarget,iWidth,iHeight,sHint,imgFolder) {
str="<td style=\"padding-right:0px\" id=\"mbtn_td"+iIndex+"\">";
str+="<a ";
str+="onMouseOver=\"btnMouseOver('mbtn"+iIndex+"');"
str+="hideAllLayers();stopTime();\" ";
str+="onMouseOut=\"btnMouseOut('mbtn"+iIndex+"');startTime();\" onMouseDown=\"btnMouseDown('mbtn"+iIndex+"');\" href=\""+sLink+"\"";
if (sTarget.length >0)
    str+="onClick=\""+sTarget+"\"";
//	str+=" target=\""+sTarget+"\"";
str+=">";
str+="<img src=\""+imgFolder+"/mbtn"+iIndex+"_0.gif\" name=mbtn"+iIndex+" border=0 width=\""+iWidth+"\" height=\""+iHeight+"\" alt=\""+sHint+"\">";
str+="</a></td>";
return str;
};
function get_table(bHor,imgFolder) {
str="<table id=\"mbtn_tb\" cellpadding=0 cellspacing=0 border=0>";
str+="<tr>";
str+=gen_td(0,true,"#","downloadBtnClick()","41","30","DOWNLOAD",imgFolder);
if (bHor==false) str+="</tr><tr>";
str+=get_menutd(1,0,true,0,0,0,3,3,"41","30","SELECT","JavaScript:void(null);","",imgFolder);
if (bHor==false) str+="</tr><tr>";
str+=gen_td(2,true,"#","deleteBtnClick()","41","30","DELETE",imgFolder);
if (bHor==false) str+="</tr><tr>";
str+=gen_td(3,true,"#","settingBtnClick()","41","30","SETTING.",imgFolder);
if (bHor==false) str+="</tr><tr>";
str+=gen_td(4,true,"#","refreshBtnClick()","41","30","CONNECT",imgFolder);
str+="</tr>";
str+="</table>";
return str;
};
function draw_buttons(imgFolder,divID,iPressed)
{
for (i= 0; i< btnCount; i++)
{
	btnImages[i] = new Array();
	for (j= 0; j< staCount; j++)
	{
		btnImages[i][j] = new Image();
		btnImages[i][j].src = imgFolder + '/mbtn' + i + '_' + j + '.gif';
	}
}
result=get_table(true,imgFolder);
document.write(result);
}