﻿/* pr_script code */
//申明对象
pr=function(){}
//浏览器判断
var ua=navigator.userAgent.toLowerCase();
var s;
(s=ua.match(/msie ([\d.]+)/))?pr.prototype.ie=s[1]:
(s=ua.match(/firefox\/([\d.]+)/))?pr.prototype.firefox=s[1]:
(s=ua.match(/chrome\/([\d.]+)/))?pr.prototype.chrome=s[1]:
(s=ua.match(/opera.([\d.]+)/))?pr.prototype.opera=s[1]:
(s=ua.match(/version\/([\d.]+).*safari/))?pr.prototype.safari=s[1]:0;
//$(id,tag):返回容器下某标签的集合[id可为obj,如TAG为空则只返回id对象]
pr.prototype.$=function(obj,tag){
	if(!tag){return document.getElementById(obj);}
	else if(typeof obj=='string'){return document.getElementById(obj).getElementsByTagName(tag);}
	else{return obj.getElementsByTagName(tag);}
	}
//返回一组对象中包含指定className的对象[obj=数组对象，css=指定的class名称]
pr.prototype.$s=function(css,obj){
	if(!obj){obj=document.getElementsByTagName('*');}
	var objs=[];
	var cssName=new RegExp("\\b"+css+"\\b");
	for(i=0;i<obj.length;i++){if(obj[i].className.match(cssName)){objs.push(obj[i]);}}
	return objs;
	}
//选项卡
pr.prototype.tabs=function(obja,a,b,objb){
	var d=new RegExp("\\b"+b+"\\b","ig");
	for(i=0;i<obja.length;i++){
		if(i==a){obja[a].className+=" "+b;if(objb){objb[a].className+=" "+b}}
		else{obja[i].className=obja[i].className.replace(d,"");if(objb){objb[i].className=objb[i].className.replace(d,"");}}
		}
	}
//隔行换色
pr.prototype.colorLine=function(objs,css,onmm,off){
	for(i=0;i<objs.length;i++){
		var cssTemp=new RegExp("\\b"+css+"\\b","ig");
		if(!onmm){objs[i].className+=(i%2>0)?"":" "+css;}
		else if(off=="+"){objs[i][onmm]=function(){this.className+=" "+css;}}
		else if(off=="-"){objs[i][onmm]=function(){this.className=this.className.replace(cssTemp,"");}}
		else if(off=="~"){objs[i].ai=i;objs[i][onmm]=function(){var i=new pr();i.tabs(objs,this.ai,css);}}
		}
	}