
function loop11addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else
      window.onload = fnc;
  }
}

if ( ! get_cookie ( "loop11" ) && (document.domain != 'www.loop11.com') ) {
	loop11addOnloadEvent(loop11init);
	var current_date = new Date;
    var cookie_year = current_date.getFullYear ( );
    var cookie_month = current_date.getMonth ( ) + 1;
    var cookie_day = current_date.getDate ( );
    set_cookie ( "loop11", 942, cookie_year, cookie_month, cookie_day );
}

function loop11init() {
  loop11include_styles();
  var loop11overlay = document.createElement('div');
  loop11overlay.setAttribute('id', 'loop11overlay');
  var loop11lightbox = document.createElement('div');
  loop11lightbox.setAttribute('id', 'loop11lightbox');
  
  loop11overlay.style.height = loop11getViewportDims()[1] + 'px';
  
  loop11lightbox.innerHTML = "\
  <div id='loop11close'><a href='#' onclick='loop11removewindow(); return false;'>Close this window</a></div>\
  <img id='loop11logo' alt='Loop11' src='http://www.loop11.com/media/images/loop11_small.jpg' />\
  <div id='loop11popupcontent'>\
    <p id='loop11intro'>Please take just a moment to provide us with your feedback on PHP License Script.</p>\
  </div>\
  <div id='buttonFaux'>\
    <div>\
	  <a href='http://www.loop11.com/usability-test/942/introduction/'>Begin evaluation</a>\
	</div>\
  </div>";
  
  loop11hideflash();
  
  
  document.body.appendChild(loop11overlay);
  document.body.appendChild(loop11lightbox);
  loop11overlay.style.height = document.body.offsetHeight - loop11getViewportDims()[1] - loop11lightbox.offsetHeight + 'px';
  loop11lightbox.style.top = Math.round((loop11getViewportDims()[1]/2) - (loop11lightbox.offsetHeight)) + 'px';
  window.scroll(0,0);
}


function loop11removewindow() {
  document.body.removeChild(document.getElementById('loop11lightbox'));
  document.body.removeChild(document.getElementById('loop11overlay'));
  loop11showflash();
}

function loop11include_styles() {

  var css = document.createElement('link');
  css.setAttribute('rel', 'stylesheet');
  css.setAttribute('type', 'text/css');
  css.setAttribute('href', 'http://www.loop11.com/media/css/popup.css');
  document.getElementsByTagName('head')[0].appendChild(css);
  return false;
}

function loop11getViewportDims() {
  var viewportwidth;
  var viewportheight;
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
 return [viewportwidth, viewportheight];
}

function loop11hideflash()
{
        /* hide all flash in the page */
        flash = document.getElementsByTagName('embed')
        for (var i = 0; i < flash.length; i++) 
        { 
                flash[i].style.visibility = 'hidden';
        }
}

function loop11showflash()
{
        /* show all flash */
        flash = document.getElementsByTagName('embed')
        for (var i = 0; i < flash.length; i++) 
        { 
                flash[i].style.visibility = 'visible';
        }
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}



