
function equalHeight(className) {
	var els = document.getElementsByTagName('*');
	var height = 0;
	var elr = new Array();
	for(var i = 0; i < els.length; i++) {
		if(els[i].className.match(className)) {
			if(els[i].offsetHeight > height) height = els[i].offsetHeight;
			elr.push(els[i]);
		}
	}
	for(var i = 0; i < elr.length; i++)
		elr[i].style.height = new String(height+'px');
}

function toggleAdvanced(el) {
	for(var i = 1; i < arguments.length; i++)
			toggleLayers([arguments[i]]);
	if(el.toggleState) {
		el.innerHTML='Advanced';
		el.toggleState=false;
	}
	else{
		el.innerHTML='Basic';
		el.toggleState=true;
	};
	return false;
}

function toggleLayers(els, show) {
	for(var i = 0; i < els.length; i++) {
		var el = document.getElementById(els[i]);
		if(!show && els.length == 1)
			el.style.display = (el.style.display != 'block')? 'block': 'none';
		else
			el.style.display = (show == i+1)? 'block': 'none';
	}
	return false;
}
function flipLayer(id) {
	var el = document.getElementById(id);
	el.style.display = (el.style.display == 'none' ? 'block' : 'none');
	return false;
}

function getStyle(el,styleProp)
{
	if (el.currentStyle)
		var v = el.currentStyle[styleProp.replace(/-\D/g, function(match){return match.charAt(1).toUpperCase();})];
	else if (window.getComputedStyle)
		var v = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
	return v;
}

