
$(document).ready(function(){
	iss = $('#brochureslider').children().size();
	count = 0;
	allcount = 1;
	$('#brochureslider').css('width', (iss*960)+'px');

  	$("#clickleft").hover(      function () {  if(count != 0 ) { $( this ).addClass('brochurelefthover');} },       function () {  $( this ).removeClass('brochurelefthover'); }
	);
  	$("#clickright").hover(      function () {  if(count != (iss-1)) {$( this ).addClass('brochurerighthover');} },       function () {  $( this ).removeClass('brochurerighthover'); }
	);

});


function brochureslide(di){ 

	if(di=='left' && count != 0){
		count--;
		$('#brochureslider').animate({ left: -(count*960)+'px'},500);
	} else if ((di=='right') && (count != (iss-1))){
		count++;
		$('#brochureslider').animate({ left: -(count*960)+'px'},500);
	}
	$('#counter').html('page '+(count+1)+' of 14');

	if ((count == allcount) && (count < 13) ){
	$('#rightarrow').attr('src','../admin/loading.gif');
	$('#clickright').attr('title','the next page is loading');
	iss = $('#brochureslider').children().size();
	$('<img>').attr('src', '../img/brochure/brochure'+(allcount+2)+'.jpg').css('left',(iss*960)+'px')
		.load(function(){
			$("#brochureslider").append( $(this) );
			iss = $('#brochureslider').children().size();			
			$("#brochureslider").css('width', (iss*960)+'px');
			$('#rightarrow').attr('src','../img/right.gif');
		});
	allcount++;
	}

	$("#translation div").each(function (i) {
        $(this).hide();
      });
	$("#t"+count).show();

	if(count==0){
		$('#clickleft').attr('title','You are at the first page');
		$('#leftarrow').hide();
	}else{
		$('#clickleft').attr('title','Click to see previous page');
		$('#leftarrow').show();
	}
	if(count==(13)){
		$('#clickright').attr('title','You are at the last page');
		$('#rightarrow').hide();
	}else{
		$('#clickright').attr('title','Click to see next page');
		$('#rightarrow').show();
	}

}

