jQuery(function ($) {
	$('a.stdwin').live('click', function(e) {
		e.preventDefault();	
		var viewportwidth;
    var viewportheight;
    
    if (typeof window.innerWidth != 'undefined') {
      // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
    } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
      // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
      viewportwidth = document.documentElement.clientWidth,
      viewportheight = document.documentElement.clientHeight
    } else {
      // older versions of IE
      viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
      viewportheight = document.getElementsByTagName('body')[0].clientHeight
    }

    var xposition = Math.round(viewportwidth/2)-200;

		$("#stdwin-modal-content").modal({
			overlayId: 'stdwin-overlay',
			containerId: 'stdwin-container',
			closeHTML: '<div class="close"><a href="#" class="simplemodal-close"><img src="images/x.png" width="25" height="29" border="0" /></a></div>',
			minHeight:80,
			opacity:40, 
			position:['15%',xposition+'px'],
			overlayClose:true,
			onOpen:STDWIN.open,
			onClose:STDWIN.close
		});
	});

var STDWIN = {
  container: null,
  open: function (d) {
    var self = this;
    self.container = d.container[0];
    d.overlay.fadeIn('fast', function () {
      $("#stdwin-modal-content", self.container).show();
      d.container.fadeIn('fast',	function () {
        $("div.close", self.container).show();
      });
    })
  },
  close: function (d) {
    var self = this;
    d.container.fadeOut('fast',	function () {
      d.overlay.fadeOut('fast',	function () {
        self.close(); // or $.modal.close();
        updatescreen();
      });
    });
  }
};

});
  
