
var BrowserIsOpera = (navigator.userAgent.indexOf("Opera") >= 0);


function OpenWindow(URL, Name, Width, Height) {
	var PositionX = 0;
	var PositionY = 0;
	var DefaultWidth  = 600;
	var DefaultHeight = 400;
	var WinObject, Params = 'scrollbars=1, resizable=1, left=' + PositionX + ', top=' + PositionY;
	Params += ', width=' + ((isNaN(parseInt(Width))) ? DefaultWidth : Width);
	Params += ', height=' + ((isNaN(parseInt(Height))) ? DefaultHeight : Height);
	WinObject = window.open(URL, Name, Params)
	if (!WinObject) return true;
	if (WinObject.focus) WinObject.focus();
	return false;
}


function InsertFlash(Target, ID, Version, File, Width, Height, Parameters) {
	var ParametersObjectStr = ''
	var ParametersEmbedStr = ''
	var s, v
	for (s in Parameters) {
		v = Parameters[s]
		ParametersObjectStr += '<param name="'+s+'" value="'+v+'" />'
		ParametersEmbedStr += ' '+s+'="'+v+'" '
	}
	var FlashHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' +
			'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+Version+',0,0,0" ' +
			'width="'+Width+'" height="'+Height+'" id="'+ID+'">' +
			'<param name="movie" value="'+File+'" />' +
			ParametersObjectStr +
			'<embed src="'+File+'" ' +
				'pluginspage="http://www.macromedia.com/go/getflashplayer"  ' +
				'type="application/x-shockwave-flash" width="'+Width+'" height="'+Height+'" name="'+ID+'" '+ParametersEmbedStr+' />' +
		'</object>'
	document.getElementById(Target).innerHTML = FlashHTML
}

function VerifyBrowserFlashSupport(FlashVersion) {
	var flashinstalled = 0;
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if (x) {
			flashinstalled = 2;
			if (x.description) {
				var y = x.description.split(" ");
				for (var i = 0; i < y.length; ++i) {
					if (isNaN(parseInt(y[i])))
						continue;
					if (parseInt(y[i]) >= FlashVersion) return true;
			    }
			}
		}
		if ((FlashVersion == 2) && (navigator.plugins["Shockwave Flash 2.0"])) {
			return true;
		}
	} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
	} else {
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + FlashVersion);
			return true;
		}
		catch(e){
		}
	}
	return false;
}

function InsertFlashOrHTML(Target, ID, Version, File, Width, Height, Parameters, NoFlashHTML) {
	if (VerifyBrowserFlashSupport(Version)) {
		InsertFlash(Target, ID, Version, File, Width, Height, Parameters)
	} else {
		document.getElementById(Target).innerHTML = NoFlashHTML
	}
}

function OpenOptionURL(Input, DefaultSelectedIndex) {
	if (Input.selectedIndex == DefaultSelectedIndex) return;
	var URL = Input.options[Input.selectedIndex].value;
	DefaultSelectedIndex = parseInt(DefaultSelectedIndex);
	if ((isNaN(DefaultSelectedIndex)) || (DefaultSelectedIndex < 0) || (DefaultSelectedIndex >= Input.options.length)) DefaultSelectedIndex = 0;
	Input.selectedIndex = DefaultSelectedIndex;
	Input.blur();
	if ((URL == '') || (!URL) || (URL == undefined)) return;
	window.open(URL);
}


//Remove default value in header search box or select text
function HeaderSearchBoxOnFocus(obj, defval)
{
	if (!obj) return;
	if (obj.value == defval) obj.value = ''; //Remove default value
	else obj.select(); //Select text
}
//Reset default value for header search box if no text
function HeaderSearchBoxOnBlur(obj, defval)
{
	if (!obj) return;
	if (obj.value == '') obj.value = defval; //Set default value
}

//Underline standard banner title
function StandardBannerOnMouseOver(id) {
	var obj;
	if (!document.getElementById || !(obj=document.getElementById(id))) return;
	obj.style.textDecoration = 'underline';
}
//Reset standard banner title underlayment
function StandardBannerOnMouseOut(id) {
	var obj;
	if (!document.getElementById || !(obj=document.getElementById(id))) return;
	obj.style.textDecoration = '';
}

//Feed Icon - Active
function HeaderNav2LinksFeedIconActivate() {
	var obj;
	if (!document.getElementById || !(obj=document.getElementById('HeaderNav2LinksFeedIcon'))) return;
	obj.src = 'images/feed_icon-active.gif';
}
//Feed Icon - Inactive
function HeaderNav2LinksFeedIconDeactivate() {
	var obj;
	if (!document.getElementById || !(obj=document.getElementById('HeaderNav2LinksFeedIcon'))) return;
	obj.src = 'images/feed_icon-inactive.gif';
}


var Tabs = new Object();

