
function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
function resizeBody()
{

}

function getElemPosition(id)
{
  var elem = $('#'+id).get(0);
  var l = 0;
  var t = 0;
  var w = elem.offsetWidth;
  var h = elem.offsetHeihgt;
  while (elem)
  {
    l += elem.offsetLeft;
    t += elem.offsetTop;
    elem = elem.offsetParent;
  }
  return {"l":l,"t":t,"w":w,"h":h};
}



var MessWin = {
winid:'messwin',
title:'',
body:'',
buttons:'',
zIndex:100,
shadowHeight:5,
shadowOpacity:0.5,
shadowBackground:'#757575',
blockOpacity:0.2,
blockBackground:'#FFFFFF',

init:function(title,body,buttons)
{
  this.title = title;
  this.body = body;
  this.buttons = buttons;
},

create:function()
{
  if(!$('#'+this.winid).length)
  {
    $(document.body).append("<div id='"+this.winid+"'></div>");
  }
  $('#'+this.winid).empty();
  $('#'+this.winid).html("<div /><div /><div />");
  $('#'+this.winid+' div:nth-child(1)').attr('id',this.winid+'_title');
  $('#'+this.winid+' div:nth-child(2)').attr('id',this.winid+'_body');
  $('#'+this.winid+' div:nth-child(3)').attr('id',this.winid+'_buttons');
  $('#'+this.winid+'_title').html(this.title);
  $('#'+this.winid+'_body').html(this.body);
  $('#'+this.winid+'_buttons').html(this.buttons);
  if(!$('#'+this.winid+'_shadow').length)
  {
  	$('#'+this.winid).after("<div />");
  	$('#'+this.winid).next().attr('id',this.winid+'_shadow');
  }
  if(!$('#'+this.winid+'_block').length)
  {
  	$('#'+this.winid).after("<div />");
  	$('#'+this.winid).next().attr('id',this.winid+'_block');
  }
  this.show();
},

show:function()
{
 $('#'+this.winid).css('position','absolute');
 $('#'+this.winid).css('z-index',(this.zIndex+2));
 $('#'+this.winid).show();
 $('#'+this.winid).css('left',(getClientWidth()-parseInt($('#'+this.winid).attr('offsetWidth')))/2);
 $('#'+this.winid).css('top',((getClientHeight()-parseInt($('#'+this.winid).attr('offsetHeight')))/2+document.body.scrollTop));
 $('#'+this.winid+'_shadow').css('position','absolute');
 $('#'+this.winid+'_shadow').css('z-index',(this.zIndex+1));
 $('#'+this.winid+'_shadow').css('width',$('#'+this.winid).attr('offsetWidth'));
 $('#'+this.winid+'_shadow').css('height',$('#'+this.winid).attr('offsetHeight'));
 $('#'+this.winid+'_shadow').css('top',(parseInt($('#'+this.winid).css('top'))+this.shadowHeight));
 $('#'+this.winid+'_shadow').css('left',(parseInt($('#'+this.winid).css('left'))+this.shadowHeight));
 $('#'+this.winid+'_shadow').css('background',this.shadowBackground);
 $('#'+this.winid+'_shadow').css('filter','alpha(opacity='+this.shadowOpacity*100+')');
 $('#'+this.winid+'_shadow').css('-moz-opacity',this.shadowOpacity);
 $('#'+this.winid+'_shadow').css('opacity',this.shadowOpacity);
 $('#'+this.winid+'_shadow').show();

 $('#'+this.winid+'_block').css('position','absolute');
 $('#'+this.winid+'_block').css('z-index',this.zIndex);
 $('#'+this.winid+'_block').css('top',0);
 $('#'+this.winid+'_block').css('left',0);
 $('#'+this.winid+'_block').css('width',getClientWidth());
 $('#'+this.winid+'_block').css('height',getClientHeight());
 $('#'+this.winid+'_block').css('background',this.blockBackground);
 $('#'+this.winid+'_block').css('filter','alpha(opacity='+this.blockOpacity*100+')');
 $('#'+this.winid+'_block').css('-moz-opacity',this.blockOpacity);
 $('#'+this.winid+'_block').css('opacity',this.blockOpacity);
 $('#'+this.winid+'_block').show();
},

showBox:function(title,body,buttons)
{
  this.init(title,body,buttons)
  this.create();
},

hide:function()
{
  $('#'+this.winid).hide();
  $('#'+this.winid+'_shadow').hide();
  $('#'+this.winid+'_block').hide();
}
};


$(document).ready(function () {
/*$(window).bind("resize", function(){resizeBody();});*/
$("a.popupimg").fancybox();
});


