
function browserObj() {
	this.platform = ''
	this.version = 0
	this.isNav4 = false
	this.isNav6 = false
	this.isIE4 = false
	this.isIE = false
	this.isSafari = false
	this.isMajor = false
	this.isMinor = false
	this.isOpera = navigator.appVersion.toLowerCase().indexOf('opera') != -1;
	
	if (navigator.appVersion.indexOf('Mac') != -1) {
		this.platform = "mac"
	} else {
		this.platform = "pc"
	}
	
	//if (this.platform == 'mac') { alert(navigator.appName + ',' + navigator.appVersion + ',' + navigator.userAgent) }
	
	//var isNav4, isNav6, isIE4, isMajor, isMinor;
	if (navigator.appVersion.toLowerCase().indexOf('safari') != -1) {
		this.isMajor = true
		this.isSafari = true
	} else if ((navigator.appName.indexOf('Netscape') != -1)) {
		if (navigator.appVersion.charAt(0) > "4") {
			this.version = 6
			this.isNav6 = true
			this.isMajor = true
		} else {
			this.version = 4
			this.isNav4 = true;
			this.isMinor = true
		}
	} else {
		this.isIE = true
	
		uA = navigator.userAgent.toLowerCase()
		ind = uA.indexOf("msie")
		uA = uA.substr(ind, uA.length)
		ind = uA.indexOf(";")
		uA = parseFloat(uA.substr(0, ind).replace("msie", ""))
		if (uA >= 5) {
			this.version = uA
			this.isMajor = true
		} else {
			this.version = uA
			this.isIE4 = true;
			this.isMinor = true
		}
	}
}

var b = new browserObj()

function addOption( selectElement, text, value)
{
	el = (b.isNav4) ? new Option() : document.createElement("OPTION")
	el.text = text
	el.value = value
	if (!b.isIE) {
		selectElement.options[selectElement.options.length] = el
	} else {
		selectElement.options.add(el)
	}

}   

function clearSelect( element)
{
	while(element.length > 0) {
		if (!b.isIE) {
			element.options[element.options.length-1] = null
		} else {
			element.options.remove(0)
		}
	}
}

function toggle( elementName, visible, setText)
{
	if ( b.isMajor)
	{
		var element
		if ( element = searchElement(elementName))
		{
			if ( setText)
			{
				if (element.tagName != "INPUT" )
					element.innerHTML = setText;
				else {
					element.value = setText;
					if (b.isOpera)
					{
						element.value = setText;
					}	
				}	
			}
			element.style.display = visible ? "block" : "none" 
		}
	}	
}

function setText( elementName, text)
{
	if ( b.isMajor)
	{
		var element
		if ( element = searchElement(elementName))
		{
			if ( text == null)
				text = "&nbsp;";

			if (element.tagName != "INPUT" )
				element.innerHTML = text;
			else {
				element.value = text;
				if (b.isOpera)
				{
					element.value = text;
				}	
			}	
		}
	}	
}

function searchElement(id,tag)
{
     if (document.getElementById(id)) { return document.getElementById(id); }
     if (!tag) { var tag = '*'; }
     var e = document.getElementsByTagName(tag);
     for (var i=0; i < e.length; i++) {
          if (e[i].id) {
               if (e[i].id.indexOf(id) != -1) {
               return e[i];
               }
          }
     }
    return null;
}

function inspectParams( typeName, idSequence, noChangeText)
{    
	if ( b.isMajor)
	{
		element = searchElement("sel" + typeName + idSequence);
		if ( element != null)
		{
			pvalue = element[element.selectedIndex].value.split(';');
			for( var prm = 3; prm > 0; prm --)
			{
				var pnames = new Array(3);
				if (pvalue.length > prm)
					pnames = pvalue[prm].split(",");
				if ( noChangeText )
				{
					toggle( "tb"  + typeName + "P" + idSequence + "_" + prm, pvalue.length > prm);
					toggle( "div" + typeName + "P" + idSequence + "_" + prm, pvalue.length > prm, pnames[0]);
				}
				else 
				{
					toggle( "tb"  + typeName + "P" + idSequence + "_" + prm, pvalue.length > prm, pnames[2]);
					toggle( "div" + typeName + "P" + idSequence + "_" + prm, pvalue.length > prm, pnames[0]);
				}	
			
			}
		}
	}
}

function PopupAWindow(winURL, winWidth, winHeight, winName, winStyle){
		var strWinStyle = winStyle;
		if (!strWinStyle) {
			strWinStyle = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=none,resizable=no'; 
		}
		var w = (winWidth?winWidth:600)
		var h = (winHeight?winHeight:500)
		var l = (window.screen.width - w)/2; 
		var t = (window.screen.height - h)/2; 
		var style = 'width='+w+',height='+h+',top='+t+',left='+l+','+strWinStyle;
		window.open(winURL,winName, style);
}

function doHelp( elementName)
{
	if ( b.isMajor)
	{
		var element
		if ( element = document.getElementById(elementName))
		{
			pvalue = element[element.selectedIndex].value.split(';');
			PopupAWindow('chartHelp.aspx?id=' + pvalue[0], 420, 300);
		}	
	}
}


