jQuery.fn.movableLabel = function () {
	return this.each( function (index) {
		var self = $(this);
		if(self.attr('for')){
			var label = jQuery ( this );
			var input = jQuery ( '#' + self.attr('for'));
			if ( !input ) return false;	
			label.hide ();
			input.val(label.text());
			
			input.focus(function(){
				if(jQuery( this ).val() == label.text() ){
					jQuery( this ).val('')
				}
			});
			
			input.blur(function(){
				if ( jQuery( this ).val() == '') input.val(label.text());
					
			});	
		}
	} );
}	

$(document).ready(function() {

	$('.makepreview').simplePreview();
	
	$('.artistForm input').click(function() {
		$('.artistForm').submit();
	});

	$('.artistForm select').change(function() {
		//$('.artistForm').submit();
		//top.location = '../'+$('.artistForm select option:selected').val().substring(2);
		top.location = '../'+$('.artistForm select option:selected').val();
	});
	
	$('label.movable').movableLabel();
	
	
	$('.jQCost').css('cursor','pointer');
	
	$('.jQCost').click(function() {
		$(this).next().next().next().toggle();
	});

	
	$('.closeblockbutton').css('cursor','pointer');
	
	$('.closeblockinfo').hide();
	
	$('.closeblockbutton').click(function() {
		$(this).next().toggle();
	});
	
	
	$('.gobasketbutton').click(function() {
		top.location = '/forclients/114/';
	});

	$('.uslugabutton').click(function() {
		var rel = $(this).attr('rel');
		$.cookie("pozitiffshop["+rel+"]", rel, { path: '/', expires: 3650 });
		$(this).parent().parent().hide();
		//$('.gobasketbutton[rel='+rel+']').parent().parent().parent().show();
		$('.zakazopenblocktrue[rel=div'+rel+']').show();
		
		var uslugacount = parseInt($('#uslugacountmain').text());
		$('.uslugacount').text(uslugacount+1);
	});
	
});

