function select_checkbox(me)

{

    var arrs = me.split(",");

    for(var i=0; i < arrs.length; i++)

    {

        document.getElementById(arrs[i]).checked = true;

    }

}

function select_all(th_class, typ)

{



   $(th_class).each(function()

   {

      if(!typ)

      {

         this.checked = true;

      }

      else

      {

        this.checked = false;

      }

   });

}

function clrphrase(me, phrase)

{

    if(me.value == phrase)

    {

        me.value = "";

    }

}

function setphrase(me, phrase)

{

    if(!me.value)

    {

        me.value = phrase;

    }

}



function ask(q)
{
    if(q)
    {
        if(!confirm(q))
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}
function goto(url)
{
    window.open(url, "_self");
}
function gotothispage(url)
{
    window.setTimeout('goto( "' + url + '");', 1000);
}

function ask_b(q, url)
{
    window.open('#', "_self");
    $("#head_messages").html('<center>رسالة إدارية</center>');
    $("#data_messages").html(q);

    $("#url").html(url);
    $("#hide_url").bind('click', function()
    {
        goto($("#url").html());
    }).show();
    display_form('messages');
    return false;

    /*if(ask(q))
    {
        goto(url);
    }
    else
    {
        return false;
    }*/
}

function get_id(me)
{
    return document.getElementById(me);
}
function clrphrase(me, phrase)
{
    if(me.value == phrase)
    {
        me.value = "";
    }
}
function setphrase(me, phrase)
{
    if(!me.value)
    {
        me.value = phrase;
    }
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1)
      {
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
      }
    }
    return false;
}

function close(me)
{
$("#" + me).fadeOut('slow');
}

function displaying_slide(value, id)
{
     if(value == 'show')
     {
          $("#" + id).fadeIn('slow');
     }
     else
     {
          $("#" + id).fadeOut('slow');
     }
}

function str_replace(olds, news, text)
{
    for(var i = 0; i <= text.length; i++)
    {
        text = text.replace(olds, news);
    }

    return text;
}

function gets_b(ask, url)
{
    var qsss = prompt(ask,"");
    if(qsss != null && qsss != ' ')
    {
        var url_ar = url.split('&');
        var urls = "";
        for(var i = 0; (i + 1) < url_ar.length; i++)
        {
            urls += url_ar[i] + "&";
        }
        var url_val = url_ar[url_ar.length - 1].replace('=', "");
        $("body").append('<form id="formation_main" action="' + urls + '" method="post"><input type="text" name="' + url_val + '" value="' + qsss + '"></form>');
        $("#formation_main").submit();
    }
    return false;
}

function mk_change(me)
{
    var mes = $(me).parent().get(0);
    if(document.getElementsByTagName('form') && mes.tagName != 'FORM')
    {
       var foundit;
       while(foundit != true)
       {
            mes = $(mes).parent().get(0);
            if(mes.tagName == 'FORM')
            {
                foundit = true;
            }
       }
    }

    if(mes.tagName == 'FORM')
    {
        $(mes).find('input').each(function()
        {
            if(this.type == 'checkbox' && this != me)
            {
                if(me.checked)
                {
                    this.checked = true;
                }
                else
                {
                   this.checked = false;
                }

            }
        });
    }
}

function gopopup(me)
{
    var theleft = (screen.width / 2) - 350;
    var theheight = (screen.height / 2) - 350;
    window.open(me.href, "","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=600,left=" + theleft + ",top=" + theheight);
    return false;
}

function alert(q)
{
    $("#hide_url").hide();
    window.open('#', "_self");
    $("#head_messages").html('رسالة إدارية');
    $("#data_messages").html(q);
    display_form('messages');
}
