var eTran=function (el,options){
	var self=this;
	this.options =options || {url:'',//默认URL地址
		nav:true,	//是否显示导航栏
		onstart: function(){},//效果开始执行时候触发的方法
		oncomplete: null,//效果执行完毕后触发的方法
		duration: 500,//效果的持续时间（毫秒）。默认为500
		step:500	//切换完成后的等待时间（毫秒）。默认为500
	};
	this.element={};
	this.stype="";
	this.mask={};
	this.nav={};
	this.sh=true;
	this.nr=[];
	this.index=1;
	this.sy=0;
	this.fxm={};
	this.nvobj=[];
	this.urls=[];
	if (!el)return;
	this.element = $('#'+el);
	if(!this.element[0])return;
	this.stype=this.element.attr('tagName');
	this.element.css('cursor','pointer');
	this.mask=this.element.clone().insertBefore(this.element);
	this.mask.css({'position':'absolute','visibility':'hidden'});
	if (this.options.nav) {
		this.nav=$('<div></div>').insertBefore(this.element);
		this.nav.css({'top':380,'width':640,'height':16,'position':'absolute','z-index':this.element.css('z-index')+1});
	}
	this.add=function(nr,url){
		if (!nr)return;
			url=url||"";
		this.nr[this.nr.length]=nr;
		this.urls[this.urls.length]=url;
		if (this.options.nav && (this.sy < this.nr.length)) {
			this.nav.empty();
			this.sy = this.nr.length;
			for (var i=0; i < this.nr.length; ++i) {
				var nvdiv=$('<div></div>').appendTo(this.nav);
				nvdiv.css({'opacity':'0.7','font-weight':'bold','cursor':'pointer','color':'#FFF','text-align':'center',
							'float':'right','top':0,'width':22,'height':16,'background-color':'#666','border-left':'1px #FFFFFF solid'});
				if (this.sy==1) {
					nvdiv.css('background-color','#FF6600');
				}
				nvdiv.text(this.sy);
				nvdiv.attr("index",this.sy-1);
				this.nvobj[this.sy-1] = nvdiv;
				var sobj=this;
				nvdiv.click(function(){
					sobj.index = this.getAttribute("index");
					//sobj.fxm.stop();
					sobj.goNext();
			});
			this.sy -= 1;
			}
		}
	};
	
	this.toggle=function(){
		this.timer=setInterval(function(){self.goNext();},this.options.step*5);
	};

	this.goNext=function(){
		if (this.options.nav) {
			for (var i=0; i<this.nr.length; i++) {
				this.nvobj[i].css('background-color', '#666');
			}
		}
		//alert(this.sh);
//		if (this.sh) {
//			var surl=this.urls[this.index];
//			if (surl) {
//				this.mask.click(function(){
//					window.open(surl);
//				});
//			}else {
//				this.mask.click(function (){});
//			}
//			if (this.stype == 'IMG') {
//				this.mask.attr('src',this.nr[this.index]);
//			}else {
//				this.mask.html(this.nr[this.index]);
//			}
//					//this.fxm.start(0,1);
//			this.sh=false;
//		}else {
			var surl=this.urls[this.index];
			if (surl) {
				this.element.unbind( "click" );
				this.element.click(function(){
					window.open(surl);
				});
			}else {
				this.element.unbind( "click" );
				this.element.click(function (){});
			}
			if (this.stype == 'IMG') {
				this.element.attr('src',this.nr[this.index]);
			}else {
				this.element.html(this.nr[this.index]);
			}
			//this.fxm.start(1,0);
			//this.sh=true;
		//}
		if (this.options.nav) {
			if(this.nvobj[this.index]){
				this.nvobj[this.index].css('background-color', '#FF6600');
			}
		}
		if (this.index<(this.nr.length-1)) {
			this.index+=1;
		}else {
			this.index=0;
		}
	};
	switch (this.stype) {
		case 'IMG': {
			this.mask.attr('src',this.element.attr('src'));
			this.add(this.element.attr('src'),this.options.url);
			break;
		}
		default: {
			if (this.element.html()) {
				this.mask.html(this.element.html());
				this.add(this.element.html(),this.options.url);
			}
		}
	}
				//this.fxm=new eHome.Effects.Style(this.mask, 'opacity', this.options);
	if (this.options.url) {
		var surl=this.options.url;
		this.element.unbind( "click" );
		this.element.click(function(){
			window.open(surl);
		});
	}
}
function gd()
{
	$(function (){
	    $.extend({eTran:new eTran('imgTran',{nav:true,
		    url:'http://gd.ehome.cn/Activity/eHome/Index.aspx',step:1000
	    })});

	    $.eTran.add('http://file.ehome.cn/images/main/09gq_650.jpg','http://administrators.gd.ehome.cn/Diary/Diary.aspx?diaryBookID=238312&diaryID=24465');
	    $.eTran.add('http://file.ehome.cn/images/main/shujia_650.jpg','http://gd.ehome.cn/Activity/ShuJia/index.aspx');
	    $.eTran.add('http://file.ehome.cn/images/main/qq_645230.jpg','http://gd.ehome.cn/Reg.aspx');
	    $.eTran.add('http://file.ehome.cn/images/father/father_gd.jpg','http://administrators.gd.ehome.cn/home/Diary/Diary.aspx?diaryBookID=31854&diaryID=21500');
	    $.eTran.add('http://file.ehome.cn/images/main/广告.gif','http://administrators.gd.ehome.cn/home/Diary/Diary.aspx?diaryBookID=31854&diaryID=21188');
		
	    $.eTran.toggle();
    });
}
function sn(){
	$(function (){
		$.extend({eTran:new eTran('imgTran',{nav:true,
		    url:'http://sn.ehome.cn/2010',step:1000
	    })});
		$.eTran.add('http://file.ehome.cn/images/main/09gq_650.jpg','http://csehome.sn.ehome.cn/Diary/Diary.aspx?diaryBookID=238314&diaryID=24467');
	    $.eTran.add('http://file.ehome.cn/images/banner/645230_xingfu_sn.jpg','http://file.ehome.cn/Skins/ehome/sn/BlessednessFamily/award.html');
		$.eTran.add('http://file.ehome.cn/images/ShuJiaVote/ehome.gif','http://sn.ehome.cn/Activity/ShuJia/Vote.aspx');
	    $.eTran.add('http://file.ehome.cn/images/main/qq_645230.jpg','http://sn.ehome.cn/Reg.aspx');
		
	    $.eTran.toggle();
    });
}
