var count=0;
var curent=0;
$(document).ready(function(){
/*-----THE BANNER OF THE INDEX PAGE----*/
	var list=$(".pictures div");
	var _width=list.length*615;
	$(".pictures").css({"width":_width+"px"});
	
	var temp=0;
	var temp1=0;
	var num=0;
	var slideimgs="";
	
	if(curent==0){
	     slideimgs = setInterval(slideimg,30000);	
	}
	else{
		 slideimgs = setInterval(slideimg,5000);	
	}
	$(".slidepics_in").hover(function(){
		slideimgs = clearInterval(slideimgs);
	},function(){
		slideimgs = setInterval(slideimg,5000);
	});
	function slideimg()
	{
		if(temp1==list.length){
				temp1=1;
		}
		else{
			temp1=temp1+1;
		}
		if(temp1!=1){
			curent=1;
		}
		num=-(list.length-temp1)*615;
		if(count==0)
		{
			count=1;
			$(".pictures div").each(function(){    
				if($(".pictures div").index(this)==(list.length-temp1)){	 
					$(this).css({"left": num+"px"});
				}
				else{
					$(this).animate({"left": "+=615px"},{queue:false, duration:800, 

easing:"quintEaseIn",complete:function(){
						   count=count+1;
						   if(count==list.length){
								count=0;
						  }
					   }
					}); 
				
				}
			});	
		}	
	}
	$( ".arr_left1").click(function(){ 
		curent=1;
		if(count==0){
		       count=1;
			    if(temp1==0){
					if(temp==list.length){
						temp=1;
					}
					else{
						temp=temp+1;
					}		
						num=(list.length-temp)*615;
						$(".pictures div").each(function(){    
							if($(".pictures div").index(this)==(temp-1)){	 
								$(this).css({"left": num+"px"});
							}
							 else{
								$(this).animate({"left": "-=615px"},{queue:false, duration:800, 

easing:"quintEaseIn",complete:function(){
									   count=count+1;
									   if(count==list.length){
											count=0;
									  }
								   }
								});  			
							}
						}); 
				}
				else{
					num=(temp1-1)*615;
					$(".pictures div").each(function(){    
							if($(".pictures div").index(this)==(list.length-temp1)){	
								$(this).css({"left": num+"px"});
							}
							 else{
								$(this).animate({"left": "-=615px"},{queue:false, duration:800, 

easing:"quintEaseIn",complete:function(){
									   count=count+1;
									   if(count==list.length){
											count=0;
									  }
								   }
								});  			
							}
					}); 
					temp1=temp1-1;
				}
		}
			
	});

	$( ".arr_right1").click(function(){ 
		curent=1;
	    if(count==0){
	       count=1;
	       if(temp==0){
				if(temp1==list.length){
					temp1=1;
				}
				else{
					temp1=temp1+1;
				}
				num=-(list.length-temp1)*615;
				$(".pictures div").each(function(){    
					if($(".pictures div").index(this)==(list.length-temp1)){	
						$(this).css({"left": num+"px"});
					}
					else{
						$(this).animate({"left": "+=615px"},{queue:false, duration:800, 

easing:"quintEaseIn",complete:function(){
							   count=count+1;
							   if(count==list.length){
									count=0;
							  }
						   }
						}); 
					}
				});
						
			}
			else{		     
				 num=-(temp-1)*615;
					$(".pictures div").each(function(){    
						if($(".pictures div").index(this)==(temp-1)){	
							$(this).css({"left": num+"px"});
						}
						 else{
							$(this).animate({"left": "+=615px"},{queue:false, duration:800, 

easing:"quintEaseIn",complete:function(){
							   count=count+1;
							   if(count==list.length){
									count=0;
							  }
						    }
						  }); 			
						}
					}); 
					temp=temp-1;
			}
			
		}
		
	});

	/*-------THE SMALL ADVERTISEMENT OF INDEX PAGE--------*/
	
	var snums=0;
	var scrollnum=$(".scrollinner");
	var _heightScroll=0;
	var count1=0;
	var upSlideimgs = setInterval(upscrollimgs,5000);
	$(".scrollimgs").hover(function(){
		upSlideimgs = clearInterval(upSlideimgs);
	},function(){
		upSlideimgs = setInterval(upscrollimgs,5000);
	});	
	function upscrollimgs(){
		if(count1==0){
			count1=1;
		    _heightScroll=(scrollnum.length-snums-1)*141;		
			$(".scrollinner").each(function(){  
			    if($(".scrollinner").index(this)==snums){
					$(this).css({"top" : _heightScroll+"px"});
				}
				else{
					$(this).animate({"top": "-=141px"}, {queue:false, duration:800, easing:"quintEaseIn",complete:function(){
							   count1=count1+1;
							   if(count1==4){
									count1=0;
							  }
						    }
						  }); 			
				}
			});
			if(snums==scrollnum.length-1){
				snums=0; 
			}
			else{
			snums=snums+1;
			}
		}

	}
	
});
