jQuery.fn.hint = function() {
    return $(this).each(function (){
        var t = jQuery(this);
        var title = t.attr('title');
        if (title) {
            t.blur(function (){
                if (t.val() == '') {
                    t.val(title);
                    t.addClass('blur');
                }
            });
            t.focus(function (){
                if (t.val() == title){
                    t.val('');
                    t.removeClass('blur');
                }
            });
            t.blur();
        }
    });
}


$(document).ready(function() {
	$('.snav a').click(function() {
			hrefhref = $(this).attr('href');
			idd = hrefhref.substr(1,hrefhref.length);
			$('.snav a').removeClass('here');
			$(this).addClass('here');
			$('.scont').hide();
			$('#'+idd).show();
			return false;
	});
	$('.he1').click(function() {
		$('#order').fadeIn();
		return false;
	});
	
	$('#call .call-close').live('click', function() {
		$('#call').fadeOut();
		return false;
	});
	$('.order-close').live('click', function() {
		$('#order').fadeOut();
		
		return false;
	});
	$('.togglecall').click(function() {
		$('#call').fadeIn();
		return false;
	});
	$('#call .but').click(function() {
		var urphone = $("#urphone").val(); 
		var urname = $("#urname").val(); 
		
		var dataString = 'urname='+ urname + '&urphone=' + urphone;  

		//alert(dataString);
		$.ajax({  
		  type: "POST",  
		  url: "spam.php",  
		  data: dataString,  
		  success: function() {  
		    $('#call').addClass('feedback-sent').html("<a href='#' class='call-close'></a><h2>Мы вам перезвоним!</h2>");  
		  }  
		});
		return false;
	});
	//another form
	$('#order .but').click(function() {
		var fname = $("#ff1").val(); 
		var fcall = $("#ff2").val(); 
		var femail = $("#ff3").val(); 
		var fsite = $("#ff4").val();
		var fcomment = $("#ff5").val(); 

		var dataString = 'fname='+ fname + '&fcall=' + fcall + '&femail=' + femail + '&fsite=' + fsite + '&fcomment=' + fcomment;  

		//alert(dataString);
		$.ajax({  
		  type: "POST",  
		  url: "http://www.trionika.com/order.php",  
		  data: dataString,  
		  success: function() {  
		    $('#order').addClass('feedback-sent').html("<a href='#' class='call-close order-close'></a><h2>Мы вам перезвоним!</h2>");  
		  }  
		});
		return false;
	});
	
	
	$('input[title!=""],textarea[title!=""]').hint();
});