var sfMenu = {
	//menu flags
	RIGHT: 0x1,
	LEFT: 0x2,
	TOP: 0x4,
	BOTTOM: 0x8,
	INLINE: 0x16,


	//FUNCTION init - initialise UL node as menu
	//
	//PARAM id - String, id of top-level UL node
	//PARAM type - Bitwise Mask, menu positions/type flags (optional)
	//PARAM className - String,  class name of nested UL's (optional)
	//PARAM root - String, id of element to position menus against
	//
	init: function(id, type, className, root) {
		if(!document.getElementById(id)) {
			window.setTimeout('sfMenu.init(\''+id+'\', '+type+', \''+className+'\', \''+root+'\')',250);
			return;
		}

		var d = document.getElementById(id);

		//set sfMenu root this way only first call needs to set root node
		//and  subsequent will use the same.
		sfMenu.root = (sfMenu.root)? document.getElementById(root): document.body;
		var className = (className)? className: id;

		//no flags so figure out sub-menu orientation
		if(!type || type &~sfMenu.INLINE) {
			if(!type) {
				type |= (sfMenu.getTop(d) > sfMenu.root.scrollHeight/2)? sfMenu.TOP: sfMenu.BOTTOM;
			}
			if(type & ~(sfMenu.LEFT | sfMenu.RIGHT)) {
				type |= (sfMenu.getLeft(d) > sfMenu.root.clientWidth/2)? sfMenu.LEFT: sfMenu.RIGHT;
			}
		}


		//recursive loop for initialising menu's items and sub-menus
		var exec = function(parentEl, type, index, className) {
			var d = parentEl.firstChild;
			var index = (index)? index: 0;
			//store menu item for grouping with when we hit a sub-menu
			a = null;
			//store widest node in submenu
			do {
				switch(d.nodeName) {
					//found 'LI' (menu_item) (contains an 'A' or 'SPAN' Node and possibly a 'UL' (sun-menu))
					case 'LI': {
						//process children
						exec(d, type, index, className);
						//record menu item with maximum width
						break;
					}

					//found 'DIV' (left or right area), so process it's contents
					case 'DIV':
					case 'SPAN': {
						exec(d, type, index, className);
						break;
					}

					//found 'A'  or 'SPAN' (either or these is our event recepients)
					case 'A': {
						//only process if it's in the right place
						if(d.parentNode.nodeName == 'LI') {

							//handle mouse over events if menu is floating
							if(type &~sfMenu.INLINE) {
								d.onmouseover = function() {
									sfMenu.hideEvent++;
									sfMenu.hide(sfMenu.hideEvent, this);
									this.className = this.className + ' active';
								}
								d.onmouseout = function() {
									if(!this.sfMenu) {
										this.className = this.className.replace(/active/, '');
									}
									sfMenu.hideTimer();
								}
							}

							//store 'A' for grouping with subsequent 'UL'
							a = d;
						}
						break;
					}

					//found 'UL' this means the 'A' or 'SPAN' we just passed has a sub-menu
					case 'UL': {

						//assign this 'sub-menu' to the 'A' or 'SPAN'
						a.sfMenu = d;

						//menu is floating type
						if(type &~sfMenu.INLINE) {

							//top-level menu will ignore LEFT and RIGHT if TOP or BOTTOM are set
							if(index == 0) {
								a.sfMenuRoot = true
								a.sfMenuType = (type &(sfMenu.TOP | sfMenu.BOTTOM))? type & ~(sfMenu.LEFT | sfMenu.RIGHT): type;

							//sub-menus use all flags
							} else
								a.sfMenuType = type;

							//give menu item ('LI' for floating) class name, add mouseover events to both menu and menu item
							//current shopfactory is limited, no interface to edit styles for menu items with children
							//a.parentNode.className = 'menuItem';
							a.onmouseover = sfMenu.show;
							d.onmouseover = function() { sfMenu.hideEvent++ };
							d.onmouseout = sfMenu.hideTimer;

						//menu is tree
						} else {
							//give menu item ('A' for tree) class name, add click event to menu item
							//current shopfactory is limited, no interface to edit styles for menu items with children
							//a.className = 'menuItem';
							a.sfMenuType = type;
							a.onclick = sfMenu.inlineShow;
						}

						//set sub-menu classname, hide it if it isn't already hidden, and set z-index
						d.className = className;
						d.style.display = 'none';
						d.style.zIndex = index+1;
						d.style.overflow = 'hidden';

						//clear 'A' | 'SPAN' store, set sub-menus widest node
						a = null;
						exec(d, type, index+1, className);

						//if floating menu then we move sub-menus ('UL') to document.body
						if(type &~sfMenu.INLINE)
							document.body.appendChild(d);
						break;
					}
				}
			} while((d = d.nextSibling) != null);
		};


		//start the processing
		exec(d, type, 0, className);
	},


	//returns the node that holds menu items text (incase of nested )
	getTextNode: function(d) {
		var d = d.firstChild;
		do {
			if(d.nodeName == 'A') break;
			else if(d.nodeName == 'DIV' || d.nodeName == 'SPAN') {
				d = sfMenu.getTextNode(d);
				break;
			}
		} while((d = d.nextSibling) != null);
		return d;
	},

	//position functions
	getLeft: function(d) {
		var left = 0;
		do left += d.offsetLeft;
		while((d = d.offsetParent) != null);
		return left;
	},
	getTop: function(d) {
		var top = 0;
		do top += d.offsetTop;
		while((d = d.offsetParent) != null);
		return top;
	},

	//current menu position stack
	current: new Array(),

	//event id so for hideTimer
	hideEvent: 0,

	//calls hide after a set time, so users don't get frustrated when they move
	//the cursor away from the menus for a brief second and have them disappear
	hideTimer: function() {
		window.setTimeout('sfMenu.hide('+(++sfMenu.hideEvent)+')', 500);
	},


	//the show function for inline menu types
	inlineShow: function() {
		//sub-menu is visible so hide
		if(this.sfMenu.style.display == 'block') {
			this.className = this.className.replace(/active/, '');
			this.sfMenu.style.display = 'none';
		//sub-menu is hidden so display
		} else {
			this.className = this.className = this.className+' active';
			this.sfMenu.style.visibility = 'visible';
			this.sfMenu.style.display = 'block';
		}
		return false;
	},

	//the show function for floating menus
	show: function(e) {

			//set hideEvent so any hide are cancelled
			sfMenu.hideEvent++;
			//now hide all menus, except this ones, that are below this item
			sfMenu.hide(sfMenu.hideEvent, this);

			//hilight menu item
			sfMenu.current.push({item: this, menu: this.sfMenu});
			this.className = this.className + ' active';

			//get menu item, top/left position of menu item and document width/hieght
			var d = this.parentNode;
			var left = sfMenu.getLeft(d);
			var top = sfMenu.getTop(this);
			var docHeight = sfMenu.root.clientHeight + document.body.scrollTop;
			var docWidth = sfMenu.root.clientWidth + document.body.scrollLeft;

			//work-around when css attr display: none set clientWidth is 0
			if(this.sfMenu.style.display == 'none')
				this.sfMenu.style.visibility = 'hidden';

			//display sub-menu (still not visible though)
			this.sfMenu.style.display = 'block';


			//check if we dont have the real width of menu item (for overflow issues)
			if(!this.sfMenu.sfRealWidth) {

				//get textnode of widest menu item and set all menu items of sub-menu to it's width
				var n = null;
				var pn = null
				for(var i = 0; i < this.sfMenu.childNodes.length; i++) {
					var pnode = this.sfMenu.childNodes[i];
					if(pnode.nodeName == 'LI') {
						var node = sfMenu.getTextNode(pnode);
						if(!n || n && node.innerHTML.length > n.innerHTML.length) {
							pn = pnode;
							n = node;
						}
					}
				}
				var padding = new Number(getStyle(n,'padding-left').replace(/px|em/, '')||0) + new Number(getStyle(n,'padding-right').replace(/px|em/, '')||0);
				var nWidth = n.style.width = (n.offsetWidth < n.scrollWidth)? (n.scrollWidth-padding) + 'px': (n.offsetWidth-padding) + 'px';
				var sWidth = pn.style.width = (pn.offsetWidth < pn.scrollWidth)? (pn.scrollWidth) + 'px': (pn.offsetWidth) + 'px';
				for(var i = 0; i < this.sfMenu.childNodes.length; i++) {
					var node = this.sfMenu.childNodes[i];
					if(node.nodeName == 'LI') {
						sfMenu.getTextNode(node).style.width = nWidth;
						node.style.width = sWidth;
					}
				}
				this.sfMenu.sfRealWidth = true;
			}


			//check orientation flags and set position accordingly
			if(this.sfMenuType & sfMenu.RIGHT) {
				left += d.offsetWidth;
			}
			else if(this.sfMenuType & sfMenu.LEFT) {
				left -= this.sfMenu.offsetWidth;
			}
			if(this.sfMenuType & sfMenu.TOP) {
				top -= (this.sfMenuRoot)? this.sfMenu.offsetHeight: this.sfMenu.offsetHeight - this.offsetHeight;
			}
			else if(this.sfMenuType & sfMenu.BOTTOM) {
				top += (this.sfMenuRoot)? d.offsetHeight: 0;
			}

			//beyond page boundaries, so adjust accordingly
			if(top + this.sfMenu.offsetHeight > docHeight)
				top = docHeight - this.sfMenu.offsetHeight;

			if(left + this.sfMenu.offsetWidth > docWidth) {
				var nleft = sfMenu.getLeft(d) - this.sfMenu.offsetWidth;
				left = (nleft >= 0)? nleft: left;
			}

			if(this.sfMenuType & sfMenu.LEFT && left - this.sfMenu.offsetWidth < 0)
				left = sfMenu.getLeft(d) + d.offsetWidth;

			if(this.sfMenuType & sfMenu.TOP && top - this.sfMenu.offsetHeight < 0)
				top = sfMenu.getTop(d) + d.offsetWidth;


			//put the sub-menu where it should be and make it visible
			this.sfMenu.style.left = left + 'px';
			this.sfMenu.style.top = top + 'px';
			this.sfMenu.style.visibility = 'visible';
	},


	//the hide function for floating menu
	// if sfMenu.hideEvent = n hide all sub-menus (below d if set)
	hide: function(n, d) {
		if(sfMenu.hideEvent == n) {
			var p, c;
			if(d) {
				p = d.parentNode.parentNode;
				c = d.sfMenu;
			} else
				sfMenu.hideEvent = 0;
			for(var i = sfMenu.current.length-1; i >= 0; i--) {
				var node = sfMenu.current[i];
				if(node.menu != p && node.menu != c) {
					node.menu.style.display = 'none';
					node.item.className = node.item.className.replace(/active/, '');
					sfMenu.current.pop();
				} else
					break;
			}
		}
	}
}


