﻿/*
#
# SPHERE UTILITIES LIBRARY v1.5 - Copyright © Sphere sprl - 2007
# This work is licensed under the Creative Commons Attribution-NoDerivs 2.0 License. 
# To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/2.0/be/ 
# or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
# With Creative Commons Attribution-NoDerivs 2.0 License you are free to share — to copy, distribute and transmit the work.
# You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
# You may not alter, transform, or build upon this work.
# For any reuse or distribution, you must make clear to others the license terms of this work.
#
*/
var mailre = /[-\w.,]+@[-\w.,]{2,}\.([0-9]{1,3}|[A-Za-z]{2,6})/i;
var fromchar = "à,ä,â,é,é,è,ë,ê,î,ï,ô,ö,ù,û,ü,œ,À,Ä,Â,É,È,Ë,Ê,Î,Ï,Ô,Ö,Ù,Û,Ü".split(",");
var tochar = "a,a,a,e,e,e,e,e,i,i,o,o,u,u,u,oe,A,A,A,E,E,E,E,I,I,O,O,U,U,U".split(",");

/* BROWSER DETECTION and OBJECT GET */
function BROWSER()
{
	this.n = navigator.userAgent.toLowerCase();
	this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")? document.documentElement : (document.body || null);
	this.op = !!(window.opera && document.getElementById);
	this.ie = !!(this.n.indexOf("msie") >= 0 && document.all && this.db && !this.op);
	this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0);
	this.ie4 = !!(this.ie && !document.getElementById);
	this.n4 = !!(document.layers && typeof document.classes != "undefined");
	this.n6 = !!(typeof window.getComputedStyle != "undefined" && typeof document.createRange != "undefined");
	this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById);
	this.ce = !!(document.captureEvents && document.releaseEvents && !this.n6);
}
var browser = new BROWSER();
function getObj(objId, docObj){
	var childObj;
	docObj = docObj || document;
	if(browser.n4)
	{
		if(docObj.layers[objId]) 
			return docObj.layers[objId];
		for(var i=docObj.layers.length; i;)
		{
			var childObj = getObj(objId, docObj.layers[--i].document);
			if(childObj) 
				return childObj;
		}
	}
	if(docObj.getElementById) 
		return docObj.getElementById(objId) || null;
	if(browser.ie) 
		return docObj.all[objId] || null;
	return null;
}

/* DATE AND TIME FUNCTIONS */
function isLeapYear(year){
	// February has 29 days in any year evenly divisible by four, exept for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? true : false );
}
function isDate(str){ 
	var output = false;
	var sep = "/";
	var check = null;
	var day, month, year, checkday;
	// arguments: str[string to check], sep[separator]
	// returntype: boolean
	// usage: check string to see if it is a valid date
	if(arguments.length == 2)
		sep = arguments[1];
	check = str.split(sep);
	if(check.length == 3){
		day = check[0];
		month = check[1];
		year = check[2];
		checkday = getDaysInMonth(month,year);
		
		if(day > 0 && day <= checkday && month > 0 && month <= 12)
			output = true;
	}
	return(output);
}
function getDaysInMonth(monthStr, yearStr){
	var output = 0;
	var month = parseInt(monthStr);
	var year = parseInt(yearStr);
	if(month == 2 && isLeapYear(year))
		output = 29;
	else if(month == 2)
		output = 28;
	else if(month==4 || month==6 || month==9 || month==11)
		output = 30;
	else
		output = 31;
	return(output);
}
function daysInMonth(dateObj){
	var output = 0;
	var month = dateObj.getMonth() + 1;
	var year = dateObj.getFullYear();
	if(month == 2 && isLeapYear(year))
		output = 29;
	else if(month == 2)
		output = 28;
	else if(month==4 || month==6 || month==9 || month==11)
		output = 30;
	else
		output = 31;
	return(output);
}
function stringToDate(string){
	var dateObj = null;
	var sep = "-";
	if(arguments.length == 2)
		sep = arguments[1];
	if(string != ""){
		string = string.split(sep);
		if(string.length == 3){
			dateObj = new Date(string[0],eval(string[1]-1),string[2]);
		}
	}
	return(dateObj);
}
function dateToString(dateObj){
	var string = "";
	var mask = "yyyy-mm-dd";
	if(arguments.length == 2)
		mask = arguments[1];
	if(mask == "yyyy-mm-dd"){
		string = dateObj.getFullYear() + "-" + strPad(eval(dateObj.getMonth() + 1),"00") + "-" + strPad(dateObj.getDate(),"00");
	}
	return(string);
}
function dateAdd(datepart, number, dateObj){
	var day = dateObj.getDate();
	switch(datepart){
	case "y": 
		dateObj.setFullYear(dateObj.getFullYear() + number);
		break;
	case "m":
		dateObj.setMonth(dateObj.getMonth() + number);
		if(dateObj.getDate() != day){
			dateObj.setMonth(dateObj.getMonth() - 1);
			dateObj.setDate(day - dateObj.getDate());
		}
		break;
	case "d":
		dateObj.setDate(dateObj.getDate() + number);
		break;
	case "h":
		dateObj.setHours(dateObj.getHours() + number);
		break;
	default:
		break;
	}
	return(dateObj);
}
function dateDiff(datepart, date1, date2){
	var output = 0;
	switch(datepart){
	case "d":
		output = parseInt(eval((date1 - date2) / 86400000));
		break;
	default:
		break;
	}
	return(output);
}
function clearDate(dateField, displayArea){
	if(!displayArea)
		displayArea = dateField + 'display';
	if(getObj(dateField)){
		getObj(dateField).value = "";
		if(getObj(displayArea))
			if(getObj(displayArea).value)
				getObj(displayArea).value = "";
			else
				getObj(displayArea).innerHTML = "";
	}
}
var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};

