
function onProductionChange()
{
   var selProd = document.getElementById('selProduction').value;
   document.location = "list.php?type="+selProd;
}

function onProgrammeChange(strType)
{
   var selItem = document.getElementById('selProgramme').value;
   if (selItem!=0)
   {
      document.location = "detailslist.php?type="+strType+"&id="+selItem;
   }
   
}


function onMediaChange(p_elem)
{
   if (p_elem.value != '0')
   {
      if (document.getElementById("captionPlay") == null)
      {
         var strURL = document.getElementById("vid_url_"+p_elem.value).value;
         showVideo('VideoContentDiv', '/video/'+strURL, '352px', '288px');
         return true;
      }
      var strCaption = document.getElementById("vid_title_"+p_elem.value).value;
      var strPic = document.getElementById("vid_pic_"+p_elem.value).value;
      var strURL = document.getElementById("vid_url_"+p_elem.value).value;
      document.getElementById("captionPlay").innerHTML = "&nbsp;" + strCaption.toUpperCase();
      document.getElementById("imgVideoPreview").src = "image.php?img=images/video_prev/" + strPic+"&w=352";
      document.getElementById("btnPlay").onclick = function()
      {
         showVideo('VideoContentDiv', '/video/'+strURL, '352px', '288px');
      }
   }
   return true;
}

function onMediaChange2(id)
{
      if (document.getElementById("captionPlay") == null)
      {
         var strURL = document.getElementById("vid_url_"+id).value;
         showVideo('VideoContentDiv', '/video/'+strURL, '352px', '288px');
         return true;
      }
      var strCaption = document.getElementById("vid_title_"+id).value;
      var strPic = document.getElementById("vid_pic_"+id).value;
      var strURL = document.getElementById("vid_url_"+id).value;
      document.getElementById("captionPlay").innerHTML = "&nbsp;" + strCaption.toUpperCase();
      document.getElementById("imgVideoPreview").src = "image.php?img=images/video_prev/" + strPic+"&w=352";
      if (strURL!="")
      {
         document.getElementById("btnPlay").style.display="";
      }
      else
      {
         document.getElementById("btnPlay").style.display="none";
      }
      document.getElementById("btnPlay").onclick = function()
      {
         showVideo('VideoContentDiv', '/video/'+strURL, '352px', '288px');
      }
   return true;
}

function onAboutRowClick(p_elem)
{
   var id_about = p_elem.id.split('_')[1];
   window.open("modifyabout.php?id="+id_about,"edit_window","location=0,status=1,scrollbars=0,width=620,height=650");
}

function onAddAbout()
{
   window.open("modifyabout.php","edit_window","location=0,status=1,scrollbars=0,width=620,height=650");
}

function onPartnerRowClick(p_elem)
{
   var id = p_elem.id.split('_')[1];
   window.open("modifyparthers.php?id="+id,"edit_partner_window","location=0,status=1,scrollbars=0,width=620,height=300");
}

function onAddPartner()
{
   window.open("modifyparthers.php","edit_partner_window","location=0,status=1,scrollbars=0,width=620,height=300");
}

function reloadParentWindow()
{
   opener.location.reload(true);
   opener.focus();
   self.close();
}

function doSubmit()
{
   document.getElementById("contact_form").submit();
}

function doVideoSubmit()
{
   document.getElementById("videomain").submit();
}

var g_ProductionEditWindows = [];
var g_ProductionNewWindow = null;
var g_ProductionVideoWindows = [];
var g_ProductionNewVideoWindow = null;

function onProductionRowClick(p_elem, selType)
{
  var id_item = p_elem.id.split('_')[1];
  //var selType = document.getElementById('fid_type').value;
  if (g_ProductionEditWindows["mod_prod"+id_item] && (! g_ProductionEditWindows["mod_prod"+id_item].closed))
  {
    g_ProductionEditWindows["mod_prod"+id_item].focus();
  }
  else
  {
    g_ProductionEditWindows["mod_prod"+id_item] = window.open("modifyproduction.php?id="+id_item+"&type="+selType,"mod_prod"+id_item,"location=0,status=1,scrollbars=1,width=820,height=650");
  }
}

