// JavaScript Document
$(document).ready(function(){
$.fn.glry=function(src,gallery_left2,gallery_pos,set,loadordernext,loadorderprev,div_gallery,div_prev,div_next,link_id){
			var gallery_left=0;
			if(gallery_pos<=4){
				var gallery_left=0;
			}else{
				var gallery_left=gallery_left2;
				//alert(gallery_left);
				gallery_left=gallery_left*(-564);
			
				//alert(gallery_left);
				
			}
			$(div_gallery).css({left:''+gallery_left+'px'},{duration:1000});
			if(gallery_left==0){
				$(div_prev).css({opacity:'0.4'});
				}
			if(gallery_left==set){
				$(div_next).css({opacity:'0.4'});
				}	
			var isWorking = false;
			$(div_next).css({cursor:"pointer"}).click(function(){
				if(isWorking) 
        		{
                alert('Please wait for your preceeding request to finish.');
                return false;
        		}
        		isWorking = true;
				if(gallery_left==set){}else{gallery_left=gallery_left-564;
				$(div_prev).css({opacity:'1'});
				for(var ld=loadordernext;ld<=(loadordernext+4);ld++){
				$(''+link_id+''+ld+'').attr('src', src[ld]);
				}
				loadordernext=loadordernext+4;
				}
				if(gallery_left==set){
				$(div_next).css({opacity:'0.4'});
				}
				//alert(gallery_left);
				$(div_gallery).animate({left:''+gallery_left+'px'},{duration:500});
				isWorking = false;
			});
			var isWorking1 = false;
			$(div_prev).css({cursor:"pointer"}).click(function(){
				if(isWorking1) 
        		{
                alert('Please wait for your preceeding request to finish.');
                return false;
        		}
        		isWorking1 = true;
				if(gallery_left==0){}else{gallery_left=gallery_left+564;
				$(div_next).css({opacity:'1'});
				for(var ldp=loadorderprev;ldp>=(loadorderprev-4);ldp--){
				$(''+link_id+''+ldp+'').attr('src', src[ldp]);
				}
				loadorderprev=loadorderprev-4;
				}
				if(gallery_left==0){
				$(div_prev).css({opacity:'0.4'});
				}
				//alert(gallery_left);
				$(div_gallery).animate({left:''+gallery_left+'px'},{duration:500});
				isWorking1 = false;
			});
		};
});