function SelectTab(TabListId, TabId, BodyId, TabStyle) {
	if (Tabs[TabListId] == undefined) Tabs[TabListId] = new Object();
	if (Tabs[TabListId]['ResetTimeoutSessionId'] != undefined) clearTimeout(Tabs[TabListId]['ResetTimeoutSessionId']);
	var PrevBodyId = Tabs[TabListId]['ActiveBody'];
	if (PrevBodyId == BodyId) return false;
	
	var x, FirstActive, ThisActive, LastActive, NextActive;
	
	TabId = parseInt(TabId);
	if (isNaN(TabId)) TabId = 0;
	FirstActive = (TabId == 0) ? true : false;
	LastActive = false;
	for (x = 0; document.getElementById('TabHeader' + TabListId + '_' + x + 'Item'); x++) {
		ThisActive = (TabId == x) ? true : false;
		NextActive = (TabId == x+1) ? true : false;
		document.getElementById('TabHeader' + TabListId + '_' + x + 'Delimiter').className = 'TabDelimiter' + ((LastActive||ThisActive)?'Active':'') + TabStyle;
		document.getElementById('TabHeader' + TabListId + '_' + x + 'Left').className = 'TabLeft' + ((ThisActive)?'Active':'Inactive') + ((LastActive)?'Shadow':'') + TabStyle;
		document.getElementById('TabHeader' + TabListId + '_' + x + 'Item').className = 'Tab' + ((ThisActive)?'Active':'Inactive') + TabStyle;
		document.getElementById('TabHeader' + TabListId + '_' + x + 'Right').className = 'TabRight' + ((ThisActive)?'Active':'Inactive') + ((NextActive)?'Shadow':'') + TabStyle;
		LastActive = ThisActive;
	}
	document.getElementById('TabHeader' + TabListId + '_' + x + 'Delimiter').className = 'TabDelimiter' + ((LastActive)?'Active':'') + TabStyle;
	document.getElementById('TabHeader' + TabListId + '_OutsideLeft').className = 'TabOutsideLeft' + ((FirstActive)?'Active' + TabStyle:'Inactive');
	document.getElementById('TabHeader' + TabListId + '_OutsideRight').className = 'TabOutsideRight' + ((LastActive)?'Active' + TabStyle:'Inactive');
	
	if (document.getElementById(PrevBodyId)) document.getElementById(PrevBodyId).style.display = 'none';
	Tabs[TabListId]['ActiveBody'] = BodyId;
	document.getElementById(BodyId).style.display = '';
	
	return false;
}

function ChangeCss(cssClass, element, value) {
	var cssRules;
	if (document.all) {
		cssRules = 'rules';
	} else if (document.getElementById) {
		cssRules = 'cssRules';
	}
	var selectorText;
	for (var S = 0; S < document.styleSheets.length; S++) {
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			selectorText = document.styleSheets[S][cssRules][R].selectorText;
			if (selectorText) {
				if (selectorText.substring(0, 1) == '*') selectorText = selectorText.substring(1);
				if (selectorText == cssClass) {
					document.styleSheets[S][cssRules][R].style[element] = value;
				}
			}
		}
	}
}

function addClass(element, class_name)
{
	if (!document.getElementById||!element) return;
	if (element.className.indexOf(class_name) > -1) return;
	var elementClassName = element.className;
	if (elementClassName || elementClassName == '') element.className += (elementClassName == '' ? '' : ' ') + class_name;
}

function removeClass(element, class_name)
{
	if (!document.getElementById||!element) return;
	if (element.className.indexOf(class_name) == -1) return;
	var regex = new RegExp('\\s*' + class_name + '\\s*', 'gi');
	element.className = element.className.replace(regex, ' ');
}

function makeRequest(url, callback)
{
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP.6.0");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP.3.0");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try {
						http_request = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {}
				}
			}
		}
	}
	if (!http_request) {
		// Cannot create an XMLHTTP instance;
		return false;
	}
	function innerCallback() {
		if (http_request.readyState != 4)
			return;
		if (http_request.status != 200) {
			return;
		}
		if (callback) {
			callback(http_request.responseText);
		}
	}
	http_request.open('GET', url, true);
	http_request.onreadystatechange = innerCallback;
	http_request.send(null);
}

function GetTag(Doc, Path) {
	var TagName;
	if (Path.indexOf('/') >= 0) {
		TagName = Path.substring(0, Path.indexOf('/'));
		Path = Path.substring(Path.indexOf('/')+1);
	} else {
		TagName = Path;
		Path = '';
	}
	var NodeList = Doc.getElementsByTagName(TagName);
	if (NodeList.length > 0) {
		if (Path == '') {
			return NodeList[0];
		} else {
			return GetTag(NodeList[0], Path);
		}
	}
}

function GetTagValue(Doc, Path) {
	var XML = GetTag(Doc, Path)
	if (XML) {
		return XML.text
	} else {
		return ''
	}
}
