persian= {0:'۰', 1:'۱', 2:'۲', 3:'۳', 4:'۴', 5:'۵', 6:'۶', 7:'۷', 8:'۸', 9:'۹',',':','}

function num2fa(text) {
	arr = text.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",").split("");
	out = '';
	for(x in arr) {
		out += persian[arr[x]];
	}
	return  out;
alert(out);
}

function putComma(price) {
    return price.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}

my_target = "#target";

(function (e) {
    e.fn.addScore = function (t) {
        var n = {
            data: "",
			show_result : function() {}
        };
        var r = e.extend(n, t);
        return this.each(function () {
            elm = this;
            e.ajax({
                type: "post",
                url: "" + site_url + "ajax.php?score",
                dataType: "json",
                data: r.data,
                success: function (data) {alert(data);
                    n.show_result(data, elm);
                }
			})
        })
	}
})(jQuery);

$(function() {
   default_content = $(my_target).html();
});

function go_in(e) {
    setInterval(function () {
        window.location = e
    }, 2e3)
}
function show_load() {
    if (site_dir == "rtl") {
        rol = "right"
    } else if (site_dir == "ltr") {
        rol = "left"
    }
    if (typeof $("#loader")[0] == "undefined") {
        d = $('<div id="loader">' + lang_wait + "</div>").appendTo("body")
    } else {
        d = $("#loader")
    }

    d.attr("class", "load").css("position", "fixed").css("top", "40%").css(rol, "45%").fadeIn(500)	

}

function hide_load() {
    d = $("#loader");
    if (site_dir == "rtl") {
        rol = "right"
    } else if (site_dir == "ltr") {
        rol = "left"
    }
	
    d.attr("class", "load").css("position", "fixed").css("top", "40%").css(rol, "45%").fadeOut(500, function () {
        $(this).remove()
    })
}

function load_page(e, target) {
	if(typeof target != 'undefined' ) my_target = target;
	
    lasturl = "";
	if (!$.browser.msie) {
		window.history.pushState({path:e},'',e);
	} else {
		window.location.hash = e.replace(new RegExp(site_url, "ig"), "");
	}
	
    check_hash();
}

lasturl = "";

function start_load_page() {
	if($("#link_load").size() > 0) {
		return false;
	}
	$('<div id="link_load"></div>').appendTo("body")
	$("#link_load").css("top", "0").fadeIn(500);
			
	$(".bg").fadeTo(500, 0.6);
	
	if (!$.browser.msie) {
		var t = new Sonic({
			width: 10,
			height: 10,
			padding: 15,
			strokeColor: "#5BCCD5",
			pointDistance: .01,
			stepsPerFrame: 3,
			trailLength: .7,
			step: "fader",
			setup: function () {
				this._.lineWidth = 5
			},
			path: [
				["arc", 10, 10, 10, 0, 360]
			]
		});
		t.play();
		$("#link_load").prepend(t.canvas);
	}	

}

function end_load_page() {
	$("#link_load").fadeOut(function() {
		$(this).remove();
	});

	$(".bg").fadeOut(function() {
		$(this).remove();
	});
}

function rload_page(e) {
    if (!e) e = 100;
    var n = typeof window.location.hash.split("#")[1] == "undefined" ? window.location.href : window.location.href.split("#")[1];
    if (n == "") {
        n = "#hash".value
    }
    t = setTimeout(function () {
        load_page(n);
        clearTimeout(t)
    }, e)
}

function pRslt(e, t) {
    $("#" + t).show(500).html(e)
}

function uploadsuccess(t) {
	$("#" + t).removeClass("error_error").addClass("error_success");
}

close_form = 'ok';
function ajax_done(e) {
    if (typeof now_form != "undefined") {
        $(now_form).prev().removeClass("error").addClass("success");
		
		if(close_form == 'ok') {
			$(now_form).slideUp();
		}
		
    } else {
        $("#" + e).removeClass("error_error").addClass("error_success")
    }
}

function gcu( u ) {
	window.location.href = u;
}