$(document).ready(function(){


	
  // ------------ newsletter form
	$("form.newsletter").validate({
    submitHandler: function(form) {
	     var email = $("form.newsletter input[name='formSubNewsletterEmail']").val();
	     $.get('ajax.response.php?action=addEmailToNewslleter&email='+email, '', function(data){
          $("form.newsletter").html(data);
      }); 
   },	
	 rules: {
			formSubNewsletterEmail: {required: true, email: true}
		}
	});
	
	
	$("#menu_side").treeview({
		animated: "slow",
		collapsed: true,
		unique: true
	});
	
  $('a.targetBlank').attr('target', '_blank');
	
 $("a[rel='lightbox']").lightBox({
			imageLoading:			'img/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'img/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'img/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:		'img/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'img/lightbox-blank.gif'	
  }
 );
 
	
  var imgList = $('#hiddenPhotosProductList ul li img');
  var activeElement;
  $("#productPhotoPagination ul").pagination(imgList.length, 
  
  {
                    num_edge_entries: 1,
                    num_display_entries: 8,
                    callback: pageselectCallback,
                    items_per_page:1,
                    prev_text: false,
                    next_text: false
                }
                
                
                );
                

    	function pageselectCallback(page_index, jq){
    	
    	 if($('#productPhoto img').length>0){
    	    $('#productPhoto img').animate({left: 580}, 1000 , '', function(){
              var new_content = $('#hiddenPhotosProductList ul li img:eq('+page_index+')').clone();
              new_content.css("left", -580);
              $('#productPhoto').empty().html(new_content);
              new_content.animate({left: 0}, 1000 , '', '')
          });
        }
        else{
          var new_content = $('#hiddenPhotosProductList ul li img:eq('+page_index+')').clone();
          $('#productPhoto').empty().html(new_content);
        }
        
        activeElement = page_index;
    	    
        return false;
      }
});
