

var imgButtonUId = 0;	//色変え用

function getImgButtonHtmlBase(caption,type,width,href,target,helpId,tabIndex,color) {
	var forceColor;
	if(tabIndex != undefined && color != undefined){
		forceColor = color;
	}


	var html = "";
	html = html + "<span lang='ja' style='width:"+width+"' id='imgbtn_"+ imgButtonUId +"' ";
	if (helpId != '' && helpId != undefined) {
		if(!(forceColor)){
			html = html + "onmouseover='performImgBtnMsOver(\""+imgButtonUId+"\");help.show(\""+helpId+"\");return false' ";
			html = html + "onmouseout='performImgBtnMsOut(\""+imgButtonUId+"\");help.hide();return false' ";
		}else{
			html = html + "style='background-color:"+forceColor+"'";
			html = html + "onmouseover=';help.show(\""+helpId+"\");return false' ";
			html = html + "onmouseout='help.hide();return false' ";		
		}
		html = html + "onmousedown='return false' ";
		html = html + "onmouseup='return false' ";
		html = html + "onmousemove='return false' ";
	} else {
		if(!(forceColor)){
			html = html + "onmouseover='performImgBtnMsOver(\""+imgButtonUId+"\")' ";
			html = html + "onmouseout='performImgBtnMsOut(\""+imgButtonUId+"\")' ";
		}else{
			html = html + "style='background-color:"+forceColor+"'";
		}
		html = html + "onmousedown='return false' ";
		html = html + "onmouseup='return false' ";
		html = html + "onmousemove='return false' ";
	}
	html = html + ">";

	html = html + "<img src='"+"img/Button/btnStd_"+type+"_L.gif"+"'/>";
	html = html + "<span style='width:"+ (width-20) +"px;padding-bottom:2px;text-align:center;position:absolute;font-size:12px;height:15px;border-top:solid 3px #999999;border-bottom:solid 3px #999999'>";
	html = html + "<a style='color:#000000;text-decoration:none;' href='"+href+"'  ";//このhrefはsaniしない
	html = html + "target='"+target+"'  ";

	if (tabIndex != undefined) {
		html = html + "tabindex='"+tabIndex+"'>";
	} else {
		html = html + ">";
	}
	var btnSpacerHeight = 12;
	try{
		//MSIE 7.0で分岐する
		if(navigator.userAgent.indexOf("MSIE 7.0")!=-1){
			btnSpacerHeight = $res("imgButtonSpacerHeightIE7");
    	}else{
    		btnSpacerHeight = $res("imgButtonSpacerHeight");
    	}
		//コメントアウト
		//btnSpacerHeight = $res("imgButtonSpacerHeight");
	}catch(e){
		btnSpacerHeight = 12;
	}
	
	html = html + caption + "</a>";
	html = html + "<img src='img/spacer.gif' width='1px' height='"+btnSpacerHeight+"px'/>";
	html = html + "</span>";
	html = html + "<img src='img/spacer.gif' width='"+ (width-20) +"' height='1px'/>";
	html = html + "<img src='"+"img/Button/btnStd_"+sani(type)+"_R.gif"+"'/>";
	html = html + "</span>";

	imgButtonUId++;

	return html;
}


function getImgButtonHtml(caption,type,width,functionOnClick,helpId,tabIndex) {

	if (tabIndex == undefined) {
		tabIndex = -1;
	}
	if (helpId == undefined) {
		helpId = "";
	}

	var html = getImgButtonHtmlBase(caption,type,width,"javascript:"+functionOnClick,'_self',helpId,tabIndex);
	return html;
}

function getImgButtonHtmlWithTarget(caption,type,width,href,target,tabIndex,color) {
	var html = getImgButtonHtmlBase(caption,type,width,href,target,'',tabIndex,color);
	return html;
}


function getImgButtonHtmlWithTarget2(caption,type,width,href,target,tabIndex,color) {
	var html = getImgButtonHtmlBase(caption,type,width,'javascript:openLinkedWindow("'+href+'","'+target+'");','_self','',tabIndex,color);
	return html;
}

function openLinkedWindow(link,name){
	var w = open(link,name);
	w.focus();
}


function performImgBtnMsOver(idx){
	var objImgBtn = $("imgbtn_"+idx);
	if(objImgBtn != null){
		objImgBtn.style.backgroundColor = "#FFFFDE";
	}
}

function performImgBtnMsOut(idx){
	var objImgBtn = $("imgbtn_"+idx);
	if(objImgBtn != null){
		objImgBtn.style.backgroundColor = "";
	}
}







/*
function ImgButton(parentDiv,caption,type,width,tabIndex) {
	this.parentDiv = parentDiv;
	this.type = type;	//round or square
	this.caption = caption;	
	this.width = width;
	this.tabIndex = tabIndex;	

	this.init = function(){

		var html = "";
		html = html + "<table border='0' cellpadding='0' cellspacing='0' width='"+this.width +"'>";
		html = html + "<tr>";
		html = html + "<td width='10'>";
		html = html + "<img src='"+"img/Button/btnStd_"+this.type+"_L.gif"+"'/>";
		html = html + "</td>";
		html = html + "<td align='center' valign='middle' style='font-size:12px;background-repeat:x-repeat;background-image:url(img/Button/btnStd_"+this.type+"_M.gif)'>";
		html = html + this.caption;
		html = html + "</td>";
		html = html + "<td width='10'>";
		html = html + "<img src='"+"img/Button/btnStd_"+this.type+"_R.gif"+"'/>";
		html = html + "</td>";
		html = html + "</tr>";
		html = html + "</table>";

		this.objBtnSpan = document.createElement("span");
//		this.objBtnSpan.style.position = "relative";
		this.objBtnSpan.className = "cursorHand";
		this.objBtnSpan.style.width = this.width;
		this.objBtnSpan.innerHTML = html;

		this.objBtnSpan.onmouseover = function(){
			this.objBtnSpan.style.backgroundColor = "#FFFFDE";
		}

		this.objBtnSpan.onmouseout = function(){
			this.objBtnSpan.style.backgroundColor = "#FFFFFF";
		}

		if(this.tabIndex != undefined){
			this.objBtnSpan.tabIndex = this.tabIndex;
		}

		this.parentDiv.appendChild(this.objBtnSpan);
	}	
	this.init();

	return this.objBtnSpan;
}
*/