/* ARRAY FUNCTIONS */
function arrayFind(obj, value){
	var output = false;
	if(obj.length){
		for(var i=0; i<obj.length; i++){
			if(obj[i] == value){
				output = i;
				break;
			}
		}
	}
	return(output);
}

/* DATA FORMATING FUNCTIONS */
function numberFormat(number,decimals){
	var mult = Math.pow(10,decimals);
	number = number * mult;
	number = Math.round(number);
	number = number / mult;
	var numstr = String(number);
	if(numstr.indexOf(".") == -1){
		numstr = numstr + ".";
		for(var i=0;i < decimals;i++) numstr = numstr + "0";
	}
	var decpl = numstr.length - numstr.indexOf(".");
	decpl = decpl - 1;
	if (decpl < decimals){
		for(i=decpl;i<decimals;i++) numstr = numstr + "0";
	}
	return (numstr);
}
function fulllcase(string){
	var output = "";
	output = string.toLowerCase();
	for(i=0; i<fromchar.length; i++){
		output = output.replace(/fromchar[i]/gi,tochar[i]);
	}
	return(output);
}

function fullucase(string){
	var output = "";
	output = string.toLowerCase();
	for(i=0; i<fromchar.length; i++){
		output = output.replace(/fromchar[i]/gi,tochar[i]);
	}
	output = output.toUpperCase();
	return(output);
}

/* INFORMATION FUNCTIONS */
function getFileName(fileStr) {
	// arguments: fileStr[absolute or relative file path]
	// returntype: string
	// usage: extract filename from path
	var backslach = fileStr.lastIndexOf("\\");
	var slach = fileStr.lastIndexOf("/");
	
	if(backslach == -1 && slach == -1){
		return fileStr.toLowerCase();
	}
	else if(backslach > slach){
		return fileStr.substring(backslach+1, fileStr.length).toLowerCase();
	}
	else{
		return fileStr.substring(slach+1, fileStr.length).toLowerCase();
	}
}
function getFileExt(fileStr) {
	// arguments: fileStr[absolute or relative file path]
	// returntype: string
	// usage: extract extension from path
	var dot = fileStr.lastIndexOf(".");
	
	if(dot == -1){
		return fileStr.toLowerCase();
	}
	else{
		return fileStr.substring(dot+1, fileStr.length).toLowerCase();
	}
}
function getScriptName(uri){
	var output = uri;
	if(output.indexOf("?") > 0){
		output = output.substr(0, output.indexOf("?"));
	}
	return(output);
}
function getHex(color){
	var output = "";
	var tmp = "";
	var rgb = "";
	if(color.substr(0,1) == "#"){
		output = color;
	}
	if(color.substr(0,3) == "rgb"){
		tmp = color.substr(4,color.length-5);
		rgb = tmp.split(", ");
		output = "#" + (parseInt(rgb[0]) < 16 ? '0' : '') + parseInt(rgb[0]).toString(16);
		output += (parseInt(rgb[1]) < 16 ? '0' : '') + parseInt(rgb[1]).toString(16);
		output += (parseInt(rgb[2]) < 16 ? '0' : '') + parseInt(rgb[2]).toString(16);
	}
	return(output);
}
function capsCount(string){
	var i = 0;
	var count = 0;
	while(i <= string.length){
		if(string.charCodeAt(i) >= 65 && string.charCodeAt(i) <= 90)
			count++;
		i++;	
	}
	return count;
}
function wordCount(string){
	var i = 0;
	var count = 1;
	while(i <= string.length){
		if (string.substring(i,i+1) == " ") {
			count++;
			i++; 
		}
		if (string.substring(i,i+1) == "-") {
			count++;
			i++; 
		}
		if (string.substring(i,i+1) == "\n") {
			count++;
			i++;
		}
		i++;
	}
	return count;
}
function charCount(string, charlist){
	var count = 0;
	var i = 0;
	for (i=0; i<string.length; i++) { 
        if(charlist.indexOf(string.charAt(i)) > -1)
            count++; 
    }
    return count;
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function getWinScrollX(){
	var scrollX = 0;
	if (self.pageXOffset)
		scrollX = self.pageXOffset;
	else if(document.documentElement && document.documentElement.scrollLeft)
		scrollX = document.documentElement.scrollLeft;
	else if (document.body)
		scrollX = document.body.scrollLeft;
	return scrollX;
}
function getWinScrollY(){
	var scrollY = 0;
	if (self.pageYOffset)
		scrollY = self.pageYOffset;
	else if(document.documentElement && document.documentElement.scrollTop)
		scrollY = document.documentElement.scrollTop;
	else if (document.body)
		scrollY = document.body.scrollTop;
	return scrollY;
}
function getWinWidth(){
	var winWidth = 0;
	if (typeof(window.innerWidth) == 'number')
		winWidth = window.innerWidth;
	else if(document.documentElement && document.documentElement.clientWidth)
		winWidth = document.documentElement.clientWidth;
	else if (document.body && document.body.clientWidth)
		winWidth = document.body.clientWidth;
	return winWidth;
}
function getWinHeight(){
	var winHeight = 0;
	if (typeof(window.innerHeight) == 'number')
		winHeight = window.innerHeight;
	else if(document.documentElement && document.documentElement.clientHeight)
		winHeight = document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight)
		winHeight = document.body.clientHeight;
	return winHeight;
}

