// JavaScript Document
;(function($){
	$.fn.extend({
		"dropDownMenu_xzw":function(){
			var _elem = $(this).children("li:has(div.lve_2)");
			_elem.hover(
				function(){
					$(this).find("div.lve_2").stop(true,true).slideDown(400);
				},
				function(){
					$(this).find("div.lve_2").stop(true,true).slideUp("fast");
				}
			);
			
		}			
	});		   
})(jQuery);

;(function($){
	$.fn.extend({
		"transformView":function(imgArr,numArr,msgArr,options){
			settings = $.extend({
				imgHeight: "100px",
				delay: 1000
			},options);
			var _elem = $(this);
			var _lenMax = $("li", numArr).length;
			var _index = 0;
			
			var _imgArr = $(this).find(imgArr);
			var _numElem = $(this).find(numArr);
			var _msgArr = $(this).find(msgArr);
			
			$("li", _imgArr).eq(0).css("display","block");
			_numElem.eq(0).addClass("active");
			$("li", _msgArr).eq(0).fadeIn("fast");
			
			$("li",_numElem).mouseover(function(){
				_index = $("li",_numElem).index(this);
				showImg(_index);
			});
			
			_elem.hover(function(){
					if(_timer){clearInterval(_timer);}
				},
				function(){
					_timer = setInterval(function(){
						showImg(_index);
						_index++;
						if(_index == _lenMax){_index = 0;}
					},settings.delay);
				}
			);
			
			var _timer = setInterval(function(){
				showImg(_index);
				_index++;
				if(_index == _lenMax){ _index = 0;}
				},settings.delay);
			function showImg(i){
				$("li",_imgArr).eq(i).fadeIn("slow").siblings().hide();
				$("li",_msgArr).eq(i).fadeIn("fast").siblings().hide();
				$("li", _numElem).eq(i).addClass("active").siblings().removeClass("active");
			}
			
		}			
	});		   
})(jQuery);

