function PopupImage(imgPath, title) {
    var win = window.open('','araneapreview',
    'width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1');
    
    if (title == undefined) title = VIEW_IMAGE;
    var content = '<html><head><title>' + title + '</title>' +
    			  '<style>body { margin:0px; padding:0px; } #div-image { padding:2px; overflow:auto; } img { border:0; text-align:center; } form { margin:0px; padding:0px; } #header { text-align:center; margin:0px; padding:5px; background:#E6E6E6; color:navy; font-size:14px; font-weight: bold; }</style>' +
    			  '</head><body><div id="all"><div id="header">' + title + '</div><div id="div-image" align="center"><a href="javascript:self.close()">' +
    			  '<img alt="' + CLOSE_WINDOW + '" id="image" src="' + imgPath + '" /></a></div></div></body></html>'
    win.document.write(content);
    
    win.document.body.onload = function() {
    	var obj = win.document.getElementById('image');
    	var w = obj.width, h = obj.height;
    	var iHeight= document.body.clientHeight, iWidth = self.innerWidth;
    	
    	var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;
    	var top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;
		
		if (w + 25 > screen.availWidth) {
			left = 0;
			w = screen.availWidth;
		} else {
			w += 25;
		}

		if (h + 120 > screen.availHeight) {
			top = 0;
			h = screen.availHeight;
		} else {
			h += 120;
		}
	
		win.resizeTo(w, h);	
		win.moveTo(left, top);
		win.document.getElementById('div-image').style.width = (win.document.body.clientWidth - 4) + 'px';
		win.document.getElementById('div-image').style.height = (win.document.body.clientHeight - 4 - 28) + 'px';
    }
    win.onload = win.document.body.onload; // special for Mozilla
    
    win.document.close();
    win.focus();
}

function toggleDisplay(Id) {
	if ( document.getElementById(Id) ) {
		if ( document.getElementById(Id).style.display == 'none' ) {
			document.getElementById(Id).style.display = '';
		} else {
			document.getElementById(Id).style.display = 'none';
		}
	}
	return 0
}

function checkLengthForm(fld_name, maxlength) {
	lastlength = parseInt(maxlength) - document.order_form.elements[fld_name].value.length;
	if (lastlength <= 0) {
		document.order_form.elements[fld_name].value = document.order_form.elements[fld_name].value.substring(0, maxlength);
		lastlength = parseInt(maxlength) - document.order_form.elements[fld_name].value.length;
	}
	if (document.order_form.elements['_count_' + fld_name]) {
		document.order_form.elements['_count_' + fld_name].value = lastlength;
	}
	return 0
}

function setSelected(_item) {
	if ( document.getElementById(_item) ) {
		document.getElementById(_item).className = 'selected';
	}
}

function showAJAXicon(_item, _mode) {
	if ( document.getElementById(_item) ) {
		if ( _mode == 0 ) {
			document.getElementById(_item).innerHTML = '<div style="clear:both; margin:5px 0 10px 0;"><img src="' + site_url + 'images/icon-ajax.gif" width="31" height="31" alt="-" /></div>';
		}
		if ( _mode == 1 ) {
			document.getElementById(_item).innerHTML = '<div style="clear:both; margin:0;"><img src="' + site_url + 'images/icon-ajax.gif" width="31" height="31" alt="-" /></div>';
		}
		if ( _mode == 2 ) {
			document.getElementById(_item).innerHTML = '<div style="clear:both; margin:5px 0 10px 0; text-align:center;"><img src="' + site_url + 'images/icon-ajax.gif" width="31" height="31" alt="-" /></div>';
		}
	}
}