$(document).ready(function(){											 
  $('#photos').galleryView({
    panel_width: 652,
    panel_height: 276,
    frame_width: 120,
    frame_height: 120,
    overlay_opacity: 0,
    easing: 'easeInOutQuad',
    background_color: 'transparent',
    border: 'none',
    pause_on_hover: true
  });
});

$(document).ready(function(){                      
  $("a[rel=fancybox_group]").fancybox({
    'transitionIn' : 'none',
    'transitionOut' : 'none',
    'titlePosition' : 'over',
    'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
      return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    }
  });
});

var total = 0;
var count = 0;
	
$(document).ready(function(){ 			   
  $('.numbersOnly').keydown(numbersOnly);
	$('.numbersOnly').keyup(numbersOnly);
	$('.numbersOnly').blur(function() { calculate(); });
	$('.noSelect').click(function(e) { this.blur(); });
	$('.noSelect').focus(function(e) { this.blur(); });
	$('.noInput').keyup(function(e) {	calculate(); });
	$('.calculatorRow').each(function() {
			$(this).toggleClass('lightGrayBackground', count++ % 2 == 0)				 
	});
	calculate();
});
				
function calculate() {
	total = 0;
	$('.calculatorRow').each(function () {
		//var rowTotal = roundNumber($(this).children(".valueField").val() * $(this).children(".quantityInput").val(), 2);
		var rowTotal;
		rowTotal = $(this).children(".calculatorRowArticle").children(".valueArea").html();
		rowTotal = rowTotal.replace(/[^0-9.]/g,'');
		rowTotal = parseFloat(rowTotal);
		
		if( $(this).children(".quantityInput").val() == "" )
			$(this).children(".quantityInput").val(0);
		
		rowTotal = roundNumber(rowTotal * $(this).children(".quantityInput").val(), 2);
	
		$(this).children(".resultField").val(rowTotal);
			
		total += rowTotal;
		
	});
	$('#calculatorTotal').html(roundNumber(total, 2));	
}

function numbersOnly() {
	this.value = this.value.replace(/[^0-9]/g,'');
}

function roundNumber(num, dec) {
	return Math.round( Math.round( num * Math.pow( 10, dec + 1 ) ) / Math.pow( 10, 1 ) ) / Math.pow(10,dec);
}

/***************************/
/** GOOGLE MAPS FUNCTIONS **/
/***************************/

function initializeGoogleMap() {
  var location = new google.maps.LatLng(-32.120864, 115.870378);
  var map = new google.maps.Map(document.getElementById("googleMapCanvas"), {
    zoom: 13,
    center: location,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });
  var marker = new google.maps.Marker({ map: map, position: location });
}

