Pop = {};
Pop.get = function(url)
{
	$('<div id="content" />').load(url, function(){
		$(this).hide();
		$('#main').html(this);
		$(this).slideDown(1000);
		var targetOffset = $('#scrool').offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 500);
		});
}


$(function(){

			$('a.internal-link').click(function(){
				url = $(this).attr('href');
				Pop.get(url);
				return false;
			});
});
$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#e7eef1"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  $('.error').hide();
  $('textarea').css({backgroundColor:"#FFFFFF"});
  $('textarea').focus(function(){
    $(this).css({backgroundColor:"#e7eef1"});
  });
  $('textarea').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $("#news_comment_submit").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var subject = $("input#subject").val();
		if (subject == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
    
      var web = $("input#web").val();
	  if (web == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
       var newsid = $("input#newsid").val(); 
       var text = $("textarea#text").val();
	   if (text == "") {
       $("label#phone_error").show();
       $("input#phone").focus();
      return false;
    }

		
		var dataString = 'name='+ name + '&email=' + email + '&subject=' + subject +  '&web=' + web +  '&newsid=' + newsid +  '&text=' + text  + '&submit_contact=1';
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "comment.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>نظرشما با موفقیت ارسال گردید</h2>")
        .append("<p>به زودی بررسی خواهد شد</p>")
        .hide()
        .fadeIn(1500, function() {
        });
      }
     });
    return false;
	});

});


