$(document).ready(function() {

    $('.menu a').click(function() {	
	if ( $('#popup').css('top') == '-140px' ) {
	  var name = $(this).attr('href');
	  var content = $('.content-' + name).html();
	  $('#popup .body').html(content);
	  $('#popup').animate({ 'top': '0px' });	
	} else {
	  $('#popup').animate({ 'top': '-140px' }, 400);	
	}
	return false;
    });

    $('#popup .close').click(function() {
	$('#popup').animate({ 'top': '-140px' }, 400);	
	return false;
    });

    $('.submit a').click(function() {
	if ( !selectCubeFlag ) {
	  alert('Contribute the Artwork first!');
	  return false;
	}

	if ( !$('.name').attr('value') ) {
	  alert('Fullname is compulsory');
	  return false;
	}

	if ( !$('.country').attr('value') ) {
	  alert('Country is compulsory');
	  return false;
	}
	
	if ( confirm('Validate and send your contribution?') ) {
	  DoFunction('hudMain.submit', 
		     $('.name').attr('value'),
		     $('.country').attr('value'),
		     $('.email').attr('value'));
	  //$('#SHIVA3D').hide();
	  $('.submit-form-table').hide();
	  $('.submit-form-thanks').fadeIn();
	  $('.contributors span').html(parseInt($('.contributors span').html()) + 1);
	  var countries = parseInt($('.countries span').html());
	  if ( countries == 0 )
	    $('.countries span').html("1")
	  //setTimeout(function() { location.href = "/?submit=ok" }, 1000);
	  return false;
	}

	return false;
    });


});

