/*
objs:要修改样式的元素
index:当前要修改的索引
count:同类型的元素的长度
value:已选择的元素的value
objs2:需更改显示方式的元素
*/
function tab(objs,index,count,value,objs2){
    tab_SetStyle(objs,index,count,value);
    tab_SetDisp(objs2,index,count);                           
}

function tab_SetStyle(objs,index,count,value){
	if(value==""||count==0) return;
    var tempValue = "";
    var prop = "className";
    var vIndex = 0;
    var objAry = objs.split("|");
    var values = value.split("|");
    if(values[0].indexOf("$")!=-1){
		prop = values[0].split("$")[0];
		vIndex = 1;
	}//未实现多元素
    if(eval("$(objAry[0]+index)."+prop) == values[0].split("$")[vIndex])
        return;
    else
        tempValue = eval("$(objAry[0]+index)."+prop);
    for(var i=0;i<objAry.length;i++){
        for(var j=1;j<=count;j++){
            eval("$(objAry[i]+j)."+prop+"=tempValue;");
        }
        eval("$(objAry[i]+index)."+prop+"=values[i].split('$')[vIndex];");
    }
}

function tab_SetDisp(objs,index,count){
	if(count==0) return;
    var objAry = objs.split("|");
    var temp = $(objAry[0]+index).style.display;
    if(temp == "block" || temp == "")
        return;
    for(var i=0;i<objAry.length;i++){	
        for(var j=1;j<=count;j++){
            $(objAry[i]+j).style.display = "none";
        }
        $(objAry[i]+index).style.display = "block";
    }
}

function $(){
return document.getElementById(arguments[0]);
}

function $1(id,value){
var o=$(id);
if(o) o.innerHTML=value;
}
//清除字符串前后空格
String.prototype.trim = function(){
	return this.replace(/^\s+/,"").replace(/\s+$/,"");
}
String.prototype.startsWith = function(s){
	if(this.length<s.length)
		return false;
	if(this.substr(0,s.length) == s)
		return true;
	return false;
}
String.prototype.endsWith = function(s){
	if(this.length<s.length)
		return false;
	if(this.substring(this.length-s.length)==s)
		return true;
	return false;
}
