﻿/**
 * Description: general javascript actions and functions for the news Module News V2
 * User: nuno.a
 * Date: 24/Out/2011
 **/

function loadIpaper(int_iPaperId) {
  var str_htmlHolder = '';

  /* load the dynamicweb iPaper scripts, because the global paragraph content doesn't load the paragraph module script */
  $.getScript( '/Admin/Public/Module/Ipaper/swfobject.js' , function() {
    $.getScript( '/Admin/Public/Module/Ipaper/popup.js' , function() {
      // todo o iPaper está a ficar com left:15px e right:-2px em div.popUpContent
      showIpaper( int_iPaperId );
    } );
  } );

  if ( !$( "iframe.iPaperIframe" ).length ) {
    str_htmlHolder = '' +
                     '<iframe id="ipPrintFrame' + int_iPaperId + '" class="iPaperIframe"></iframe>' +
                     '<div id="popupContent' + int_iPaperId + '" class="popUpContent" style="display:none;"></div>' +
                     '<div id="popupMask' + int_iPaperId + '" class="popUpMask" style="display:none;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;"></div>' +
                     '<div id="popupSource' + int_iPaperId + '" class="popUpSource">' +
                     '<div>' +
                     '<div class="iPaperButtonBar"><table width="100%"><tr><td class="topCell1"></td><td class="topCell2">&nbsp;</td><td class="topCell3"></td></tr></table></div>' +
                     '<div class="flashContentWrapper">' +
                     '<table width="100%"><tr><td class="middleCell1"></td><td class="middleCell2" id="tblFlashContentParent' + int_iPaperId + '"><div id="flashContent' + int_iPaperId + '" class="flashContent"></div></td><td class="middleCell3"></td></tr></table>' +
                     '</div>' +
                     '<div class="iPaperButtonBar"><table width="100%"><tr><td class="bottomCell1"></td><td class="bottomCell2"></td><td class="bottomCell3"></td></tr></table></div>' +
                     '</div>' +
                     '</div>';

    $( "div#wrapper" ).append( str_htmlHolder );
  }
  else {
    $( "iframe.iPaperFrame" ).attr( "id" , "ipPrintFrame" + int_iPaperId );
    $( "div.popUpContent" ).attr( "id" , "popupContent" + int_iPaperId );
    $( "div.popUpMask" ).attr( "id" , "popupMask" + int_iPaperId );
    $( "div.popUpSource" ).attr( "id" , "popupSource" + int_iPaperId );
    $( "td.middleCell2" ).attr( "id" , "tblFlashContentParen" + int_iPaperId );
    $( "div.flashContent" ).attr( "id" , "flashContent" + int_iPaperId );
  }
}
