﻿//IE6用absolute值不断变化模拟fixed 
var isIE6 = !-[1,] && !window.XMLHttpRequest;
var position = function(){
		html = document.getElementsByTagName('html')[0];
	if (isIE6 && document.body.currentStyle.backgroundAttachment !== 'fixed') {
		html.style.backgroundImage = 'url(about:blank)';
		html.style.backgroundAttachment = 'fixed';
	};
	return {
		fixed: isIE6 ? function(elem){
				var style = elem.style,
					dom = '(document.documentElement)',
					left = parseInt(style.left) - document.documentElement.scrollLeft,
					top = parseInt(style.top) - document.documentElement.scrollTop;
				this.absolute(elem);
				style.setExpression('left', 'eval(' + dom + '.scrollLeft + ' + left + ') + "px"');
				style.setExpression('top', 'eval(' + dom + '.scrollTop + ' + top + ') + "px"');
			} : function(elem){
				elem.style.position = 'fixed';
		},
		absolute: isIE6 ? function(elem){
				var style = elem.style;
				style.position = 'absolute';
				style.removeExpression('left');
				style.removeExpression('top');
			} : function(elem){
				elem.style.position = 'absolute';
		}
	};
}();

function openWin(o){
	var $o = $('#'+o),
		w =  document.documentElement.clientWidth,
		h =  document.documentElement.clientHeight,
		boxLeft = (w - $o.width() )/2 +'px',
		sh = isIE6? document.documentElement.scrollTop:0,
		boxTop = (h - $o.height())/2 + sh - 100+'px';
	$o.css({'top':boxTop, 'left':boxLeft}).show();
	


	//add overlay
	if($('#overlay').length>0){
		$('#overlay').show();
	}else{
	    var w=pageWidth();
		var	h =  Math.max(document.body.clientHeight, document.documentElement.clientHeight);
			iFrame = isIE6? '<iframe style="position:absolute; width:'+w+';height:' + h + '"frameborder="0"></iframe>':'';
		$('#append_parent').append('<div id="overlay" style="position:absolute; top:0;left:0;z-index:1984;width:'+w+';height:'+ h +'px;background:#000;opacity:.2;filter:alpha(Opacity:20);">'+ iFrame +'</div>');
	}

}
function closeWin(o){
	$('#overlay').hide();
	$('#'+o).hide();
	return false;
}
function pageWidth(){ 
if($.browser.msie){ 
return document.compatMode == "CSS1Compat"? document.documentElement.clientWidth : 
document.body.clientWidth; 
}else{ 
return self.innerWidth; 
} 
}; 
