// global variables - no global variables//
  var topposition
  var leftposition 


// calculate the current window width //
 function pageWidth()  
  {
  return window.innerWidth != null ? window.innerWidth : document.documentElement && 
  document.documentElement.clientWidth ? 
  document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
 }

// calculate the current window height //
function pageHeight()  
 {
  return window.innerHeight != null? window.innerHeight : document.documentElement && 
  document.documentElement.clientHeight ? 
  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
 }

// calculate the current window vertical offset //
function topPosition() 
  {
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && 
  document.documentElement.scrollTop ? 
  document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
  }

// calculate the position starting at the left of the window //
  function leftPosition() 
  {
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && 
  document.documentElement.scrollLeft ? 
  document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
   }

function showDialog(toppsotion, leftposition)
 {
  var main;
  if(!document.getElementById('main')) 
   {
    main = document.createElement('div');  // for I.E.//
    main.id = 'main';  //assigning the css id 'main' to variable 'main.id // 
     document.body.appendChild(main);
   } 
    else 
  {
    main = document.getElementById('main');
     main.style.visibility = "visible";
   }
   
  var width = pageWidth(); //defines the variable 'width' from the function window.innerWidth //
  var height = pageHeight(); //defines the variable 'height' from the function window.innerHeight //
  var left = leftPosition(); //defines the variable 'left' from the function topPosition from 'window.pageXOffset' //
  var top = topPosition(); //defines the variable 'top' from the function leftPosition from 'window.pageYOffset' //
  var mainwidth = main.offsetWidth; //asignes offset in width of main box from the css propery//
  var mainheight = main.offsetHeight;
  if  (width >= 1280) 
{
 var topposition = top + (height/2) - (mainheight/2); //defines the variable for positioning the main box from the top //
  var leftposition = left + (width/2) - (mainwidth/2); //defines the variable leftposition to center the main box//
  main.style.top = topposition + "px";  
  main.style.left = leftposition + "px"; 
  }
  else
  {	
  var topposition = 0; //defines the variable for positioning the main box from the top //
  var leftposition = 0; //defines the variable leftposition to center the main box//
  main.style.top = topposition + "px";  
  main.style.left = leftposition + "px"; 
}

