var nowopenedselectbox = "";
var mouseposition = "";
function selectthisvalue(thisid,thisindex,thisvalue,thisstring) {
var objid = thisid;
var nowindex = thisindex;
var valuestring = thisstring;
var sourceobj = document.getelementbyid(objid);
var nowselectedvalue = document.getelementbyid(objid+"selectboxoptionvalue"+nowindex).value;
hideoptionlayer(objid);
if (sourceobj) sourceobj.value = nowselectedvalue;
settingvalue(objid,valuestring);
selectboxfocus(objid);
if (sourceobj.onchange) sourceobj.onchange();
}
function settingvalue(thisid,thisstring) {
var objid = thisid;
var valuestring = thisstring;
var selectedarea = document.getelementbyid(objid+"selectboxselectedvalue");
if (selectedarea)
{
if(navigator.appname.indexof("explorer") > -1)
selectedarea.innertext = valuestring;
else
selectedarea.textcontent = valuestring;
}
}
function viewoptionlayer(thisid) {
var objid = thisid;
var optionlayer = document.getelementbyid(objid+"selectboxoptionlayer");
if (optionlayer) optionlayer.style.display = "";
nowopenedselectbox = objid;
setmouseposition("inbox");
}
function hideoptionlayer(thisid) {
var objid = thisid;
var optionlayer = document.getelementbyid(objid+"selectboxoptionlayer");
if (optionlayer) optionlayer.style.display = "none";
}
function setmouseposition(thisvalue) {
var positionvalue = thisvalue;
mouseposition = positionvalue;
}
function clickmouse() {
if (mouseposition == "out") hideoptionlayer(nowopenedselectbox);
}
function selectboxfocus(thisid) {
var objid = thisid;
var obj = document.getelementbyid(objid + "selectboxselectedvalue");
obj.classname = "selectboxselectedareafocus";
obj.focus();
}
function selectboxblur(thisid) {
var objid = thisid;
var obj = document.getelementbyid(objid + "selectboxselectedvalue");
obj.classname = "selectboxselectedarea";
}
function makeselectbox(thisid, imgsrc) {
var downarrowsrc = imgsrc + "news/templates/images/down.gif";
var downarrowsrcwidth = 16;
var optionheight = 16;
var optionmaxnum = 5;
var optioninnerlayerheight = "";
var objid = thisid;
var obj = document.getelementbyid(objid);
var selectboxwidth = parseint(obj.style.width);
var selectboxheight = parseint(obj.style.height);
if (obj.options.length > optionmaxnum) optioninnerlayerheight = "height:"+ (optionheight * optionmaxnum) + "px";
newselect = "
";
newselect += " ";
newselect += " | ";
newselect += "
";
newselect += " ";
newselect += " | ";
newselect += "
";
newselect += " ";
newselect += " ";
newselect += " ";
newselect += " ";
for (var i=0 ; i < obj.options.length ; i++) {
var nowvalue = obj.options[i].value;
var nowtext = obj.options[i].text;
newselect += " ";
newselect += " " + nowtext + " | ";
newselect += " ";
newselect += " ";
}
newselect += " ";
newselect += " ";
newselect += " | ";
newselect += "
";
newselect += "
";
newselect += "
";
newselect += " ";
newselect += " ";
newselect += " ";
newselect += " ";
newselect += " | ";
newselect += " | ";
newselect += " ";
newselect += " ";
newselect += " | ";
newselect += "
";
newselect += "
";
document.write(newselect);
var haveselectedvalue = false;
for (var i=0 ; i < obj.options.length ; i++) {
if (obj.options[i].selected == true) {
haveselectedvalue = true;
settingvalue(objid,obj.options[i].text);
}
}
if (!haveselectedvalue) settingvalue(objid,obj.options[0].text);
}
document.onmousedown = clickmouse;