
//var picWidth = 558;
//var picHeight = 1600;

function ajustImageSize(obj,picWidth,picHeight){
	var rw = obj.width;
	var rh = obj.height;
	var w = picWidth;
	var h = picHeight;
	
	var s1=rw/w;
	var s2=rh/h;
	var r={w:0,h:0};
	if(s1>s2)
	{
		r.w=rw/s1
		r.h=rh/s1;	
	}else{
		r.w=rw/s2
		r.h=rh/s2;
	}
	if(isNaN(r.w)){
		setTimeout(function(){
			ajustImageSize(obj,picWidth,picHeight);
			obj=void(0);
		},100);
		return;
	};
	obj.width = r.w;
	obj.height  = r.h; 
	
	//var marginTop = (h-r.h)/2   +"px";
	//var marginLeft = (w-r.w)/2  +"px";
	
	//obj.style.marginTop = parseInt(marginTop)+"px";
	//obj.style.marginLeft = parseInt(marginLeft)+"px";
	obj.setAttribute("ajusted","1");
	
	if(picWidth>=860){
		makeCenter(obj.width,obj.height);
	}

}


//window.onresize=
//window.onload =  
function makeCenter(w,h){
    var fade = document.getElementById('fade');
    var getBody = document.getElementById('body');
    fade.style.left = (getBody.clientWidth - 960)/2 + "px";
    
    var light = document.getElementById('light');
    light.style.left = (getBody.clientWidth - 860)/2 + "px";
 	
 	fade.style.height = h+200+"px";
}



function openWin () {
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	document.getElementById('showSelect').style.display='none';
}
function closeWin () {
	document.getElementById('light').style.display='none';
	document.getElementById('fade').style.display='none'
	document.getElementById('showSelect').style.display='block';
}