function putOffset(){
if(document.forms[0].elements['settings/offset'].value.length<2){
now = new Date();
offset = -now.getTimezoneOffset();
if(offset>0){
offsetH = parseInt(offset/60);
offsetM = offset - offsetH*60;
if(offsetM<10) offsetM = '0' + offsetM;
offset = '+' + offsetH + ':' + offsetM;
} else {
offsetH = parseInt(offset/60);
offsetM = -offset + offsetH*60;
if(offsetM<10) offsetM = '0' + offsetM;
offset = offsetH + ':' + offsetM;
}
document.forms[0].elements['settings/offset'].value = offset;
}
}
function showGMT(){
now = new Date();
offset = -now.getTimezoneOffset();
if(offset>0){
offsetH = parseInt(offset/60);
offsetM = offset - offsetH*60;offsetH='+'+offsetH;
if(offsetM<10){offsetM = '0' + offsetM;}
} else {
offsetH = parseInt(offset/60);
offsetM = -offset + offsetH*60;
if(offsetM<10) offsetM = '0' + offsetM;
}
offset = 60000*offset;
gmtnow = new Date(now.getTime()-offset);
year = now.getYear();
year = '' + year;
year = year.substr(2,2);
mon = now.getMonth();
mday = now.getDate();
if(mday<10) mday = '0' + mday;
hour = now.getHours();
if(hour<10) hour = '0' + hour;
min = now.getMinutes();
if(min<10) min = '0' + min;
gmtyear = gmtnow.getYear();
gmtyear = '' + gmtyear;
gmtyear = gmtyear.substr(2,2);
gmtmon = gmtnow.getMonth();
gmtmday = gmtnow.getDate();
if(gmtmday<10) gmtmday = '0' + gmtmday;
gmthour = gmtnow.getHours();
if(gmthour<10) gmthour = '0' + gmthour;
gmtmin = gmtnow.getMinutes();
if(gmtmin<10) gmtmin = '0' + gmtmin;
alert('GMT = '+top.mymonth(gmtmon)+' '+gmtmday+', '+gmthour+':'+gmtmin+'\n'+
'Your computer time  = '+top.mymonth(mon)+' '+mday+', '+hour+':'+min+'\n'+
'Time difference  = '+offsetH+':'+offsetM);
}
function submitForm() {
var form= document.companydet;
var errFlag=false;
var errStr="The following field(s) require data" + ":\n";
if (!validInput(form.elements["first_name"].value)) {
errFlag = true;
errStr += "First Name" + "\n";
}
if (!validInput(form.elements["last_name"].value)) {
errFlag = true;
errStr += "Last Name" + "\n";
}
if (!validInput(form.elements["street"].value)) {
errFlag = true;
errStr += "Address" + "\n";
}
if (!validInput(form.elements["city"].value)) {
errFlag = true;
errStr += "City/Town" + "\n";
}
if (!validInput(form.elements["country"].value)) {
errFlag = true;
errStr += "Country" + "\n";
}
if (!validInput(form.elements["email"].value)) {
errFlag = true;
errStr += "Email" + "\n";
return false;
}
if (!validEmail(form.elements["email"].value)) {
alert("Invalid Email address");
form.email.focus();
form.email.select();
return false;
}
if (form.elements["email"].value != form.elements["D_email"].value) {
alert("Your email addresses do not match. Please try again.")
return false;
}
if (form.elements["users/password"].value != form.elements["users/D_password"].value){
alert("Your passwords do not match. Please retype them");
return false;
}
if (form.elements["users/password"].value != form.elements["users/D_password"].value){
errFlag = true;
errStr += "Your passwords do not match. Please retype them" + "\n";
}
// test if all fields required had a value
if(errFlag) {
alert(errStr);
return(false);
} else {
form.submit();
return true;
}
}
function validEmail(email) {
invalidChars = " /:,;";
if (email == "") {
return false;
}
for (i=0; i != invalidChars.length; i++) {
badChar = invalidChars.charAt(i);
if (email.indexOf(badChar,0) != -1) {
return false;
}
}
atPos = email.indexOf("@",1);
if (atPos == -1) {
return false;
}
if (email.indexOf("@",atPos+1) != -1) {
return false;
}
periodPos = email.indexOf(".",atPos);
if (periodPos == -1) {
return false;
}
if (periodPos+3 > email.length)	{
return false;
}
return true;
}
function validInput(input) {
if (input == "") {
return false;
}
return true;
}
function update_state(){
var idx = document.forms['companydet'].elements['country'].selectedIndex;
var code = document.forms['companydet'].elements['country'].options[idx].value;
if(code == 'AU' || code == 'US' || code == 'CA' || code == 'EG'){
document.forms['companydet'].elements['_refresh'].value = 1;
document.forms['companydet'].submit();
}
code = document.forms['companydet'].elements['from/country'].value;
if(code == 'AU' || code == 'US' || code == 'CA' || code == 'EG'){
document.forms['companydet'].elements['_refresh'].value = 1;
document.forms['companydet'].submit();
}
}
function go(){
if(!parent.frames['leftFrame'].companydet_left){
parent.frames['leftFrame'].document.location="/html/en-us/company-details-left.html";
}
}
function go1(){
if(!parent.frames['leftFrame'].companydet_left){
parent.frames['leftFrame'].document.location="/html/en-us/company-details-left1.html";
}
}

