﻿function placeImages(HD, CC, Audience) {   

    //DIVs
    var currDiv = document.getElementById('divInfo');
    var newDiv = document.createElement('div');

    //Check Corresponding elements
    if (CC == "Closed Captioned") {

          CC = " <img src='../images/television/closed_caption_icon.png'> ";
     }
     
     if (HD == "HD") {

          HD = " <img src='../images/television/hdtv_icon.png'> ";
     }

     //Attibutes
     newDiv.setAttribute('id', 'descImages')
     newDiv.innerHTML = HD + ' ' + CC;
     currDiv.appendChild(newDiv);
 }

 function actorLabels(programID) {
  
     //Current Division
     var currDiv = document.getElementById('actorDiv');     
     var i = 0;

     //Missing jSON
     $.getJSON('../television/getCastDetail.aspx', { program: programID, type: 'actor' }, function (data) {

         $.each(data.posts, function (i, json) {

             console.log('Actor', json.name);

             //New Label
             var newLabel = document.createElement('label');
             i++;
             newLabel.setAttribute('id', i);
             newLabel.innerHTML = newLabel.innerHTML + json.name + "    ";

             if (i > 0 && ((i + 1) % 3 == 0)) {

                 newLabel.innerHTML = newLabel.innerHTML + "<br/>";
             }
             currDiv.appendChild(newLabel);
         });
     });
        
     //}
 }

 function directorLabels(programID) {

     //Current Division
     var currDiv = document.getElementById('directorDiv');
     //for (i = 0; i < 5; i++) {

     //Missing jSON
     $.getJSON('../television/getCastDetail.aspx', { program: programID,type: 'director' }, function (data) {

         $.each(data.posts, function (i, json) {

             console.log('Actor', json.name);

             //New Label
             var newLabel = document.createElement('label');

             newLabel.setAttribute('id', i + 5);
             newLabel.innerHTML = newLabel.innerHTML + json.name + "    ";

             if (i > 0 && ((i + 1) % 3 == 0)) {

                 newLabel.innerHTML = newLabel.innerHTML + "<br/>";
             }

             currDiv.appendChild(newLabel);

         });
     });
         
    //}
 }                    
