// Loading Page

$('#header').hide();$('#header').fadeIn(1500);
$('#news').hide();$('#news').fadeIn(2000);
$('#head_info').hide();$('#head_info').fadeIn(2000);
$('#menu').hide();$('#menu').fadeIn(2000);
$('#txt').hide();$('#txt').fadeIn(2000);
$('.box').hide();$('.box').fadeIn(2500);
$('#footer').hide();$('#footer').fadeIn(2000);

//End Loading Page


function enter_pressed(e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return false;
return (keycode == 13);
}



function mm()
{
var yu = window.location.hash.substring(1);
var nuu = yu.replace("&", "|");

    $("#txtHint").html('<img border="0" src="/image/loading.gif" width="32" height="32" align="middle">');
$.ajax({
   type: "GET",
   url: "/include/get",
   data: 'ha='+encodeURIComponent(nuu),
   success: function(msg){
      $('#txtHint').hide(); $('#txtHint').html(msg).fadeIn(3000);
   }
 });
}
$(function(){
	$('#news').vTicker({ 
		speed: 1000,
		pause: 7000,
		animation: 'fade',
		mousePause: true,
		showItems: 1
	});
});

function ghesar()
{

    $("#loadingghesar").addClass("second");
$.ajax({
   type: "POST",
   url: "/include/jomle-ghesar",
   data: "",
   success: function(msg){
      $('#ghesar').hide(); $('#ghesar').html(msg).fadeIn(1700);
    $("#loadingghesar").removeClass("second");
    $("#loadingghesar").addClass("first");
   }
 });
}


function vasiat()
{
    $("#loadingvasiat").addClass("second");

$.ajax({
   type: "POST",
   url: "/include/vasiat",
   data: "",
   success: function(msg){
      $('#vasiat').hide(); $('#vasiat').html(msg).fadeIn(1700);
    $("#loadingvasiat").removeClass("second");
    $("#loadingvasiat").addClass("first");
   }
 });
}


function get_mail(mail, ha)
{

for (var i=0; i < document.testform.halat.length; i++)
   {
   if (document.testform.halat[i].checked)
      {
      var ha = document.testform.halat[i].value;
      }
   }

    $("#message").html('<img border="0" src="/image/loading.gif" width="32" height="32" align="middle">');
$.ajax({
   type: "POST",
   url: "/include/getmail",
   data: "q="+mail+"&ha="+ha,
   success: function(msg){
      $('#message').hide(); $('#message').html(msg).fadeIn(3000);

   }
 });
}

function send_mail(txt, mail, se)
{
	if (txt != "")
	{
    	$("#message").html('<img border="0" src="/image/loading.gif" width="32" height="32" align="middle">');
		$.ajax
		(
			{
   				type: "POST",
   				url: "/include/sendmail",
   				data: "mail="+mail+"&txt="+txt+"&se="+se,
   				success: function(msg)
				{
      				$('#message').hide(); $('#message').html(msg).fadeIn(3000);
   				}
			}
		);
	}
}

// Comment Code

function send_comment(txt, mail)
{
	if (txt != "")
	{
    	$("#message_comment").html('<img border="0" src="/image/loading.gif" width="32" height="32" align="middle">');
		$.ajax
		(
			{
   				type: "POST",
   				url: "/include/sendcomment",
   				data: "mail="+mail+"&txt="+txt,
   				success: function(msg){
      			$('.close').fadeOut(500); $('#message_comment').hide(); $('#message_comment').html(msg).fadeIn(3000); $('.commentform').animate({ height: "50px" },3000, function() { $('.close').fadeIn(500); }); $('.commentform form').fadeOut(2000);
   				}
 			}
		);
	}
}

function show_comment_form()
{
		$('#mask').fadeIn(1000);
		$('.commentform').fadeIn(1500);
}

$('.comment-icon').click
(
	function()
	{
		$('#mask').fadeIn(1000);
		$('.commentform').fadeIn(1500);
	}
);

$(' .close').click
(
	function ()
	{
		$('#mask').fadeOut(1000);
		$('.commentform').fadeOut(500);
	}
);

// End Comment Code


function fg (num,hi,name) {
window.location.hash = name;
	if (num != 1) {
		for (i=1; i<=allbooks; i++) {
			$('#book'+i).fadeOut("slow");

 			$('#book'+i).css( "cursor","default" );
		}
	}else{
		for (i=1; i<=allbooks; i++) {
			if (i != num) $('#book'+i).fadeOut("slow");

 			$('#book'+i).css( "cursor","default" );
		}
	}
 document.getElementById("book"+num).setAttribute ("onclick", "");
 $('#book'+num).fadeIn(3000,function() {
 	$('#fl'+num).animate({ width: "565px" },1000);

 	$('#fl'+num).animate({ height: hi+"px" },1000, function () { $('#book'+num).css( "margin-left","0" ); $('#b'+num).fadeIn(); $('#content'+num).fadeIn(); });
 	$('#book'+num).css( "cursor","default" );

});
}

function ba (num,hi,name) {
window.location.hash = "";
$('#fl'+num).animate({ width: "255px" },1000);
$('#content'+num).fadeOut("fast");
$('#b'+num).fadeOut("fast"); 
 	$('#fl'+num).animate({ height: "200px" },1000, function() { 
		for (i=1; i<=allbooks; i++) {
			if (i != num) $('#book'+i).fadeIn(1000);
 			$('#book'+i).css( "cursor","pointer" );
		}

	if (num % 2 != 0) $('#book'+num).css( "margin-left","10px" );

	document.getElementById("book"+num).setAttribute ("onclick", "fg("+num+","+hi+",'"+name+"')");

	});


}

$(document).ready(function() {


vasiat();
ghesar();

$('.tTip').betterTooltip({speed: 150, delay: 300});

});

if (window.location.hash) {
$(document).ready(function() {
mm();
});
}

mm();

function hide_footer() {
 	$('hr').fadeOut(1000);
 	$('.footer').fadeOut(1000);
}

$("#book").change(function() {

	if ($("#book").val() == 2) {
			$("#tanzim_2").fadeIn(1500);
	}
});