function RollBox(){
	var ME = this;
	var Speed = 3; 
	var Space = 5;  
	var PageWidth = 204; 
	var fill = 0; 
	var MoveLock = false; 
	var MoveTimeObj; 
	var Comp = 0; 
	var AutoPlayObj = null; 

	this.init = function(){
		this.AutoPlay(); 
		this.GetObj("List2").innerHTML = this.GetObj("List1").innerHTML; 
		this.GetObj('ISL_Cont').scrollLeft = fill; 
		this.GetObj("ISL_Cont").onmouseover = function(){clearInterval(AutoPlayObj);} 
		this.GetObj("ISL_Cont").onmouseout	= function(){ME.AutoPlay();}
		
		
		this.GetObj("ISL_LeftBotton").onmousedown	= this.ISL_GoUp; 
		this.GetObj("ISL_LeftBotton").onmouseout	= this.ISL_StopUp; 
		this.GetObj("ISL_LeftBotton").onmouseup	= this.ISL_StopUp; 
		
		this.GetObj("ISL_RightBotton").onmousedown	= this.ISL_GoDown; 
		this.GetObj("ISL_RightBotton").onmouseout	= this.ISL_StopDown; 
		this.GetObj("ISL_RightBotton").onmouseup 	= this.ISL_StopDown; 
	}
	
	this.GetObj = function(objName){
		if(document.getElementById){
			return eval('document.getElementById("'+objName+'")')
		}else{
			return eval('document.all.'+objName)
		}
	}

	this.AutoPlay = function(){ 
		clearInterval(AutoPlayObj);
		AutoPlayObj = setInterval('RollBox.ISL_GoDown();RollBox.ISL_StopDown();',3000); //ΌδΈτΚ±Όδ 
	}

	this.ISL_GoUp = function(){ 
		if(MoveLock) return;
		clearInterval(AutoPlayObj); 
		MoveLock = true; 
		MoveTimeObj = setInterval('RollBox.ISL_ScrUp();',Speed); 
	}
	 
	this.ISL_StopUp = function(){ 
		clearInterval(MoveTimeObj); 
		if(ME.GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0){ 
			Comp = fill - (ME.GetObj('ISL_Cont').scrollLeft % PageWidth); 
			ME.CompScr(); 
		}else{
			MoveLock = false;
		} 
		ME.AutoPlay(); 
	}

	this.ISL_ScrUp = function(){  
		if(ME.GetObj('ISL_Cont').scrollLeft <= 0){
			ME.GetObj('ISL_Cont').scrollLeft = ME.GetObj('ISL_Cont').scrollLeft + ME.GetObj('List1').offsetWidth
		} 
		ME.GetObj('ISL_Cont').scrollLeft -= Space ; 
	}

	this.ISL_GoDown = function(){ 
		clearInterval(MoveTimeObj); 
		if(MoveLock) return; 
		clearInterval(AutoPlayObj); 
		MoveLock = true; 
		ME.ISL_ScrDown(); 
		MoveTimeObj = setInterval('RollBox.ISL_ScrDown()',Speed); 
	} 

	this.ISL_StopDown = function(){  
		clearInterval(MoveTimeObj);
		if(ME.GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0 ){ 
			Comp = PageWidth - ME.GetObj('ISL_Cont').scrollLeft % PageWidth + fill; 
			ME.CompScr(); 
		}else{ 
			MoveLock = false; 
		} 
		ME.AutoPlay(); 
	}

	this.ISL_ScrDown = function(){  
		if(ME.GetObj('ISL_Cont').scrollLeft >= ME.GetObj('List1').scrollWidth){
			ME.GetObj('ISL_Cont').scrollLeft = ME.GetObj('ISL_Cont').scrollLeft - ME.GetObj('List1').scrollWidth;
		} 
		ME.GetObj('ISL_Cont').scrollLeft += Space ; 
	}

	this.CompScr = function(){ 
		var num; 
		if(Comp == 0){
			MoveLock = false;
			return;
		} 
		if(Comp < 0){ 
			if(Comp < -Space){ 
				Comp += Space; 
				num = Space; 
			}else{ 
				num = -Comp; 
				Comp = 0; 
			} 
			ME.GetObj('ISL_Cont').scrollLeft -= num; 
			setTimeout('RollBox.CompScr()',Speed); 
		}else{ 
			if(Comp > Space){
				Comp -= Space; 
				num = Space; 
			}else{ 
				num = Comp; 
				Comp = 0; 
			}
		ME.GetObj('ISL_Cont').scrollLeft += num; 
		setTimeout('RollBox.CompScr()',Speed);
		} 
	} 
}

var showPic= function(){
			var picURL;
			picURL = $(this).find("a").attr("href");
			//alert(picURL)
				$("#bigPic").find("img").attr("src",picURL);													 
			return false;
}

;(function($){
	$.fn.extend({
		"xzw_Accordion_1":function(options){
			var settings = $.extend({targetA:null, current:null}, options);
			var _elem = $(this);
			var a_1_Arr = $("li:has(dl)",_elem).children("a");
			var _currentTitle = $("#"+settings.targetA, _elem).find("a");
			var _ddArr = _currentTitle.next("dl").children("dd");
			_currentTitle.next("dl").slideDown(500);
			$(_ddArr[settings.current-1]).addClass("Current");
			
			a_1_Arr.toggle(function(){
				$(this).next("dl").slideDown(500);
				return false;
				},
				function(){
					$(this).next("dl").slideUp(500);
					return false;
				}
			);
		}
	});
})(jQuery);

jQuery(document).ready(function(){
	jQuery("ul#topMenu").dropDownMenu_xzw();
	jQuery(".ScrCont").find("li").click(showPic);
	jQuery("#photos").transformView("#slider","#numList",null,{delay:"3000"});
	jQuery("#leftMenu3").xzw_Accordion_1();

});

