
//为select 末尾增加 option
function InsertLastOptionOfSelect( text,value,oSelect  )
{
	var oOption = document.createElement("OPTION");
	oOption.text=text;
	oOption.value=value;
	oSelect.add(oOption);
}


//清理 Slect中的内容
function ClearOptionOfSelect(oSelect)
{

	for (i=oSelect.length - 1 ;i>=0 ; i-- )
	{
		oSelect.remove(i);
	}

}

//查找selec中是否有此option
function FindOptionValueOfSelect(oSelect,v)
{
	for (i=oSelect.length - 1 ;i>=0 ; i-- )
	{
		if (oSelect.options[i].value == v)
			return true;
	}
	
	return false;
}

//删除指定位置的 option
function RemoveOptionOfSelect(oSelect,Postion) {
    if (oSelect.options.length>0) {
        oSelect.remove(Postion);
    }
}


//快速定位
function ChangeList(KeyValue,SelectList)
{

	for ( i = 0 ; i<= SelectList.length -1 ; i++ )
	{	
		if(SelectList.options[i].text.toUpperCase().indexOf(KeyValue.value.toUpperCase()) > -1)
		{
			SelectList.selectedIndex = i;
			SelectList.fireEvent("onchange")
				break;
		}
	}	
}

//快速定位并，触发联动
function ChangeListAndLinkage(KeyValue,SelectList)
{
    ChangeList(KeyValue,SelectList);
    SelectList.onchange();
}


Date.prototype.format = function(format) //author: meizz 
{ 
    var o = { 
    "M+" : this.getMonth()+1, //month 
    "d+" : this.getDate(), //day 
    "h+" : this.getHours(), //hour 
    "m+" : this.getMinutes(), //minute 
    "s+" : this.getSeconds(), //second 
    "q+" : Math.floor((this.getMonth()+3)/3), //quarter 
    "S" : this.getMilliseconds() //millisecond 
    } 
    if(/(y+)/.test(format)) format=format.replace(RegExp.$1, 
    (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
    for(var k in o)if(new RegExp("("+ k +")").test(format)) 
    format = format.replace(RegExp.$1, 
    RegExp.$1.length==1 ? o[k] : 
    ("00"+ o[k]).substr((""+ o[k]).length)); 
    return format; 
} 
