function cmnInformation(){
	this.sUser_agent = navigator.userAgent.toLowerCase();
	this.bIE       = ( ( this.sUser_agent.indexOf("msie") != -1 ) && ( this.sUser_agent.indexOf("opera") == -1 ) );
	this.bOpera    = ( this.sUser_agent.indexOf("opera") != -1 );
	this.bMAC      = ( this.sUser_agent.indexOf("mac") != -1 );
	this.bGecko    = ( navigator.product == "Gecko" );
	this.bMozilla  = this.bGecko;
	this.sLanguage = null;
	this.bHTTP = null;
	return this;
}

var cmn_aPopup_defaults = [
	["width", 540],
	["height", 600],
	["menubar", "no"],
	["toolbar", "no"],
	["resizable", "yes"],
	["scrollbars", "yes"],
	["status", "yes"]
]
var cmn_aPopup = new Array();
function cmnPopup( sURL, sName, sFeatures, bReplace ){
	if( !sURL.length ){
		if( sURL && sURL.tagName.toLowerCase() == "a" ){
			if( !sName ){ sName = ( sURL.id ) ? sURL.id : "_blank"; }
			sURL = sURL.href;
		}else{
			return false;
		}
	}else if( !sName ){
		sName = "_blank";
	}
	for( var i = 0 ; i < cmn_aPopup_defaults.length ; i++ ){
		if( !cmnPairs_string_get_value( sFeatures, cmn_aPopup_defaults[i][0], "=", "," ) ){
			sFeatures = cmnPairs_string_set_value( sFeatures, cmn_aPopup_defaults[i][0], cmn_aPopup_defaults[i][1], "=", "," );
		}
	}

	var iWidth = cmnPairs_string_get_value( sFeatures, "width", "=", "," );
	var iHeight = cmnPairs_string_get_value( sFeatures, "height", "=", "," );
	if( screen ){
		var iScreen_height = screen.height ? screen.height - 100 : 0;
		var iScreen_width = screen.width ? screen.width - 100 : 0;
		var bScroll = false;
		if( iScreen_height < iHeight ){ bScroll = true; iHeight = iScreen_height; sFeatures = cmnPairs_string_set_value( sFeatures, "height", iHeight, "=", "," ); }
		if( iScreen_width < iWidth ){ bScroll = true; iWidth = iScreen_width; sFeatures = cmnPairs_string_set_value( sFeatures, "width", iWidth, "=", "," ); }
		if( bScroll ) {
			sFeatures = cmnPairs_string_set_value( sFeatures, "scrollbars", "yes", "=", "," );
		}
		sFeatures = cmnPairs_string_set_value( sFeatures, "top", Math.round( ( iScreen_height - iHeight ) / 2 ), "=", "," );
		sFeatures = cmnPairs_string_set_value( sFeatures, "left", Math.round( ( iScreen_width - iWidth ) / 2 ), "=", "," );
	}

	if( sURL.match(/\.(gif|jpe?g|png)$/i) ){
		cmn_aPopup[sName] = window.open( "", sName, sFeatures );
		if( cmn_aPopup[sName] ){
			var sTitle = unescape( cmnPairs_string_get_value( sFeatures, "title", "=", "," ) );
			sTitle = sTitle.replace( /<\/?\w[^>]*>/g, " " ).replace( /</g, "&lt;" ).replace( /</g, "&lt;" ).replace( /"/g, "&quot;" );
			cmn_aPopup[sName].document.open();
			cmn_aPopup[sName].document.write('<html><head><title>'
				+ sTitle
				+ '</title></head><body bgcolor="white" style="margin: 0px; padding: 0px;"><table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td align="center"><img src="'
				+ sURL + '" alt="'
				+ sTitle + '" /></td></tr></table></body></html>');
			cmn_aPopup[sName].document.close();
		}
	}else{
		if( !cmn_aPopup[sName] || cmn_aPopup[sName].closed || cmn_aPopup[sName].location.href != sURL ){
			cmn_aPopup[sName] = window.open( sURL, sName, sFeatures, bReplace );
		}
	}
	if( sName != "_blank" ){
		cmn_aPopup[sName].focus();
	}

	return false;
}

function cmnPairs_string_get_value( sText, sName, sFrom, sBefore ){
	var sValue = "";
	if( sText ){
		if( !sFrom ) sFrom = "=";
		if( !sBefore ) sBefore = ";";
		sText = sText.replace( new RegExp( "(" + sBefore + ")\\s+", "g" ), "$1" );
		var iStart = sText.indexOf( sBefore + sName + sFrom );
		if( iStart >= 0 ){
			iStart += ( sBefore.length + sName.length + sFrom.length );
		}else{
			iStart = sText.indexOf( sName + sFrom );
			if( iStart == 0 ){
				iStart += ( sName.length + sFrom.length );
			}else{
				iStart = -1;
			}
		}
		if( iStart >= 0 ){
			var iEnd = sText.indexOf( sBefore, iStart );
			if( iEnd < 0 ){
				iEnd = sText.length;
			}
			sValue = sText.substring( iStart, iEnd );
		}
	}
	return sValue;
}

function cmnPairs_string_set_value( sText, sName, sValue, sFrom, sBefore ){
	if( !sFrom ) sFrom = "=";
	if( !sBefore ) sBefore = ";";
	var iStart = -1;
	if( sText ){
		sText = sText.replace( new RegExp( "\\s+(" + sBefore + "|" + sFrom + ")\\s+", "g" ), "$1" );
		iStart = sText.indexOf( sBefore + sName + sFrom );
		if( iStart >= 0 ){
			iStart += ( sBefore.length + sName.length + sFrom.length );
		}else{
			iStart = sText.indexOf( sName + sFrom );
			if( iStart == 0 ){
				iStart += ( sName.length + sFrom.length );
			}else{
				iStart = -1;
			}
		}
		if( iStart >= 0 ){
			var iEnd = sText.indexOf( sBefore, iStart );
			if( iEnd < 0 ){
				iEnd = sText.length;
			}
			sText = sText.substring( 0, iStart ) + sValue + sText.substr( iEnd );
		}
	}
	if( iStart < 0 ){
		if( sText && sText.lastIndexOf( sBefore ) != ( sText.length - sBefore.length ) ){
			sText += sBefore;
		}
		sText += sName + sFrom + sValue + sBefore;
	}
	return sText;
}
