
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function status(page,div,id)
{
    loading("module/poems/status/" + page + ".php?poem_id=" + id,div);
}


function mok(id,m_id)
{
   loading("plugin/modcp/action/cp_table_posts_mok.php?id=" + id + "&m_id=" + m_id ,"p_m_id"); 
}



function mat(id)
{
   loading("module/majales/addmajles-matam.php?id=" + id,"mawk"); 
}


function refr(id)
{
    loading("module/poems/get_subsection.php?id=" + id, id);
}



function shaaq(page,div)
{
    loading("plugin/shaaq/" + page + ".php",div);
}


function download(id,div)
{
    loading("plugin/download/show.php?d_id=" + id,div);
}


function show_numbers(id,div)
{
    loading("plugin/phonedirectory/show_inc.php?cat_id=" + id,div);
}


function waseelah(page,div)
{
    loading("plugin/nashraat/show.php?w_id=" + page,div);
}

function markaz(page,div)
{
    loading("plugin/nashraat/show2.php?w_id=" + page,div);
}


function jamm3eah(page,div)
{
    loading("plugin/nashraat/show3.php?w_id=" + page,div);
}


function nashraat(page,div)
{
    loading("plugin/nashraat/show_no.php?id=" + page,div);
}


function last(page)
{
    loading("pages/last/" + page + ".php","last");
}

function media(page,div,id)
{
    loading("module/poems/media/" + page + ".php?poem_id=" + id,div);
}


function poem_sound_show(sound_id)
{
    loading("plugin/poems/tools/poem_sound_show.php?sound_id=" + sound_id , "soundshow");
}


function poem_reply_add (poem_id)
{
    loading("plugin/poems/db/poems_reply_add.php?poem_id=" + poem_id , "addreply");
}


function poem_sound_add (poem_id)
{
    loading("plugin/poems/db/poems_sound_add.php?poem_id=" + poem_id , "soundadd");
}


function player(page,div)
{
    loading("plugin/poems/player/" + page + ".php",div);
}


function sendrate(x,poemid)
{
    if(x == 1)
    {
        loading("plugin/poems/tools/poem_rate_send.php?x=1&poem_id=" + poemid ,"yesoh");
    }
    
    if(x == 2)
    {
        loading("plugin/poems/tools/poem_rate_send.php?x=2&poem_id=" + poemid ,"yesoh");
    }
    
    if(x == 3)
    {
        loading("plugin/poems/tools/poem_rate_send.php?x=3&poem_id=" + poemid ,"yesoh");
    }
    
    if(x == 4)
    {
        loading("plugin/poems/tools/poem_rate_send.php?x=4&poem_id=" + poemid ,"yesoh");
    }
    
    if(x == 5)
    {
        loading("plugin/poems/tools/poem_rate_send.php?x=5&poem_id=" + poemid ,"yesoh");
    }
        
}


function sendtell(poemid)
{

   var name   = document.getElementById(name);
   var email   = document.getElementById(email);
   var email2 = document.getElementById(email2);

  loading("plugin/poems/tools/poem_tell_send.php?name=" + name + "&email=" + email + "&email2=" + email2 + "&poem_id=" + poemid ,"tell");
     
}


function checkpoem(poem_view,poem_title)
{
    if (poem_view.value == '') 
    {
      alert('الرجاء كتابة القصيدة أولا');
    } 
    else if (poem_title.value == '') 
    {
      alert('الرجاء كتابة عنوان للقصيدة');
    } 
    else
    {
       loading("plugin/poems/db/sections_poem_add_checkpoem.php?poem_view=" + poem_view.value + "&poem_title=" + poem_title.value ,"mosadaqa");
    }
}


function loading(url, containerid)
{
  var page_request = false
  
  if (window.XMLHttpRequest) // if Mozilla, Safari etc
     page_request = new XMLHttpRequest()
  else if (window.ActiveXObject)
  { // if IE
    try 
    {
       page_request = new ActiveXObject("Msxml2.XMLHTTP")
    } 
    catch (e)
    {
      try
      {
         page_request = new ActiveXObject("Microsoft.XMLHTTP")
      }
      catch (e)
      {
      }
    }
  }
  else
  return false
  page_request.onreadystatechange=function()
  {
    loadpage(page_request, containerid)
  } 
  if (bustcachevar) //if bust caching of external page
  bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
  page_request.open('GET', url+bustcacheparameter, true)
  page_request.send(null)
}

function loadpage(page_request, containerid)
{
  if (page_request.readyState == 1)
  {
    document.getElementById(containerid).innerHTML='<p><font face="Tahoma" style="font-size: 9pt"><img border=0 src=images/spinner.gif width=16 height=16>جار التحميل..</font></p>';
  }

  if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
  document.getElementById(containerid).innerHTML=page_request.responseText
}


