/* Functions for Noorderparkkamer 
 * Created by:	01.04.2008 - Edgar Vijgeboom (Par
 * 
 * 
 * 
 * 
*/


/* Carrousel on the homepage */
function fotoCarrousel() {
  $('#carrousel').innerfade({ animationtype: 'fade', speed: 750, timeout: 10000, type: 'sequence', containerheight: '330px' }); 
  }

/* carrousel paging */
function carrouselPaging(direction){

  /* Destrou the innerfade function */
  $.innerfade = function() {};
  $.innerfade.next = function() {};
	
	var carLength = $('#carrousel').children().length;
	var currentCarItem = yourInt = parseInt($('#carrousel').children('li:visible').attr('id'));
	
	if (direction == 'next') {
  	if ((currentCarItem + 1) <= carLength) {
  		nextCarItem = currentCarItem + 1;
  	}
  	else {
  		nextCarItem = 1;
  	}
		
  } else {
  
  	if ((currentCarItem - 1) >= 1) {
  		nextCarItem = currentCarItem - 1;
  	}
  	else {
  		nextCarItem = carLength;
  	}
  	
  }

	$('#' + currentCarItem).fadeOut(750);
	$('#' + nextCarItem).fadeIn(750, function(){
		removeFilter($(this)[0]);
	});
}


function browserScroll(direction) {
  if (direction == 'left') {
    $('#browsercontent').animate({left: "-=150px"}, 500 );
  }

  if (direction == 'right' && $('#browsercontent').css('left') != '10px') {
    $('#browsercontent').animate({left: "+=150px"}, 500 );
  }
}


function showPhoto(id){
  var tmpParameters = "action=get_photo&id=" + id;
  $('#detailphoto').attr('style','background-image:url(images/loader.gif)');
  $.ajax({
    type: "GET",
    url:  "ajax/ajax_calls.php", 
    data: tmpParameters,
    dataType: "json",
    success: function(data){
      $('.triggerLightbox').attr('id',data['photo'][0]['photo']);
		  $('#detailphoto').attr('style','background-image:url(footage/0x330_'+data['photo'][0]['photo']+')');
			$('#p_title').html(data['photo'][0]['title']);
			$('#p_year').html(data['photo'][0]['year']);
			$('#p_print').html(data['photo'][0]['print']);
			$('#p_size1').html(data['photo'][0]['size1']);
			$('#p_price1').html(data['photo'][0]['price1']);
			$('#p_size2').html(data['photo'][0]['size2']);
			$('#p_price2').html(data['photo'][0]['price2']);
			$('#p_edition').html(data['photo'][0]['edition']);
			$('#p_markings').html(data['photo'][0]['markings']);
			$('#p_provenance').html(data['photo'][0]['provenance']);
			$('#p_extraprintinfo').html(data['photo'][0]['extraprintinfo']);
			$('#p_order').attr('href','order/'+data['photo'][0]['photoid']);
			if (data['photo'][0]['size2']) { 
			 $('#size2Holder').show();
			} else {
			 $('#size2Holder').hide();
			}
      }
   }
 );
}


/* parse the Jquery functions after document ready */
$(document).ready(function(){

   $(document).bind("contextmenu",function(e){
        return false;
   });

	/* Cufon */
  $.each($.browser, function(i, val) {
   if(i=="msie" && $.browser.version.substr(0,3)=="7") {
   } else {
	    //Cufon.replace('#nav_left h1, #nav_left a.alfabet', {});
	}
	});
	
		
	/* Photographers Navigation folding */
	$(".alfabet").click(function(){
		if ($(this).next('ul').css('display') == 'block') {
			$(this).next('ul').hide();
			$(this).parent('li').removeClass('pijl-open');
		}
		else {
			$(this).next('ul').show();
			$(this).parent('li').addClass('pijl-open');
		}
		return false;
	});
	
		
	/* carrousel paging */
	$('.car_pag_next').click(function(){
    carrouselPaging('next');
		return false;
	});
	
	 $('.car_pag_prev').click(function(){
    carrouselPaging('prev');
		return false;
  });
  
  
   /* browser paging */
  $('.right').click(function(){
    browserScroll('left');
    return false;
  });
  
   $('.left').click(function(){
    browserScroll('right');
    return false;
  });
	
	
	/* Bio more */
	$('.biomore').click(function(){
    $('.bio').css({height : 'auto'});
    $('.biomore').hide();
    return false;
  });
	
	
	 /* Lighbox */
  $('.triggerLightbox').overlay({ 
        onBeforeLoad: function() { 
 
            // grab wrapper element inside content 
            var fotoname = this.getTrigger().attr('id');  
            $('#lightbox-content').html('<img src="footage/'+fotoname+'" onmousedown="alert(\'Copyright by Eyemazing Editions\');return false" />');

        } ,
        top: 70,
        left: 0,
        
     expose: { 

          color: '#000000', 
          loadSpeed: 200, 
          opacity: 0.9
      }, 
     target: '#lightbox',
     closeOnClick: true
	
	});
	

  /* Submit form */
  $('.place_order').click(function(){
    $('#orderform').submit();
    return false;
  });
  
	
});



