// JavaScript Document
jQuery.fn.gallery = function(){
 var gallery_images = [
    '/image/commandprinting/show/353',
    '/image/commandprinting/show/403',
    '/image/commandprinting/show/404',
	'/image/commandprinting/show/405',
    '/image/commandprinting/show/406',
    '/image/commandprinting/show/407',
	'/image/commandprinting/show/408',
    '/image/commandprinting/show/409',
    '/image/commandprinting/show/410',
	'/image/commandprinting/show/411',
    '/image/commandprinting/show/412',
    '/image/commandprinting/show/413',
	'/image/commandprinting/show/414',
    '/image/commandprinting/show/415',
    '/image/commandprinting/show/416',
	'/image/commandprinting/show/417',
    '/image/commandprinting/show/418',
   
 ]; 
 
 var preloader_id = '#image_loader';
 var btn_next_id = '#next_btn';
 var btn_prev_id = '#prev_btn';
 var gallery_box = this;
 var preloader = new Image();
 var Index = 0;
 var next_start_x = 702;
 var next_btn_width = 98;
 var next_hidden_x = next_start_x + next_btn_width-10;
 jQuery(btn_next_id).hide();
 jQuery(btn_prev_id).hide();
// alert(next_hidden_x+'px');
 jQuery(gallery_box).append('<img id="image_box_img" src="" />');
jQuery('#click_here').css({display:'none'});

 loadImage(gallery_images[Index]);
 jQuery(gallery_box).css({'background-repeat':'no-repeat'});
 jQuery(gallery_box).css({'background-position':'center'});
 jQuery(gallery_box).each(function(){
jQuery(jQuery('#click_here').find('a')).click(function(){
parent.window.location = jQuery(this).attr('href');
});
 });
  jQuery(btn_next_id).click(function(){
     Index++;
     jQuery('#click_here').css({display:'none'});

	 if (Index>=gallery_images.length)Index = 0;
	 if(Index == gallery_images.length-1)jQuery('#click_here').css({display:'block'});

	 loadImage(gallery_images[Index]);
 });

 jQuery(btn_prev_id).click(function(){
     Index--;
	 if (Index<0)Index = gallery_images.length-1;
	  jQuery('#click_here').css({display:'none'});
     if(Index == gallery_images.length-1)jQuery('#click_here').css({display:'block'});

	 loadImage(gallery_images[Index]);
 });
 jQuery(gallery_box).mousemove(function(e){
  if(e.clientX > 500){
	   jQuery(btn_next_id).show();
  } else {
	   jQuery(btn_next_id).hide();
  } 
  if(e.clientX < 300){
	    jQuery(btn_prev_id).show();

  } else {
	   jQuery(btn_prev_id).hide();
  }
 });

 function loadImage(url){
 	//preloader.src = url;
    jQuery('#image_box_img').attr('src','');
    jQuery(preloader_id).hide();
    jQuery('#image_box_img').attr('src',url);
	jQuery('#image_box_img').css({width:650,height:448});

 }
 return this;
}
jQuery(document).ready(function(){
   jQuery('#image_box').gallery();
});