/* STRING MANIPULATION FUNCTIONS */
function strPad(string,pad){
	var output = "";
	var strObj = string + "";
	var i = 0;
	for(i=strObj.length-1; i<pad.length-1; i++){
		output += pad.charAt(i);
	}
	output += strObj;
	return(output);
}
function strReplace(string, subStr, replStr, mode){
	var output = "" + string;
	var charIdx = output.indexOf(subStr);
	while(charIdx != -1){
		output = output.replace(subStr, replStr);
		charIdx = output.indexOf(subStr);
	}
	return(output);	
}

/* DATA VALIDATION FUNCTIONS */
function isEmail(str){
	var check = str.match(mailre);
	if(check == null)
		return false;
	else
		return true;
}

/* FORM INPUT CHECK FUNCTIONS */
function checkDecimal(e){
	var key = e.keyCode ? e.keyCode : e.which;
	var caller = e.srcElement ? e.srcElement : e.target;
	var checkval;
	var signed = false;
	if(arguments.length == 2)
		signed = arguments[1];
	if(key >= 8 && key < 13){ // Allow backspace, tab and line feed
		return true;
	}
	if(key >=48 && key <= 57 || key == 46 || key == 13 || (signed && (key == 43 || key == 45))){ // Allow numbers, dot(.), plus and minus signs (+,-) if allowed and carriage return
		checkval = caller.value + String.fromCharCode(key);
		if(!isNaN(checkval)){
			return true;
		}
		else{
			if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
			return false;
		}
	}
	else{
		if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
		return false;
	}
}
function checkInteger(e){
	var key = e.keyCode ? e.keyCode : e.which;
	var caller = e.srcElement ? e.srcElement : e.target;
	var checkval;
	var signed = false;
	if(arguments.length == 2)
		signed = arguments[1];
	if(key >= 8 && key < 13){ // Allow backspace, tab and line feed
		return true;
	}
	
	if(key >=48 && key <= 57 || key == 13 || (signed && (key == 43 || key == 45))){ // Allow numbers, plus and minus signs (+,-) if allowed and carriage return
		checkval = caller.value + String.fromCharCode(key);
		if(!isNaN(checkval)){
			return true;
		}
		else{
			if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
			return false;
		}
	}
	else{
		if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
		return false;
	}
}
function checkStrictAlphaNum(e){
	var key = e.keyCode ? e.keyCode : e.which;
	var exludechar = new Array();
	if(arguments.length == 2)
		exludechar = arguments[1].split(",");
		
	if(key >= 8 && key < 13){ // Allow backspace, tab and line feed
		return true;
	}
	for(var i=0; i<exludechar.length; i++){ //Reject excluded char list
		if(key == exludechar[i].charCodeAt(0))
			return false;
	}
	if(key >=48 && key <= 57 || key >=97 && key <= 122 || key >=65 && key <= 90 || key == 13 || key == 32){ // Allow [A-Za-z0-9[:space:]] and carriage return
		return true;
	}
	else{
		if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
		return false;
	}
}
function checkFileName(e){
	var key = e.keyCode ? e.keyCode : e.which;
	if(key >= 8 && key < 13){ // Allow backspace, tab and line feed
		return true;
	}
	if(key >=48 && key <= 57 || key >=97 && key <= 122 || key >=65 && key <= 90 || key == 13 || key == 45 || key == 95){ // Allow [A-Za-z0-9[:space:]] and carriage return
		return true;
	}
	else{
		if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
		return false;
	}
}
function checkDirectoryName(e){
	var key = e.keyCode ? e.keyCode : e.which;
	if(key >= 8 && key < 13){ // Allow backspace, tab and line feed
		return true;
	}
	if(key >=48 && key <= 57 || key >=97 && key <= 122 || key >=65 && key <= 90 || key == 13 || key == 45 || key == 95){ // Allow [A-Za-z0-9-_] and carriage return
		return true;
	}
	else{
		if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
		return false;
	}
}
function checkFullAlphaNum(e){
	var key = e.keyCode ? e.keyCode : e.which;
	var exludechar = new Array();
	if(arguments.length == 2)
		exludechar = arguments[1].split(",");
		
	if(key >= 8 && key < 13){ // Allow backspace, tab and line feed
		return true;
	}
	for(var i=0; i<fromchar.length; i++){ // Allow accentuated chars
		if(key == fromchar[i].charCodeAt(0))
			return true;
	}
	for(var i=0; i<exludechar.length; i++){ //Reject excluded char list
		if(key == exludechar[i].charCodeAt(0))
			return false;
	}
	if(key >=48 && key <= 57 || key >=97 && key <= 122 || key >=65 && key <= 90 || key == 13 || key == 32){ // Allow [A-Za-z0-9[:space:]] and carriage return
		return true;
	}
	else{
		if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
		return false;
	}
}
function checkFullRange(e){
	var key = e.keyCode ? e.keyCode : e.which;
	var exludechar = new Array();
	if(arguments.length == 2)
		exludechar = arguments[1].split(",");

	if(key >= 8 && key < 13){ // Allow backspace, tab and line feed
		return true;
	}
	for(var i=0; i<fromchar.length; i++){ // Allow accentuated chars
		if(key == fromchar[i].charCodeAt(0))
			return true;
	}
	for(var i=0; i<exludechar.length; i++){ //Reject excluded char list
		if(key == exludechar[i].charCodeAt(0))
			return false;
	}
	if(key >=32 && key <= 126 || key == 13){ // Allow full ascii range, punctuations and carriage return
		return true;
	}
	else{
		if(e.keyCode){ e.keyCode = ""; } else { which = ""; }
		return false;
	}
}
function checkPasswordWeakness(formObj, formField) {
	var score = 0;
	var result = 0;
	var commonPasswords = new Array('password', 'pass', '1234', '1246');
	
	if(formObj && formObj[formField]){
		var passStr = formObj[formField].value;
		if (passStr.length < 5)
			score += 3;
		else if(passStr.length > 4 && passStr.length < 8)
			score += 6;
		else if (passStr.length > 7 && passStr.length < 16)
			score += 12;
		else if (passStr.length > 15)
			score += 18;
		
		if (passStr.match(/[a-z]/))
			score += 1;
		
		if (passStr.match(/[A-Z]/))
			score += 5;
		
		if (passStr.match(/\d+/))
			score += 5;
		
		if (passStr.length > 0 && passStr.match(/(.*[0-9].*[0-9].*[0-9])/))
			score += 5;
		
		if (passStr.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
			score += 5;
		
		if (passStr.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
			score += 5;
	
		if (passStr.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))
			score += 2;

		if (passStr.match(/([a-zA-Z])/) && passStr.match(/([0-9])/))
			score += 2;
 
		if (passStr.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
			score += 2;
		
		if(passStr.length > 0 && score < 16)
		   result = 1;
		else if (passStr.length > 0 && score > 15 && score < 25)
		   result = 2;
		else if (passStr.length > 0 && score > 24 && score < 35)
		   result = 3;
		else if (passStr.length > 0 && score > 34 && score < 45)
		   result = 4;
		else if(passStr.length > 0)
		   result = 5;
		
		if(getObj('passwordweakbar') && getObj('weakbarlevel1')){
			getObj('weakbarlevel1').style.backgroundColor = "#FFFFFF";
			if (result >= 1)
				getObj('weakbarlevel1').style.backgroundColor = "#9F0000";
			else
				getObj('weakbarlevel1').style.backgroundColor = "#FFFFFF";
			if (result >= 2)
				getObj('weakbarlevel2').style.backgroundColor = "#FF5A00";
			else
				getObj('weakbarlevel2').style.backgroundColor = "#FFFFFF";
			if (result >= 3)
				getObj('weakbarlevel3').style.backgroundColor = "#FFBE0F";
			else
				getObj('weakbarlevel3').style.backgroundColor = "#FFFFFF";
			if (result >= 4)
				getObj('weakbarlevel4').style.backgroundColor = "#EDEF1D";
			else
				getObj('weakbarlevel4').style.backgroundColor = "#FFFFFF";
			if (result >= 5)
				getObj('weakbarlevel5').style.backgroundColor = "#0BCF00";
			else
				getObj('weakbarlevel5').style.backgroundColor = "#FFFFFF";
		}
	}
	return (result);
} 

/* FORM VALIDATION FUNCTIONS */
function isCheckedRadio(formObj, formField, value){
	var ischecked = false;
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				if(formObj[formField][i].value == value && formObj[formField][i].checked){
					ischecked = true;
					break;
				}
			}
		}
		else if(formObj[formField].value == value && formObj[formField].checked){
			ischecked = true;
		}
	}
	return(ischecked);
}
function getRadio(formObj, formField){
	var output = "";
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				if(formObj[formField][i].checked){
					output = formObj[formField][i].value;
					break;
				}
			}
		}
		else if(formObj[formField].value && formObj[formField].checked){
			output = formObj[formField].value;
		}
	}
	return(output);
}
function clearRadio(formObj, formField){
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				formObj[formField][i].checked = false;
			}
		}
	}
}
function getDropDown(formObj, formField){
	var output = "";
	if(formObj && formObj[formField]){
		if(formObj[formField].options && formObj[formField].options.length >= 1){
			thisField = formObj[formField];
			output = formObj[formField][formObj[formField].selectedIndex].value;
		}
		else if(formObj[formField].value){
			output = formObj[formField].value;
		}
	}
	return(output);
}
function isDropDown(formObj, formField){
	var output = null;
	if(formObj && formObj[formField]){
		if(formObj[formField].options && formObj[formField].options.length > 1){
			output = true;
		}
		else{
			output = false;
		}
	}
	return(output);
}
function selectRadio(formObj, formField, value, actionStr){
	var haschanged = false;
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				if(formObj[formField][i].value == value && !formObj[formField][i].checked){
					formObj[formField][i].checked = true;
					haschanged = true;
					break;
				}
			}
		}
		else if(formObj[formField].value == value){
			formObj[formField].checked = true;
		}
	}
	if(actionStr && haschanged){
		doFormAction(formObj, actionStr);
	}
}
function hasCheckbox(formObj, formField){
	var haschecked = false;
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				if(formObj[formField][i].checked == true){
					haschecked = true;
					break;
				}
			}
		}
		else if(formObj[formField].checked == true){
			haschecked = true;
		}
	}	
	return(haschecked);
}
function selectCheckbox(formObj, formField, value, actionStr){
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				if(value == true){
					formObj[formField][i].checked = true;
				}
				else if(value == false){
					formObj[formField][i].checked = false;
				}
				else if(formObj[formField][i].value == value){
					formObj[formField][i].checked = true;
					break;
				}
			}
		}
		else if(value == true){
			formObj[formField].checked = true;
		}
		else if(value == false){
			formObj[formField].checked = false;
		}
		else if(formObj[formField].value == value){
			formObj[formField].checked = true;
		}
		else if(!value){
			formObj[formField].checked = !formObj[formField].checked;
		}
	}
	if(actionStr){
		doFormAction(formObj, actionStr);
	}
}
function selectAllCheckbox(formObj, formField, mode){
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				switch(mode){
					case "auto": formObj[formField][i].checked = !formObj[formField][i].checked; break;
					case "all": formObj[formField][i].checked = true; break;
					default: formObj[formField][i].checked = false; break;
				}
			}
		}
		else if(formObj[formField]){
			switch(mode){
				case "auto": formObj[formField].checked = !formObj[formField].checked; break;
				case "all": formObj[formField].checked = true; break;
				default: formObj[formField].checked = false; break;
			}
		}
	}
}
function toggleCheckbox(formObj, formField, value, actionStr){
	if(formObj && formObj[formField]){
		if(formObj[formField].length){
			for(var i=0; i<formObj[formField].length; i++){
				if(value == true && value.toString() == "true"){
					formObj[formField][i].checked = !formObj[formField][i].checked;
				}
				else if(formObj[formField][i].value == value){
					formObj[formField][i].checked = !formObj[formField][i].checked;
					break;
				}
			}
		}
		else if(value == true){
			formObj[formField].checked = !formObj[formField].checked;
		}
		else if(formObj[formField].value == value){
			formObj[formField].checked = !formObj[formField].checked;
		}
	}
	if(actionStr){
		doFormAction(formObj, actionStr);
	}
}
function setBooleanCheckbox(formObj, formField, value, actionStr){
	if(formObj && formObj[formField]){
		formObj[formField].value = value;
	}
	if(actionStr){
		doFormAction(formObj, actionStr);
	}
}
function setHiddenField(formObj, formField, value, actionStr){
	if(formObj && formObj[formField]){
		formObj[formField].value = value;
	}
	if(actionStr){
		doFormAction(formObj, actionStr);
	}
}
function selectFormTab(formObj, hiddenField, value){
	if(formObj && formObj[hiddenField]){
		var tabitems = document.getElementById('formtabs_' + hiddenField).getElementsByTagName("a");
		if(tabitems.length){
			formObj[hiddenField].value = "";
			for(var i=0; i<tabitems.length; i++){
				if(tabitems[i].getAttribute("rel") && tabitems[i].getAttribute("rel") == value){
					tabitems[i].className = "selected";
					formObj[hiddenField].value = value;
				}
				else if(tabitems[i].getAttribute("rel") && tabitems[i].getAttribute("rel") != value){
					tabitems[i].className = "";
				}
			}
		}
	}
}
function selectDropDown(formObj, formField, value, actionStr){
	if(formObj && formObj[formField]){
		if(formObj[formField].options){
			for(var i=0; i<formObj[formField].options.length; i++){
				if(formObj[formField].options[i].value == value){
					formObj[formField].selectedIndex = i;
					break;
				}
			}
		}
	}
	if(actionStr){
		doFormAction(formObj, actionStr);
	}
}
function nextSelectOption(formObj, formField, actionStr){
	var haschanged = false;
	if(formObj && formObj[formField]){
		if(formObj[formField].length && formObj[formField].selectedIndex < formObj[formField].length-1){
			formObj[formField].selectedIndex++;
			haschanged = true;
		}
		else if(formObj[formField].length && formObj[formField].selectedIndex == formObj[formField].length-1){
			formObj[formField].selectedIndex = 0;
			haschanged = true;
		}
		if(actionStr && haschanged){
			doFormAction(formObj, actionStr);
		}
	}
}
function previousSelectOption(formObj, formField, actionStr){
	var haschanged = false;
	if(formObj && formObj[formField]){
		if(formObj[formField].length && formObj[formField].selectedIndex > 0){
			formObj[formField].selectedIndex--;
			haschanged = true;
		}
		else if(formObj[formField].length && formObj[formField].selectedIndex == 0){
			formObj[formField].selectedIndex = formObj[formField].length-1;
			haschanged = true;
		}
		if(actionStr && haschanged){
			doFormAction(formObj, actionStr);
		}
	}
}
function getAttributeValue(obj, key){
	var output = "";
	var attribStr;
	var isFunction;
	if(obj && obj.getAttribute(key)){
		attribStr = obj.getAttribute(key).toString();
		attribStr = strReplace(attribStr, "\n", "");
		attribStr = strReplace(attribStr, "\r", "");
		isFunction = attribStr.split("{");
		if(isFunction.length > 1){
			output = strReplace(isFunction[1],"}","");
		}
		else{
			output = attribStr;
		}
	}
	return(output);
}
function hasField(formObj, formField){
	var output = false;
	var i = 0;
	if(formObj && formObj.elements){
		for(i=0; i < formObj.elements.length; i++){
			if(formObj.elements[i].name == formField)
				output = true;
		}
	}
	return(output);
}
function validate(formObj, formField){
	var output = false;
	var validation = "none";
	var obj;
	var minvalue;
	var maxvalue;
	var checkvalue;
	if(formObj && formObj[formField]){
		obj = formObj[formField];
		if(obj.getAttribute("validation")){
			validation = obj.getAttribute("validation");
			switch(validation){
				case "integer":
					if(obj.getAttribute('minvalue') && !isNaN(parseInt(obj.getAttribute('minvalue'))))
							minvalue = parseInt(obj.getAttribute('minvalue'));
					if(obj.getAttribute('maxvalue') && !isNaN(parseInt(obj.getAttribute('maxvalue'))))
							maxvalue = parseInt(obj.getAttribute('maxvalue'));
					if(minvalue && parseInt(obj.value) < minvalue)
						obj.value = minvalue;
					if(maxvalue && parseInt(obj.value) > maxvalue)
						obj.value = maxvalue;
					break;
				case "decimal":
					if(obj.getAttribute('minvalue') && !isNaN(parseFloat(obj.getAttribute('minvalue'))))
							minvalue = parseFloat(obj.getAttribute('minvalue'));
					if(obj.getAttribute('maxvalue') && !isNaN(parseFloat(obj.getAttribute('maxvalue'))))
							maxvalue = parseFloat(obj.getAttribute('maxvalue'));
					if(minvalue && parseFloat(obj.value) < minvalue)
						obj.value = minvalue;
					if(maxvalue && parseFloat(obj.value) > maxvalue)
						obj.value = maxvalue;
					break;
				default: 
					break;
			}
		}
	}
}
function doFormAction(formObj, actionStr, checkfunction, returncheck){
	// arguments: formObj[form object], actionStr[form action], checckfuntion[function to execute before submit], returncheck[return checckfuntion result]
	// returntype: boolean or none
	// usage: validate and submit a form
	var check;
	if(checkfunction){
		check = checkfunction(formObj);
		if(check){
			formObj.setAttribute('action', actionStr);
			formObj.submit();
		}
		if(returncheck){
			return check;
		}
	}
	else{
		formObj.setAttribute('action', actionStr);
		formObj.submit();
	}
}

