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) selectedArea.innerText = 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) {
    var downArrowSrc = "images/sj.gif";    //三角
    var downArrowSrcWidth = 16;    //宽
    var optionHeight = 18; // 高
    var optionMaxNum = 7; // 
    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  = "<div id='lm'><table id='" + objId + "selectBoxOptionLayer' cellpadding='0' cellspacing='0' border='0' style='position:absolute;z-index:100;display:none;' onMouseOver=\"viewOptionLayer('"+ objId + "')\" onMouseOut=\"setMousePosition('out')\">";
    newSelect += "    <tr>";
    newSelect += "        <td height='" + selectBoxHeight + "' style='cursor:hand;' onClick=\"hideOptionLayer('"+ objId + "')\"></td>";
    newSelect += "    </tr>";
    newSelect += "    <tr>";
    newSelect += "        <td height='1'></td>";
    newSelect += "    </tr>";
    newSelect += "    <tr>";
    newSelect += "        <td bgcolor='#000000'>";
    newSelect += "        <div class='selectBoxOptionInnerLayer' style='width:" + (selectBoxWidth-1) + "px;" + optionInnerLayerHeight + "'>";
    newSelect += "        <table cellpadding='0' cellspacing='0' border='0' width='100%' style='table-layout:fixed;word-break:break-all;'>";
    for (var i=0 ; i < obj.options.length ; i++) {
        var nowValue = obj.options[i].value;
        var nowText = obj.options[i].text;
        newSelect += "            <tr>";
        newSelect += "                <td onMouseOver=this.style.backgroundColor='#cccccc';return true;  onMouseOut=this.style.backgroundColor='537193';return true; bgcolor=#537193 height='" + optionHeight + "' class='selectBoxOption' onMouseOver=\"this.className='selectBoxOptionOver'\" onMouseOut=\"this.className='selectBoxOption'\" onClick=\"selectThisValue('"+ objId + "'," + i + ",'" + nowValue + "','" + nowText + "')\" style='cursor:hand;' >" + nowText + "</td>";
        newSelect += "                <input type='hidden' id='"+ objId + "SelectBoxOptionValue" + i + "' value='" + nowValue + "'>";
        newSelect += "            </tr>";
    }
    newSelect += "        </table>";
    newSelect += "        </div>";
    newSelect += "        </td>";
    newSelect += "    </tr>";
    newSelect += "</table>";
    newSelect += "<table cellpadding='0' cellspacing='1' border='0' bgcolor='#000000' onClick=\"viewOptionLayer('"+ objId + "')\" style='cursor:hand;'>";
    newSelect += "    <tr>";
    newSelect += "        <td style='padding-left:1px' bgcolor='#537193'>";
    newSelect += "        <table cellpadding='0' cellspacing='0' border='0'>";
    newSelect += "            <tr>";
    newSelect += "                <td><div id='" + objId + "selectBoxSelectedValue' class='selectBoxSelectedArea' style='width:" + (selectBoxWidth - downArrowSrcWidth - 4) + "px;height:" + (selectBoxHeight - 2) + "px;overflow:hidden;' onBlur=\"selectBoxBlur('" + objId + "')\" ></div></td>";
    newSelect += "                <td><img src='" + downArrowSrc + "' width='" + downArrowSrcWidth + "' border='0'></td>";
    newSelect += "            </tr>";
    newSelect += "        </table>";
    newSelect += "        </td>";
    newSelect += "    </tr>";
    newSelect += "</table></div>";
    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;


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function cs(){
if(document.myform.U_name.value==''){
alert('你的姓名不能为空');
return false;
}
if(document.myform.U_dw.value==''){
alert('请输入你所在的单位');
return false;
}
if(document.myform.U_tel.value==''){
alert('你的电话不能为空');
return false;
}
if(document.myform.U_mail.value==''){
alert('你的邮件不能为空');
return false;
}
if(document.myform.U_add.value==''){
alert('你的地址不能为空');
return false;
}
if(document.myform.U_user.value==''){
alert('你的登陆名称');
return false;
}
if(document.myform.U_pass.value==''){
alert('登入密码不能为空');
return false;
}
if(document.myform.U_pass.value.length<=5){
alert('登入密码必须大于六位数！');
return false;
}
if(document.myform.U_upwd.value==''){
alert('请再次输入登入密码');
return false;
}
if(document.myform.U_pass.value != document.myform.U_upwd.value){
alert('两次密码不一致');
return false;
}
return true;
}

function writeflashhtml( arg )
{
var parm = []
var _default_version = "8,0,24,0";
var _default_quality = "high";
var _default_align = "middle";
var _default_menu = "false";

for(i = 0; i < arguments.length; i ++)
{
parm[i] = arguments[i].split(' ').join('').split('=')
for (var j = parm[i].length-1; j > 1; j --){
parm[i][j-1]+="="+parm[i].pop();
}
switch (parm[i][0])
{
case '_version' : var _version = parm[i][1] ; break ; 
case '_swf' : var _swf = parm[i][1] ; break ; 
case '_base' : var _base = parm[i][1] ; break ; 
case '_quality' : var _quality = parm[i][1] ; break ; 
case '_loop' : var _loop = parm[i][1] ; break ; 
case '_bgcolor' : var _bgcolor = parm[i][1] ; break ; 
case '_wmode' : var _wmode = parm[i][1] ; break ; 
case '_play' : var _play = parm[i][1] ; break ; 
case '_menu' : var _menu = parm[i][1] ; break ; 
case '_scale' : var _scale = parm[i][1] ; break ; 
case '_salign' : var _salign = parm[i][1] ; break ; 
case '_height' : var _height = parm[i][1] ; break ; 
case '_width' : var _width = parm[i][1] ; break ; 
case '_hspace' : var _hspace = parm[i][1] ; break ; 
case '_vspace' : var _vspace = parm[i][1] ; break ; 
case '_align' : var _align = parm[i][1] ; break ; 
case '_class' : var _class = parm[i][1] ; break ; 
case '_id' : var _id = parm[i][1] ; break ; 
case '_name' : var _name = parm[i][1] ; break ; 
case '_style' : var _style = parm[i][1] ; break ; 
case '_declare' : var _declare = parm[i][1] ; break ; 
case '_flashvars' : var _flashvars = parm[i][1] ; break ; 
default :;
}
}
var thtml = ""
thtml += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + ((_version)?_version:_default_version) + "'"
if(_width) thtml += " width='" + _width + "'"
if(_height) thtml += " height='" + _height + "'"
if(_hspace) thtml += " hspace='" + _hspace + "'"
if(_vspace) thtml += " vspace='" + _vspace + "'"
if(_align) thtml += " align='" + _align + "'"
else thtml += " align='" + _default_align + "'"
if(_class) thtml += " class='" + _class + "'"
if(_id) thtml += " id='" + _id + "'"
if(_name) thtml += " name='" + _name + "'"
if(_style) thtml += " style='" + _style + "'"
if(_declare) thtml += " " + _declare
thtml += ">"
if(_swf) thtml += "<param name='movie' value='" + _swf + "'>"
if(_quality) thtml += "<param name='quality' value='" + _quality + "'>" 
else thtml += "<param name='quality' value ='" + _default_quality + "'>"
if(_loop) thtml += "<param name='loop' value='" + _loop + "'>"
if(_bgcolor) thtml += "<param name='bgcolor' value='" + _bgcolor + "'>"
if(_play) thtml += "<param name='play' value='" + _play + "'>"
if(_menu) thtml += "<param name='menu' value='" + _menu + "'>"
else thtml += "<param name='menu' value='" + _default_menu + "'>"
if(_scale) thtml += "<param name='scale' value='" + _scale + "'>"
if(_salign) thtml += "<param name='salign' value='" + _salign + "'>"
if(_wmode) thtml += "<param name='wmode' value='" + _wmode + "'>"
if(_base) thtml += "<param name='base' value='" + _base + "'>"
if(_flashvars) thtml += "<param name='flashvars' value='" + _flashvars + "'>"
thtml += "<embed pluginspage='http://www.macromedia.com/go/getflashplayer'"
if(_width) thtml += " width='" + _width + "'"
if(_height) thtml += " height='" + _height + "'"
if(_hspace) thtml += " hspace='" + _hspace + "'"
if(_vspace) thtml += " vspace='" + _vspace + "'"
if(_align) thtml += " align='" + _align + "'"
else thtml += " align='" + _default_align + "'"
if(_class) thtml += " class='" + _class + "'"
if(_id) thtml += " id='" + _id + "'"
if(_name) thtml += " name='" + _name + "'"
if(_style) thtml += " style='" + _style + "'"
thtml += " type='application/x-shockwave-flash'"
if(_declare) thtml += " " + _declare 
if(_swf) thtml += " src='" + _swf + "'"
if(_quality) thtml += " quality='" + _quality + "'"
else thtml += " quality='" + _default_quality + "'"
if(_loop) thtml += " loop='" + _loop + "'"
if(_bgcolor) thtml += " bgcolor='" + _bgcolor + "'"
if(_play) thtml += " play='" + _play + "'"
if(_menu) thtml += " menu='" + _menu + "'"
else thtml += " menu='" + _default_menu + "'"
if(_scale) thtml += " scale='" + _scale + "'"
if(_salign) thtml += " salign='" + _salign + "'"
if(_wmode) thtml += " wmode='" + _wmode + "'"
if(_base) thtml += " base='" + _base + "'"
if(_flashvars) thtml += " flashvars='" + _flashvars + "'"
thtml += "></embed>"
thtml += "</object>"
document.write(thtml)
}
