var absAjaxImgPopupDir = '/abs/lib/absAjaxImgPopup/';
var absAjaxImgPopupAjPhp = absAjaxImgPopupDir+'src.aj.php';
var imgPopup = {
	_showOriginal : function(img_file){
		windowSize.getWindowSize();
		$j.get(
			absAjaxImgPopupAjPhp, 
			{ 
				act: 'img_popup',
				img_file: img_file,
				winWidth: windowSize.winWidth,
				winHeight: windowSize.winHeight
			},
			function(data){
				if(data){
					var reply = data.split('|');
					// размеры изображения
					var cont = trim(reply[0]); 
					var height = trim(reply[1]); 
					var width = trim(reply[2]); 
					JsPopupWin.init(width,height,'#000','#fff','#000',0.5,'',cont);
				}
			}
		);

	
	},
	close : function(){
		JsPopupWin.close();
	},
	imgResize : function(width,height,MAXwidth,MAXheight){
		var k = 1;
		if((width > MAXwidth)||(height > MAXheight)){
			var kW = 1; var kH = 1;
			if(width > MAXwidth) var kW = width/MAXwidth;
			if(height > MAXheight) var kH = height/MAXheight;
			if(kW > kH) k = kW;
			else k = kH;
			this.NEWwidth = width/k;
			this.NEWheight = height/k;
		}
		else{
			this.NEWwidth = width;
			this.NEWheight = height;
		}
		return(this.NEWwidth+','+this.NEWheight);
	}
}


var windowSize = {
	getWindowSize: function(doc) {
    	//alert('getWindowSize');
    	doc = doc || document;
    	var win_w, win_h;
    	if (self.innerHeight) {
    		win_w = self.innerWidth;
            win_h = self.innerHeight;
        } 
        else if (doc.documentElement && doc.documentElement.clientHeight) {
            win_w = doc.documentElement.clientWidth;
            win_h = doc.documentElement.clientHeight;
        }
        else if (doc.body) {
            win_w = doc.body.clientWidth;
            win_h = doc.body.clientHeight;
        }
       // alert('win_w = '+win_w);
        this.winWidth = win_w;
        this.winHeight = win_h;
    },
    _width: function(){
    	//alert('_width');
    	this.getWindowSize();
    	//alert('return winWidth = '+this.winWidth);
    	return this.winWidth;
    },
    _height: function(){
    	this.getWindowSize();
    	return this.winHeight;
    }
}