function openViewerAction(formObj, actionStr, checkfunction, allowResize, width, height){
	// arguments: formObj[form object], actionStr[form action], checckfuntion[function to execute before submit]
	// returntype: boolean or none
	// usage: validate and submit a form
	var winargs = "";
	var winname = "viewer";
	var winwidth = (width && parseInt(width) > 0)?parseInt(width):640;
	var winheight = (height && parseInt(height) > 0)?parseInt(height):580;
	var check, oldTarget, oldAction;
	
	winargs = "width=" + winwidth + ", height=" + winheight;
	winname = winname + winwidth;
	
	if(allowResize){
		winargs = winargs + "resizable=1,scrollbars=1";
	}
	if(checkfunction){
		check = checkfunction(formObj);
		if(check){
			if(formObj){
				oldTarget = formObj.getAttribute('target');
				oldAction = formObj.getAttribute('action');
				formObj.setAttribute('target', winname);
				formObj.setAttribute('action', actionStr);
				eval("winname = window.open('', winname, winargs);");
				formObj.submit();
			}
			else if(actionStr){
				eval("winname = window.open(actionStr, winname, winargs);");
			}
		}
	}
	else{
		if(formObj){
			oldTarget = formObj.getAttribute('target');
			oldAction = formObj.getAttribute('action');
			formObj.setAttribute('target', winname);
			formObj.setAttribute('action', actionStr);
			eval("winname = window.open('', winname, winargs);");
			formObj.submit();
		}
		else if(actionStr){
			eval("winname = window.open(actionStr, winname, winargs);");
		}
	}
	try {
		if(formObj){
			formObj.setAttribute('target', oldTarget);
			formObj.setAttribute('action', oldAction);
		}
		eval("winname.focus();");
	}
	catch(e){
	}
}
function closeViewerAction(formObj, actionStr){
	if(formObj && actionStr){
		//formObj.setAttribute('target', 'parent');
		doFormAction(formObj, actionStr);
	}
	else if(actionStr){
		parent.opener.location.href = actionStr;
	}
	parent.opener.focus();
	window.close();
}
function confirmAction(messageStr, actionStr) {
	if(window.confirm(messageStr)){
		window.location.href = actionStr;
	}
}
function confirmFormAction(formObj, actionStr, messageStr, checkfunction, returncheck){
	// arguments: formObj[form object], actionStr[form action], checckfuntion[function to execute before submit], returncheck[return checckfuntion result]
	// returntype: boolean or none
	// usage: validate and submit a form
	var check;
	if(checkfunction){
		check = checkfunction(formObj);
		if(check && messageStr){
			check = window.confirm(messageStr);
			if(check){
				formObj.setAttribute('action', actionStr);
				formObj.submit();
			}
		}
		else if(check){
			formObj.setAttribute('action', actionStr);
			formObj.submit();
		}
		if(returncheck){
			return check;
		}
	}
	else if(messageStr){
		if(window.confirm(messageStr)){
			formObj.setAttribute('action', actionStr);
			formObj.submit();
		}
	}
	else{
		formObj.setAttribute('action', actionStr);
		formObj.submit();
	}
}

