/*! TE*/

var vartimeout;
function NotifyMsgWithTimeout(lbl, str, timeout) {
	lbl.innerHTML = str;
	clearTimeout(vartimeout);
	vartimeout = setTimeout(function () { lbl.innerHTML = ''; }, timeout);
}

function NotifyMsgWithTimeoutShowCtl(lbl, str, timeout, ctl) {
	lbl.innerHTML = str;
	clearTimeout(vartimeout);
	vartimeout = setTimeout(function () {  ctl.style.display = ''; lbl.innerHTML = ''; }, timeout);
}

function NotifyMsg(lbl, str) {
	lbl.innerHTML = str;
}

function NotifyMsgHideCtl(lbl, str, ctl) {
	ctl.style.display = 'none';
	lbl.innerHTML = str;
}

function popNew(strURL) {
	window.open(strURL);
}

function popLogin(strURL) {
	popWin = window.open(strURL, "popWin", "left=200,top=150,width=264,height=199,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,menubar=no");
}

function popHelp(strURL) {
	popWin = window.open(strURL, "popWin", "left=10,top=10,width=300,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

function popAvail(strURL) {
	popWin = window.open(strURL, "popWin", "left=5,top=10,width=790,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

function PF() { window.print(); }
function PrintMe() {
	window.print();
	return false;
}

function PFpop() {
	var location = "" + document.location.pathname
	if (location.length < 3)
	{ location = "/"; }
	else
	{ location = "" + document.location; }
	if (location.indexOf("?") == -1)
	{ document.location = location + '?POP=1&Print=1'; }
	else
	{ document.location = location + '&POP=1&Print=1'; }
}

function EMailPage() {
	var location = "" + document.location.pathname
	if (location.length < 3)
	{ location = "/"; }
	else
	{ location = "" + document.location; }
	if (location.indexOf("?") == -1)
	{ document.location = location + '?EMailPage=1'; }
	else
	{ document.location = location + '&EMailPage=1'; }
}

function ChangeLanguage(LangID) {
	var location = "" + document.location.pathname
	if (location.length < 3)
	{ location = "/"; }
	else
	{ location = "" + document.location; }
	if (location.indexOf("?") == -1)
	{ document.location = location + '?LangID=' + LangID; }
	else {
		if (location.indexOf("LangID") == -1) {
			document.location = location + '&LangID=' + LangID;
		}
		else {
			var langIndex = location.indexOf("LangID=");
			var newLocation = location.slice(0, langIndex + 7);
			document.location = newLocation + LangID;
		}
	}
}

function SamePage(AddToQ, AddToQval) {
	var location = "" + document.location.pathname
	if (location.length < 3)
	{ location = "/"; }
	else
	{ location = "" + document.location; }
	if (location.indexOf("?") == -1) {
		document.location = location + '?' + AddToQ + '=' + AddToQval;
	}
	else {
		var QLoc = location.indexOf("?");
		if (location.indexOf(AddToQ, QLoc) == -1) {
			document.location = location + '&' + AddToQ + '=' + AddToQval;
		}
		else {
			var AddToQLoc = location.indexOf(AddToQ, QLoc);
			var AmpLoc = location.indexOf("&", AddToQLoc);
			if (AmpLoc == -1) {
				if (AddToQLoc - QLoc == 1) {
					document.location = location.substring(0, AddToQLoc - 1) + '?' + AddToQ + '=' + AddToQval;
				}
				else {
					document.location = location.substring(0, AddToQLoc - 1) + '&' + AddToQ + '=' + AddToQval;
				}
			}
			else {
				var eqLoc = location.substring(0, AddToQLoc + AddToQ.length) + AddToQval + location.substring(AmpLoc);
			}
		}
	}
}

function GetRadWindow() {
	var oWindow = null;
	try {
		if (window.radWindow) oWindow = window.radWindow;
		else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
	}
	catch (e) {
		oWindow = null
	}
	return oWindow;
}

function closewindow() {
	var oWindow = GetRadWindow();
	if (oWindow != null) {
		oWindow.Close();
	}
	else {
		window.close();
	}
}
var initWidth;
var initHeight;
function ResizeWindowToContent() {
	var oWnd;
	var theTop;
	var theLeft;
	window.setTimeout(
        function () {
        	oWnd = GetRadWindow();
        	//GetParentWindowProperties(oWnd);
        	if (initWidth == null) initWidth = document.body.scrollWidth + 40;
        	if (initWidth > 850) initWidth = 850;
        	if (initHeight == null) initHeight = document.body.scrollHeight + 90;
        	if (initHeight > 800) initHeight = 800;
        	oWnd.SetSize(initWidth, initHeight);
        	//oWnd.MoveTo((window.top.document.body.clientWidth - initWidth) / 2, 0);
        }, 10);
}

function ResizeWindowToContentNews() {
	var oWnd;
	var theTop;
	var theLeft;
	var Height;
	window.setTimeout(
        function () {
        	oWnd = GetRadWindow();
        	Height = document.body.scrollHeight + 62;
        	if (Height > 800) Height = 800;
        	oWnd.SetSize(540, Height);
        }, 10);

}

function remMe(chkBox) {
	var confirmText = "If you tick this box then you will no longer need to log in\n" +
		"when visiting our site from this computer.\n\n" +
		"You can disable this feature at any time by logging out.\n\n" +
		"Don't use this option unless you are the only person\nwho has access to this computer.\n\n" +
		"WARNING:\n" +
		"If you do decide to use this option you could be exposed to \nsecurity breach by anyone who uses your machine to access this site."

	if (chkBox.checked)
		if (!confirm(confirmText))
			chkBox.checked = false;
}
// For evoRadGrid 
function RowDoubleClick(sender, eventArgs) {
	var UniqueID = eventArgs.getDataKeyValue(teKeyValue);
	if (UniqueID != null) {
		OpenEditForm(UniqueID, 0, 0);
		return false;
	}
}

var WindowWidth = 0;
var WindowHeight = 0;
var WindowScrollX = 0;
var WindowScrollY = 0;

function GetParentWindowProperties(oWnd) {
	if (typeof (oWnd.BrowserWindow.window.innerWidth) == 'number') {
		WindowWidth = oWnd.BrowserWindow.window.innerWidth;
		WindowHeight = oWnd.BrowserWindow.window.innerHeight;
	} else if (oWnd.BrowserWindow.document.documentElement && (oWnd.BrowserWindow.document.documentElement.clientWidth || oWnd.BrowserWindow.document.documentElement.clientHeight)) {
		WindowWidth = oWnd.BrowserWindow.document.documentElement.clientWidth;
		WindowHeight = oWnd.BrowserWindow.document.documentElement.clientHeight;
	} else if (oWnd.BrowserWindow.document.body && (oWnd.BrowserWindow.document.body.scrollWidth || oWnd.BrowserWindow.document.body.scrollHeight)) {
		WindowWidth = oWnd.BrowserWindow.document.body.scrollWidth;
		WindowHeight = oWnd.BrowserWindow.document.body.scrollHeight;
	}
	if (typeof (oWnd.BrowserWindow.window.pageYOffset) == 'number') {
		WindowScrollY = oWnd.BrowserWindow.window.pageYOffset;
		WindowScrollX = oWnd.BrowserWindow.window.pageXOffset;
	} else if (oWnd.BrowserWindow.document.body && (oWnd.BrowserWindow.document.body.scrollLeft || oWnd.BrowserWindow.document.body.scrollTop)) {
		WindowScrollY = oWnd.BrowserWindow.document.body.scrollTop;
		WindowScrollX = oWnd.BrowserWindow.document.body.scrollLeft;
	} else if (oWnd.BrowserWindow.document.documentElement && (oWnd.BrowserWindow.document.documentElement.scrollLeft || oWnd.BrowserWindow.document.documentElement.scrollTop)) {
		WindowScrollY = oWnd.BrowserWindow.document.documentElement.scrollTop;
		WindowScrollX = oWnd.BrowserWindow.document.documentElement.scrollLeft;
	}
}

function GetOriginalWindowProperties() {
	if (typeof (window.innerWidth) == 'number') {
		WindowWidth = window.innerWidth;
		WindowHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		WindowWidth = document.documentElement.clientWidth;
		WindowHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
		WindowWidth = document.body.scrollWidth;
		WindowHeight = document.body.scrollHeight;
	}

	if (typeof (window.pageYOffset) == 'number') {
		WindowScrollY = window.pageYOffset;
		WindowScrollX = window.pageXOffset;
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		WindowScrollY = document.body.scrollTop;
		WindowScrollX = document.body.scrollLeft;
	} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		WindowScrollY = document.documentElement.scrollTop;
		WindowScrollX = document.documentElement.scrollLeft;
	}
}

function OpenEditForm(KeyID1, KeyID2, KeyID3, KeyID4, KeyID5, KeyID6, KeyID7, KeyID8) {
	var URLToAppend = "";
	if (KeyID1 != undefined) { URLToAppend += '&KeyID1=' + KeyID1; }
	if (KeyID2 != undefined) { URLToAppend += '&KeyID2=' + KeyID2; }
	if (KeyID3 != undefined) { URLToAppend += '&KeyID3=' + KeyID3; }
	if (KeyID4 != undefined) { URLToAppend += '&KeyID4=' + KeyID4; }
	if (KeyID5 != undefined) { URLToAppend += '&KeyID5=' + KeyID5; }
	if (KeyID6 != undefined) { URLToAppend += '&KeyID6=' + KeyID6; }
	if (KeyID7 != undefined) { URLToAppend += '&KeyID7=' + KeyID7; }
	if (KeyID8 != undefined) { URLToAppend += '&KeyID8=' + KeyID8; }
	var oWindow = window.radopen(teURL + URLToAppend, teTitle);
	oWindow.set_title(teTitle);
	return false;
}

function OpenEditFormExtended(ControlID, NoSave, KeyID1, KeyID2, KeyID3, KeyID4, KeyID5, KeyID6, KeyID7, KeyID8) {
	var URLToAppend = "";
	if (ControlID != undefined) { URLToAppend += ControlID; }
	if (NoSave != undefined) { URLToAppend += '&NoSave=' + NoSave; }
	if (KeyID1 != undefined) { URLToAppend += '&KeyID1=' + KeyID1; }
	if (KeyID2 != undefined) { URLToAppend += '&KeyID2=' + KeyID2; }
	if (KeyID3 != undefined) { URLToAppend += '&KeyID3=' + KeyID3; }
	if (KeyID4 != undefined) { URLToAppend += '&KeyID4=' + KeyID4; }
	if (KeyID5 != undefined) { URLToAppend += '&KeyID5=' + KeyID5; }
	if (KeyID6 != undefined) { URLToAppend += '&KeyID6=' + KeyID6; }
	if (KeyID7 != undefined) { URLToAppend += '&KeyID7=' + KeyID7; }
	if (KeyID8 != undefined) { URLToAppend += '&KeyID8=' + KeyID8; }
	var oWindow = window.radopen(URL + URLToAppend, teTitle);
	oWindow.set_title(teTitle);
	return false;
}

function RefreshGrid(arg) {
	if (teGrid) {
		if (arg == null)
		{ __doPostBack(teGrid, "CloseAndRebind"); }
		else
		{ __doPostBack(teGrid, arg); };
	}
	else {
		//setTimeout('__doPostBack(null, null)', 0)
		__doPostBack(null, null);
	}
}

var expand = false;
function ExpColap() {
	var masterview = $find(teMaster);
	var count = masterview.get_dataItems().length;
	if (expand == false)
		expand = true;
	else
		expand = false;

	for (var i = 0; i < count; i++) {
		var mtvItem = masterview.get_dataItems()[i];
		if (mtvItem != null) {
			mtvItem.set_expanded(expand)
		}
	}
}
// Image transition
var stopSwappingBanner = false;
function changeOpac(opacity, id) {
	if (!stopSwappingBanner) {
		var object = document.getElementById(id).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	}
}
function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	var currentOpac = 100;
	var newOpac = 0;
	if (document.getElementById(imageid).style.opacity < 100) {
		currentOpac = document.getElementById(imageid).style.opacity * 100;
	}
	if (currentOpac > 50) {
		document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	}
	else {
		newOpac = currentOpac;
	}
	changeOpac(newOpac, imageid);
	document.getElementById(imageid).src = imagefile;
	for (i = newOpac; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')", (timer * speed));
		timer++;
	}
}
function currentOpac(id, opacEnd, millisec) {
	if (!stopSwappingBanner) {
		var currentOpac = 100;
		if (document.getElementById(id).style.opacity < 100) {
			currentOpac = document.getElementById(id).style.opacity * 100;
		}
		opacity(id, currentOpac, opacEnd, millisec)
	}
}

function OnLoad(sender, eventArgs) {
	var panelBar = sender;
	var allItems = panelBar.get_allItems();
	for (var i = 0; i < allItems.length; i++) {
		var panelItem = allItems[i];
		var imageElement = panelItem.get_imageElement();
		if (imageElement) {
			imageElement.AssociatedItem = panelItem;
			imageElement.onclick = function (e) {
				if (!e) e = window.event;
				if (this.AssociatedItem.get_expanded()) {
					this.AssociatedItem.collapse();
				}
				else {
					this.AssociatedItem.expand();
				}
				e.cancelBubble = true;
				if (e.stopPropagation) {
					e.stopPropagation();
				}
				return false;
			}
		}
	}
}

//YT PLAYER;
function updateHTML(elmId, value) {
	document.getElementById(elmId).innerHTML = value;
}

function setytplayerState(newState) {
	if (newState == 1) {
		document.getElementById('PlayLink').style.display = 'none';
		document.getElementById('PauseLink').style.display = 'inline';
	}
	else if (newState == 2) {
		document.getElementById('PlayLink').style.display = 'inline';
		document.getElementById('PauseLink').style.display = 'none';
	}
	else if (newState == 5) {
		document.getElementById('PlayLink').style.display = 'inline';
		document.getElementById('PauseLink').style.display = 'none';
	}
}

function onytplayerStateChange(newState) {
	setytplayerState(newState);
}

function onPlayerError(errorCode) {
	alert("An error occured: " + errorCode);
}

function updateytplayerInfo() {
	updateHTML("bytesloaded", getBytesLoaded());
	updateHTML("bytestotal", getBytesTotal());
	updateHTML("videoduration", getDuration());
	updateHTML("videotime", getCurrentTime());
	updateHTML("startbytes", getStartBytes());
	updateHTML("volume", getVolume());
}


function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById("myytplayer");
	ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
	ytplayer.addEventListener("onError", "onPlayerError");
	playerReady();
}

function loadNewVideo(id, startSeconds) {
	if (ytplayer) {
		ytplayer.loadVideoById(id, parseInt(startSeconds));
	}
}

function cueNewVideo(id, startSeconds) {
	if (ytplayer) {
		ytplayer.cueVideoById(id, startSeconds);
	}
}

function play() {
	if (ytplayer) {
		ytplayer.playVideo();
	}
}

function pause() {
	if (ytplayer) {
		ytplayer.pauseVideo();
	}
}

function stop() {
	if (ytplayer) {
		ytplayer.stopVideo();
	}
}

function getPlayerState() {
	if (ytplayer) {
		return ytplayer.getPlayerState();
	}
}

function seekTo(seconds) {
	if (ytplayer) {
		ytplayer.seekTo(seconds, true);
	}
}

function getBytesLoaded() {
	if (ytplayer) {
		return ytplayer.getVideoBytesLoaded();
	}
}

function getBytesTotal() {
	if (ytplayer) {
		return ytplayer.getVideoBytesTotal();
	}
}

function getCurrentTime() {
	if (ytplayer) {
		return ytplayer.getCurrentTime();
	}
}

function getDuration() {
	if (ytplayer) {
		return ytplayer.getDuration();
	}
}

function getStartBytes() {
	if (ytplayer) {
		return ytplayer.getVideoStartBytes();
	}
}

function mute() {
	if (ytplayer) {
		ytplayer.mute();
		document.getElementById('UnmuteLink').style.display = 'inline';
		document.getElementById('MuteLink').style.display = 'none';
	}
}

function unMute() {
	if (ytplayer) {
		ytplayer.unMute();
		document.getElementById('MuteLink').style.display = 'inline';
		document.getElementById('UnmuteLink').style.display = 'none';
	}
}

function getEmbedCode() {
	alert(ytplayer.getVideoEmbedCode());
}

function getVideoUrl() {
	alert(ytplayer.getVideoUrl());
}

function setVolume(newVolume) {
	if (ytplayer) {
		ytplayer.setVolume(newVolume);
	}
}

function getVolume() {
	if (ytplayer) {
		return ytplayer.getVolume();
	}
}

function clearVideo() {
	if (ytplayer) {
		ytplayer.clearVideo();
	}
}



/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject = function () { var D = "undefined", r = "object", S = "Shockwave Flash", W = "ShockwaveFlash.ShockwaveFlash", q = "application/x-shockwave-flash", R = "SWFObjectExprInst", x = "onreadystatechange", O = window, j = document, t = navigator, T = false, U = [h], o = [], N = [], I = [], l, Q, E, B, J = false, a = false, n, G, m = true, M = function () { var aa = typeof j.getElementById != D && typeof j.getElementsByTagName != D && typeof j.createElement != D, ah = t.userAgent.toLowerCase(), Y = t.platform.toLowerCase(), ae = Y ? /win/.test(Y) : /win/.test(ah), ac = Y ? /mac/.test(Y) : /mac/.test(ah), af = /webkit/.test(ah) ? parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, X = ! +"\v1", ag = [0, 0, 0], ab = null; if (typeof t.plugins != D && typeof t.plugins[S] == r) { ab = t.plugins[S].description; if (ab && !(typeof t.mimeTypes != D && t.mimeTypes[q] && !t.mimeTypes[q].enabledPlugin)) { T = true; X = false; ab = ab.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); ag[0] = parseInt(ab.replace(/^(.*)\..*$/, "$1"), 10); ag[1] = parseInt(ab.replace(/^.*\.(.*)\s.*$/, "$1"), 10); ag[2] = /[a-zA-Z]/.test(ab) ? parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0 } } else { if (typeof O.ActiveXObject != D) { try { var ad = new ActiveXObject(W); if (ad) { ab = ad.GetVariable("$version"); if (ab) { X = true; ab = ab.split(" ")[1].split(","); ag = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)] } } } catch (Z) { } } } return { w3: aa, pv: ag, wk: af, ie: X, win: ae, mac: ac} } (), k = function () { if (!M.w3) { return } if ((typeof j.readyState != D && j.readyState == "complete") || (typeof j.readyState == D && (j.getElementsByTagName("body")[0] || j.body))) { f() } if (!J) { if (typeof j.addEventListener != D) { j.addEventListener("DOMContentLoaded", f, false) } if (M.ie && M.win) { j.attachEvent(x, function () { if (j.readyState == "complete") { j.detachEvent(x, arguments.callee); f() } }); if (O == top) { (function () { if (J) { return } try { j.documentElement.doScroll("left") } catch (X) { setTimeout(arguments.callee, 0); return } f() })() } } if (M.wk) { (function () { if (J) { return } if (!/loaded|complete/.test(j.readyState)) { setTimeout(arguments.callee, 0); return } f() })() } s(f) } } (); function f() { if (J) { return } try { var Z = j.getElementsByTagName("body")[0].appendChild(C("span")); Z.parentNode.removeChild(Z) } catch (aa) { return } J = true; var X = U.length; for (var Y = 0; Y < X; Y++) { U[Y]() } } function K(X) { if (J) { X() } else { U[U.length] = X } } function s(Y) { if (typeof O.addEventListener != D) { O.addEventListener("load", Y, false) } else { if (typeof j.addEventListener != D) { j.addEventListener("load", Y, false) } else { if (typeof O.attachEvent != D) { i(O, "onload", Y) } else { if (typeof O.onload == "function") { var X = O.onload; O.onload = function () { X(); Y() } } else { O.onload = Y } } } } } function h() { if (T) { V() } else { H() } } function V() { var X = j.getElementsByTagName("body")[0]; var aa = C(r); aa.setAttribute("type", q); var Z = X.appendChild(aa); if (Z) { var Y = 0; (function () { if (typeof Z.GetVariable != D) { var ab = Z.GetVariable("$version"); if (ab) { ab = ab.split(" ")[1].split(","); M.pv = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)] } } else { if (Y < 10) { Y++; setTimeout(arguments.callee, 10); return } } X.removeChild(aa); Z = null; H() })() } else { H() } } function H() { var ag = o.length; if (ag > 0) { for (var af = 0; af < ag; af++) { var Y = o[af].id; var ab = o[af].callbackFn; var aa = { success: false, id: Y }; if (M.pv[0] > 0) { var ae = c(Y); if (ae) { if (F(o[af].swfVersion) && !(M.wk && M.wk < 312)) { w(Y, true); if (ab) { aa.success = true; aa.ref = z(Y); ab(aa) } } else { if (o[af].expressInstall && A()) { var ai = {}; ai.data = o[af].expressInstall; ai.width = ae.getAttribute("width") || "0"; ai.height = ae.getAttribute("height") || "0"; if (ae.getAttribute("class")) { ai.styleclass = ae.getAttribute("class") } if (ae.getAttribute("align")) { ai.align = ae.getAttribute("align") } var ah = {}; var X = ae.getElementsByTagName("param"); var ac = X.length; for (var ad = 0; ad < ac; ad++) { if (X[ad].getAttribute("name").toLowerCase() != "movie") { ah[X[ad].getAttribute("name")] = X[ad].getAttribute("value") } } P(ai, ah, Y, ab) } else { p(ae); if (ab) { ab(aa) } } } } } else { w(Y, true); if (ab) { var Z = z(Y); if (Z && typeof Z.SetVariable != D) { aa.success = true; aa.ref = Z } ab(aa) } } } } } function z(aa) { var X = null; var Y = c(aa); if (Y && Y.nodeName == "OBJECT") { if (typeof Y.SetVariable != D) { X = Y } else { var Z = Y.getElementsByTagName(r)[0]; if (Z) { X = Z } } } return X } function A() { return !a && F("6.0.65") && (M.win || M.mac) && !(M.wk && M.wk < 312) } function P(aa, ab, X, Z) { a = true; E = Z || null; B = { success: false, id: X }; var ae = c(X); if (ae) { if (ae.nodeName == "OBJECT") { l = g(ae); Q = null } else { l = ae; Q = X } aa.id = R; if (typeof aa.width == D || (!/%$/.test(aa.width) && parseInt(aa.width, 10) < 310)) { aa.width = "310" } if (typeof aa.height == D || (!/%$/.test(aa.height) && parseInt(aa.height, 10) < 137)) { aa.height = "137" } j.title = j.title.slice(0, 47) + " - Flash Player Installation"; var ad = M.ie && M.win ? "ActiveX" : "PlugIn", ac = "MMredirectURL=" + O.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + ad + "&MMdoctitle=" + j.title; if (typeof ab.flashvars != D) { ab.flashvars += "&" + ac } else { ab.flashvars = ac } if (M.ie && M.win && ae.readyState != 4) { var Y = C("div"); X += "SWFObjectNew"; Y.setAttribute("id", X); ae.parentNode.insertBefore(Y, ae); ae.style.display = "none"; (function () { if (ae.readyState == 4) { ae.parentNode.removeChild(ae) } else { setTimeout(arguments.callee, 10) } })() } u(aa, ab, X) } } function p(Y) { if (M.ie && M.win && Y.readyState != 4) { var X = C("div"); Y.parentNode.insertBefore(X, Y); X.parentNode.replaceChild(g(Y), X); Y.style.display = "none"; (function () { if (Y.readyState == 4) { Y.parentNode.removeChild(Y) } else { setTimeout(arguments.callee, 10) } })() } else { Y.parentNode.replaceChild(g(Y), Y) } } function g(ab) { var aa = C("div"); if (M.win && M.ie) { aa.innerHTML = ab.innerHTML } else { var Y = ab.getElementsByTagName(r)[0]; if (Y) { var ad = Y.childNodes; if (ad) { var X = ad.length; for (var Z = 0; Z < X; Z++) { if (!(ad[Z].nodeType == 1 && ad[Z].nodeName == "PARAM") && !(ad[Z].nodeType == 8)) { aa.appendChild(ad[Z].cloneNode(true)) } } } } } return aa } function u(ai, ag, Y) { var X, aa = c(Y); if (M.wk && M.wk < 312) { return X } if (aa) { if (typeof ai.id == D) { ai.id = Y } if (M.ie && M.win) { var ah = ""; for (var ae in ai) { if (ai[ae] != Object.prototype[ae]) { if (ae.toLowerCase() == "data") { ag.movie = ai[ae] } else { if (ae.toLowerCase() == "styleclass") { ah += ' class="' + ai[ae] + '"' } else { if (ae.toLowerCase() != "classid") { ah += " " + ae + '="' + ai[ae] + '"' } } } } } var af = ""; for (var ad in ag) { if (ag[ad] != Object.prototype[ad]) { af += '<param name="' + ad + '" value="' + ag[ad] + '" />' } } aa.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + ah + ">" + af + "</object>"; N[N.length] = ai.id; X = c(ai.id) } else { var Z = C(r); Z.setAttribute("type", q); for (var ac in ai) { if (ai[ac] != Object.prototype[ac]) { if (ac.toLowerCase() == "styleclass") { Z.setAttribute("class", ai[ac]) } else { if (ac.toLowerCase() != "classid") { Z.setAttribute(ac, ai[ac]) } } } } for (var ab in ag) { if (ag[ab] != Object.prototype[ab] && ab.toLowerCase() != "movie") { e(Z, ab, ag[ab]) } } aa.parentNode.replaceChild(Z, aa); X = Z } } return X } function e(Z, X, Y) { var aa = C("param"); aa.setAttribute("name", X); aa.setAttribute("value", Y); Z.appendChild(aa) } function y(Y) { var X = c(Y); if (X && X.nodeName == "OBJECT") { if (M.ie && M.win) { X.style.display = "none"; (function () { if (X.readyState == 4) { b(Y) } else { setTimeout(arguments.callee, 10) } })() } else { X.parentNode.removeChild(X) } } } function b(Z) { var Y = c(Z); if (Y) { for (var X in Y) { if (typeof Y[X] == "function") { Y[X] = null } } Y.parentNode.removeChild(Y) } } function c(Z) { var X = null; try { X = j.getElementById(Z) } catch (Y) { } return X } function C(X) { return j.createElement(X) } function i(Z, X, Y) { Z.attachEvent(X, Y); I[I.length] = [Z, X, Y] } function F(Z) { var Y = M.pv, X = Z.split("."); X[0] = parseInt(X[0], 10); X[1] = parseInt(X[1], 10) || 0; X[2] = parseInt(X[2], 10) || 0; return (Y[0] > X[0] || (Y[0] == X[0] && Y[1] > X[1]) || (Y[0] == X[0] && Y[1] == X[1] && Y[2] >= X[2])) ? true : false } function v(ac, Y, ad, ab) { if (M.ie && M.mac) { return } var aa = j.getElementsByTagName("head")[0]; if (!aa) { return } var X = (ad && typeof ad == "string") ? ad : "screen"; if (ab) { n = null; G = null } if (!n || G != X) { var Z = C("style"); Z.setAttribute("type", "text/css"); Z.setAttribute("media", X); n = aa.appendChild(Z); if (M.ie && M.win && typeof j.styleSheets != D && j.styleSheets.length > 0) { n = j.styleSheets[j.styleSheets.length - 1] } G = X } if (M.ie && M.win) { if (n && typeof n.addRule == r) { n.addRule(ac, Y) } } else { if (n && typeof j.createTextNode != D) { n.appendChild(j.createTextNode(ac + " {" + Y + "}")) } } } function w(Z, X) { if (!m) { return } var Y = X ? "visible" : "hidden"; if (J && c(Z)) { c(Z).style.visibility = Y } else { v("#" + Z, "visibility:" + Y) } } function L(Y) { var Z = /[\\\"<>\.;]/; var X = Z.exec(Y) != null; return X && typeof encodeURIComponent != D ? encodeURIComponent(Y) : Y } var d = function () { if (M.ie && M.win) { window.attachEvent("onunload", function () { var ac = I.length; for (var ab = 0; ab < ac; ab++) { I[ab][0].detachEvent(I[ab][1], I[ab][2]) } var Z = N.length; for (var aa = 0; aa < Z; aa++) { y(N[aa]) } for (var Y in M) { M[Y] = null } M = null; for (var X in swfobject) { swfobject[X] = null } swfobject = null }) } } (); return { registerObject: function (ab, X, aa, Z) { if (M.w3 && ab && X) { var Y = {}; Y.id = ab; Y.swfVersion = X; Y.expressInstall = aa; Y.callbackFn = Z; o[o.length] = Y; w(ab, false) } else { if (Z) { Z({ success: false, id: ab }) } } }, getObjectById: function (X) { if (M.w3) { return z(X) } }, embedSWF: function (ab, ah, ae, ag, Y, aa, Z, ad, af, ac) { var X = { success: false, id: ah }; if (M.w3 && !(M.wk && M.wk < 312) && ab && ah && ae && ag && Y) { w(ah, false); K(function () { ae += ""; ag += ""; var aj = {}; if (af && typeof af === r) { for (var al in af) { aj[al] = af[al] } } aj.data = ab; aj.width = ae; aj.height = ag; var am = {}; if (ad && typeof ad === r) { for (var ak in ad) { am[ak] = ad[ak] } } if (Z && typeof Z === r) { for (var ai in Z) { if (typeof am.flashvars != D) { am.flashvars += "&" + ai + "=" + Z[ai] } else { am.flashvars = ai + "=" + Z[ai] } } } if (F(Y)) { var an = u(aj, am, ah); if (aj.id == ah) { w(ah, true) } X.success = true; X.ref = an } else { if (aa && A()) { aj.data = aa; P(aj, am, ah, ac); return } else { w(ah, true) } } if (ac) { ac(X) } }) } else { if (ac) { ac(X) } } }, switchOffAutoHideShow: function () { m = false }, ua: M, getFlashPlayerVersion: function () { return { major: M.pv[0], minor: M.pv[1], release: M.pv[2]} }, hasFlashPlayerVersion: F, createSWF: function (Z, Y, X) { if (M.w3) { return u(Z, Y, X) } else { return undefined } }, showExpressInstall: function (Z, aa, X, Y) { if (M.w3 && A()) { P(Z, aa, X, Y) } }, removeSWF: function (X) { if (M.w3) { y(X) } }, createCSS: function (aa, Z, Y, X) { if (M.w3) { v(aa, Z, Y, X) } }, addDomLoadEvent: K, addLoadEvent: s, getQueryParamValue: function (aa) { var Z = j.location.search || j.location.hash; if (Z) { if (/\?/.test(Z)) { Z = Z.split("?")[1] } if (aa == null) { return L(Z) } var Y = Z.split("&"); for (var X = 0; X < Y.length; X++) { if (Y[X].substring(0, Y[X].indexOf("=")) == aa) { return L(Y[X].substring((Y[X].indexOf("=") + 1))) } } } return "" }, expressInstallCallback: function () { if (a) { var X = c(R); if (X && l) { X.parentNode.replaceChild(l, X); if (Q) { w(Q, true); if (M.ie && M.win) { l.style.display = "block" } } if (E) { E(B) } } a = false } } } } ();


//  CC Validator
function validateCard(controlform, IsOption) {
	var doCheck;
	doCheck = true;
	var radCCOnPhone;
	var radCCOnForm;
	if (IsOption == 1) {
		radCCOnPhone = document.getElementsByName(controlform + 'radCCOnPhone');
		radCCOnForm = document.getElementsByName(controlform + 'radCCOnForm');
		if (radCCOnPhone != null && radCCOnForm != null && radCCOnPhone.length > 0 && radCCOnForm.length > 0) {
			if (radCCOnPhone.item(0).checked == true) {
				doCheck = false;
			}
		}
	}

	if (doCheck == false) {
		return true;
	}

	var ddlCCCardType = document.getElementsByName(controlform + 'ddlCCCardType');
	var txtCCCardNo = document.getElementsByName(controlform + 'txtCCCardNo');
	var txtCCCCV = document.getElementsByName(controlform + 'txtCCCCV');
	var ddlCCExpMonth = document.getElementsByName(controlform + 'ddlCCExpMonth');
	var ddlCCExpYear = document.getElementsByName(controlform + 'ddlCCExpYear');
	var txtCCCardName = document.getElementsByName(controlform + 'txtCCCardName');
	if (ddlCCCardType != null && txtCCCardNo != null && txtCCCCV != null && ddlCCExpMonth != null && ddlCCExpYear != null && txtCCCardName != null && ddlCCCardType.length > 0 && txtCCCardNo.length > 0 && txtCCCCV.length > 0 && ddlCCExpMonth.length > 0 && ddlCCExpYear.length > 0 && txtCCCardName.length > 0) {
		var cardType = ddlCCCardType.item(0).value;
		var cardNumber = txtCCCardNo.item(0).value;
		var cardCCV = txtCCCCV.item(0).value;
		var cardMonth = ddlCCExpMonth.item(0).value;
		var cardYear = ddlCCExpYear.item(0).value;
		var NameOnCard = txtCCCardName.item(0).value;

		if (cardNumber.length == 0) {
			alert("Please enter a valid Card Number.");
			txtCCCardNo.item(0).focus();
			return false;
		}
		for (var i = 0; i < cardNumber.length; ++i) {		// make sure the number is all digits.. (by design)
			var c = cardNumber.charAt(i);
			if (c < '0' || c > '9') {
				alert("Please enter a valid Card Number.\n\n Use only digits. Do not use Spaces or any Special Characters.");
				txtCCCardNo.item(0).focus();
				return false;
			}
		}

		if (cardCCV.length == 0) {
			alert("Please enter a valid Card Security Number.");
			txtCCCCV.item(0).focus();
			return false;
		}
		for (var i = 0; i < cardCCV.length; ++i) {		// make sure the number is all digits.. (by design)
			var c = cardCCV.charAt(i);
			if (c < '0' || c > '9') {
				alert("Please enter a valid Card Security Number.\n\n Use only digits. Do not use Spaces or any Special Characters.");
				txtCCCCV.item(0).focus();
				return false;
			}
		}

		//perform card specific length and prefix tests
		var length = cardNumber.length;

		switch (cardType) {
			case '1':
				if (length != 16 && length != 13) {
					alert("Please enter a valid Visa Card Number.\n\nA Visa Card Number contains either 13 or 16 digits.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				var prefix = parseInt(cardNumber.substring(0, 1));
				if (prefix != 4) {
					alert("Please enter a valid Visa Card Number.\n\nA Visa Card Number starts with 4.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				break;
			case '2':
				if (length != 16) {
					alert("Please enter a valid MasterCard Number.\n\nA MasterCard Number contains 16 digits.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				var prefix = parseInt(cardNumber.substring(0, 2));

				if (prefix < 51 || prefix > 55) {
					alert("Please enter a valid MasterCard Card Number.\n\nA MasterCard Number starts with 51 to 55.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				break;
			case '3':
				if (length != 15) {
					alert("Please enter a valid American Express Card Number.\n\nAn American Express Card Number contains 15 digits.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				var prefix = parseInt(cardNumber.substring(0, 2));
				if (prefix != 34 && prefix != 37) {
					alert("Please enter a valid American Express Card Number.\n\nAn American Express Card Number starts with either 34 or 37.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				break;
			case '4':
				if (length != 14) {
					alert("Please enter a valid Diners Club / Carte Blanche Card Number.\n\nThe Card Number contains 14 digits.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				var prefix = parseInt(cardNumber.substring(0, 2));

				if (prefix != 30 && prefix != 36 && prefix != 38) {
					alert("Please enter a valid Diners Club / Carte Blanche Card Number.\n\nThe Card Number starts with 30, 36 or 38.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				break;
			case '5':
				if (length != 16) {
					alert("Please enter a valid Discover Card Number.\n\nA Discover Card Number contains 16 digits.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				var prefix = parseInt(cardNumber.substring(0, 4));

				if (prefix != 6011) {
					alert("Please enter a valid Discover Card Number.\n\nA Discover Card Number starts with 6011.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				break;
			case '6':
				if (length != 15 && length != 16) {
					alert("Please enter a valid JCB Number.\n\nA JCB Number contains either 15 or 16 digits.");
					txtCCCardNo.item(0).focus();
					return false;
				}
				if (length == 15) {
					var prefix = parseInt(cardNumber.substring(0, 1));

					if (prefix != 3) {
						alert("Please enter a valid JCB Card Number.\n\nA JCB Number starts with 3, 1800 or 2131.");
						txtCCCardNo.item(0).focus();
						return false;
					}
				}
				else if (length == 16) {
					var prefix = parseInt(cardNumber.substring(0, 4));

					if (prefix != 1800 && prefix != 2131) {
						alert("Please enter a valid JCB Card Number.\n\nA JCB Number starts with 3, 1800 or 2131.");
						txtCCCardNo.item(0).focus();
						return false;
					}
				}
				break;
		}

		var lengthCCV = cardCCV.length;

		switch (cardType) {
			case '1':
				if (lengthCCV != 3) {
					alert("Please enter a valid Visa Card Security Number.\n\nA Visa Card Security Number contains 3 digits.");
					txtCCCCV.item(0).focus();
					return false;
				}
				break;
			case '2':
				if (lengthCCV != 3) {
					alert("Please enter a valid MasterCard Security Number.\n\nA MasterCard Security Number contains 3 digits.");
					txtCCCCV.item(0).focus();
					return false;
				}
				break;
			case '3':
				if (lengthCCV != 4) {
					alert("Please enter a valid American Express Card Security Number.\n\nAn American Express Card Security Number contains 4 digits.");
					txtCCCCV.item(0).focus();
					return false;
				}
				break;
			case '4':
				if (lengthCCV != 3) {
					alert("Please enter a valid Diners Club / Carte Blanche Card Security Number.\n\nThe Card Security Number contains 3 digits.");
					txtCCCCV.item(0).focus();
					return false;
				}
				break;
			case '5':
				if (lengthCCV != 3) {
					alert("Please enter a valid Discover Card Security Number.\n\nA Discover Card Security Number contains 3 digits.");
					txtCCCCV.item(0).focus();
					return false;
				}
				break;
			case '6':
				if (lengthCCV != 3) {
					alert("Please enter a valid JCB Security Number.\n\nA JCB Security Number contains 3 digits.");
					txtCCCCV.item(0).focus();
					return false;
				}
				break;
		}

		if (!mod10(cardNumber)) { 		// run the check digit algorithm
			alert("Sorry! this is not a valid Card Number.");
			txtCCCardNo.item(0).focus();
			return false;
		}
		if (expired(cardMonth, cardYear)) {							// check if entered date is already expired.
			alert("Sorry! The Expiration Date you have entered would make this Card invalid.");
			ddlCCExpMonth.item(0).focus();
			return false;
		}
		if (NameOnCard.length == 0) {
			alert("Please enter Name on Card.");
			txtCCCardName.item(0).focus();
			return false;
		}
		return true; // at this point card has not been proven to be invalid
	}
	return false;
}
function mod10(cardNumber) { // LUHN Formula for validation of credit card numbers.
	var ar = new Array(cardNumber.length);
	var i = 0, sum = 0;
	for (i = 0; i < cardNumber.length; ++i) {
		ar[i] = parseInt(cardNumber.charAt(i));
	}
	for (i = ar.length - 2; i >= 0; i -= 2) { // you have to start from the right, and work back.
		ar[i] *= 2; 						 // every second digit starting with the right most (check digit)
		if (ar[i] > 9) ar[i] -= 9; 		 // will be doubled, and summed with the skipped digits.
	} 									 // if the double digit is > 9, ADD those individual digits together 
	for (i = 0; i < ar.length; ++i) {
		sum += ar[i]; 					 // if the sum is divisible by 10 mod10 succeeds
	}
	return (((sum % 10) == 0) ? true : false);
}

function expired(month, year) {
	if (month == undefined || month == null || month == "" || year == undefined || year == null || year == "") return true;
	var now = new Date(); 						// this function is designed to be Y2K compliant.
	var expiresIn = new Date(20 + year, month, 0, 0, 0); 	// create an expired on date object with valid thru expiration date
	expiresIn.setMonth(expiresIn.getMonth() + 1); 	// adjust the month, to first day, hour, minute & second of expired month
	if (now.getTime() < expiresIn.getTime()) return false;
	return true; 								// then we get the miliseconds, and do a long integer comparison
}

//*********** evoCalendar
var datePickerDivID = "datepicker";
var iFrameDivID = "datepickeriframe";

var dayArrayShort = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
var dayArrayMed = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
var dayArrayLong = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
var monthArrayLong = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

var defaultDateSeparator = "/";
var defaultDateFormat = "dmy"    // valid values are "mdy", "dmy", and "ymd"
var dateSeparator = defaultDateSeparator;
var dateFormat = defaultDateFormat;

var img_Date_UP = new Image();
img_Date_UP.src = "/Pics/Design/cal.gif";

var img_Date_OVER = new Image();
img_Date_OVER.src = "/Pics/Design/cal1.gif";


function calSwapImg(img, NewSrc) {
	img.src = eval(NewSrc + ".src");
}

function displayDatePicker(dateFieldName, displayBelowThisObject, dtFormat, dtSep) {
	var targetDateField = document.getElementsByName(dateFieldName).item(0);

	if (!displayBelowThisObject)
		displayBelowThisObject = targetDateField;

	if (dtSep)
		dateSeparator = dtSep;
	else
		dateSeparator = defaultDateSeparator;

	if (dtFormat)
		dateFormat = dtFormat;
	else
		dateFormat = defaultDateFormat;

	var x = displayBelowThisObject.offsetLeft;
	var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight;

	var parent = displayBelowThisObject;
	while (parent.offsetParent) {
		parent = parent.offsetParent;
		x += parent.offsetLeft;
		y += parent.offsetTop;
	}
	drawDatePicker(targetDateField, x, y);
}

function drawDatePicker(targetDateField, x, y) {
	var dt = getFieldDate(targetDateField.value);

	if (!document.getElementById(datePickerDivID)) {

		var newNode = document.createElement("div");
		newNode.setAttribute("id", datePickerDivID);
		newNode.setAttribute("class", "dpDiv");
		newNode.setAttribute("style", "visibility: hidden;");
		document.body.appendChild(newNode);
	}

	var pickerDiv = document.getElementById(datePickerDivID);
	pickerDiv.style.position = "absolute";
	pickerDiv.style.left = x + "px";
	pickerDiv.style.top = y + "px";
	pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
	pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
	pickerDiv.style.zIndex = 10000;

	refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
}

function refreshDatePicker(dateFieldName, year, month, day) {
	var thisDay = new Date();
	var today = new Date();

	if ((month >= 0) && (year > 0)) {
		thisDay = new Date(year, month, 1);
	} else {
		day = thisDay.getDate();
		thisDay.setDate(1);
	}

	var crlf = "\r\n";
	var TABLE = "<table cols=7 class='dpTable'>" + crlf;
	var xTABLE = "</table>" + crlf;
	var TR = "<tr class='dpTR'>";
	var TR_title = "<tr class='dpTitleTR' nowrap>";
	var TR_days = "<tr class='dpDayTR'>";
	var TR_todaybutton = "<tr class='dpTodayButtonTR'>";
	var xTR = "</tr>" + crlf;
	var TD = "<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver=' this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
	var TD_title = "<td colspan=4 class='dpTitleTD' nowrap='nowrap'>";
	var TD_buttons = "<td class='dpButtonTD'>";
	var TD_todaybutton = "<td colspan=7 class='dpTodayButtonTD'>";
	var TD_days = "<td class='dpDayTD'>";
	var TD_selected = "<td class='dpDayHighlightTD' onMouseOut='this.className=\"dpDayHighlightTD\";' onMouseOver='this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
	var xTD = "</td>" + crlf;
	var DIV_title = "<div class='dpTitleText'>";
	var DIV_selected = "<div class='dpDayHighlight'>";
	var xDIV = "</div>";

	var html = TABLE;
	html += TR_title;
	html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "&laquo;") + xTD;
	html += TD_title;
	html += "<SELECT class='cal-TextBox' NAME='cboMonth' onChange='refreshDatePicker(\"" + dateFieldName + "\", " + thisDay.getFullYear() + ", this.value);'>"
	for (m = 0; m < 12; m++) {
		if (m == month) html += "<OPTION VALUE='" + m + "' SELECTED>" + monthArrayMed[m] + "<\/OPTION>";
		else html += '<OPTION VALUE="' + m + '">' + monthArrayMed[m] + '<\/OPTION>';
	}
	html += "<\/SELECT>"
	html += "<SELECT class='cal-TextBox' NAME='cboYear' onChange='refreshDatePicker(\"" + dateFieldName + "\", this.value," + thisDay.getMonth() + ");'>"
	for (y = 1900; y < today.getFullYear() + 21; y++) {
		if (y == year) html += "<OPTION VALUE='" + y + "' SELECTED>" + y + "<\/OPTION>";
		else html += "<OPTION VALUE='" + y + "'>" + y + "<\/OPTION>";
	}
	html += "<\/SELECT>"
	html += xTD;
	html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, "&raquo;");
	html += xTD + "<TD>";
	html += "<img src='/Pics/Design/btn_close_small.gif' border='0' width='12' height='10' onClick='updateDateField(\"" + dateFieldName + "\");'/>";
	html += xTD + xTR;

	html += TR_days;
	for (i = 0; i < dayArrayShort.length; i++)
		html += TD_days + dayArrayShort[i] + xTD;
	html += xTR;

	html += TR;
	for (i = 0; i < thisDay.getDay(); i++)
		html += TD + "&nbsp;" + xTD;
	do {
		dayNum = thisDay.getDate();
		TD_onclick = " onclick=\"updateDateField('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";

		if (dayNum == day)
			html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
		else
			html += TD + TD_onclick + dayNum + xTD;

		if (thisDay.getDay() == 6)
			html += xTR + TR;

		thisDay.setDate(thisDay.getDate() + 1);
	} while (thisDay.getDate() > 1)

	if (thisDay.getDay() > 0) {
		for (i = 6; i > thisDay.getDay(); i--)
			html += TD + "&nbsp;" + xTD;
	}
	html += xTR;

	var todayString = "Today is " + dayArrayMed[today.getDay()] + ", " + monthArrayMed[today.getMonth()] + " " + today.getDate();
	html += TR_todaybutton + TD_todaybutton;
	html += "<button class='dpTodayButton' onClick='refreshDatePicker(\"" + dateFieldName + "\"," + today.getFullYear() + "," + today.getMonth() + ");'>Today</button> ";
	html += xTD + xTR;

	html += xTABLE;

	document.getElementById(datePickerDivID).innerHTML = html;

	adjustiFrame();
}


function getButtonCode(dateFieldName, dateVal, adjust, label) {
	var newMonth = (dateVal.getMonth() + adjust) % 12;
	var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
	if (newMonth < 0) {
		newMonth += 12;
		newYear += -1;
	}

	return "<div class='dpButton' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</div>";
}

function getDateString(dateVal) {
	var dayString = "00" + dateVal.getDate();
	var monthString = "00" + (dateVal.getMonth() + 1);
	dayString = dayString.substring(dayString.length - 2);
	monthString = monthString.substring(monthString.length - 2);

	switch (dateFormat) {
		case "dmy":
			return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
		case "ymd":
			return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
		case "mdy":
		default:
			return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
	}
}

function getFieldDate(dateString) {
	var dateVal;
	var dArray;
	var d, m, y;

	try {
		dArray = splitDateString(dateString);
		if (dArray) {
			switch (dateFormat) {
				case "dmy":
					d = parseInt(dArray[0], 10);
					m = parseInt(dArray[1], 10) - 1;
					y = parseInt(dArray[2], 10);
					break;
				case "ymd":
					d = parseInt(dArray[2], 10);
					m = parseInt(dArray[1], 10) - 1;
					y = parseInt(dArray[0], 10);
					break;
				case "mdy":
				default:
					d = parseInt(dArray[1], 10);
					m = parseInt(dArray[0], 10) - 1;
					y = parseInt(dArray[2], 10);
					break;
			}
			dateVal = new Date(y, m, d);
		} else if (dateString) {
			dateVal = new Date(dateString);
		} else {
			dateVal = new Date();
		}
	} catch (e) {
		dateVal = new Date();
	}

	return dateVal;
}

function splitDateString(dateString) {
	var dArray;
	if (dateString.indexOf("/") >= 0)
		dArray = dateString.split("/");
	else if (dateString.indexOf(".") >= 0)
		dArray = dateString.split(".");
	else if (dateString.indexOf("-") >= 0)
		dArray = dateString.split("-");
	else if (dateString.indexOf("\\") >= 0)
		dArray = dateString.split("\\");
	else
		dArray = false;

	return dArray;
}

function updateDateField(dateFieldName, dateString) {
	var targetDateField = document.getElementsByName(dateFieldName).item(0);
	if (dateString)
		targetDateField.value = dateString;

	var pickerDiv = document.getElementById(datePickerDivID);
	pickerDiv.style.visibility = "hidden";
	pickerDiv.style.display = "none";

	adjustiFrame();
	targetDateField.focus();

	if ((dateString) && (typeof (datePickerClosed) == "function"))
		datePickerClosed(targetDateField);

	if (targetDateField.onchange)
		targetDateField.onchange();
}

function adjustiFrame(pickerDiv, iFrameDiv) {
	var is_opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
	if (is_opera)
		return;

	try {
		if (!document.getElementById(iFrameDivID)) {
			var newNode = document.createElement("iFrame");
			newNode.setAttribute("id", iFrameDivID);
			newNode.setAttribute("src", "javascript:false;");
			newNode.setAttribute("scrolling", "no");
			newNode.setAttribute("frameborder", "0");
			document.body.appendChild(newNode);
		}

		if (!pickerDiv)
			pickerDiv = document.getElementById(datePickerDivID);
		if (!iFrameDiv)
			iFrameDiv = document.getElementById(iFrameDivID);

		try {
			iFrameDiv.style.position = "absolute";
			iFrameDiv.style.width = pickerDiv.offsetWidth;
			iFrameDiv.style.height = pickerDiv.offsetHeight;
			iFrameDiv.style.top = pickerDiv.style.top;
			iFrameDiv.style.left = pickerDiv.style.left;
			iFrameDiv.style.zIndex = pickerDiv.style.zIndex - 1;
			iFrameDiv.style.visibility = pickerDiv.style.visibility;
			iFrameDiv.style.display = pickerDiv.style.display;
		} catch (e) {
		}

	} catch (ee) {
	}

}

// format a number
function formatNumber(number, decimals, decimalSeparator, groupSeparator) {
	number = number.toString();
	var k = '';
	if (number.indexOf('-') == 0) {
		k = '-';
		number = number * -1;
	}
	number = Math.round(number * Math.pow(10, decimals)) / Math.pow(10, decimals);
	var e = number + '';
	var f = e.split('.');
	if (!f[0]) f[0] = '0';
	if (!f[1]) f[1] = '';
	if (f[1].length < decimals) {
		var g = f[1];
		for (var i = f[1].length + 1; i <= decimals; i++) {
			g += '0';
		}
		f[1] = g;
	}

	if (groupSeparator != '' && f[0].length > 3) {
		var h = f[0];
		f[0] = '';
		for (var j = 3; j < h.length; j += 3) {
			i = h.slice(h.length - j, h.length - j + 3);
			f[0] = groupSeparator + i + f[0] + '';
		}
		j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
		f[0] = j + f[0];
	}
	decimalSeparator = (decimals <= 0) ? '' : decimalSeparator;

	return k + f[0] + decimalSeparator + f[1];
}

// format a number based on the currency
function formatCurr(number, currencyCode, decimals) {
	var toCheck = "";

	if (decimals != undefined && decimals != null) {
		decimals = parseInt(decimals);
	}
	else {
		decimals = 2;
	}

	if (currencyCode) toCheck = currencyCode.toUpperCase();
	switch (toCheck) {
		case "NZD":
		case "AUD":
		case "USD":
		case "CAD":
		case "HKD":
			return "$" + formatNumber(number, decimals, ".", ",");
			break;
		case "CNY":
		case "JPY":
			return "&#165;" + formatNumber(number, decimals, ".", ",");
			break;
		case "KPW":
		case "KRW":
			return "&#8361;" + formatNumber(number, decimals, ".", ",");
			break;
		case "SAR":
			return "&#65020;" + formatNumber(number, decimals, ".", ",");
			break;
		case "THB":
			return "&#3647;" + formatNumber(number, decimals, ".", ",");
			break;
		case "EUR":
			return "&#8364;" + formatNumber(number, decimals, ",", ".");
			break;
		case "GBP":
			return "&#163;" + formatNumber(number, decimals, ".", ",");
			break;
		case "ZAR":
			return "R" + formatNumber(number, decimals, ".", ",");
			break;
		case "ZWD":
			return "Z$" + formatNumber(number, decimals, ".", ",");
			break;
		default:
			return formatNumber(number, decimals, ".", ",");
			break;
	}
}
