$(document).ready(
		
		
	function()
    {
		
		$('#PayConfirm').bind('click', function(){
	    	var Credits = $('#Credits').val();
	    	var PayMethod = $('#PayMethod').val();
	    	var uLang = 'en';
	    	url = '/' + uLang + '/usys/credits/userCheckPay/';
	    	
	    	if(Credits == 0 || PayMethod == 0) 
	    	{
	    		$('#Credits').addClass('null_field');
	    		$('#PayMethod').addClass('null_field');
	    		$('#PayAttention').removeClass('hide');
	    	}
	    	
	    	if(Credits != 0 || PayMethod != 0)
	    	{
	    		if(Credits != 0) $('#Credits').removeClass('null_field');
	    		if(PayMethod != 0) $('#PayMethod').removeClass('null_field');
	    		if(Credits != 0 && PayMethod != 0)$('#PayAttention').addClass('hide');
	    	}
	    	
	    	if(Credits != 0 && PayMethod != 0)
	    	{
	    		$.ajax(
	    				{
	    		            type: 'POST',
	    		            url: url,
	    		            data: { 'credits': Credits, 'pay_method': PayMethod },

	    		            success: function( data )
	    		            {
	    		            	var Result = data.split('/');
	    		            	$('#PayMethodSelector').addClass('hide');
	    			    		$('#CreditsSelector').addClass('hide');
	    			    		$('#PayConfirmSelector').addClass('hide');
	    			    		$('#PayCheck').removeClass('hide');
	    			    		$('#PayConfirmCheck').removeClass('hide');
	    			    		
	    			    		var Msg = "<p><strong>Проверьте данные</strong></p>" +
	    			    				"<p>Способ оплаты: <strong>" + Result[0] + "</strong></p>" +
	    			    				"<p>Тип валюты: <strong>" + Result[1] + "</strong></p>"+
	    			    				"<p>Сумма: <strong>" + Result[2] + " " + Result[1] + "</strong></p>";

	    			    		$('#PayCheckText').html(Msg);

	    		            }
	    		        }
	    		    );
	    	}

	    	return false;  
		});
		
		
		$('#PayChange').bind('click', function(){
			
			$('#PayMethodSelector').removeClass('hide');
			$('#CreditsSelector').removeClass('hide');
			$('#PayConfirmSelector').removeClass('hide');
			$('#PayCheck').addClass('hide');
			$('#PayConfirmCheck').addClass('hide');
			
		});
    	
		if ($('#over-slider').size() > 0) 
		{
			$('#over-slider').cycle({
				fx: 'fade',
				speed: 'fast',
				timeout: 0,
				next: '#overNext',
				prev: '#overPrev'
			});
		}
		

		setTimeout(function() {
			$("#errBlock").animate( {
				opacity : "hide",
				top : "-=30",
				height : "0"
			}, 1500);
		}, 10000);
		

		setTimeout(function() {
		$("#infBlock").animate( {
				opacity : "hide",
				top : "-=30",
				height : "0"
			}, 1500);
		}, 10000); 
		
		
		if( $('a.title').size() > 0 ) {
			$('a.title').cluetip( {
				cluetipClass : 'jtip',
				arrows : true,
				splitTitle : '|'
			});
		} 
		
		
		if ($("a[rel='photo-message']").size() > 0) {
			$("a[rel='photo-message']").colorbox({
					transition:'elastic',
					speed:500,
					overlayClose: true,
					opacity:0.70,
					preloading: true,
					iframe: true,
					width: 600,
					height: 500
				});
			}
		
		
		
		
		if ($("a[rel='languages']").size() > 0) {
			$("a[rel='languages']").colorbox({
					transition:'elastic',
					speed:500,
					overlayClose: true,
					opacity:0.70,
					preloading: true,
					iframe: true,
					width: 635,
					height: 420
				});
			}
		
		
		if ( $('#datepicker').length > 0 )
	    {
			$('#datepicker').datepicker();
	    }
		

		if ($(".red").size() > 0) {
			$(".red").treeview({
				animated: "fast",
				collapsed: true,
				unique: true,
				persist: "cookie",
				
				toggle: function() {
					window.console && console.log("%o was toggled", this);
				}
				
			});
		}
		
		
		if ($("a[rel='preview-mail']").size() > 0) {
			$("a[rel='preview-mail']").colorbox({
					transition:'elastic',
					speed:500,
					overlayClose: true,
					opacity:0.70,
					preloading: true,
					iframe: true,
					width: 850,
					height: 620
				});
			}
		
		
		$('a#store-payment').each(function() {
			var $link = $(this);
			var $dialog = $('<div></div>')
				.load($link.attr('href') + ' #payment-content')
				.dialog({
					autoOpen: false,
					title: $link.attr('title'),
					//title: $link.attr('href') + 'title',
					width: 520,
					height: 350,
				});

			$link.click(function() {
				$dialog.dialog('open');

				return false;
			});
		});
		
		
		if($('#adult_second').is(':checked'))
        {
        	$("#mainGroups").hide();
        }
        else
        {
        	$("#mainGroups").show();
        	$("#adultGroups").hide();
        }
		
		
    }
	
);