// OBJECT MANIPULATIONS - CLASSES AND COLORS

function hilight(itemid){
	var data = "#ffffcc";
	var mode = "color";
	if(arguments.length == 2){
		if(arguments[1].substr(0,1) != "#")
			mode = "class";
		data = arguments[1];
	}
	if(document.getElementById(itemid) && mode == "color")
		document.getElementById(itemid).style.backgroundColor = data;
	else if(document.getElementById(itemid) && mode == "class")
		document.getElementById(itemid).className = data;
}
function unlight(itemid){
	var data = "#ffffff";
	var mode = "color";
	if(arguments.length == 2){
		if(arguments[1].substr(0,1) != "#")
			mode = "class";
		data = arguments[1];
	}
	if(document.getElementById(itemid) && mode == "color")
		document.getElementById(itemid).style.backgroundColor = data;
	else if(document.getElementById(itemid) && mode == "class")
		document.getElementById(itemid).className = data;
}
function setVisible(objidlist){
	var objList = objidlist.split(",");
	if(objList){
		for(var i=0; i<objList.length; i++){
			if(document.getElementById(objList[i]) && document.getElementById(objList[i]).style)
				document.getElementById(objList[i]).style.visibility = "visible";
		}
	}
}
function setHidden(objidlist){
	var objList = objidlist.split(",");
	if(objList){
		for(var i=0; i<objList.length; i++){
			if(document.getElementById(objList[i]) && document.getElementById(objList[i]).style)
				document.getElementById(objList[i]).style.visibility = "hidden";
		}
	}
}
function setFieldDefault(formObj, formField, status, className){
	if(formObj && formObj[formField]){
		switch(status){
			case "on":
				if(className)
					formObj[formField].className = className + "_" + status;
				else
					formObj[formField].style.color = "#000000";
				if(formObj[formField].value == formObj[formField].alt)
					formObj[formField].value = "";
				break;
			case "off":
				if(className && (formObj[formField].value == "" || formObj[formField].value == formObj[formField].alt))
					formObj[formField].className = className + "_" + status;
				else if(formObj[formField].value == "" || formObj[formField].value == formObj[formField].alt)
					formObj[formField].style.color = "#aaaaaa";
				if(formObj[formField].value == "")
					formObj[formField].value = formObj[formField].alt;
				break;
			default:
				break;
		}
	}
}

