function $(id)
{
 return document.getElementById(id);
}

function marbsno1over(obj){
   
		obj.style.backgroundImage='url(images/navimg/fr_nar_bule_btn_img_no1.gif)';
		obj.style.width='102px';
		obj.style.height='25px';
		obj.firstChild.style.textDecoration='none';
		obj.firstChild.style.color='#FFFFFF';
		obj.style.fontWeight='bold';
    
}
function marbsno1out(obj){
	
		obj.style.backgroundImage='url(images/navimg/fr_nar_white_btn_img_no1.gif)';
		obj.style.width='102px';
		obj.style.height='25px';
		obj.firstChild.style.textDecoration='none';
		obj.firstChild.style.color='#656565';
		obj.style.fontWeight='bold';
}
function marbsno2over(obj){
   
		obj.style.backgroundImage='url(images/navimg/fr_nar_bule_btn_img_no2.gif)';
		obj.style.width='174px';
		obj.style.height='25px';
		obj.firstChild.style.textDecoration='none';
		obj.firstChild.style.color='#FFFFFF';
		obj.style.fontWeight='bold';
    
}
function marbsno2out(obj){
	
		obj.style.backgroundImage='url(images/navimg/fr_nar_white_btn_img_no2.gif)';
		obj.style.width='174px';
		obj.style.height='25px';
		obj.firstChild.style.textDecoration='none';
		obj.firstChild.style.color='#656565';
		obj.style.fontWeight='bold';
}
function marbsno3over(obj){
   
		obj.style.backgroundImage='url(images/navimg/fr_nar_bule_btn_img_no3.gif)';
		obj.style.width='123px';
		obj.style.height='25px';
		obj.firstChild.style.textDecoration='none';
		obj.firstChild.style.color='#FFFFFF';
		obj.style.fontWeight='bold';
    
}
function marbsno3out(obj){
	
		obj.style.backgroundImage='url(images/navimg/fr_nar_white_btn_img_no3.gif)';
		obj.style.width='123px';
		obj.style.height='25px';
		obj.firstChild.style.textDecoration='none';
		obj.firstChild.style.color='#656565';
		obj.style.fontWeight='bold';
}

        //图片资源
var imgs_m=[],imgs_s=[],imgs_url=[];
		imgs_m[0]="http://fr.jimei.me/testimg/indeximgs/b_1.jpg";
		imgs_m[1]="http://fr.jimei.me/testimg/indeximgs/b_2.jpg";
		imgs_m[2]="http://fr.jimei.me/testimg/indeximgs/b_3.jpg";
		imgs_s[0]="http://fr.jimei.me/testimg/indeximgs/s_1.jpg";
		imgs_s[1]="http://fr.jimei.me/testimg/indeximgs/s_2.jpg";
		imgs_s[2]="http://fr.jimei.me/testimg/indeximgs/s_3.jpg";
		imgs_url[0]="http://www.tradejm.com/en/index.aspx";
		imgs_url[1]="http://en.jimei.me";
		imgs_url[2]="http://en.jimei.me";
	//显示小图
	function imgs_s_dis(){
		var imgs=document.getElementById("imgs");
		var fr=document.createDocumentFragment();
		for(var i=0;i<imgs_s.length;i++){
			var li=document.createElement("li");
				li.innerHTML="<img src='"+imgs_s[i]+"' alt='' />";
				lis.push(li);
				fr.appendChild(li);
		}
		imgs.appendChild(fr);
	}
	
	
	//图片切换
	function img_scroll(num){
		cur_img.src=imgs_m[num];
		$('img_a').href=imgs_url[num];	 
	}
	
	//图片切换效果
	 var ie=/MSIE/.test(navigator.userAgent);//浏览器
	 var img_title=null;//title
	 var f_img_roll=null;//大图
	 var cur_img=null;//当前大图
	 var mb_img=null;//目标图
	 var f_mask=null;//MASK层
	 var lis=[];//所有LI
	 var cur_li=null;//当前MASK所在LI
	 var mb_li=null;//目标LI位置
	 var tt=null;//时间函数
	 var m=0;//默认top
	 var r=0;//当前lis下标
	 
	 //自动播放
	 function img_play(){
		r++;
		if(r>lis.length-1)r=0;
		mb_li=lis[r].offsetTop;
		if(tt)clearTimeout(tt);
		tt=setInterval("f_mask_mov()",25);
		cur_li=lis[r];
		img_scroll(r);
		
	 }
	
	 //加载动作
	 function _focus(){
		imgs_s_dis();//初始小图显示
		cur_li=lis[0];//初始当前mask所在元素
		f_img_roll=document.getElementById("f_img_roll");
		cur_img=f_img_roll.getElementsByTagName("img")[0];//得到默认大图引用
		f_mask=document.getElementById("f_mask");//得到MASK引用
		for(var i=0;i<lis.length;i++){
			lis[i].onmouseover=function(){
				this.style.border="1px solid #cc0000";
			}
			lis[i].onmouseout=function(){
				this.style.border="1px solid #0066cc";
			}
			lis[i].num=i;
			lis[i].onclick=function(){
				if(cur_li!=this){
					if(tt)clearTimeout(tt);//停止正在的播放
					clearTimeout(ttt);//停止自动播放
					r=this.num;
					mb_li=this.offsetTop;
					tt=setInterval("f_mask_mov()",40);
					cur_li=this;
					img_scroll(this.num);
				}
			}
		}
		ttt=setTimeout("img_play()",3000);//开始自动播放
	 }
	 
	 //滑动效果
	 function f_mask_mov(){
		if(m>mb_li){
			m-=(m-mb_li)*0.2;
			if((m-1)<mb_li){
				clearTimeout(tt);
				f_mask.style.top=mb_li+"px";
				f_mask_top=mb_li;//更新M值
				m=mb_li;
				ttt=setTimeout("img_play()",3000);//开始自动播放
				return;
			}else{
				f_mask.style.top=m+"px";
			}
		}else{
			m+=(mb_li+5-m)*0.2;
			if(m>mb_li){
				clearTimeout(tt);
				f_mask.style.top=mb_li+"px";
				m=f_mask_top=f_mask.offsetTop;//更新M值
				ttt=setTimeout("img_play()",3000);//开始自动播放
				return;
			}else{
				f_mask.style.top=m+"px";
			}
		}
		
	 }
	 window.onload=_focus;

