function PopupImage(imgPath, title) {
    var win = window.open('','araneapreview',
    'width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1,scrollbar=0,status=0');
    
    if (title == undefined) title = VIEW_IMAGE;
    var content = '<html><head><title>' + title + '</title>' +
    			  '<style>body { overflow:hidden; margin:0px; padding:0px; } img { border:0; text-align:center; } form { margin:0px; padding:0px; } #all { margin:5px; padding:2px; border:1px solid #CCCCCC; } #header { text-align:center; margin:0px; padding:10px; background:#E6E6E6; color:navy; font-size:14px; font-weight: bold; }</style>' +
    			  '</head><body><div id="all"><div id="header">' + title + '</div><div 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;
    	win.resizeTo(w+25, h+130);
    	win.moveTo(left, top);
    }
    win.onload = win.document.body.onload; // special for Mozilla
    
    // !!! Very important statement: popup onload won't execute without it!
    win.document.close();
    win.focus();
}    

function toggleDisplay(Id) {
	
	if ( document.getElementById(Id) ) {
		if ( document.getElementById(Id).style.display == 'none' ) {
			hideAll();
			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
}