/* REPLACE SELECT DROP DOWN */

function replaceSelect(formObj, formField) {
	if(formObj && formObj[formField]){
		formObj[formField].id = formField;
		formObj[formField].style.display = "none";
		
		var selectObj = document.createElement('ul');
			selectObj.id = formField + "_select";
			selectObj.className = "select";
		for (var i=0; i<formObj[formField].options.length; i++) {
			if(formObj[formField].options[i].style.display != "none"){

				var optionObj = document.createElement('li');
				if(formObj[formField].options[i].getAttribute("content")){
					var optionText = formObj[formField].options[i].getAttribute("content");
					optionObj.innerHTML = optionText;
				}
				else{
					var optionText = document.createTextNode(formObj[formField].options[i].text);
					optionObj.appendChild(optionText);
				}
				optionObj.index = formObj[formField].options[i].index;
				optionObj.collection = formObj[formField].id;
				optionObj.onclick = function() {
					selectOption(this);
				}
				if (formObj[formField].options[i].selected){
					optionObj.className = "selected";
					optionObj.onclick = function() {
						this.parentNode.className += ' selectOpen';
						this.onclick = function() {
							selectOption(this);
						}
					}
				}
				if (window.attachEvent){
					optionObj.onmouseover = function() {
						this.className += ' hover';
					}
					optionObj.onmouseout = function() {
						this.className = 
						this.className.replace(new RegExp(" hover\\b"), '');
					}
				}
				selectObj.appendChild(optionObj);
			}
		}
	}
	if(document.getElementById(selectObj.id)){
		var selectOld = document.getElementById(selectObj.id);
		selectOld.parentNode.removeChild(selectOld);
	}
	formObj[formField].parentNode.appendChild(selectObj);
}
function selectOption(obj) {
	var optionObj = obj.parentNode.getElementsByTagName('li');
	for (var i=0; i<optionObj.length; i++){
		if (optionObj[i] != obj) { // not the selected list item
			optionObj[i].className='';
			optionObj[i].onclick = function(){
				selectOption(this);
			}
		}
		else{
			document.getElementById(obj.collection).selectedIndex = obj.index;
			obj.className='selected';
			obj.parentNode.className = obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), '');
			obj.onclick = function() {
				obj.parentNode.className += ' selectOpen';
				this.onclick = function() {
					selectOption(this);
				}
			}
		}
	}
}

