jQuery.ajaxback=jQuery.ajax;
jQuery.extend({ajax: function(s) {
	try{
		if(s&&s.url&&s.url.indexOf('.action')<0&&s.url.indexOf('cache')<0)s.url=_.notcache(s.url);
	}catch(ex){};
	if(location.href.indexOf("xjdebug")>0)_.log(s.url);
	jQuery.ajaxback(s);
}});

jQuery.extend({xjInit:function(){
				// String.trim start...
				String.prototype.trim=function(){
					return this.replace(/^\s+|\s+$/g,"");
				};
				// String.trim end  ...
				// bind  start.....
				//函数邦定...
				Function.prototype._bind = function() {
				  var __method = this, object = arguments[0], args = arguments;
				  return function() {
					var _args = [];
					for (var _i = 1; _i < args.length; _i++) _args.push(args[_i]);
					for (_i = 0; _i < arguments.length; _i++) _args.push(arguments[_i]);
					return __method.apply(object, _args);
				  }
				};
				//事件邦定...
				Function.prototype._bindAsEventListener = function(object) {
				  var __method = this;
				  return function(event) {
					return __method.call(object, event || window.event);
				  }
				};
				// bind  end.....

				//==================================================================================
				//动态显示效果;
				$.current = 'new';
				$.MoveEffect = function() {
					if (this.id != $.current) {
						var $current = $('#' + $.current);
						var $target = $("#" + this.target);
						var effect = (this.effect)?this.effect:"4";
						$current.removeClass("frm_tab_a").removeClass("frm_tab_a_" + effect)
								.addClass("frm_tab_l").addClass("frm_tab_l_" + effect);
						$(this).addClass("frm_tab_a").addClass("frm_tab_a_" + effect)
								.removeClass("frm_tab_l").removeClass("frm_tab_l_" + effect);
						$('#' + $current[0].target).hide();
						$.current = this.id;
						var loader=this;
						$(".rgt a").each(function(){
							this.par = loader.id;
						});
						if ($target[0].childNodes.length < 10)
							$.xjEvent.call(this);
						$target.show();
					}
					return false;
				}
				$.MoveEffectMouseMove = function() {
					$.MoveEffectInterval = setInterval($.MoveEffect._bind(this), 1);
				}
				$.MoveEffectMouseOut = function() {
					clearInterval($.MoveEffectInterval);
				}
				//===================================================================================
				//使a标记具有无刷新功能;
				$.xjEvent = function() {
					if (this.href == '' || this.href == '#')return;
					if (this.random && (this.href.indexOf('%') != -1 || this.hrefback)) {
						if (!this.hrefback)this.hrefback = this.href
						this.href = _.replace(this.hrefback, {1:_.random(this.random)});
					}
					if (!this.target || this.target == '_self')
						this.target = $(this).parent().parent().parent().attr("id");
					try {
						function callback() {
							if (!this.loading) {
								var mainDiv = $("#" + this.target);
								if (mainDiv.html() != null) {
									var b = $("<div>");
									b.addClass("loading");
									b.attr({id:"mainTemp"});
									b.css("height", ((this.height)?this.height:mainDiv.height()) + "px");
									b.css("width", mainDiv.width() + "px");
									b.css("margin", (this.margin)?this.margin:"");
									b.html("<div style='text-align:center; margin-top:40px;height:0px;'>" +
										   "<img src='http://www.516.com/images/indicator_flower.gif'" +
										   "border='0'/> 数据加载中... </div>");
									mainDiv.before(b);
								}
								this.loading = "loading";
							} else {
								$("#mainTemp").remove();
								this.loading = null;
								$.compatible();
							}
						}
						function callbac2() {
							var hrefurl = (this.href.indexOf('?') != -1)?this.href + '&':this.href + '?';
							$("#" + this.target).load(_.notcache(hrefurl),callback._bind(this));
						}
						callback.call(this);
						setTimeout(callbac2._bind(this), 500);
					} catch(e) {
						alert(e.message)
					}
					return false;
				}
				$.extend({//firefox兼容处理;
					displayEffect:function(displayName, effect) {/*页面首选显示项*/
							this.id = displayName;
							this.length = 0;
							[].push.apply(this, [$("#" + displayName).get(0)]);
							this.href = $("#" + this.id).attr("href");

							this.random = "20";
							this.target = this.id + "context";
							this.effect = (!effect)?4:effect;
							$.MoveEffect.call(this);
					},display:function(displayName, notDisplayRegx, effect) {/*页面首选显示项*/
						var parameter = (document.location.href.indexOf('=')==-1)?(document.location.href).valueOf().split("?"):[];
						if (parameter.length < 2 || parameter.length > 3 || !notDisplayRegx.test(parameter[1])) {
							var href=_.notcache($("#" + displayName).attr("href"));	
							$("#" + displayName + "context").load(href);
							$("#" + displayName + "context").show("slow");
						} else {
							new this.displayEffect(parameter[1], effect);
						}
					},compatible:function(value) {/*FireFox兼容处理*/
						var moveeffect = $(".moveeffect"); 
						var xjEvent = $(".xjEvent");
						if (value) {
							if (value.moveeffect)
								$.each(moveeffect, function(a, b) {
									$.extend(moveeffect[a], value.moveeffect);
								});
							if (value.xjEvent)
								$.each(xjEvent, function(a, b) {
									$.extend(xjEvent[a], value.xjEvent);
								});
						}
						moveeffect.click($.MoveEffect);
						//moveeffect.click($.MoveEffect).mouseover($.MoveEffectMouseMove).mouseout($.MoveEffectMouseOut);
						xjEvent.click($.xjEvent);
					}
				})

				//_Timer start ...
				var _Timer = function($options) {
					this.options = {
						callback : function() { ; },
						interval : 1,
						times : -1,
						args : [],
						start_timeout : 0
					};
					$.extend(this.options, $options);
					this._timer = null;
					this.is_excuting = false;
					this._curtimes = 0;
					
					if (this.options['start_timeout']) {
						setTimeout(this.start._bind(this), this.options['start_timeout']);
					}
					else {
						this.start();
					}
				};
				_Timer.prototype = {
					start : function() {
						try {
							this._timer = setInterval(this._onTimerEvent._bind(this), this.options['interval'] * 1000);
							this.is_excuting = true;
						}
						catch (e) {
							this.is_excuting = false;
						}
					},
					_onTimerEvent : function() {
						this._curtimes++;
						if (this.options['times'] != -1 && this._curtimes >= this.options['times']) {
							this.stop();
						}
						var $aArgs = this.options['args'].slice(0);
						$aArgs.unshift(this);
						this.options['callback']._bind.apply(this.options['callback'], $aArgs)();
					},
					stop : function() {
						this.is_excuting = false;
						clearInterval(this._timer);
						this._timer = null;
					},
					times : function() {
						return this._curtimes;
					},
					// 已用时
					seconds : function() {
						return parseFloat(__format(this._curtimes * this.options['interval']));
					}
				};
				//_Timer end ...
				// date format ....
				var __format = function(n, m) {
					if (!n) return 0;
					var _m;
					var s;
					var _n;
					_m = m === undefined ? 0 : m;
					_n = n * Math.pow(10, _m);
					_n = Math.round(_n);
					_n = _n / Math.pow(10, _m);
					return _n.toString();
				};
				var __formatSize = function(n) {
					var s;
					var m;
					var a = [];
					var i;
					for (i = 0; n > 0; i++) {
						m = Math.floor(n / 1024);
						a[i] = n - m * 1024;
						n = m;
					}
					switch (a.length) {
						case 0:
							return '0KB';
						case 1:
							return __format(a[0]) + 'B';
						case 2:
							return __format(a[1] + a[0] / 1024) + 'KB';
						case 3:
							return __format(a[2] + a[1] / 1024) + 'MB';
						case 4:
							return __format(a[3] + a[2] / 1024) + 'GB';
						case 5:
							return __format(a[4] + a[3] / 1024) + 'TB';
						default:
							;
					}
				};
				var __formatTime = function(n, isEn) {
					var s;
					isEn = isEn ? true : false;
					if (n < 1000) s = __format(n) + (isEn ? 'ms' : '毫秒');
					else if (n < 60 * 1000) s = __format(n / 1000) + (isEn ? 's' : '秒');
					else if (n < 60 * 60 * 1000) s = __format(n / (60 * 1000)) + (isEn ? 'm' : '分钟');
					else if (n < 24 * 60 * 60 * 1000) s = __format(n / (60 * 60 * 1000)) + (isEn ? 'h' : '小时');
					else s = __format(n / (24 * 60 * 60 * 1000)) + (isEn ? 'd' : '天');
					return s;
				};
				var __formatClock = function(ms) {
					var n = parseInt(ms / 1000);
					var s;
					var hour = parseInt(n / 3600);
					var minute = parseInt((n - hour * 3600) / 60);
					var second = parseInt(n % 60);
					return (hour < 10 ? '0' + hour : hour) + ':' + (minute < 10 ? '0' + minute : minute) + ':' + (second < 10 ? '0' + second : second);
				};
				// date format ....
				// cookie start ....
				var	__cookie = function(name, value, options) {
					if (typeof value != 'undefined') {
						options = options || {};
						var expires = '';
						var date = new Date();
						if (options.expires && (typeof options.expires == 'number' || options.expires.toGMTString)) {
							if (typeof options.expires == 'number') {
								date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
							} else {
								date = options.expires;
							}
						}else{
							date.setTime(date.getTime() + (1 * 60 * 60 * 1000));
						}
						expires = '; expires=' + date.toGMTString(); // use expires attribute, max-age is not supported by IE
						var path = options.path ? '; path=' + options.path : '';
						var domain = options.domain ? '; domain=' + options.domain : '';
						var secure = options.secure ? '; secure' : '';
						document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
					} else { // only name given, get cookie
						var cookieValue = null;
						if (document.cookie && document.cookie != '') {
							var cookies = document.cookie.split(';');
							for (var i = 0; i < cookies.length; i++) {
								var cookie = jQuery.trim(cookies[i]);
								// Does this cookie string begin with the name we want?
								if (cookie.substring(0, name.length + 1) == (name + '=')) {
									cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
									break;
								}
							}
						}
						return cookieValue;
					}
				};
				// cookie end  ....

				//XjFjax flash ajax...
				$.extend($.prototype, {
					fjax:function(options){
						
						this.fadeIn(2000);
						options={url:options.url?options.url:"http://www.516show.cn",
								 id:options.id?options.id:"#"+this.attr("id"),
								 fjaxid:options.fjaxid?options.fjaxid:'fjax',
								 callback:options.callback?options.callback:function(){}};
						var objFjax = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
									+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '
									+ 'width="1" height="1" id="'+ options.fjaxid +'" align="middle">'
									+ '<param name="allowScriptAccess" value="always" />'
									+ '<param name="movie" value="../player/flv_player.swf?sXML=' + options.url 
									+ '&sOutputDivID=' + options.id + '&sFjaxEngine=' + options.fjaxid + '" />'
									+ '<param name="wmode" value="transparent" />'
									+ '<param name="bgcolor" value="#ffffff" />'
									+ '<embed src="../player/flv_player.swf?sXML=' + options.url 
									+ '&sOutputDivID=' + options.id + '&sFjaxEngine=' + options.fjaxid + '" '
									+ 'wmode="transparent" bgcolor="#ffffff" width="1" height="1"'
									+ 'align="middle" allowScriptAccess="sameDomain" '
									+ 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" '
									+ 'name="'+ options.fjaxid +'" swLiveConnect="true" />'
									+ '</object>'
						this.html(objFjax);
						
						$.showFjaxContent=function(outputid,engineid){
							var ThisContent = "";
							if(document.all){
								if(document.all[engineid].getVariable("sContent") == ''){
									ThisContent = "There was an error retrieving content for this page.";
								}else{
									ThisContent = document.all[engineid].getVariable("sContent");
								}
							}else{
								if(document[engineid].GetVariable('sContent') == ''){
									ThisContent = "There was an error retrieving content for this page.";
								}else{
									ThisContent = document[engineid].GetVariable('sContent');
								}
							}
							$(outputid).html(ThisContent);
							//alert(ThisContent);
						}
					}
				});
				// Extended jQuery - wy6/-;
				jQuery.extend({xj:{}});
				window._=jQuery.xj;
				jQuery.extend(jQuery.xj,{
					notcache:function($urlstr){
						var timer=(new Date).valueOf();
						
						if($urlstr)return $urlstr.indexOf('?')>1?$urlstr+="&cache="+timer:$urlstr+="?cache="+timer;
						return timer;
					},
					log:function(msg){
						alert(msg);
					},
					timer:function(options){
						return new _Timer(options);
					},
					format:function(n, m){
						return __format(n, m);
					},
					formatSize:function(n){
						return __formatSize(n);
					},
					formatTime:function(n, isEn){
						return __formatTime(n, isEn);
					},
					formatClock:function(ms){
						return __formatClock(ms);
					},replace:function($s, $a){
						for (var $i in $a) {
							$s = $s.replace('%' + $i, $a[$i]);
						}
						return $s;
					},cookie:function(name,value,options){
						return __cookie(name,value,options);
					},rehide:function($rel){
						$($rel).parent().toggle();
						$("#"+$rel.rel).toggle();
					},copy:function(vars,note){
						note=note||'网址复制成功!';
						window.clipboardData.setData('text',vars);
						if(note)_.log(note);
					},write:function(string){
						document.write(string);
					},find:function(id){
						var elements = [];
						for (var i = 0; i < arguments.length; i++){
							var element = arguments[i];
							if (typeof element == 'string')
								element = document.getElementById(element);
							if (arguments.length == 1)
								return element;
							elements.push(element);
						}
						return elements;
					},random:function(random){
						 return (Math.floor(Math.random() * random) + 1).valueOf();
					}
				});
				 $.extend($.prototype, {
					setValue:function(propertyName, value) {
						try {
							this[0].SetVariable(propertyName, value);
						} catch(ex) {
							$.log(ex.message)
						}
					},gotoFrame:function(framenum) {
						try {
							this[0].GotoFrame(framenum);
						} catch(ex) {
							$.log(ex.message)
						}
					},toggleDiv:function($date){
						var current=1,xji=$(this).find('div[@name=shows]');
						var div=$(this)[0];
						if(!div.current)div.current=0;
						if($date=='left'){
							div.current++;
							if(div.current>= xji.size())div.current=0;
						}else{
							div.current--;
							if(div.current<=-1)div.current=xji.size()-1;
						}
						xji.each(function(i){
							if(i==div.current&&current==1){
								current=0;
								$(this).show();
							}else{$(this).hide();}
						});
					}
				});
}});
jQuery.xjInit();