﻿				$(function(){
						   
			$(document).ready(function() {
			$("#SignUpForm").validationEngine()
			$("#LoginForm").validationEngine()
			$("#CommentForm").validationEngine()
			});
				
			$('#CommentForm').validationEngine({
				ajaxSubmit: true,
					ajaxSubmitFile: 'CommentAjax.php',
					ajaxSubmitMessage: '<div class="Form-Success">با تشکر، نظرات شما دریافت شد. در صورت تایید مدیریت سایت نظر شما در این صفحه نمایش داده خواهد شد.</div>',
				success : function() { callSuccessFunction() },
				failure : function() { callFailFunction()  }
			});
			
				// Dialog			
				$('#dialog').dialog({
					autoOpen: false,
					width: 500,
					buttons: {
						"بستن": function() { 
							$(this).dialog("close"); 
						}
					}
				});
				
				$('#dialog2').dialog({
					autoOpen: false,
					width: 270,
					buttons: {
						"بستن": function() { 
							$(this).dialog("close"); 
						}
					}
				});
				
		
				// Dialog Link
				$('#dialog_link').click(function(){
					$('#dialog').dialog('open');
					return false;
				});
				
				$('#dialog_link2').click(function(){
					$('#dialog2').dialog('open');
					return false;
				});
				
			//hover states on the static widgets
			$('#dialog_link2, ul#icons li').hover(
				function() { $(this).addClass('ui-state-hover'); }, 
				function() { $(this).removeClass('ui-state-hover'); }
			);
			
			
		  // Reset Font Size
		  var originalFontSize = $('.Left-Bar').css('font-size');
		  $(".resetFont").click(function(){
		  $('.Left-Bar').css('font-size', originalFontSize);
		  });
		  // Increase Font Size
		  $(".increaseFont").click(function(){
			var currentFontSize = $('.Left-Bar').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			if ( newFontSize < 26 ) {
			$('.Left-Bar').css('font-size', newFontSize);
			}
			return false;
		  });
		  // Decrease Font Size
		  $(".decreaseFont").click(function(){
			var currentFontSize = $('.Left-Bar').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*0.8;
			if ( newFontSize > 8 ) {
			$('.Left-Bar').css('font-size', newFontSize);
			}
			return false;
		  });
		  
		// ToolTip	
		$("a").tooltip();
							
		});
				
			function AjaxCatList(cat_id) {
			var timestamp = Number(new Date()); // current time as number
			// Show the loading div
			$("#Ajax-Loading").fadeIn("slow");
			// Delete any pre-existingtable
			$("#AjaxCatList").slideUp("slow");
			$("#AjaxCatList").empty("fast");
			$("#AjaxSubList").slideUp("slow");
			$("#AjaxSubList").empty("fast");
			$("#AjaxItems").slideUp("slow");
			$("#AjaxItems").empty("fast");
			$("#AjaxCatText").slideUp("slow");
			$("#AjaxCatText").empty("fast");
			$("#AjaxSubText").slideUp("slow");
			$("#AjaxSubText").empty("fast");
			// Load the data
			$.get("../AjaxCatList.php?cat_id="+cat_id+"", {type: "A"}, function(data) {
			// When the Ajax call finishes:
			// fade out the loading div
			$("#Ajax-Loading").fadeOut("slow");
			// append the table of data to the contentArea div
			$("#AjaxCatList").append(data);
			$("#AjaxCatList").slideDown("slow");
			});
			$.get("../AjaxCatText.php?cat_id="+cat_id+"&time="+timestamp+"", {type: "A"}, function(data3) {
			// When the Ajax call finishes:
			// fade out the loading div
			$.get("../AjaxCatItems.php?cat_id="+cat_id+"", {type: "A"}, function(data2) {
			// When the Ajax call finishes:
			// fade out the loading div
			$("#Ajax-Loading").fadeOut("slow");
			// append the table of data to the contentArea div
			$("#AjaxItems").append(data2);
			$("#AjaxItems").slideDown("slow");
			});
			$("#Ajax-Loading").fadeOut("slow");
			// append the table of data to the contentArea div
			$("#AjaxCatText").append(data3);
			$("#AjaxCatText").slideDown("slow");
			});
			}
			
			function AjaxSubList(cat_id) {
			var timestamp = Number(new Date()); // current time as number
			// Show the loading div
			$("#Ajax-Loading").fadeIn("slow");
			// Delete any pre-existingtable
			$("#AjaxSubList").slideUp("slow");
			$("#AjaxSubList").empty("slow");
			$("#AjaxItems").slideUp("slow");
			$("#AjaxItems").empty("fast");
			$("#AjaxSubText").slideUp("slow");
			$("#AjaxSubText").empty("fast")
			// Load the data
			$.get("../AjaxSubList.php?cat_id="+cat_id+"", {type: "A"}, function(data) {
			// When the Ajax call finishes:
			// fade out the loading div
			$("#Ajax-Loading").fadeOut("slow");
			// append the table of data to the contentArea div
			$("#AjaxSubList").append(data);
			$("#AjaxSubList").slideDown("slow");
			});
			$.get("../AjaxCatItems.php?cat_id="+cat_id+"", {type: "A"}, function(data2) {
			// When the Ajax call finishes:
			// fade out the loading div
			$("#Ajax-Loading").fadeOut("slow");
			// append the table of data to the contentArea div
			$("#AjaxItems").append(data2);
			$("#AjaxItems").slideDown("slow");
			});
			$.get("../AjaxCatText.php?cat_id="+cat_id+"&time="+timestamp+"", {type: "A"}, function(data4) {
			// When the Ajax call finishes:
			// fade out the loading div
			$("#Ajax-Loading").fadeOut("slow");
			// append the table of data to the contentArea div
			$("#AjaxSubText").append(data4);
			$("#AjaxSubText").slideDown("slow");
			});
			}
			
			function AjaxItemList(cat_id,StartRow) {
			// Show the loading div
			$("#Ajax-Loading").fadeIn("slow");
			// Delete any pre-existingtable
			$("#AjaxItems").slideUp("slow");
			$("#AjaxItems").empty("slow");
			// Load the data
			$.get("../AjaxCatItems.php?cat_id="+cat_id+"&StartRow="+StartRow+"", {type: "A"}, function(data) {
			// When the Ajax call finishes:
			// fade out the loading div
			$("#Ajax-Loading").fadeOut("slow");
			// append the table of data to the contentArea div
			$("#AjaxItems").append(data);
			$("#AjaxItems").slideDown("slow");
			});
			}
