var nx_timeout;
function showPage(view, req, p1)
{
	$.post(
		'view/' + view + '.php',
		{req: req, par1: p1},
		function (data)
		{
			$("#content").html(data);
			//jqScrollTo($('#main-content'), -130);
			if (view=='customer') {initTooltip(); nx_timeout = setTimeout('showNextCustomer()', 8000);}
			if (view=='orgchart') {initTooltip(); initChartSlider();}
			hideLoading();
		}
	);
	showLoading();
}
function showNextCustomer()
{
	$.post(
		'view/customer.php',
		{req: 'shownext'},
		function (data)
		{
			if ($("#customerslist").length == 1 && data.substr(0,1) == '1') {
				$("#customerslist").html(data.substr(1)).fadeTo(800, 1, function() {nx_timeout = setTimeout('showNextCustomer()', 8000);});
				initTooltip();
			}
		}
	);
	$("#customerslist").fadeTo(1000, 0.3);
}
function showNextGallery(id)
{
	$.post(
		'view/gallery.php',
		{req: 'shownext', id: id},
		function (data)
		{
			var sp = data.split("@`@");
			$("#appreciationlist").html(sp[1]).fadeTo(800, 1, function() {nx_timeout = setTimeout('showNextGallery('+sp[0]+')', 8000);});
		}
	);
	$("#appreciationlist").fadeTo(1000, 0.3);
}
function saveJob()
{
	$.post(
		'view/employ.php',
		{ req: "add", fname: $("#fname").val(), lname: $("#lname").val(), email: $("#email").val(), age: $("#age").val(), tel: $("#tel").val(), mob: $("#mob").val(), reshte: $("#reshte").val(), uni: $("#uni").val(), cert: $("#cert").val(), sabeghe: $("#sabeghe").val(), lesson: $("#lesson").val() },
		function (data)
		{
			if (data.substr(0, 1) == 0) {
				$("#cstatus").attr("class", "fail").html(data.substr(1));
			} else {
				$("#cstatus").attr("class", "success").html(data);
				$("dl input,textarea").val("");
			}
			jqScrollTo($('#content'), -15);
			hideLoading();
		}
	);
	showLoading();
}
function saveUser()
{
	$.post(
		'view/user.php',
		{ req: "add", fname: $("#fname").val(), lname: $("#lname").val(), email: $("#email").val(), ext: $("#ext").val(), regtype: $("input:radio:checked").val(), info: $("#info").val() },
		function (data)
		{
			if (data.substr(0, 1) == 0) {
				$("#cstatus").attr("class", "fail").html(data.substr(1));
			} else {
				$("#cstatus").attr("class", "success").html(data);
				$("dl").css("display",'none');
				
			}
			jqScrollTo($('#content'), -15);
			hideLoading();
		}
	);
	showLoading();
}
function showLicence()
{
	$.post(
		'view/licence.php',
		{ req: "search", name: $("#Name").val(), family: $("#Family").val() },
		function (data)
		{
			if (data.substr(0, 1) == 0) {
				$("#cstatus").attr("class", "fail").css('display','block').html(data.substr(1));
			} else {
				$("#cstatus").css('display','none');
				$("#lictxt").html(data);
			}
			hideLoading();
		}
	);
	showLoading();
}
function sendMessage()
{
	$.post(
		'view/contact.php',
		{ req: "savemessage", name: $("#Name").val(), email: $("#Email").val(), tel: $("#Tel").val(), message: $("#Message").val() },
		function (data)
		{
			if (data.substr(0, 1) == 0) {
				$("#cstatus").attr("class", "fail").html(data.substr(1));
			} else {
				$("#cstatus").attr("class", "success").html(data);
				$("#Name,#Email,#Tel,#Message").val("");
			}
			hideLoading();
		}
	);
	showLoading();
}
function showCert(id)
{
	$.post(
		'view/licence.php',
		{ req: "makelicence", id: id },
		function (data)
		{
			hideLoading();
			show_modal_licence(data);
		}
	);
	showLoading();
}


function showLoading()
{
	$("#loading").css("height", $(document).height()).css("opacity", 0.0).css("display", "block").fadeTo(700, 0.5);
	$("#inprogress").css("top", ($(window).height() / 2) - 100 + $(window).scrollTop() + "px").css("left", ($(document).width() / 2) - 75 + "px").css("display", "block");
}
function hideLoading()
{
	$("#loading").fadeTo(500, 0, function() { $(this).css("display", "none"); });
	$("#inprogress").css("display", "none");
}
function inlineLoading1(el)
{
	$(el).html('<div style="background: url(image/indicator_blue_large.gif) no-repeat center center; height: 40px;"></div>');
}