var js_popupMenus = 0;

$( document ).ready( function() {
	$( '#startEmail' ).click( function() {
		$( '#startEmail' ).val( '' ).css( 'color', '#000' );
		$( '#startPw1' ).hide();
		$( '#startPw2' ).show().css( 'color', '#000' );
		
		return false;
	});
	
	$( '.submenus' ).click( function( event ) {
		var id = $( this ).attr( 'id' ).split( '_' );
		var coor = $(this).offset();
		
		if( id[1] == js_popupMenus ) {
			$( '#boxMenu_' + id[1] ).fadeOut();
			js_popupMenus = 0;
			
			return false;
		}
		
		if( js_popupMenus )
			$( '#boxMenu_' + js_popupMenus ).fadeOut();
		
		$( '#boxMenu_' + id[1] ).css( {'top' : coor.top, 'left' : coor.left + 150} ).fadeIn();
		js_popupMenus = id[1];
		
		return false;
	});
	
	// Go to register
	$( '#register' ).click( function() {
		window.location.href = 'index.php?ctr=registerIndex';
	});
	
	// Manage captcha function
	$('#btContinue').click(function() {
		$.ajax({
			type: 'POST',
			url: 'index.php?ctr=ajaxCommander&class=contactCreateCaptcha&tpl=captcha',
			data: {
				data: 1
			},
			success: function( data ) {
				$('.boxCaptcha').html( data ).slideDown();
				$('#btContinue').hide();
				$('#btSend').show();
			}
		});
	});
	
	// Show photo preview
	$( '.pictPrev' ).click( function( event ) {
		var ID = $( this ).attr( 'id' );
		showMainPopup();
		
		$.ajax({
			type: 'POST',
			url: 'index.php?ctr=ajaxCommander&class=photosGetPhoto',
			data: {
				id: ID
			},
			success: function(data) {
				$('.showPhoto').html(data);

				$('.close').click(function() {
					$('.lightbox_bg').fadeOut();
					$('.showPhoto').fadeOut();
					
					return false;
				});
			}
		});
	});
});
