var isIE=!!window.navigator.userAgent.match(/MSIE/gi)&&!window.navigator.userAgent.match(/opera/gi);


window._alert=window.alert;
window.alert=function(msg){
	window._alert('\u202b'+msg);	
};

window._confirm=window.confirm;
window.confirm=function(msg){
	return window._confirm('\u202b'+msg);	
};


var XMLHttpRequest=XMLHttpRequest?XMLHttpRequest:function(){
try{return new ActiveXObject((parseFloat(window.navigator.userAgent.match(/MSIE\s*([\d\.]*)/i)[1])<6)?"MSXML2.XMLHTTP.5.0":"Microsoft.XMLHTTP")}catch(e){
try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){
try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){
try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){
try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(e){
	alert('مرورگر شما از آژاکس پشتیبانی نمی کند\nلطفا از مرورگر دیگری استفاده کنید');
}}}}}};

window.$=function(ID){
	var obj=((typeof ID)=="object")?(ID):(document.getElementById(ID));
	if(!obj) return false;
	if(obj.getbytag) return obj;
	obj.getbytag=obj.getElementsByTagName;
	obj.getfirst=function(tag){
		var objgroup=obj.getElementsByTagName(tag);
		return objgroup?$(objgroup[0]):null;
	};
	obj._css=function(style,value){
		style=window.$.setnormal(style);
		switch(style){
			case "opacity":window.$.setopacity(obj,value);return;
		}
		obj.style[style]=value;								  
	};
	obj.css=function(style,value){
		style=style.replace(/(\s*;\s*)/gi,";").replace(/(\s*:\s*)/gi,":");
		if(style.toLowerCase()=="style"){
			obj.css(value);
		}else if(value){
			obj._css(style,value);	
		}else{
			var s=style.split(";"),i,e;
			for(i=0;i<s.length;i++){
				e=s[i].split(":");
				if(e.length<2) continue;
				this._css(e[0],e[1]);
			}
		}
		return obj;
	};
	obj.gcss=function(style){
		style=window.$.setnormal(style);
		switch(style){
			case "opacity":return window.$.getopacity(obj);
		}
		return obj.style[style];
	};
	obj.move=function(style,start,end,time,unit,finish){
		style=window.$.setnormal(style);
		var TimerID=obj.move['TimerID_'+style];
		if(TimerID) clearInterval(TimerID);
		start=start!=null?start:parseFloat(obj.gcss(style));
		if(!unit) unit="";
		if(!finish) finish=new Function;
		obj.css(style,start+unit);
		var ftime=new Date().getTime(),stime,upert=(end-start)/time;
		TimerID=setInterval(function(){
			stime=new Date().getTime();
			if(stime-ftime<time){
				obj.css(style,(start+(stime-ftime)*upert)+unit)
			}else{
				obj.css(style,end+unit);
				clearInterval(TimerID);
				finish();
			}
		},1);
		obj.move['TimerID_'+style]=TimerID;
		return obj;

	};
	obj.move.stop=function(style){
		var TimerID=obj.move['TimerID_'+style];
		if(TimerID) clearInterval(TimerID);
		return obj;
	};
	obj.addevent=function(event,func){
		var e=event.match(/(on)?(.*)/)[2],f=(typeof func=="string")?Function(func):func;
		if(this.addEventListener){
			this.addEventListener(e,f,false);
		}else{
			this["on"+e]=f;
		}
		return obj;
	};
	obj.addchild=function(childtag,style){
		var child=$(document.createElement(childtag));
		if(style) child.css(style);
		obj.appendChild(child);
		return child;
	};
	return obj;
}
window.$.setopacity=!isIE?function(obj,v){obj.style.opacity=v/100}
	:((parseFloat(window.navigator.userAgent.match(/MSIE\s*([\d\.]*)/i)[1])<6)?function(obj,v){obj.style.filter="alpha(opacity="+v+")"}
	:function(obj,v){if(obj.style.filter){obj.filters.item("DXImageTransform.Microsoft.Alpha").opacity=v}else{obj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+v+")"}});
		
window.$.getopacity=!isIE?function(obj){var opacity=obj.style.opacity;return opacity==""?100:opacity*100}
					:function(obj){var opacity=(parseFloat(window.navigator.userAgent.match(/MSIE\s*([\d\.]*)/i)[1])<6)?false:obj.filters.item("DXImageTransform.Microsoft.Alpha");
							if(opacity){return opacity.opacity;}else{opacity=obj.style.filter.match(/alpha\(opacity=([\d\.]*)\)/i);return opacity?opacity[1]:100;};};
							
window.$.setnormal=function(style){return style.toLowerCase().replace(/-\w/g,function(u){return u.replace("-","").toUpperCase()})};

var setopacity=window.$.setopacity;

//Masoud Noori ( info@mnoori.com )
//Pasargadae Tech
