	var g_jlibs = Array();
	var g_clibs = Array();

	function loadFile()
	{
		for(var i = 0 ; i< arguments.length;i++){
			var file = arguments[i];
			if(file.indexOf("css") != -1)
			{
				if(jQuery.inArray(file,g_clibs) == -1)
				{
					$("head").append("<link type='text/css' rel='stylesheet' href='"+file+"' />");
					g_clibs.push(file);	
				}
			}else
			{
				if(jQuery.inArray(file,g_jlibs) == -1) // indexof doesn't work in IE
				{
					$("head").append("<script type='text/javascript' src='"+file+"'></script>");
					g_jlibs.push(file);	
				}
			}
		}
	}
	
	String.prototype.trim = function()
	{
		return this.replace(/^[\s]+|[\s]+$/,"");
	}
    
	function ulogin(trs, indicator)
	{
		this._trs = trs;
        this.busy = false;
        this.indicator = indicator;
	}
	
	ulogin.prototype.loginit = function(submit)
	{
        if( this.busy )
            return;
            
        this.busy = true;
        
        
		var lg = this;
		if($("input#ulogin").val().length < 3 || $("input#upwd").val().length < 6)
		{
			new Boxy("<p>يرجى تحديد المعلومات الصحيحة </p>",{title: 'خطأ', modal: true});
            this.busy = false;
			return;
		}
		if(lg._trs > 2 && $("tr#captchah")[0])
		{
			if($("input#captcha").val().length == 0)
			{
				new Boxy("<p>قم بتحديد الإسم المستخدم و كلمة المرور !</p>",{title: 'خطأ', modal: true});
                this.busy = false;
				return;
			}
		}
		$("span#loader").html("&nbsp; &nbsp; <img src='images/ajax-loader.gif' align='absmiddle' />");
        var act = new Boxy("<p>"+ this.indicator +" جاري تسجيل الدخول ...</p>", { title: "تسجيل الدخول", modal : true });
		$.ajax({
			url: 'ajax.php',
			dataType: 'html',
			type: 'post',
			data: $("#frmlogin").serialize(),
			success: function(i){
				var r = eval("("+i+")");
                lg.busy = false;
                act.toggle();
				if(!r.ok)
				{
					new Boxy("<p>"+r.msg+"</p>",{title: 'رسالة'});
					lg._trs++;
				}else{
                    if(r.loc)
                         location.href = r.loc;
                    else
                         location.reload();
				}
				$("span#loader").html("");
				if($("tr#captchah")[0])
				{
					if(lg._trs > 2 && $("tr#captchah").css("display") == "none")
					{
						$("tr#captchah").toggle();
						$("input#cpt_vl").val() = lg._trs;
					}
				}	
				}
			});
				
	}
	function adSearch(btn)
	{
		$(btn).parents("form").get(0).submit();
		
	}
	function msg(el,msg)
	{
		var pos = $(el).position();
		var w = $(el).ouwterWidth();
		var h = $(el).outerHeight;
		
	}
    
    
    function addToFav(url,title)
    {
        if (document.all)
            window.external.AddFavorite(url,title)
        else if (window.sidebar) // firefox
            window.sidebar.addPanel(title, url, "");
    }
    
    function printPage()
    {
        window.print();
    }
    
    function refreshCaptcha(img){
        $(img).attr("src","captcha/captcha.php?test="+(new Date).getTime());
    }
    
    function show_msg(divid,content, timer)
    {
        var elm = $("[id="+divid+"]");
        elm.html(content);
        elm.slideToggle("slow",function(){
            var obj = $(this);
            timer = (timer)?timer:3500;
            setTimeout(function(){ obj.slideToggle("slow"); },timer);
        });
    }
    
    function BoxyExists()
    {   
        if($(".boxy-wrapper").get(0))
        {
                return true;
        }
        return;
    }
    
    
    
	
	
