/*
   =============================================
   Project:		Sucrehomes
   Version:		1.0
   Author:		Paulo Mendes
*/

function doc_GetHeight()
{
  var h = 0;

  if (typeof (window.innerWidth) == 'number') {
    h = window.innerHeight;
  } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    h = document.documentElement.clientHeight;
  } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
    h = document.body.clientHeight;
  }

  return h;
}

function newsletter_OnInit(w, h, src)
{
  var lb = document.createElement('div');
  var sw = doc_GetHeight();

  if (document.body.scrollHeight > sw) sw = document.body.scrollHeight;

  with (lb) {
    id = 'lightbox';
    style.height = sw + 'px';

    setAttribute('onclick', 'newsletter_OnUnload();');
  }

  document.body.appendChild(lb);

  newsletter_OnLoad(w, h, src);
}

function newsletter_OnUnload()
{
  parent.document.body.removeChild(parent.document.getElementById('lightbox'));
  parent.document.body.removeChild(parent.document.getElementById('newsletter'));

}

function newsletter_OnLoad(w, h, s)
{
  var d = document.createElement('div');
  
  with (d) {
    id = 'newsletter';

    style.width = w + 'px';
    style.height = h + 'px';

    style.marginLeft = '-' + parseInt(w / 2) + 'px';
    style.top = ($(window).height() - h) / 2 + $(window).scrollTop() + 'px';
  }

  var i = document.createElement('iframe');

  var mw = 14;
  var mh = 28;

  with (i) {
    width = (w - mw) + 'px';
    height = (h - mh) + 'px';

    setAttribute('frameborder', 0);
    setAttribute('scrolling', 'no');
    setAttribute('src', s);
    setAttribute('marginwidth', 0);
    setAttribute('marginheight', 0);
  }

  d.appendChild(i);
  document.body.appendChild(d);
}

function newsletter_OnClick()
{
  for (var i=0; i < document.forms[0].elements.length; i++) {
    if (document.forms[0][i].type == 'radio') {
      if (document.forms[0][i].checked == true) {
        window.open(document.forms[0][i].value);
        newsletter_OnUnload();
        break;
      }
    }
  }
}










function _close()
{
  window.close();
}

function _print()
{
  window.print();
}

function _flash(d, s, w, h) 
{
  var html = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + w + "' height='" + h + "'>" +
  			 "<param name='movie' value='" + s + "'>"+
			 "<param name='quality' value='high'>"+
			 "<embed src='" + s + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + w + "' height='" + h + "'></embed>"+
			 "</object>"

  document.getElementById(d).innerHTML = html
}

function _open(_id)
{
    window.open('../WebPages/PrintPreview.aspx?nidartigo=' + _id, '', 'resizable=yes,location=no,status=no,toolbar=no,scrollbars=yes,width=594,height=600,left=' + (screen.width - 594) / 2 + ',top=' + (screen.height - 600) / 2);
}