function onAddProduction()
{
  var selType = document.getElementById('fid_type').value;
  if (g_ProductionNewWindow && (! g_ProductionNewWindow.closed))
  {
    g_ProductionNewWindow.focus();
  }
  else
  {
    g_ProductionNewWindow = window.open("modifyproduction.php?type="+selType,"add_window"+selType,"location=0,status=1,scrollbars=0,width=820,height=650");
  }
}

function onChangeViewProductionType(p_elem,id)
{
  strQuery = "action=ChangeViewProductionType";
  if (id == "")
  {
    strQuery += "&type="+p_elem.value;
  }
  else
  {
    strQuery += "&type="+p_elem.value+"&id="+id;
  }
  http("POST", "ajax.php", ChangeViewProductionHandler, strQuery);
}

function ChangeViewProductionHandler(p_strResult)
{
  var elem = document.getElementById("newIndex");
  if (elem)
  {
    elem.options.length = 0;
    for (var i = 0; i < p_strResult.length; i++)
    {
      elem.options[i] = new Option(p_strResult[i].value, p_strResult[i].value);
      if (p_strResult[i].selected) elem.selectedIndex = i;
    }
  }
}


function UpdateVideoList(id)
{
  strQuery = "action=FetchVideoList";
  strQuery += "&id="+id;
  http("POST", "ajax.php", UpdateVideoListHandler, strQuery);
}

function UpdateVideoListHandler(p_strResult)
{
  var strHTML = "<table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
  var elem = document.getElementById("videoList");
  if (elem)
  {
    for (var i = 0; i < p_strResult.length; i++)
    {
      strHTML +=
       "<tr class=\"TextWhite\" id=\"row_"+p_strResult[i].IdItem+"\""+
       " onMouseOver=\"this.className='TextRed'\" onMouseOut=\"this.className='TextWhite'\" ondblclick=\"onVideoRowClick(this,'"+p_strResult[i].IdProd+"');\"> \n" +
       "<td width=\"350\" style=\"border: 1px solid black; border-right : none;\">&nbsp;"+p_strResult[i].ItemName+"</td>\n"+
       "<td align=\"center\"  style=\"border: 1px solid black;border-right : none;\">"+p_strResult[i].IsVisible+"</td>\n"+
       "<td align=\"center\"  style=\"border: 1px solid black;\">"+p_strResult[i].OnlyVideo+"</td>\n"+
       "</tr>";
    }
    strHTML += "</table>";
    elem.innerHTML = strHTML;
  }
}

function onChangeProductionType(p_elem)
{
   document.location = "production.php?type="+p_elem.value;
}

function onAddVideo(p_id_prod)
{
  if (g_ProductionNewVideoWindow && (! g_ProductionNewVideoWindow.closed))
  {
    g_ProductionNewVideoWindow.focus();
  }
  else
  {
    g_ProductionNewVideoWindow = window.open("modifyvideo.php?idp="+p_id_prod,"new_video"+p_id_prod,"location=0,status=1,scrollbars=0,width=700,height=550");
  }
}

function onVideoRowClick(p_elem,p_id_prod)
{
    var id_item = p_elem.id.split('_')[1];
   window.open("modifyvideo.php?idp="+p_id_prod+"&id="+id_item,"video_window","location=0,status=1,scrollbars=0,width=700,height=550");
}

function onAttachVideo()
{
   var ReturnedValue = window.open("../upload/upload.php","upload_window","location=0,status=1,scrollbars=0,width=400,height=200");
}

function removeVideo(id, id_prod)
{
   if (confirm("Do you really want to remove this item?"))
   {
      document.location = "modifyvideo.php?id="+id+"&par=remove&id_prod="+id_prod;
   }
}

function removeProduction(id)
{
   if (confirm("Do you really want to remove this item and all assigned to it video items??"))
   {
      document.location = "modifyproduction.php?id="+id+"&par=remove";
   }
}



