$(document).ready(function(){

	my_smothscroll();

	$(window).load(initchattyform);

	// igootooltip();

	$("#clientlist").jFlow({
		slides: "#mySlides",
		controller: ".jFlowControl",
		slideWrapper : "#jFlowSlide",
		selectedWrapper: "jFlowSelected",
		width: "100%",
		//height: "240px",
		duration: 200,
		interval: 5000,//小官提示：修改间隔时间
		prev: ".jFlowPrev",
		next: ".jFlowNext"
	});

	$('div#navigation ul li a').hover(function() {
		$(this).animate({ paddingLeft: '0px' },200);//10px
	}, function() {
		$(this).animate({ paddingLeft: '0' }, 200);
	});

	// validate the comment form when it is submitted
	//$("#commentform").validate();

	/*
	$('#comment').one('focus',function(){
		$('#comment').parent().after('');
	});
	*/

	var $comment = ''; // that's two single quotation-marks at the end

	
	$('#email').keyup(function(){
		$author = $.md5($(this).val());
		$('#preview-gravatar').attr('src','http://www.gravatar.com/avatar/' + $author + '?s=48')
		//$('#preview-gravatar-test').html('http://www.gravatar.com/avatar/' + $author + '?s=32');
		//$md5test = $.md5("I'm Persian.");
		//$('#preview-gravatar').html($md5test);
	});

	$('#author').keyup(function(){
		$commentby = $(this).val();
		$('#comment-by').html($commentby);
	});

	$('#url').keyup(function(){
		$commenturl = $(this).val();
		$('#comment-by').attr('href', $commenturl); 
	});
	
	$('#comment').keyup(function(){
		$comment = $(this).val();
		$comment = $comment.replace(/\n/g, "<br />").replace(/\n\n+/g, '<br /><br />').replace(/(<\/?)script/g,"$1noscript");
		$('#live-preview').html( $comment );
	});

	$("#seallprojects").click(function(){
		$("#otherprojects").slideToggle("slow");
		return false;
	});

	//$.pir.options.php="pir.php";
	//$("h1").pir({font: "porytt.ttf", wrap: true});
	//$("h4").pir();




	$('ul#foliofilter a').click(function()
	{
		$(this).css('outline','none');
		$('ul#foliofilter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'all') 
		{
			//$('ul#folio li.hidden').removeClass('hidden');
			//$('ul#folio li.on').removeClass('on');
			//$('ul#folio li.off').removeClass('off');

			$('ul#folio li').animate({opacity: 1},500);
		} 
		else 
		{
			$('ul#folio li').each(function()
			{
				if(!$(this).hasClass(filterVal))
				{
					//$(this).addClass('poff');
					//$(this).removeClass('pon');
					$(this).animate({opacity: 0.1},500);
				} 
				else
				{
					//$(this).addClass('pon');
					//$(this).removeClass('poff');
					$(this).animate({opacity: 1},500);
				}
			});
		}
		return false;
	});




/*
	$('form#cForm').submit(function() {
		$('form#cForm .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			$('form#cForm li.buttons button').fadeOut('normal', function(){
				$(this).parent().append('<span class="formloading"></span>');
			});
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#cForm').slideUp("fast", function() {				   
					$(this).before('<span class="thanks"><strong>Thanks!</strong> The information you provided in the contact form has been sent and we will get back to you shortly.</span>');
				});
			});
		}
		
		return false;
		
	});





 
===	LOGIN BOX 


	// some functions to resuse
	function slideboxin(){	$("div#loginbox").animate({"marginTop": "+=50px", "opacity": "toggle"}, "slow");}
	function slideboxout(){	$("div#loginbox").animate({"marginTop": "+=50px", "opacity": "toggle"}, "slow");}
	function fademaskout(){	$("div#loginmask").fadeOut("fast")}

	// login button
	$('div#loginbutton').click(function()
	{
		$("div#loginmask").fadeIn("fast", slideboxin)

	}, function()
	{
		$("div#loginmask").fadeOut("fast", slideboxout)
	});

	// click mask to dismiss
	$("div#loginmask").click(function(){
			$("div#loginbox").animate({"marginTop": "-=50px", "opacity": "toggle"}, "slow", fademaskout);
	});

	// or closeme button
	$("span#closeme").click(function(){
		$("div#loginbox").animate({"marginTop": "-=50px", "opacity": "toggle"}, "slow", fademaskout);
	});

	// input hints for login inputs
	$('div#loginbox input[title!=""]').hint();

	// logged in notification
	$("p#loginstatus").fadeOut('slow').fadeIn('slow').fadeOut('slow').fadeIn('slow').fadeOut('slow').fadeIn('slow');


*/



});