function zebra(a) // sets alt on alternate tr elements
{
	var tbl = document.getElementById(a).tBodies[0].getElementsByTagName('TR');
	for (var i=0;i<tbl.length;i++){
		if(i%2) tbl[i].className = 'alt '+tbl[i].className;
	}
}

var wssig=document.location.href.replace(/\\/g,'/').replace(/\/([^/]*){1}$/,'/');
var nametag={
	get:function(t){if(t!='sig'&&t!='wssig'&&!this.valid())return'';var tt='<'+t+'>',p=window.name.indexOf(tt);if(p==-1)return'';else return window.name.substring(p+tt.length,window.name.indexOf('</'+t+'>'));},
	add:function(t,v){if(this.valid())this.del(t);window.name=window.name+'<'+t+'>'+v+'</'+t+'>';},
	del:function(t){window.name=window.name.replace(new RegExp('<'+t+'>(?:.|[\n\r])*?</'+t+'>'),'');},
	valid:function(){var ss='<sig>'+window.wssig+'</sig>';if(typeof(window.wssig)!='undefined'&&this.get('sig')=='')window.name+=ss;else if(this.get('sig')!=window.wssig){this.del('sig');window.name+=(window.wssig?ss:'');return false;}return true;}
};

function addOnload(f){addEvent('onload',f);}
function addEvent(e,f,t){if(!t)var t=window;if (t.addEventListener)t.addEventListener(e.replace(/^on/,''),f,false);else if (t.attachEvent)t.attachEvent(e,f);}