/* NAVIGATION FUNCTIONS AND UTILS */
function getUrl(url){
	var location = "/" + url;
	if(url.indexOf('http://') != -1)
		location = url;
	window.location.href = location;	
}
function getPathroot(){
	var output = "/";
	if(location.pathname.indexOf('/') != -1){
		output = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);	
	}
	return(output);
}
function openViewer(locationStr, width, height, winMode){
	var mode = "simple";
	var winargs = "";
	var winname = "viewer";
	var winwidth = (width && parseInt(width) > 0)?parseInt(width):640;
	var winheight = (height && parseInt(height) > 0)?parseInt(height):580;
	
	if(winMode){
		mode = winMode;
	}
	
	switch(mode){
		case "simple": winargs = "directories=no, menubar=no, toolbar=no, resizable=no, scrollbars=1, status=no"; break;
		case "resizable": winargs = "directories=no, menubar=no, toolbar=no, resizable=yes, scrollbars=1, status=no"; break;
		case "full": winargs = "directories=no, menubar=yes, toolbar=yes, resizable=yes, scrollbars=1, status=yes"; break;
		default: break;
	}
	winargs = winargs + ", width=" + winwidth + ", height=" + winheight;
	
	// Set a unique name for this window size
	winname = winname + (winwidth+"x"+winheight);

	if(locationStr){
		eval("winname = window.open(locationStr, winname, winargs);");
	}
	try {
		eval("winname.focus();");
	}
	catch(e){
	}
}
function openEditor(mode, formObj, formField){
	var winMode = "popup";
	var width = 800;
	var height = 600;
	var root = getPathroot();
	var url = root + "popup.cfm?action=global.htmleditor." + mode;
	if(formObj && formObj[formField]){
		url += "&winmode=popup";
		url += "&field=" + formField;
		if(formObj[formField].getAttribute("customcss"))
			url += "&customcss=" + formObj[formField].getAttribute("customcss");
		if(formObj[formField].getAttribute("lang"))
			url += "&lang=" + formObj[formField].getAttribute("lang");
		if(formObj[formField].getAttribute("snippets"))
			url += "&snippets=" + formObj[formField].getAttribute("snippets");
		if(formObj[formField].getAttribute("winheight"))
			height = parseInt(formObj[formField].getAttribute("winheight"));
		if(formObj[formField].getAttribute("winwidth"))
			width = parseInt(formObj[formField].getAttribute("winwidth"));
		url += "&height=" + height;
		url += "&width=" + width;
		htmleditor = window.open(url, "htmleditor", "width=" + width + ", height=" + height + ", resizable=0");
		htmleditor.focus();
	}
}
function openMedia(mode){
	var width = 1005;
	var height = 600;
	var root = getPathroot();
	var url = root + "popup.cfm?action=global.mediamanager." + mode;
	if(arguments.length == 3){
		var formObj = arguments[1];
		var formField = arguments[2];
	}
	if(formObj && formObj[formField]){
		url += "&field=" + formField;
		url += "&current=" + formObj[formField].value;
	}
	if(formObj && formObj[formField].getAttribute("resolution"))
		url += "&resolution=" + formObj[formField].getAttribute("resolution");
	mediamanager = window.open(url, "mediamanager", "width=" + width + ", height=" + height + ", resizable=0, location=0, status=0, toolbar=0, menubar=0");
	mediamanager.focus();
}
function openCropper(mode){
	var width = 730;
	var height = 490;
	var root = getPathroot();
	var url = root + "popup.cfm?action=global.mediamanager.cropper";
	if(arguments.length == 3){
		var formObj = arguments[1];
		var formField = arguments[2];
	}
	if(formObj && formObj[formField]){
		url += "&field=" + formField;
		url += "&current=" + formObj[formField].value;
	}
	cropmanager = window.open(url, "cropmanager", "width=" + width + ", height=" + height + ", resizable=0");
	cropmanager.focus();
}
function toolTip(objId) {
	var id = objId;
	var active = false;
	var offX = 10;
	var offY = 20;
	if(arguments.length == 3){
		offX = parseInt(arguments[1]);
		offY = parseInt(arguments[2]);
	}
	this.obj = getObj(objId);
	this.show = function() {
		active = true;
	};
	this.hide = function() {
		active = false;
		getObj(id).style.visibility = "hidden";
		getObj(id).style.left = "-1000px";
	};
	this.move = function(e){
		if(!e)
			e = window.event;
		if(active){
			var curX = (browser.w3c) ? e.pageX : e.clientX + browser.db.scrollLeft;
			var curY = (browser.w3c) ? e.pageY : e.clientY + browser.db.scrollTop;
			//Find out how close the mouse is to the corner of the window
			var rightSide = browser.ie ? browser.db.clientWidth - e.clientX - offX : window.innerWidth - e.clientX - offX - 20;
			var bottomSide = browser.ie ? browser.db.clientHeight - e.clientY - offY : window.innerHeight - e.clientY - offY - 20;
			
			var leftSide = (offX < 0) ? offX * (-1) : -1000;
	
			if (rightSide + offX < getObj(id).offsetWidth)
				getObj(id).style.left = browser.ie? browser.db.scrollLeft + event.clientX - getObj(id).offsetWidth - offX + "px" : window.pageXOffset + e.clientX - getObj(id).offsetWidth - offX + "px";
			else if (curX<leftSide)
				getObj(id).style.left = 5 + "px";
			else
				getObj(id).style.left = curX + offX + "px";
	
			if (bottomSide + offY < getObj(id).offsetHeight)
				getObj(id).style.top = browser.ie? browser.db.scrollTop + event.clientY - getObj(id).offsetHeight - offY + "px" : window.pageYOffset + e.clientY - getObj(id).offsetHeight - offY + "px";
			else
				getObj(id).style.top = curY + offY + "px";
				
			getObj(id).style.visibility = "visible";
		}		
	};
}
/*function trace(message){
	if(message && message.toString().length){
		if(document.getElementById("debug-tracebox")){
			$("#debug-tracebox").html(message.toString());
		}
		else{
			$("<div/>").attr({ 
				id: "debug-tracebox",
				class: "tracebox",
				style: "display:none; margin: 5px; padding: 5px; top: 0px; left: 0px; position: absolute; z-index: 999999; border: 1px solid black; background-color: white; font-familly: Arial; font-size: 11px;"
			}).appendTo("body");
			$("#debug-tracebox").fadeIn().html(message.toString());
			window.setTimeout(trace,10000);
		}
	}
	else{
		$('#debug-tracebox').fadeOut().remove();
	}
}*/
function toggleGUI(element){
	var status = "visible";
	var request = "";
	if(document.getElementById(element)){
		if(document.getElementById(element).style.display != "none"){
			document.getElementById(element).style.display = "none";
			status = "hidden";
		}
		else{
			document.getElementById(element).style.display = "";
			status = "visible";
		}
	}
	if(window.refresh) refresh();
	// Try to set the session variable
	if(document.getElementById("bgtask")){
		request = getScriptName(document.getElementById("bgtask").src) + "?interface." + element + "=" + status;
		if(document.getElementById("container")){
			request += "&interface.width=" + $('container').getWidth();
		}
		document.getElementById("bgtask").src = request;
	}
}
function showhide(obj){
	if(document.getElementById(obj)){
		if(document.getElementById(obj).style.display != "none"){
			document.getElementById(obj).style.display = "none";
		}
		else{
			document.getElementById(obj).style.display = "";
		}
	}
}
function initCssMenus(menuid){
	var menuroot = null;
	var menunode = null;
	var i = 0;
	if(document.all && document.getElementById && document.getElementById(menuid)){
		menuroot = document.getElementById(menuid);
		for (i=0; i < menuroot.childNodes.length; i++){
			menunode = menuroot.childNodes[i];
			if(menunode.nodeName == "LI"){
				menunode.onmouseover = function(){
					this.className += " over";
				}
				menunode.onmouseout = function(){
					this.className = this.className.replace(" over", "");
				}
			}
		}
	}
}
function fixIePng(){
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)){
		for(var i=0; i<document.images.length; i++){
			var img = document.images[i];
			var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
				i = i-1;
			}
		}
	}
}