var gcJSON=function(){function f(n){return n<10?'0'+n:n;}
	Date.prototype.toJSON=function(){return this.getUTCFullYear()+'-'+
	f(this.getUTCMonth()+1)+'-'+
	f(this.getUTCDate())+'T'+
	f(this.getUTCHours())+':'+
	f(this.getUTCMinutes())+':'+
	f(this.getUTCSeconds())+'Z';};var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};function stringify(value,whitelist,treatAsObject){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case'string':return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c){return c;}
	c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+
	(c%16).toString(16);})+'"':'"'+value+'"';case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
	if(typeof value.toJSON==='function'){return stringify(value.toJSON());}
	a=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))&&!treatAsObject){l=value.length;for(i=0;i<l;i+=1){a.push(stringify(value[i],whitelist,treatAsObject)||'null');}
	return'['+a.join(',')+']';}
	if(whitelist){l=whitelist.length;for(i=0;i<l;i+=1){k=whitelist[i];if(typeof k==='string'){v=stringify(value[k],whitelist,treatAsObject);if(v){a.push(stringify(k,whitelist,treatAsObject)+':'+v);}}}}else{for(k in value){if(typeof k==='string'){v=stringify(value[k],whitelist,treatAsObject);if(v){a.push(stringify(k,whitelist,treatAsObject)+':'+v);}}}}
	return'{'+a.join(',')+'}';}}
	return{stringify:stringify,parse:function(text,filter){if(!text)return{};var j;function walk(k,v){var i,n;if(v&&typeof v==='object'){for(i in v){if(Object.prototype.hasOwnProperty.apply(v,[i])){n=walk(i,v[i]);if(n!==undefined){v[i]=n;}}}}
	return filter(k,v);}
	if(/^[\],:{}\s]*$/.test(text.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?::?[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof filter==='function'?walk('',j):j;}
	throw new SyntaxError('parseJSON');},parseClone:function(text){var o=this.parse(text);return this.clone(o);},clone:function(arr){var ret=[];for(var i in arr){if(typeof(arr[i])=='object'&&typeof(arr[i].tagName)=='undefined'){ret[i]=this.clone(arr[i]);}
	else{ret[i]=arr[i];}}
	return ret;}};}();

function formSerialiser(frm) {
	this.frm = frm;
	this.doSave = true;
	this.store = {};
	this.saveForm = function() {
		if (!this.doSave) return;
		var coll = this.frm;
		for (var i = 0, ii = coll.length; i < ii; i++) {
			if (coll[i].name) this.store[coll[i].name] = coll[i].value;
		}
	}
	this.loadForm = function() {
		var coll = this.frm;
		for (var i = 0, ii = coll.length; i < ii; i++) {
			if (typeof(this.store[coll[i].name]) != 'undefined') {
				coll[i].value = this.store[coll[i].name];
			}
		}
	}
	this.resetForm = function() {
		var coll = this.frm;
		for (var i = 0, ii = coll.length; i < ii; i++) {
			switch (coll[i].nodeName.toUpperCase()) {
			case 'SELECT':
				coll[i].selectedIndex = 0;
				break;
			case 'INPUT':
				if (coll[i].type.toUpperCase() == 'TEXT') coll[i].value = '';
				break;
			case 'BUTTON':
				break;
			default:
				coll[i].value = '';
			}
		}
	}
}

function searchPersist(frmid, containerid, fnBeforeLoadForm, fnAfterLoadForm, fnBeforeResetSubmit) {
	this.frmid = frmid;
	this.containerid = containerid;
	this.fnBeforeLoadForm = fnBeforeLoadForm;
	this.fnAfterLoadForm = fnAfterLoadForm;
	this.serialiser = new formSerialiser(document.forms[this.frmid]);
	this.data = {'submitted':false, 'store':this.serialiser.store};

	this.save = function(){
		this.data['display'] = document.getElementById(this.containerid).style.display;
		this.data['sig'] = document.location.pathname;
		this.serialiser.saveForm();
		var str = gcJSON.stringify(this.data);
		nametag.add('search', str);
	}
	this.load = function(){
		var str = nametag.get('search');
		if (str) {
			this.data = gcJSON.parse(str);
			this.serialiser.store = this.data['store'];
			document.getElementById(this.containerid).style.display = this.data['display'];

			if (this.data['sig'] == document.location.pathname) {
				if (this.fnBeforeLoadForm) this.fnBeforeLoadForm.call(this);
				this.serialiser.loadForm();
				if (this.fnAfterLoadForm) this.fnAfterLoadForm.call(this);
			}
		}
	}
	this.reset = function() {
		nametag.del('search');
		this.serialiser.resetForm();

		if (this.fnBeforeResetSubmit) this.fnBeforeResetSubmit.call(this);
		if (this.serialiser.frm.action) this.serialiser.frm.submit();

		return false;
	}
	this.addEvents = function() {
		var myself = this;
		addEvent('onsubmit', function(){myself.save();}, myself.serialiser.frm);
		addEvent('onunload', function(){myself.save();});
	}
}

var calendarMgr = {
	data:null, ld:null,
	initialise:function() {
		for (var n in this.data) {
			var o = this.data[n]['obj'];
			o.setReturnFunction('calendarMgr.data[\''+n+'\'][\'fnSetValues\']');
			o.setCssPrefix(this.data[n]['cssprefix']);
			o.showNavigationDropdowns();

			if (this.ld) {
				var mths = this.ld['months'], days = this.ld['days'], today = this.ld['today'];
				if (mths.length == 12) o.setMonthNames(mths[0], mths[1], mths[2], mths[3], mths[4], mths[5], mths[6], mths[7], mths[8], mths[9], mths[10], mths[11]);
				if (days.length == 7) o.setDayHeaders(days[0], days[1], days[2], days[3], days[4], days[5], days[6]);
				if (today) o.setTodayText(today);
			}
		}
	},
	setDateValues:function(frmid, prefix, y, m, d) {
		function matchOptionValue(options, value) {
			for(var i = 0, n = options.length; i < n; i++) {
				if(options[i].value == value)
					return i;
			}
			return 0;
		}
		y=parseInt(y);
		m=parseInt(m);
		d=parseInt(d);
		var frm = document.forms[frmid];
		frm[prefix+'year'].selectedIndex = matchOptionValue(frm[prefix+'year'].options, y);
		frm[prefix+'month'].selectedIndex = matchOptionValue(frm[prefix+'month'].options, m);
		frm[prefix+'day'].selectedIndex = matchOptionValue(frm[prefix+'day'].options, d);
	},
	toggleCalendar:function(el) {
		var calendarName = el.id.replace('-anchor',''), calDiv = document.getElementById(calendarName);
		var data = this.data[calendarName];
		if (calDiv && calDiv.style.display != 'block') {
			var frm = document.forms[data['frmid']];
			var dateStr = frm[data['prefix']+'day'].value+'/'+frm[data['prefix']+'month'].value+'/'+frm[data['prefix']+'year'].value;
			if (dateStr != '0/0/0') data['obj'].currentDate=new Date(getDateFromFormat(dateStr,'d/M/yyyy'));
			data['obj'].showCalendar(el.id);
		}
		else {
			data['obj'].hideCalendar();
		}
		return false;
	}
};

var tableSorter = {
	getParentElement: function(el, nodeName){
		var elRow = el;
		while (elRow && elRow.nodeName.toUpperCase() != nodeName) {
			elRow = elRow.parentNode;
		}
		return elRow;
	},
	getCurrentRow: function(el) { return this.getParentElement(el, 'TR'); },
	getCurrentTable: function(el) { return this.getParentElement(el, 'TABLE'); },
	swapRows: function(el, offset, v) {
		if (!el) return;

		function setFormValue(tr, v, newidx) {
			var coll = tr.getElementsByTagName('INPUT');
			for (var n = 0, nn = coll.length; n < nn; n++) {
				if (coll[n].className == v) {
					coll[n].value = newidx;
				}
			}
		}

		var r1 = this.getCurrentRow(el);
		if (r1){
			var t = this.getCurrentTable(r1), idx1 = r1.rowIndex, idx2 = idx1 + offset;
			if (idx1 > 0 && idx1 <= t.tBodies[0].rows.length && idx2 > 0 && idx2 <= t.tBodies[0].rows.length){
				var r2 = t.tBodies[0].rows[idx2 - 1];
				if (r2) {
					var tmpCls = r1.className;
					r1.className = r2.className;
					r2.className = tmpCls;
					this.highlightRow(r1);
					this.unhighlightRow(r2);
					if (idx1 > idx2) t.tBodies[0].insertBefore(r1, r2);
					else t.tBodies[0].insertBefore(r2, r1);

					if (v && r2) {
						setFormValue(r1, v, idx2);
						setFormValue(r2, v, idx1);
					}
				}
			}
		}

		var me = this;
		setTimeout(function(){
			me.unhighlightRow(r1);
		}, 500);
	},
	highlightRow: function(el) {
		if (!el) return;
		var r1 = this.getCurrentRow(el);
		if (r1) {
			r1.className = r1.className.replace(' sort-row-highlight','') + ' sort-row-highlight';
		}
	},
	unhighlightRow: function(el) {
		if (!el) return;
		var r1 = this.getCurrentRow(el);
		if (r1) {
			r1.className = r1.className.replace(' sort-row-highlight','');
		}
	}
};

