/* NEXT FILE : D:\WWWSource\Site\js\dnncore.js************************************************************/
//General
//for example: instead of each module writing out script found in moduleMaxMin_OnClick have the functionality cached
//

var DNN_COL_DELIMITER = String.fromCharCode(16);
var DNN_ROW_DELIMITER = String.fromCharCode(15);
var __dnn_m_bPageLoaded = false;

window.onload = __dnn_Page_OnLoad;

function __dnn_ClientAPIEnabled()
{
	return typeof(dnn) != 'undefined';
}


function __dnn_Page_OnLoad()
{
	if (__dnn_ClientAPIEnabled())
	{
		var sLoadHandlers = dnn.getVar('__dnn_pageload');
		if (sLoadHandlers != null)
			eval(sLoadHandlers);
		
		dnn.dom.attachEvent(window, 'onscroll', __dnn_bodyscroll);
	}
	__dnn_m_bPageLoaded = true;
}

function __dnn_KeyDown(iKeyCode, sFunc, e)
{
	if (e == null)
		e = window.event;

	if (e.keyCode == iKeyCode)
	{
		eval(unescape(sFunc));
		return false;
	}
}

function __dnn_bodyscroll() 
{
	var oF=document.forms[0];
	if (__dnn_ClientAPIEnabled() && __dnn_m_bPageLoaded) {
	    var e = document.getElementById("ScrollTop");
	    if (e) {
	        e.value = document.documentElement.scrollTop ? document.documentElement.scrollTop : dnn.dom.getByTagName("body")[0].scrollTop;
	    }
	}
}

function __dnn_setScrollTop(iTop)
{
	if (__dnn_ClientAPIEnabled())
	{
		if (iTop == null)
			iTop = document.getElementById("ScrollTop").value.value;
	
		var sID = dnn.getVar('ScrollToControl');
		if (sID != null && sID.length > 0)
		{
			var oCtl = dnn.dom.getById(sID);
			if (oCtl != null)
			{
				iTop = dnn.dom.positioning.elementTop(oCtl);
				dnn.setVar('ScrollToControl', '');
			}
		}
		window.scrollTo(0, iTop);
	}
}

//Focus logic
function __dnn_SetInitialFocus(sID)
{
	var oCtl = dnn.dom.getById(sID);	
	if (oCtl != null && __dnn_CanReceiveFocus(oCtl))
		oCtl.focus();
}	

function __dnn_CanReceiveFocus(e)
{
	//probably should call getComputedStyle for classes that cause item to be hidden
	if (e.style.display != 'none' && e.tabIndex > -1 && e.disabled == false && e.style.visible != 'hidden')
	{
		var eParent = e.parentElement;
		while (eParent != null && eParent.tagName != 'BODY')
		{
			if (eParent.style.display == 'none' || eParent.disabled || eParent.style.visible == 'hidden')
				return false;
			eParent = eParent.parentElement;
		}
		return true;
	}
	else
		return false;
}

//Max/Min Script
function __dnn_ContainerMaxMin_OnClick(oLnk, sContentID)
{
	var oContent = dnn.dom.getById(sContentID);
	if (oContent != null)
	{
		var oBtn = oLnk.childNodes[0];
		var sContainerID = oLnk.getAttribute('containerid');
		var sCookieID = oLnk.getAttribute('cookieid');
		var sCurrentFile = oBtn.src.toLowerCase().substr(oBtn.src.lastIndexOf('/'));
		var sMaxFile;
		var sMaxIcon;
		var sMinIcon;

		if (dnn.getVar('min_icon_' + sContainerID))
			sMinIcon = dnn.getVar('min_icon_' + sContainerID);
		else
			sMinIcon = dnn.getVar('min_icon');

		if (dnn.getVar('max_icon_' + sContainerID))
			sMaxIcon = dnn.getVar('max_icon_' + sContainerID);
		else
			sMaxIcon = dnn.getVar('max_icon');

		sMaxFile = sMaxIcon.toLowerCase().substr(sMaxIcon.lastIndexOf('/'));

		var iNum = 5;
		if (oLnk.getAttribute('animf') != null)
			iNum = new Number(oLnk.getAttribute('animf'));
			
		if (sCurrentFile == sMaxFile)
		{
			oBtn.src = sMinIcon;				
			//oContent.style.display = '';
			dnn.dom.expandElement(oContent, iNum);
			oBtn.title = dnn.getVar('min_text');
			if (sCookieID != null)
			{
				if (dnn.getVar('__dnn_' + sContainerID + ':defminimized') == 'true')
					dnn.dom.setCookie(sCookieID, 'true', 365);
				else
					dnn.dom.deleteCookie(sCookieID);
			}
			else
				dnn.setVar('__dnn_' + sContainerID + '_Visible', 'true');
		}
		else
		{
			oBtn.src = sMaxIcon;				
			//oContent.style.display = 'none';
			dnn.dom.collapseElement(oContent, iNum);
			oBtn.title = dnn.getVar('max_text');
			if (sCookieID != null)
			{
				if (dnn.getVar('__dnn_' + sContainerID + ':defminimized') == 'true')
					dnn.dom.deleteCookie(sCookieID);
				else
					dnn.dom.setCookie(sCookieID, 'false', 365);				
			}
			else
				dnn.setVar('__dnn_' + sContainerID + '_Visible', 'false');			
		}
		
		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

function __dnn_Help_OnClick(sHelpID)
{
	var oHelp = dnn.dom.getById(sHelpID);
	if (oHelp != null)
	{
		if (oHelp.style.display == 'none')
			oHelp.style.display = '';
		else
			oHelp.style.display = 'none';

		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

function __dnn_SectionMaxMin(oBtn, sContentID)
{
	var oContent = dnn.dom.getById(sContentID);
	if (oContent != null)
	{
		var sMaxIcon = oBtn.getAttribute('max_icon');
		var sMinIcon = oBtn.getAttribute('min_icon');
		var bCallback = oBtn.getAttribute('userctr') != null;
		var sVal;
		if (oContent.style.display == 'none')
		{
			oBtn.src = sMinIcon;				
			oContent.style.display = '';
			if (bCallback)
			    sVal = 'True';
			else
			    dnn.setVar(oBtn.id + ':exp', 1);
		}
		else
		{
			oBtn.src = sMaxIcon;				
			oContent.style.display = 'none';
			if (bCallback)
			    sVal = 'False';
			else
                dnn.setVar(oBtn.id + ':exp', 0);
		}
		if (bCallback)
		    dnncore.setUserProp(oBtn.getAttribute('userctr'), oBtn.getAttribute('userkey'), sVal, null);
		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

//Drag N Drop
function __dnn_enableDragDrop()
{
	var aryConts = dnn.getVar('__dnn_dragDrop').split(";");	
	var aryTitles;

	for (var i=0; i < aryConts.length; i++)
	{
		aryTitles = aryConts[i].split(" ");
		if (aryTitles[0].length > 0)
		{			
			var oCtr = dnn.dom.getById(aryTitles[0]);
			var oTitle = dnn.dom.getById(aryTitles[1]);
			if (oCtr != null && oTitle != null)
			{
				oCtr.setAttribute('moduleid', aryTitles[2]);
				dnn.dom.positioning.enableDragAndDrop(oCtr, oTitle, '__dnn_dragComplete()', '__dnn_dragOver()');
			}	
		}
	}
}

var __dnn_oPrevSelPane;
var __dnn_oPrevSelModule;
var __dnn_dragEventCount=0;
function __dnn_dragOver()
{
	__dnn_dragEventCount++;
	if (__dnn_dragEventCount % 75 != 0)	//only calculate position every 75 events
		return;
	
	var oCont = dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);

	var oPane = __dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);
		
	if (__dnn_oPrevSelPane != null)	//reset previous pane's border
		__dnn_oPrevSelPane.pane.style.border = __dnn_oPrevSelPane.origBorder;

	if (oPane != null)
	{		
		__dnn_oPrevSelPane = oPane;
		oPane.pane.style.border = '4px double ' + DNN_HIGHLIGHT_COLOR;
		var iIndex = __dnn_getPaneControlIndex(oCont, oPane);

		var oPrevCtl;
		var oNextCtl;
		for (var i=0; i<oPane.controls.length; i++)
		{
			if (iIndex > i && oPane.controls[i].id != oCont.id)
				oPrevCtl = oPane.controls[i];
			if (iIndex <= i && oPane.controls[i].id != oCont.id)
			{
				oNextCtl = oPane.controls[i];
				break;
			}
		}			
		
		if (__dnn_oPrevSelModule != null)
			dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border = __dnn_oPrevSelModule.origBorder;
			

		if (oNextCtl != null)
		{
			__dnn_oPrevSelModule = oNextCtl;
			dnn.dom.getNonTextNode(oNextCtl.control).style.borderTop = '5px groove ' + DNN_HIGHLIGHT_COLOR;
		}
		else if (oPrevCtl != null)
		{
			__dnn_oPrevSelModule = oPrevCtl;
			dnn.dom.getNonTextNode(oPrevCtl.control).style.borderBottom = '5px groove ' + DNN_HIGHLIGHT_COLOR;
		}
	}
}

function __dnn_dragComplete()
{
	var oCtl = dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);
	var sModuleID = oCtl.getAttribute('moduleid');
	
	if (__dnn_oPrevSelPane != null)
		__dnn_oPrevSelPane.pane.style.border = __dnn_oPrevSelPane.origBorder;

	if (__dnn_oPrevSelModule != null)
		dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border = __dnn_oPrevSelModule.origBorder;
		
	var oPane = __dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);
	var iIndex;
	if (oPane == null)
	{
		var oPanes = __dnn_Panes();
		for (var i=0; i<oPanes.length; i++)
		{
			if (oPanes[i].id == oCtl.parentNode.id)
				oPane = oPanes[i];
		}
	}	
	if (oPane != null)
	{
		iIndex = __dnn_getPaneControlIndex(oCtl, oPane);
		__dnn_MoveToPane(oPane, oCtl, iIndex);

		dnn.callPostBack('MoveToPane', 'moduleid=' + sModuleID, 'pane=' + oPane.paneName, 'order=' + iIndex * 2); 
	}
}

function __dnn_MoveToPane(oPane, oCtl, iIndex)
{

	if (oPane != null)
	{
		var aryCtls = new Array();
		for (var i=iIndex; i<oPane.controls.length; i++)
		{
			if (oPane.controls[i].control.id != oCtl.id)
				aryCtls[aryCtls.length] = oPane.controls[i].control;

			dnn.dom.removeChild(oPane.controls[i].control);
		}
		dnn.dom.appendChild(oPane.pane, oCtl);
		oCtl.style.top=0;
		oCtl.style.left=0;
		oCtl.style.position = 'relative';
		for (var i=0; i<aryCtls.length; i++)
		{
			dnn.dom.appendChild(oPane.pane, aryCtls[i]);
		}
		__dnn_RefreshPanes();
	}
	else
	{
		oCtl.style.top=0;
		oCtl.style.left=0;
		oCtl.style.position = 'relative';
	}
}

function __dnn_RefreshPanes()
{
	var aryPanes = dnn.getVar('__dnn_Panes').split(';');
	var aryPaneNames = dnn.getVar('__dnn_PaneNames').split(';');
	__dnn_m_aryPanes = new Array();
	for (var i=0; i<aryPanes.length; i++)
	{
		if (aryPanes[i].length > 0)
			__dnn_m_aryPanes[__dnn_m_aryPanes.length] = new __dnn_Pane(dnn.dom.getById(aryPanes[i]), aryPaneNames[i]);
	}
}

var __dnn_m_aryPanes;
var __dnn_m_aryModules;
function __dnn_Panes()
{
	if (__dnn_m_aryPanes == null)
	{
		__dnn_m_aryPanes = new Array();
		__dnn_RefreshPanes();
	}
	return __dnn_m_aryPanes;
}

function __dnn_Modules(sModuleID)
{
	if (__dnn_m_aryModules == null)
		__dnn_RefreshPanes();
	
	return __dnn_m_aryModules[sModuleID];
}

function __dnn_getMostSelectedPane(oContent)
{
	var oCDims = new dnn.dom.positioning.dims(oContent);
	var iTopScore=0;
	var iScore;
	var oTopPane;
	for (var i=0; i<__dnn_Panes().length; i++)
	{
		var oPane = __dnn_Panes()[i];
		var oPDims = new dnn.dom.positioning.dims(oPane.pane);
		iScore = dnn.dom.positioning.elementOverlapScore(oPDims, oCDims);
		
		if (iScore > iTopScore)
		{
			iTopScore = iScore;
			oTopPane = oPane;
		}
	}
	return oTopPane;
}

function __dnn_getPaneControlIndex(oContent, oPane)
{
	if (oPane == null)
		return;
	var oCDims = new dnn.dom.positioning.dims(oContent);
	var oCtl;
	if (oPane.controls.length == 0)
		return 0;
	for (var i=0; i<oPane.controls.length; i++)
	{
		oCtl = oPane.controls[i];
		var oIDims = new dnn.dom.positioning.dims(oCtl.control);
		if (oCDims.t < oIDims.t)
			return oCtl.index;
	}
	if (oCtl != null)
		return oCtl.index+1;
	else
		return 0;
}

//Objects
function __dnn_Pane(ctl, sPaneName)
{
	this.pane = ctl;
	this.id = ctl.id;
	this.controls = new Array();
	this.origBorder = ctl.style.border;
	this.paneName = sPaneName;
	
	var iIndex = 0;
	var strModuleOrder='';
	for (var i=0; i<ctl.childNodes.length; i++)
	{
		var oNode = ctl.childNodes[i];
		if (dnn.dom.isNonTextNode(oNode))	
		{
			if (__dnn_m_aryModules == null)
				__dnn_m_aryModules = new Array();

			//if (oNode.tagName == 'A' && oNode.childNodes.length > 0)
			//	oNode = oNode.childNodes[0];	//DNN now embeds anchor tag 
				
			var sModuleID = oNode.getAttribute('moduleid');
			if (sModuleID != null && sModuleID.length > 0)
			{
				strModuleOrder += sModuleID + '~';
				this.controls[this.controls.length] = new __dnn_PaneControl(oNode, iIndex);
				__dnn_m_aryModules[sModuleID] = oNode.id;
				iIndex+=1;
			}
		}
	}
	this.moduleOrder = strModuleOrder;

}

function __dnn_PaneControl(ctl, iIndex)
{
	this.control = ctl;
	this.id = ctl.id;
	this.index = iIndex;
	this.origBorder = ctl.style.border;
	
}

//move towards dnncore ns.  right now only for personalization
function __dnncore()
{
    this.GetUserVal = 0;
    this.SetUserVal = 1;
}

__dnncore.prototype = {
getUserProp: function(sNameCtr, sKey, pFunc) {
    this._doUserCallBack(dnncore.GetUserVal, sNameCtr, sKey, null, new dnncore.UserPropArgs(sNameCtr, sKey, pFunc));
},

setUserProp: function(sNameCtr, sKey, sVal, pFunc) {
    this._doUserCallBack(dnncore.SetUserVal, sNameCtr, sKey, sVal, new dnncore.UserPropArgs(sNameCtr, sKey, pFunc));
},

_doUserCallBack: function(iType, sNameCtr, sKey, sVal, pFunc) {
    if (dnn && dnn.xmlhttp)
    {
        var sPack = iType + COL_DELIMITER + sNameCtr + COL_DELIMITER + sKey + COL_DELIMITER + sVal;
        dnn.xmlhttp.doCallBack('__Page',sPack,dnncore._callBackSuccess,pFunc,dnncore._callBackFail,null,true,null,0);
    }
    else
        alert('Client Personalization not enabled');
},

_callBackSuccess: function (result, ctx, req) {
    if (ctx.pFunc)
        ctx.pFunc(ctx.namingCtr, ctx.key, result);
},

_callBackFail: function (result, ctx) {
	window.status = result;
}
}

__dnncore.prototype.UserPropArgs = function(sNameCtr, sKey, pFunc)
{
    this.namingCtr = sNameCtr;
	this.key = sKey;
	this.pFunc = pFunc;
}

var dnncore = new __dnncore();

/* NEXT FILE : D:\WWWSource\Site\App_Scripts\jQuery\jQuery-1.2.3.js************************************************************/
(function(){
/*
 * jQuery 1.2.3 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008-02-06 00:21:25 -0500 (Wed, 06 Feb 2008) $
 * $Rev: 4663 $
 */

// Map over jQuery in case of overwrite
if ( window.jQuery )
	var _jQuery = window.jQuery;

var jQuery = window.jQuery = function( selector, context ) {
	// The jQuery object is actually just the init constructor 'enhanced'
	return new jQuery.prototype.init( selector, context );
};

// Map over the $ in case of overwrite
if ( window.$ )
	var _$ = window.$;
	
// Map the jQuery namespace to the '$' one
window.$ = jQuery;

// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;

// Is it a simple selector
var isSimple = /^.[^:#\[\.]*$/;

jQuery.fn = jQuery.prototype = {
	init: function( selector, context ) {
		// Make sure that a selection was provided
		selector = selector || document;

		// Handle $(DOMElement)
		if ( selector.nodeType ) {
			this[0] = selector;
			this.length = 1;
			return this;

		// Handle HTML strings
		} else if ( typeof selector == "string" ) {
			// Are we dealing with HTML string or an ID?
			var match = quickExpr.exec( selector );

			// Verify a match, and that no context was specified for #id
			if ( match && (match[1] || !context) ) {

				// HANDLE: $(html) -> $(array)
				if ( match[1] )
					selector = jQuery.clean( [ match[1] ], context );

				// HANDLE: $("#id")
				else {
					var elem = document.getElementById( match[3] );

					// Make sure an element was located
					if ( elem )
						// Handle the case where IE and Opera return items
						// by name instead of ID
						if ( elem.id != match[3] )
							return jQuery().find( selector );

						// Otherwise, we inject the element directly into the jQuery object
						else {
							this[0] = elem;
							this.length = 1;
							return this;
						}

					else
						selector = [];
				}

			// HANDLE: $(expr, [context])
			// (which is just equivalent to: $(content).find(expr)
			} else
				return new jQuery( context ).find( selector );

		// HANDLE: $(function)
		// Shortcut for document ready
		} else if ( jQuery.isFunction( selector ) )
			return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );

		return this.setArray(
			// HANDLE: $(array)
			selector.constructor == Array && selector ||

			// HANDLE: $(arraylike)
			// Watch for when an array-like object, contains DOM nodes, is passed in as the selector
			(selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||

			// HANDLE: $(*)
			[ selector ] );
	},
	
	// The current version of jQuery being used
	jquery: "1.2.3",

	// The number of elements contained in the matched element set
	size: function() {
		return this.length;
	},
	
	// The number of elements contained in the matched element set
	length: 0,

	// Get the Nth element in the matched element set OR
	// Get the whole matched element set as a clean array
	get: function( num ) {
		return num == undefined ?

			// Return a 'clean' array
			jQuery.makeArray( this ) :

			// Return just the object
			this[ num ];
	},
	
	// Take an array of elements and push it onto the stack
	// (returning the new matched element set)
	pushStack: function( elems ) {
		// Build a new jQuery matched element set
		var ret = jQuery( elems );

		// Add the old object onto the stack (as a reference)
		ret.prevObject = this;

		// Return the newly-formed element set
		return ret;
	},
	
	// Force the current matched set of elements to become
	// the specified array of elements (destroying the stack in the process)
	// You should use pushStack() in order to do this, but maintain the stack
	setArray: function( elems ) {
		// Resetting the length to 0, then using the native Array push
		// is a super-fast way to populate an object with array-like properties
		this.length = 0;
		Array.prototype.push.apply( this, elems );
		
		return this;
	},

	// Execute a callback for every element in the matched set.
	// (You can seed the arguments with an array of args, but this is
	// only used internally.)
	each: function( callback, args ) {
		return jQuery.each( this, callback, args );
	},

	// Determine the position of an element within 
	// the matched set of elements
	index: function( elem ) {
		var ret = -1;

		// Locate the position of the desired element
		this.each(function(i){
			if ( this == elem )
				ret = i;
		});

		return ret;
	},

	attr: function( name, value, type ) {
		var options = name;
		
		// Look for the case where we're accessing a style value
		if ( name.constructor == String )
			if ( value == undefined )
				return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined;

			else {
				options = {};
				options[ name ] = value;
			}
		
		// Check to see if we're setting style values
		return this.each(function(i){
			// Set all the styles
			for ( name in options )
				jQuery.attr(
					type ?
						this.style :
						this,
					name, jQuery.prop( this, options[ name ], type, i, name )
				);
		});
	},

	css: function( key, value ) {
		// ignore negative width and height values
		if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
			value = undefined;
		return this.attr( key, value, "curCSS" );
	},

	text: function( text ) {
		if ( typeof text != "object" && text != null )
			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );

		var ret = "";

		jQuery.each( text || this, function(){
			jQuery.each( this.childNodes, function(){
				if ( this.nodeType != 8 )
					ret += this.nodeType != 1 ?
						this.nodeValue :
						jQuery.fn.text( [ this ] );
			});
		});

		return ret;
	},

	wrapAll: function( html ) {
		if ( this[0] )
			// The elements to wrap the target around
			jQuery( html, this[0].ownerDocument )
				.clone()
				.insertBefore( this[0] )
				.map(function(){
					var elem = this;

					while ( elem.firstChild )
						elem = elem.firstChild;

					return elem;
				})
				.append(this);

		return this;
	},

	wrapInner: function( html ) {
		return this.each(function(){
			jQuery( this ).contents().wrapAll( html );
		});
	},

	wrap: function( html ) {
		return this.each(function(){
			jQuery( this ).wrapAll( html );
		});
	},

	append: function() {
		return this.domManip(arguments, true, false, function(elem){
			if (this.nodeType == 1)
				this.appendChild( elem );
		});
	},

	prepend: function() {
		return this.domManip(arguments, true, true, function(elem){
			if (this.nodeType == 1)
				this.insertBefore( elem, this.firstChild );
		});
	},
	
	before: function() {
		return this.domManip(arguments, false, false, function(elem){
			this.parentNode.insertBefore( elem, this );
		});
	},

	after: function() {
		return this.domManip(arguments, false, true, function(elem){
			this.parentNode.insertBefore( elem, this.nextSibling );
		});
	},

	end: function() {
		return this.prevObject || jQuery( [] );
	},

	find: function( selector ) {
		var elems = jQuery.map(this, function(elem){
			return jQuery.find( selector, elem );
		});

		return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
			jQuery.unique( elems ) :
			elems );
	},

	clone: function( events ) {
		// Do the clone
		var ret = this.map(function(){
			if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
				// IE copies events bound via attachEvent when
				// using cloneNode. Calling detachEvent on the
				// clone will also remove the events from the orignal
				// In order to get around this, we use innerHTML.
				// Unfortunately, this means some modifications to 
				// attributes in IE that are actually only stored 
				// as properties will not be copied (such as the
				// the name attribute on an input).
				var clone = this.cloneNode(true),
					container = document.createElement("div");
				container.appendChild(clone);
				return jQuery.clean([container.innerHTML])[0];
			} else
				return this.cloneNode(true);
		});

		// Need to set the expando to null on the cloned set if it exists
		// removeData doesn't work here, IE removes it from the original as well
		// this is primarily for IE but the data expando shouldn't be copied over in any browser
		var clone = ret.find("*").andSelf().each(function(){
			if ( this[ expando ] != undefined )
				this[ expando ] = null;
		});
		
		// Copy the events from the original to the clone
		if ( events === true )
			this.find("*").andSelf().each(function(i){
				if (this.nodeType == 3)
					return;
				var events = jQuery.data( this, "events" );

				for ( var type in events )
					for ( var handler in events[ type ] )
						jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
			});

		// Return the cloned set
		return ret;
	},

	filter: function( selector ) {
		return this.pushStack(
			jQuery.isFunction( selector ) &&
			jQuery.grep(this, function(elem, i){
				return selector.call( elem, i );
			}) ||

			jQuery.multiFilter( selector, this ) );
	},

	not: function( selector ) {
		if ( selector.constructor == String )
			// test special case where just one selector is passed in
			if ( isSimple.test( selector ) )
				return this.pushStack( jQuery.multiFilter( selector, this, true ) );
			else
				selector = jQuery.multiFilter( selector, this );

		var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
		return this.filter(function() {
			return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
		});
	},

	add: function( selector ) {
		return !selector ? this : this.pushStack( jQuery.merge( 
			this.get(),
			selector.constructor == String ? 
				jQuery( selector ).get() :
				selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ?
					selector : [selector] ) );
	},

	is: function( selector ) {
		return selector ?
			jQuery.multiFilter( selector, this ).length > 0 :
			false;
	},

	hasClass: function( selector ) {
		return this.is( "." + selector );
	},
	
	val: function( value ) {
		if ( value == undefined ) {

			if ( this.length ) {
				var elem = this[0];

				// We need to handle select boxes special
				if ( jQuery.nodeName( elem, "select" ) ) {
					var index = elem.selectedIndex,
						values = [],
						options = elem.options,
						one = elem.type == "select-one";
					
					// Nothing was selected
					if ( index < 0 )
						return null;

					// Loop through all the selected options
					for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
						var option = options[ i ];

						if ( option.selected ) {
							// Get the specifc value for the option
							value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
							
							// We don't need an array for one selects
							if ( one )
								return value;
							
							// Multi-Selects return an array
							values.push( value );
						}
					}
					
					return values;
					
				// Everything else, we just grab the value
				} else
					return (this[0].value || "").replace(/\r/g, "");

			}

			return undefined;
		}

		return this.each(function(){
			if ( this.nodeType != 1 )
				return;

			if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
				this.checked = (jQuery.inArray(this.value, value) >= 0 ||
					jQuery.inArray(this.name, value) >= 0);

			else if ( jQuery.nodeName( this, "select" ) ) {
				var values = value.constructor == Array ?
					value :
					[ value ];

				jQuery( "option", this ).each(function(){
					this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
						jQuery.inArray( this.text, values ) >= 0);
				});

				if ( !values.length )
					this.selectedIndex = -1;

			} else
				this.value = value;
		});
	},
	
	html: function( value ) {
		return value == undefined ?
			(this.length ?
				this[0].innerHTML :
				null) :
			this.empty().append( value );
	},

	replaceWith: function( value ) {
		return this.after( value ).remove();
	},

	eq: function( i ) {
		return this.slice( i, i + 1 );
	},

	slice: function() {
		return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
	},

	map: function( callback ) {
		return this.pushStack( jQuery.map(this, function(elem, i){
			return callback.call( elem, i, elem );
		}));
	},

	andSelf: function() {
		return this.add( this.prevObject );
	},

	data: function( key, value ){
		var parts = key.split(".");
		parts[1] = parts[1] ? "." + parts[1] : "";

		if ( value == null ) {
			var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
			
			if ( data == undefined && this.length )
				data = jQuery.data( this[0], key );

			return data == null && parts[1] ?
				this.data( parts[0] ) :
				data;
		} else
			return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
				jQuery.data( this, key, value );
			});
	},

	removeData: function( key ){
		return this.each(function(){
			jQuery.removeData( this, key );
		});
	},
	
	domManip: function( args, table, reverse, callback ) {
		var clone = this.length > 1, elems; 

		return this.each(function(){
			if ( !elems ) {
				elems = jQuery.clean( args, this.ownerDocument );

				if ( reverse )
					elems.reverse();
			}

			var obj = this;

			if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
				obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );

			var scripts = jQuery( [] );

			jQuery.each(elems, function(){
				var elem = clone ?
					jQuery( this ).clone( true )[0] :
					this;

				// execute all scripts after the elements have been injected
				if ( jQuery.nodeName( elem, "script" ) ) {
					scripts = scripts.add( elem );
				} else {
					// Remove any inner scripts for later evaluation
					if ( elem.nodeType == 1 )
						scripts = scripts.add( jQuery( "script", elem ).remove() );

					// Inject the elements into the document
					callback.call( obj, elem );
				}
			});

			scripts.each( evalScript );
		});
	}
};

// Give the init function the jQuery prototype for later instantiation
jQuery.prototype.init.prototype = jQuery.prototype;

function evalScript( i, elem ) {
	if ( elem.src )
		jQuery.ajax({
			url: elem.src,
			async: false,
			dataType: "script"
		});

	else
		jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );

	if ( elem.parentNode )
		elem.parentNode.removeChild( elem );
}

jQuery.extend = jQuery.fn.extend = function() {
	// copy reference to target object
	var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;

	// Handle a deep copy situation
	if ( target.constructor == Boolean ) {
		deep = target;
		target = arguments[1] || {};
		// skip the boolean and the target
		i = 2;
	}

	// Handle case when target is a string or something (possible in deep copy)
	if ( typeof target != "object" && typeof target != "function" )
		target = {};

	// extend jQuery itself if only one argument is passed
	if ( length == 1 ) {
		target = this;
		i = 0;
	}

	for ( ; i < length; i++ )
		// Only deal with non-null/undefined values
		if ( (options = arguments[ i ]) != null )
			// Extend the base object
			for ( var name in options ) {
				// Prevent never-ending loop
				if ( target === options[ name ] )
					continue;

				// Recurse if we're merging object values
				if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
					target[ name ] = jQuery.extend( target[ name ], options[ name ] );

				// Don't bring in undefined values
				else if ( options[ name ] != undefined )
					target[ name ] = options[ name ];

			}

	// Return the modified object
	return target;
};

var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};

// exclude the following css properties to add px
var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;

jQuery.extend({
	noConflict: function( deep ) {
		window.$ = _$;

		if ( deep )
			window.jQuery = _jQuery;

		return jQuery;
	},

	// See test/unit/core.js for details concerning this function.
	isFunction: function( fn ) {
		return !!fn && typeof fn != "string" && !fn.nodeName && 
			fn.constructor != Array && /function/i.test( fn + "" );
	},
	
	// check if an element is in a (or is an) XML document
	isXMLDoc: function( elem ) {
		return elem.documentElement && !elem.body ||
			elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
	},

	// Evalulates a script in a global context
	globalEval: function( data ) {
		data = jQuery.trim( data );

		if ( data ) {
			// Inspired by code by Andrea Giammarchi
			// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
			var head = document.getElementsByTagName("head")[0] || document.documentElement,
				script = document.createElement("script");

			script.type = "text/javascript";
			if ( jQuery.browser.msie )
				script.text = data;
			else
				script.appendChild( document.createTextNode( data ) );

			head.appendChild( script );
			head.removeChild( script );
		}
	},

	nodeName: function( elem, name ) {
		return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
	},
	
	cache: {},
	
	data: function( elem, name, data ) {
		elem = elem == window ?
			windowData :
			elem;

		var id = elem[ expando ];

		// Compute a unique ID for the element
		if ( !id ) 
			id = elem[ expando ] = ++uuid;

		// Only generate the data cache if we're
		// trying to access or manipulate it
		if ( name && !jQuery.cache[ id ] )
			jQuery.cache[ id ] = {};
		
		// Prevent overriding the named cache with undefined values
		if ( data != undefined )
			jQuery.cache[ id ][ name ] = data;
		
		// Return the named cache data, or the ID for the element	
		return name ?
			jQuery.cache[ id ][ name ] :
			id;
	},
	
	removeData: function( elem, name ) {
		elem = elem == window ?
			windowData :
			elem;

		var id = elem[ expando ];

		// If we want to remove a specific section of the element's data
		if ( name ) {
			if ( jQuery.cache[ id ] ) {
				// Remove the section of cache data
				delete jQuery.cache[ id ][ name ];

				// If we've removed all the data, remove the element's cache
				name = "";

				for ( name in jQuery.cache[ id ] )
					break;

				if ( !name )
					jQuery.removeData( elem );
			}

		// Otherwise, we want to remove all of the element's data
		} else {
			// Clean up the element expando
			try {
				delete elem[ expando ];
			} catch(e){
				// IE has trouble directly removing the expando
				// but it's ok with using removeAttribute
				if ( elem.removeAttribute )
					elem.removeAttribute( expando );
			}

			// Completely remove the data cache
			delete jQuery.cache[ id ];
		}
	},

	// args is for internal usage only
	each: function( object, callback, args ) {
		if ( args ) {
			if ( object.length == undefined ) {
				for ( var name in object )
					if ( callback.apply( object[ name ], args ) === false )
						break;
			} else
				for ( var i = 0, length = object.length; i < length; i++ )
					if ( callback.apply( object[ i ], args ) === false )
						break;

		// A special, fast, case for the most common use of each
		} else {
			if ( object.length == undefined ) {
				for ( var name in object )
					if ( callback.call( object[ name ], name, object[ name ] ) === false )
						break;
			} else
				for ( var i = 0, length = object.length, value = object[0]; 
					i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
		}

		return object;
	},
	
	prop: function( elem, value, type, i, name ) {
			// Handle executable functions
			if ( jQuery.isFunction( value ) )
				value = value.call( elem, i );
				
			// Handle passing in a number to a CSS property
			return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
				value + "px" :
				value;
	},

	className: {
		// internal only, use addClass("class")
		add: function( elem, classNames ) {
			jQuery.each((classNames || "").split(/\s+/), function(i, className){
				if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
					elem.className += (elem.className ? " " : "") + className;
			});
		},

		// internal only, use removeClass("class")
		remove: function( elem, classNames ) {
			if (elem.nodeType == 1)
				elem.className = classNames != undefined ?
					jQuery.grep(elem.className.split(/\s+/), function(className){
						return !jQuery.className.has( classNames, className );	
					}).join(" ") :
					"";
		},

		// internal only, use is(".class")
		has: function( elem, className ) {
			return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
		}
	},

	// A method for quickly swapping in/out CSS properties to get correct calculations
	swap: function( elem, options, callback ) {
		var old = {};
		// Remember the old values, and insert the new ones
		for ( var name in options ) {
			old[ name ] = elem.style[ name ];
			elem.style[ name ] = options[ name ];
		}

		callback.call( elem );

		// Revert the old values
		for ( var name in options )
			elem.style[ name ] = old[ name ];
	},

	css: function( elem, name, force ) {
		if ( name == "width" || name == "height" ) {
			var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
		
			function getWH() {
				val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
				var padding = 0, border = 0;
				jQuery.each( which, function() {
					padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
					border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
				});
				val -= Math.round(padding + border);
			}
		
			if ( jQuery(elem).is(":visible") )
				getWH();
			else
				jQuery.swap( elem, props, getWH );
			
			return Math.max(0, val);
		}
		
		return jQuery.curCSS( elem, name, force );
	},

	curCSS: function( elem, name, force ) {
		var ret;

		// A helper method for determining if an element's values are broken
		function color( elem ) {
			if ( !jQuery.browser.safari )
				return false;

			var ret = document.defaultView.getComputedStyle( elem, null );
			return !ret || ret.getPropertyValue("color") == "";
		}

		// We need to handle opacity special in IE
		if ( name == "opacity" && jQuery.browser.msie ) {
			ret = jQuery.attr( elem.style, "opacity" );

			return ret == "" ?
				"1" :
				ret;
		}
		// Opera sometimes will give the wrong display answer, this fixes it, see #2037
		if ( jQuery.browser.opera && name == "display" ) {
			var save = elem.style.outline;
			elem.style.outline = "0 solid black";
			elem.style.outline = save;
		}
		
		// Make sure we're using the right name for getting the float value
		if ( name.match( /float/i ) )
			name = styleFloat;

		if ( !force && elem.style && elem.style[ name ] )
			ret = elem.style[ name ];

		else if ( document.defaultView && document.defaultView.getComputedStyle ) {

			// Only "float" is needed here
			if ( name.match( /float/i ) )
				name = "float";

			name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();

			var getComputedStyle = document.defaultView.getComputedStyle( elem, null );

			if ( getComputedStyle && !color( elem ) )
				ret = getComputedStyle.getPropertyValue( name );

			// If the element isn't reporting its values properly in Safari
			// then some display: none elements are involved
			else {
				var swap = [], stack = [];

				// Locate all of the parent display: none elements
				for ( var a = elem; a && color(a); a = a.parentNode )
					stack.unshift(a);

				// Go through and make them visible, but in reverse
				// (It would be better if we knew the exact display type that they had)
				for ( var i = 0; i < stack.length; i++ )
					if ( color( stack[ i ] ) ) {
						swap[ i ] = stack[ i ].style.display;
						stack[ i ].style.display = "block";
					}

				// Since we flip the display style, we have to handle that
				// one special, otherwise get the value
				ret = name == "display" && swap[ stack.length - 1 ] != null ?
					"none" :
					( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || "";

				// Finally, revert the display styles back
				for ( var i = 0; i < swap.length; i++ )
					if ( swap[ i ] != null )
						stack[ i ].style.display = swap[ i ];
			}

			// We should always get a number back from opacity
			if ( name == "opacity" && ret == "" )
				ret = "1";

		} else if ( elem.currentStyle ) {
			var camelCase = name.replace(/\-(\w)/g, function(all, letter){
				return letter.toUpperCase();
			});

			ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];

			// From the awesome hack by Dean Edwards
			// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291

			// If we're not dealing with a regular pixel number
			// but a number that has a weird ending, we need to convert it to pixels
			if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
				// Remember the original values
				var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;

				// Put in the new values to get a computed value out
				elem.runtimeStyle.left = elem.currentStyle.left;
				elem.style.left = ret || 0;
				ret = elem.style.pixelLeft + "px";

				// Revert the changed values
				elem.style.left = style;
				elem.runtimeStyle.left = runtimeStyle;
			}
		}

		return ret;
	},
	
	clean: function( elems, context ) {
		var ret = [];
		context = context || document;
		// !context.createElement fails in IE with an error but returns typeof 'object'
		if (typeof context.createElement == 'undefined') 
			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;

		jQuery.each(elems, function(i, elem){
			if ( !elem )
				return;

			if ( elem.constructor == Number )
				elem = elem.toString();
			
			// Convert html string into DOM nodes
			if ( typeof elem == "string" ) {
				// Fix "XHTML"-style tags in all browsers
				elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
					return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
						all :
						front + "></" + tag + ">";
				});

				// Trim whitespace, otherwise indexOf won't work as expected
				var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");

				var wrap =
					// option or optgroup
					!tags.indexOf("<opt") &&
					[ 1, "<select multiple='multiple'>", "</select>" ] ||
					
					!tags.indexOf("<leg") &&
					[ 1, "<fieldset>", "</fieldset>" ] ||
					
					tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
					[ 1, "<table>", "</table>" ] ||
					
					!tags.indexOf("<tr") &&
					[ 2, "<table><tbody>", "</tbody></table>" ] ||
					
				 	// <thead> matched above
					(!tags.indexOf("<td") || !tags.indexOf("<th")) &&
					[ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
					
					!tags.indexOf("<col") &&
					[ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||

					// IE can't serialize <link> and <script> tags normally
					jQuery.browser.msie &&
					[ 1, "div<div>", "</div>" ] ||
					
					[ 0, "", "" ];

				// Go to html and back, then peel off extra wrappers
				div.innerHTML = wrap[1] + elem + wrap[2];
				
				// Move to the right depth
				while ( wrap[0]-- )
					div = div.lastChild;
				
				// Remove IE's autoinserted <tbody> from table fragments
				if ( jQuery.browser.msie ) {
					
					// String was a <table>, *may* have spurious <tbody>
					var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
						div.firstChild && div.firstChild.childNodes :
						
						// String was a bare <thead> or <tfoot>
						wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
							div.childNodes :
							[];
				
					for ( var j = tbody.length - 1; j >= 0 ; --j )
						if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
							tbody[ j ].parentNode.removeChild( tbody[ j ] );
					
					// IE completely kills leading whitespace when innerHTML is used	
					if ( /^\s/.test( elem ) )	
						div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
				
				}
				
				elem = jQuery.makeArray( div.childNodes );
			}

			if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
				return;

			if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
				ret.push( elem );

			else
				ret = jQuery.merge( ret, elem );

		});

		return ret;
	},
	
	attr: function( elem, name, value ) {
		// don't set attributes on text and comment nodes
		if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
			return undefined;

		var fix = jQuery.isXMLDoc( elem ) ?
			{} :
			jQuery.props;

		// Safari mis-reports the default selected property of a hidden option
		// Accessing the parent's selectedIndex property fixes it
		if ( name == "selected" && jQuery.browser.safari )
			elem.parentNode.selectedIndex;
		
		// Certain attributes only work when accessed via the old DOM 0 way
		if ( fix[ name ] ) {
			if ( value != undefined )
				elem[ fix[ name ] ] = value;

			return elem[ fix[ name ] ];

		} else if ( jQuery.browser.msie && name == "style" )
			return jQuery.attr( elem.style, "cssText", value );

		else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )
			return elem.getAttributeNode( name ).nodeValue;

		// IE elem.getAttribute passes even for style
		else if ( elem.tagName ) {

			if ( value != undefined ) {
				// We can't allow the type property to be changed (since it causes problems in IE)
				if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
					throw "type property can't be changed";

				// convert the value to a string (all browsers do this but IE) see #1070
				elem.setAttribute( name, "" + value );
			}

			if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) ) 
				return elem.getAttribute( name, 2 );

			return elem.getAttribute( name );

		// elem is actually elem.style ... set the style
		} else {
			// IE actually uses filters for opacity
			if ( name == "opacity" && jQuery.browser.msie ) {
				if ( value != undefined ) {
					// IE has trouble with opacity if it does not have layout
					// Force it by setting the zoom level
					elem.zoom = 1; 
	
					// Set the alpha filter to set the opacity
					elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
						(parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
				}
	
				return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
					(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :
					"";
			}

			name = name.replace(/-([a-z])/ig, function(all, letter){
				return letter.toUpperCase();
			});

			if ( value != undefined )
				elem[ name ] = value;

			return elem[ name ];
		}
	},
	
	trim: function( text ) {
		return (text || "").replace( /^\s+|\s+$/g, "" );
	},

	makeArray: function( array ) {
		var ret = [];

		// Need to use typeof to fight Safari childNodes crashes
		if ( typeof array != "array" )
			for ( var i = 0, length = array.length; i < length; i++ )
				ret.push( array[ i ] );
		else
			ret = array.slice( 0 );

		return ret;
	},

	inArray: function( elem, array ) {
		for ( var i = 0, length = array.length; i < length; i++ )
			if ( array[ i ] == elem )
				return i;

		return -1;
	},

	merge: function( first, second ) {
		// We have to loop this way because IE & Opera overwrite the length
		// expando of getElementsByTagName

		// Also, we need to make sure that the correct elements are being returned
		// (IE returns comment nodes in a '*' query)
		if ( jQuery.browser.msie ) {
			for ( var i = 0; second[ i ]; i++ )
				if ( second[ i ].nodeType != 8 )
					first.push( second[ i ] );

		} else
			for ( var i = 0; second[ i ]; i++ )
				first.push( second[ i ] );

		return first;
	},

	unique: function( array ) {
		var ret = [], done = {};

		try {

			for ( var i = 0, length = array.length; i < length; i++ ) {
				var id = jQuery.data( array[ i ] );

				if ( !done[ id ] ) {
					done[ id ] = true;
					ret.push( array[ i ] );
				}
			}

		} catch( e ) {
			ret = array;
		}

		return ret;
	},

	grep: function( elems, callback, inv ) {
		var ret = [];

		// Go through the array, only saving the items
		// that pass the validator function
		for ( var i = 0, length = elems.length; i < length; i++ )
			if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )
				ret.push( elems[ i ] );

		return ret;
	},

	map: function( elems, callback ) {
		var ret = [];

		// Go through the array, translating each of the items to their
		// new value (or values).
		for ( var i = 0, length = elems.length; i < length; i++ ) {
			var value = callback( elems[ i ], i );

			if ( value !== null && value != undefined ) {
				if ( value.constructor != Array )
					value = [ value ];

				ret = ret.concat( value );
			}
		}

		return ret;
	}
});

var userAgent = navigator.userAgent.toLowerCase();

// Figure out what browser is being used
jQuery.browser = {
	version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
	safari: /webkit/.test( userAgent ),
	opera: /opera/.test( userAgent ),
	msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
	mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};

var styleFloat = jQuery.browser.msie ?
	"styleFloat" :
	"cssFloat";
	
jQuery.extend({
	// Check to see if the W3C box model is being used
	boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
	
	props: {
		"for": "htmlFor",
		"class": "className",
		"float": styleFloat,
		cssFloat: styleFloat,
		styleFloat: styleFloat,
		innerHTML: "innerHTML",
		className: "className",
		value: "value",
		disabled: "disabled",
		checked: "checked",
		readonly: "readOnly",
		selected: "selected",
		maxlength: "maxLength",
		selectedIndex: "selectedIndex",
		defaultValue: "defaultValue",
		tagName: "tagName",
		nodeName: "nodeName"
	}
});

jQuery.each({
	parent: function(elem){return elem.parentNode;},
	parents: function(elem){return jQuery.dir(elem,"parentNode");},
	next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
	prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
	nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
	prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
	siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
	children: function(elem){return jQuery.sibling(elem.firstChild);},
	contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
}, function(name, fn){
	jQuery.fn[ name ] = function( selector ) {
		var ret = jQuery.map( this, fn );

		if ( selector && typeof selector == "string" )
			ret = jQuery.multiFilter( selector, ret );

		return this.pushStack( jQuery.unique( ret ) );
	};
});

jQuery.each({
	appendTo: "append",
	prependTo: "prepend",
	insertBefore: "before",
	insertAfter: "after",
	replaceAll: "replaceWith"
}, function(name, original){
	jQuery.fn[ name ] = function() {
		var args = arguments;

		return this.each(function(){
			for ( var i = 0, length = args.length; i < length; i++ )
				jQuery( args[ i ] )[ original ]( this );
		});
	};
});

jQuery.each({
	removeAttr: function( name ) {
		jQuery.attr( this, name, "" );
		if (this.nodeType == 1) 
			this.removeAttribute( name );
	},

	addClass: function( classNames ) {
		jQuery.className.add( this, classNames );
	},

	removeClass: function( classNames ) {
		jQuery.className.remove( this, classNames );
	},

	toggleClass: function( classNames ) {
		jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
	},

	remove: function( selector ) {
		if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
			// Prevent memory leaks
			jQuery( "*", this ).add(this).each(function(){
				jQuery.event.remove(this);
				jQuery.removeData(this);
			});
			if (this.parentNode)
				this.parentNode.removeChild( this );
		}
	},

	empty: function() {
		// Remove element nodes and prevent memory leaks
		jQuery( ">*", this ).remove();
		
		// Remove any remaining nodes
		while ( this.firstChild )
			this.removeChild( this.firstChild );
	}
}, function(name, fn){
	jQuery.fn[ name ] = function(){
		return this.each( fn, arguments );
	};
});

jQuery.each([ "Height", "Width" ], function(i, name){
	var type = name.toLowerCase();
	
	jQuery.fn[ type ] = function( size ) {
		// Get window width or height
		return this[0] == window ?
			// Opera reports document.body.client[Width/Height] properly in both quirks and standards
			jQuery.browser.opera && document.body[ "client" + name ] || 
			
			// Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
			jQuery.browser.safari && window[ "inner" + name ] ||
			
			// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
			document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
		
			// Get document width or height
			this[0] == document ?
				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
				Math.max( 
					Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]), 
					Math.max(document.body["offset" + name], document.documentElement["offset" + name]) 
				) :

				// Get or set width or height on the element
				size == undefined ?
					// Get width or height on the element
					(this.length ? jQuery.css( this[0], type ) : null) :

					// Set the width or height on the element (default to pixels if value is unitless)
					this.css( type, size.constructor == String ? size : size + "px" );
	};
});

var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
		"(?:[\\w*_-]|\\\\.)" :
		"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
	quickChild = new RegExp("^>\\s*(" + chars + "+)"),
	quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
	quickClass = new RegExp("^([#.]?)(" + chars + "*)");

jQuery.extend({
	expr: {
		"": function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},
		"#": function(a,i,m){return a.getAttribute("id")==m[2];},
		":": {
			// Position Checks
			lt: function(a,i,m){return i<m[3]-0;},
			gt: function(a,i,m){return i>m[3]-0;},
			nth: function(a,i,m){return m[3]-0==i;},
			eq: function(a,i,m){return m[3]-0==i;},
			first: function(a,i){return i==0;},
			last: function(a,i,m,r){return i==r.length-1;},
			even: function(a,i){return i%2==0;},
			odd: function(a,i){return i%2;},

			// Child Checks
			"first-child": function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},
			"last-child": function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},
			"only-child": function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},

			// Parent Checks
			parent: function(a){return a.firstChild;},
			empty: function(a){return !a.firstChild;},

			// Text Check
			contains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},

			// Visibility
			visible: function(a){return "hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},
			hidden: function(a){return "hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},

			// Form attributes
			enabled: function(a){return !a.disabled;},
			disabled: function(a){return a.disabled;},
			checked: function(a){return a.checked;},
			selected: function(a){return a.selected||jQuery.attr(a,"selected");},

			// Form elements
			text: function(a){return "text"==a.type;},
			radio: function(a){return "radio"==a.type;},
			checkbox: function(a){return "checkbox"==a.type;},
			file: function(a){return "file"==a.type;},
			password: function(a){return "password"==a.type;},
			submit: function(a){return "submit"==a.type;},
			image: function(a){return "image"==a.type;},
			reset: function(a){return "reset"==a.type;},
			button: function(a){return "button"==a.type||jQuery.nodeName(a,"button");},
			input: function(a){return /input|select|textarea|button/i.test(a.nodeName);},

			// :has()
			has: function(a,i,m){return jQuery.find(m[3],a).length;},

			// :header
			header: function(a){return /h\d/i.test(a.nodeName);},

			// :animated
			animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}
		}
	},
	
	// The regular expressions that power the parsing engine
	parse: [
		// Match: [@value='test'], [@foo]
		/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,

		// Match: :contains('foo')
		/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,

		// Match: :even, :last-chlid, #id, .class
		new RegExp("^([:.#]*)(" + chars + "+)")
	],

	multiFilter: function( expr, elems, not ) {
		var old, cur = [];

		while ( expr && expr != old ) {
			old = expr;
			var f = jQuery.filter( expr, elems, not );
			expr = f.t.replace(/^\s*,\s*/, "" );
			cur = not ? elems = f.r : jQuery.merge( cur, f.r );
		}

		return cur;
	},

	find: function( t, context ) {
		// Quickly handle non-string expressions
		if ( typeof t != "string" )
			return [ t ];

		// check to make sure context is a DOM element or a document
		if ( context && context.nodeType != 1 && context.nodeType != 9)
			return [ ];

		// Set the correct context (if none is provided)
		context = context || document;

		// Initialize the search
		var ret = [context], done = [], last, nodeName;

		// Continue while a selector expression exists, and while
		// we're no longer looping upon ourselves
		while ( t && last != t ) {
			var r = [];
			last = t;

			t = jQuery.trim(t);

			var foundToken = false;

			// An attempt at speeding up child selectors that
			// point to a specific element tag
			var re = quickChild;
			var m = re.exec(t);

			if ( m ) {
				nodeName = m[1].toUpperCase();

				// Perform our own iteration and filter
				for ( var i = 0; ret[i]; i++ )
					for ( var c = ret[i].firstChild; c; c = c.nextSibling )
						if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) )
							r.push( c );

				ret = r;
				t = t.replace( re, "" );
				if ( t.indexOf(" ") == 0 ) continue;
				foundToken = true;
			} else {
				re = /^([>+~])\s*(\w*)/i;

				if ( (m = re.exec(t)) != null ) {
					r = [];

					var merge = {};
					nodeName = m[2].toUpperCase();
					m = m[1];

					for ( var j = 0, rl = ret.length; j < rl; j++ ) {
						var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
						for ( ; n; n = n.nextSibling )
							if ( n.nodeType == 1 ) {
								var id = jQuery.data(n);

								if ( m == "~" && merge[id] ) break;
								
								if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
									if ( m == "~" ) merge[id] = true;
									r.push( n );
								}
								
								if ( m == "+" ) break;
							}
					}

					ret = r;

					// And remove the token
					t = jQuery.trim( t.replace( re, "" ) );
					foundToken = true;
				}
			}

			// See if there's still an expression, and that we haven't already
			// matched a token
			if ( t && !foundToken ) {
				// Handle multiple expressions
				if ( !t.indexOf(",") ) {
					// Clean the result set
					if ( context == ret[0] ) ret.shift();

					// Merge the result sets
					done = jQuery.merge( done, ret );

					// Reset the context
					r = ret = [context];

					// Touch up the selector string
					t = " " + t.substr(1,t.length);

				} else {
					// Optimize for the case nodeName#idName
					var re2 = quickID;
					var m = re2.exec(t);
					
					// Re-organize the results, so that they're consistent
					if ( m ) {
						m = [ 0, m[2], m[3], m[1] ];

					} else {
						// Otherwise, do a traditional filter check for
						// ID, class, and element selectors
						re2 = quickClass;
						m = re2.exec(t);
					}

					m[2] = m[2].replace(/\\/g, "");

					var elem = ret[ret.length-1];

					// Try to do a global search by ID, where we can
					if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
						// Optimization for HTML document case
						var oid = elem.getElementById(m[2]);
						
						// Do a quick check for the existence of the actual ID attribute
						// to avoid selecting by the name attribute in IE
						// also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
						if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
							oid = jQuery('[@id="'+m[2]+'"]', elem)[0];

						// Do a quick check for node name (where applicable) so
						// that div#foo searches will be really fast
						ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
					} else {
						// We need to find all descendant elements
						for ( var i = 0; ret[i]; i++ ) {
							// Grab the tag name being searched for
							var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];

							// Handle IE7 being really dumb about <object>s
							if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
								tag = "param";

							r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
						}

						// It's faster to filter by class and be done with it
						if ( m[1] == "." )
							r = jQuery.classFilter( r, m[2] );

						// Same with ID filtering
						if ( m[1] == "#" ) {
							var tmp = [];

							// Try to find the element with the ID
							for ( var i = 0; r[i]; i++ )
								if ( r[i].getAttribute("id") == m[2] ) {
									tmp = [ r[i] ];
									break;
								}

							r = tmp;
						}

						ret = r;
					}

					t = t.replace( re2, "" );
				}

			}

			// If a selector string still exists
			if ( t ) {
				// Attempt to filter it
				var val = jQuery.filter(t,r);
				ret = r = val.r;
				t = jQuery.trim(val.t);
			}
		}

		// An error occurred with the selector;
		// just return an empty set instead
		if ( t )
			ret = [];

		// Remove the root context
		if ( ret && context == ret[0] )
			ret.shift();

		// And combine the results
		done = jQuery.merge( done, ret );

		return done;
	},

	classFilter: function(r,m,not){
		m = " " + m + " ";
		var tmp = [];
		for ( var i = 0; r[i]; i++ ) {
			var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
			if ( !not && pass || not && !pass )
				tmp.push( r[i] );
		}
		return tmp;
	},

	filter: function(t,r,not) {
		var last;

		// Look for common filter expressions
		while ( t && t != last ) {
			last = t;

			var p = jQuery.parse, m;

			for ( var i = 0; p[i]; i++ ) {
				m = p[i].exec( t );

				if ( m ) {
					// Remove what we just matched
					t = t.substring( m[0].length );

					m[2] = m[2].replace(/\\/g, "");
					break;
				}
			}

			if ( !m )
				break;

			// :not() is a special case that can be optimized by
			// keeping it out of the expression list
			if ( m[1] == ":" && m[2] == "not" )
				// optimize if only one selector found (most common case)
				r = isSimple.test( m[3] ) ?
					jQuery.filter(m[3], r, true).r :
					jQuery( r ).not( m[3] );

			// We can get a big speed boost by filtering by class here
			else if ( m[1] == "." )
				r = jQuery.classFilter(r, m[2], not);

			else if ( m[1] == "[" ) {
				var tmp = [], type = m[3];
				
				for ( var i = 0, rl = r.length; i < rl; i++ ) {
					var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
					
					if ( z == null || /href|src|selected/.test(m[2]) )
						z = jQuery.attr(a,m[2]) || '';

					if ( (type == "" && !!z ||
						 type == "=" && z == m[5] ||
						 type == "!=" && z != m[5] ||
						 type == "^=" && z && !z.indexOf(m[5]) ||
						 type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
						 (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
							tmp.push( a );
				}
				
				r = tmp;

			// We can get a speed boost by handling nth-child here
			} else if ( m[1] == ":" && m[2] == "nth-child" ) {
				var merge = {}, tmp = [],
					// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
					test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
						m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
						!/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
					// calculate the numbers (first)n+(last) including if they are negative
					first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
 
				// loop through all the elements left in the jQuery object
				for ( var i = 0, rl = r.length; i < rl; i++ ) {
					var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);

					if ( !merge[id] ) {
						var c = 1;

						for ( var n = parentNode.firstChild; n; n = n.nextSibling )
							if ( n.nodeType == 1 )
								n.nodeIndex = c++;

						merge[id] = true;
					}

					var add = false;

					if ( first == 0 ) {
						if ( node.nodeIndex == last )
							add = true;
					} else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 )
						add = true;

					if ( add ^ not )
						tmp.push( node );
				}

				r = tmp;

			// Otherwise, find the expression to execute
			} else {
				var fn = jQuery.expr[ m[1] ];
				if ( typeof fn == "object" )
					fn = fn[ m[2] ];

				if ( typeof fn == "string" )
					fn = eval("false||function(a,i){return " + fn + ";}");

				// Execute it against the current filter
				r = jQuery.grep( r, function(elem, i){
					return fn(elem, i, m, r);
				}, not );
			}
		}

		// Return an array of filtered elements (r)
		// and the modified expression string (t)
		return { r: r, t: t };
	},

	dir: function( elem, dir ){
		var matched = [];
		var cur = elem[dir];
		while ( cur && cur != document ) {
			if ( cur.nodeType == 1 )
				matched.push( cur );
			cur = cur[dir];
		}
		return matched;
	},
	
	nth: function(cur,result,dir,elem){
		result = result || 1;
		var num = 0;

		for ( ; cur; cur = cur[dir] )
			if ( cur.nodeType == 1 && ++num == result )
				break;

		return cur;
	},
	
	sibling: function( n, elem ) {
		var r = [];

		for ( ; n; n = n.nextSibling ) {
			if ( n.nodeType == 1 && (!elem || n != elem) )
				r.push( n );
		}

		return r;
	}
});

/*
 * A number of helper functions used for managing events.
 * Many of the ideas behind this code orignated from 
 * Dean Edwards' addEvent library.
 */
jQuery.event = {

	// Bind an event to an element
	// Original by Dean Edwards
	add: function(elem, types, handler, data) {
		if ( elem.nodeType == 3 || elem.nodeType == 8 )
			return;

		// For whatever reason, IE has trouble passing the window object
		// around, causing it to be cloned in the process
		if ( jQuery.browser.msie && elem.setInterval != undefined )
			elem = window;

		// Make sure that the function being executed has a unique ID
		if ( !handler.guid )
			handler.guid = this.guid++;
			
		// if data is passed, bind to handler 
		if( data != undefined ) { 
			// Create temporary function pointer to original handler 
			var fn = handler; 

			// Create unique handler function, wrapped around original handler 
			handler = function() { 
				// Pass arguments and context to original handler 
				return fn.apply(this, arguments); 
			};

			// Store data in unique handler 
			handler.data = data;

			// Set the guid of unique handler to the same of original handler, so it can be removed 
			handler.guid = fn.guid;
		}

		// Init the element's event structure
		var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
			handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
				// returned undefined or false
				var val;

				// Handle the second event of a trigger and when
				// an event is called after a page has unloaded
				if ( typeof jQuery == "undefined" || jQuery.event.triggered )
					return val;
		
				val = jQuery.event.handle.apply(arguments.callee.elem, arguments);
		
				return val;
			});
		// Add elem as a property of the handle function
		// This is to prevent a memory leak with non-native
		// event in IE.
		handle.elem = elem;
			
			// Handle multiple events seperated by a space
			// jQuery(...).bind("mouseover mouseout", fn);
			jQuery.each(types.split(/\s+/), function(index, type) {
				// Namespaced event handlers
				var parts = type.split(".");
				type = parts[0];
				handler.type = parts[1];

				// Get the current list of functions bound to this event
				var handlers = events[type];

				// Init the event handler queue
				if (!handlers) {
					handlers = events[type] = {};
		
					// Check for a special event handler
					// Only use addEventListener/attachEvent if the special
					// events handler returns false
					if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
						// Bind the global event handler to the element
						if (elem.addEventListener)
							elem.addEventListener(type, handle, false);
						else if (elem.attachEvent)
							elem.attachEvent("on" + type, handle);
					}
				}

				// Add the function to the element's handler list
				handlers[handler.guid] = handler;

				// Keep track of which events have been used, for global triggering
				jQuery.event.global[type] = true;
			});
		
		// Nullify elem to prevent memory leaks in IE
		elem = null;
	},

	guid: 1,
	global: {},

	// Detach an event or set of events from an element
	remove: function(elem, types, handler) {
		// don't do events on text and comment nodes
		if ( elem.nodeType == 3 || elem.nodeType == 8 )
			return;

		var events = jQuery.data(elem, "events"), ret, index;

		if ( events ) {
			// Unbind all events for the element
			if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") )
				for ( var type in events )
					this.remove( elem, type + (types || "") );
			else {
				// types is actually an event object here
				if ( types.type ) {
					handler = types.handler;
					types = types.type;
				}
				
				// Handle multiple events seperated by a space
				// jQuery(...).unbind("mouseover mouseout", fn);
				jQuery.each(types.split(/\s+/), function(index, type){
					// Namespaced event handlers
					var parts = type.split(".");
					type = parts[0];
					
					if ( events[type] ) {
						// remove the given handler for the given type
						if ( handler )
							delete events[type][handler.guid];
			
						// remove all handlers for the given type
						else
							for ( handler in events[type] )
								// Handle the removal of namespaced events
								if ( !parts[1] || events[type][handler].type == parts[1] )
									delete events[type][handler];

						// remove generic event handler if no more handlers exist
						for ( ret in events[type] ) break;
						if ( !ret ) {
							if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) {
								if (elem.removeEventListener)
									elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
								else if (elem.detachEvent)
									elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
							}
							ret = null;
							delete events[type];
						}
					}
				});
			}

			// Remove the expando if it's no longer used
			for ( ret in events ) break;
			if ( !ret ) {
				var handle = jQuery.data( elem, "handle" );
				if ( handle ) handle.elem = null;
				jQuery.removeData( elem, "events" );
				jQuery.removeData( elem, "handle" );
			}
		}
	},

	trigger: function(type, data, elem, donative, extra) {
		// Clone the incoming data, if any
		data = jQuery.makeArray(data || []);

		if ( type.indexOf("!") >= 0 ) {
			type = type.slice(0, -1);
			var exclusive = true;
		}

		// Handle a global trigger
		if ( !elem ) {
			// Only trigger if we've ever bound an event for it
			if ( this.global[type] )
				jQuery("*").add([window, document]).trigger(type, data);

		// Handle triggering a single element
		} else {
			// don't do events on text and comment nodes
			if ( elem.nodeType == 3 || elem.nodeType == 8 )
				return undefined;

			var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
				// Check to see if we need to provide a fake event, or not
				event = !data[0] || !data[0].preventDefault;
			
			// Pass along a fake event
			if ( event )
				data.unshift( this.fix({ type: type, target: elem }) );

			// Enforce the right trigger type
			data[0].type = type;
			if ( exclusive )
				data[0].exclusive = true;

			// Trigger the event
			if ( jQuery.isFunction( jQuery.data(elem, "handle") ) )
				val = jQuery.data(elem, "handle").apply( elem, data );

			// Handle triggering native .onfoo handlers
			if ( !fn && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
				val = false;

			// Extra functions don't get the custom event object
			if ( event )
				data.shift();

			// Handle triggering of extra function
			if ( extra && jQuery.isFunction( extra ) ) {
				// call the extra function and tack the current return value on the end for possible inspection
				ret = extra.apply( elem, val == null ? data : data.concat( val ) );
				// if anything is returned, give it precedence and have it overwrite the previous value
				if (ret !== undefined)
					val = ret;
			}

			// Trigger the native events (except for clicks on links)
			if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
				this.triggered = true;
				try {
					elem[ type ]();
				// prevent IE from throwing an error for some hidden elements
				} catch (e) {}
			}

			this.triggered = false;
		}

		return val;
	},

	handle: function(event) {
		// returned undefined or false
		var val;

		// Empty object is for triggered events with no data
		event = jQuery.event.fix( event || window.event || {} ); 

		// Namespaced event handlers
		var parts = event.type.split(".");
		event.type = parts[0];

		var handlers = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 );
		args.unshift( event );

		for ( var j in handlers ) {
			var handler = handlers[j];
			// Pass in a reference to the handler function itself
			// So that we can later remove it
			args[0].handler = handler;
			args[0].data = handler.data;

			// Filter the functions by class
			if ( !parts[1] && !event.exclusive || handler.type == parts[1] ) {
				var ret = handler.apply( this, args );

				if ( val !== false )
					val = ret;

				if ( ret === false ) {
					event.preventDefault();
					event.stopPropagation();
				}
			}
		}

		// Clean up added properties in IE to prevent memory leak
		if (jQuery.browser.msie)
			event.target = event.preventDefault = event.stopPropagation =
				event.handler = event.data = null;

		return val;
	},

	fix: function(event) {
		// store a copy of the original event object 
		// and clone to set read-only properties
		var originalEvent = event;
		event = jQuery.extend({}, originalEvent);
		
		// add preventDefault and stopPropagation since 
		// they will not work on the clone
		event.preventDefault = function() {
			// if preventDefault exists run it on the original event
			if (originalEvent.preventDefault)
				originalEvent.preventDefault();
			// otherwise set the returnValue property of the original event to false (IE)
			originalEvent.returnValue = false;
		};
		event.stopPropagation = function() {
			// if stopPropagation exists run it on the original event
			if (originalEvent.stopPropagation)
				originalEvent.stopPropagation();
			// otherwise set the cancelBubble property of the original event to true (IE)
			originalEvent.cancelBubble = true;
		};
		
		// Fix target property, if necessary
		if ( !event.target )
			event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
				
		// check if target is a textnode (safari)
		if ( event.target.nodeType == 3 )
			event.target = originalEvent.target.parentNode;

		// Add relatedTarget, if necessary
		if ( !event.relatedTarget && event.fromElement )
			event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;

		// Calculate pageX/Y if missing and clientX/Y available
		if ( event.pageX == null && event.clientX != null ) {
			var doc = document.documentElement, body = document.body;
			event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
			event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
		}
			
		// Add which for key events
		if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
			event.which = event.charCode || event.keyCode;
		
		// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
		if ( !event.metaKey && event.ctrlKey )
			event.metaKey = event.ctrlKey;

		// Add which for click: 1 == left; 2 == middle; 3 == right
		// Note: button is not normalized, so don't use it
		if ( !event.which && event.button )
			event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
			
		return event;
	},
	
	special: {
		ready: {
			setup: function() {
				// Make sure the ready event is setup
				bindReady();
				return;
			},
			
			teardown: function() { return; }
		},
		
		mouseenter: {
			setup: function() {
				if ( jQuery.browser.msie ) return false;
				jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
				return true;
			},
		
			teardown: function() {
				if ( jQuery.browser.msie ) return false;
				jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
				return true;
			},
			
			handler: function(event) {
				// If we actually just moused on to a sub-element, ignore it
				if ( withinElement(event, this) ) return true;
				// Execute the right handlers by setting the event type to mouseenter
				arguments[0].type = "mouseenter";
				return jQuery.event.handle.apply(this, arguments);
			}
		},
	
		mouseleave: {
			setup: function() {
				if ( jQuery.browser.msie ) return false;
				jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
				return true;
			},
		
			teardown: function() {
				if ( jQuery.browser.msie ) return false;
				jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
				return true;
			},
			
			handler: function(event) {
				// If we actually just moused on to a sub-element, ignore it
				if ( withinElement(event, this) ) return true;
				// Execute the right handlers by setting the event type to mouseleave
				arguments[0].type = "mouseleave";
				return jQuery.event.handle.apply(this, arguments);
			}
		}
	}
};

jQuery.fn.extend({
	bind: function( type, data, fn ) {
		return type == "unload" ? this.one(type, data, fn) : this.each(function(){
			jQuery.event.add( this, type, fn || data, fn && data );
		});
	},
	
	one: function( type, data, fn ) {
		return this.each(function(){
			jQuery.event.add( this, type, function(event) {
				jQuery(this).unbind(event);
				return (fn || data).apply( this, arguments);
			}, fn && data);
		});
	},

	unbind: function( type, fn ) {
		return this.each(function(){
			jQuery.event.remove( this, type, fn );
		});
	},

	trigger: function( type, data, fn ) {
		return this.each(function(){
			jQuery.event.trigger( type, data, this, true, fn );
		});
	},

	triggerHandler: function( type, data, fn ) {
		if ( this[0] )
			return jQuery.event.trigger( type, data, this[0], false, fn );
		return undefined;
	},

	toggle: function() {
		// Save reference to arguments for access in closure
		var args = arguments;

		return this.click(function(event) {
			// Figure out which function to execute
			this.lastToggle = 0 == this.lastToggle ? 1 : 0;
			
			// Make sure that clicks stop
			event.preventDefault();
			
			// and execute the function
			return args[this.lastToggle].apply( this, arguments ) || false;
		});
	},

	hover: function(fnOver, fnOut) {
		return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut);
	},
	
	ready: function(fn) {
		// Attach the listeners
		bindReady();

		// If the DOM is already ready
		if ( jQuery.isReady )
			// Execute the function immediately
			fn.call( document, jQuery );
			
		// Otherwise, remember the function for later
		else
			// Add the function to the wait list
			jQuery.readyList.push( function() { return fn.call(this, jQuery); } );
	
		return this;
	}
});

jQuery.extend({
	isReady: false,
	readyList: [],
	// Handle when the DOM is ready
	ready: function() {
		// Make sure that the DOM is not already loaded
		if ( !jQuery.isReady ) {
			// Remember that the DOM is ready
			jQuery.isReady = true;
			
			// If there are functions bound, to execute
			if ( jQuery.readyList ) {
				// Execute all of them
				jQuery.each( jQuery.readyList, function(){
					this.apply( document );
				});
				
				// Reset the list of functions
				jQuery.readyList = null;
			}
		
			// Trigger any bound ready events
			jQuery(document).triggerHandler("ready");
		}
	}
});

var readyBound = false;

function bindReady(){
	if ( readyBound ) return;
	readyBound = true;

	// Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
	if ( document.addEventListener && !jQuery.browser.opera)
		// Use the handy event callback
		document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
	
	// If IE is used and is not in a frame
	// Continually check to see if the document is ready
	if ( jQuery.browser.msie && window == top ) (function(){
		if (jQuery.isReady) return;
		try {
			// If IE is used, use the trick by Diego Perini
			// http://javascript.nwbox.com/IEContentLoaded/
			document.documentElement.doScroll("left");
		} catch( error ) {
			setTimeout( arguments.callee, 0 );
			return;
		}
		// and execute any waiting functions
		jQuery.ready();
	})();

	if ( jQuery.browser.opera )
		document.addEventListener( "DOMContentLoaded", function () {
			if (jQuery.isReady) return;
			for (var i = 0; i < document.styleSheets.length; i++)
				if (document.styleSheets[i].disabled) {
					setTimeout( arguments.callee, 0 );
					return;
				}
			// and execute any waiting functions
			jQuery.ready();
		}, false);

	if ( jQuery.browser.safari ) {
		var numStyles;
		(function(){
			if (jQuery.isReady) return;
			if ( document.readyState != "loaded" && document.readyState != "complete" ) {
				setTimeout( arguments.callee, 0 );
				return;
			}
			if ( numStyles === undefined )
				numStyles = jQuery("style, link[rel=stylesheet]").length;
			if ( document.styleSheets.length != numStyles ) {
				setTimeout( arguments.callee, 0 );
				return;
			}
			// and execute any waiting functions
			jQuery.ready();
		})();
	}

	// A fallback to window.onload, that will always work
	jQuery.event.add( window, "load", jQuery.ready );
}

jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
	"mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 
	"submit,keydown,keypress,keyup,error").split(","), function(i, name){
	
	// Handle event binding
	jQuery.fn[name] = function(fn){
		return fn ? this.bind(name, fn) : this.trigger(name);
	};
});

// Checks if an event happened on an element within another element
// Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function(event, elem) {
	// Check if mouse(over|out) are still within the same parent element
	var parent = event.relatedTarget;
	// Traverse up the tree
	while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; }
	// Return true if we actually just moused on to a sub-element
	return parent == elem;
};

// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other browsers
// Window isn't included so as not to unbind existing unload events
jQuery(window).bind("unload", function() {
	jQuery("*").add(document).unbind();
});
jQuery.fn.extend({
	load: function( url, params, callback ) {
		if ( jQuery.isFunction( url ) )
			return this.bind("load", url);

		var off = url.indexOf(" ");
		if ( off >= 0 ) {
			var selector = url.slice(off, url.length);
			url = url.slice(0, off);
		}

		callback = callback || function(){};

		// Default to a GET request
		var type = "GET";

		// If the second parameter was provided
		if ( params )
			// If it's a function
			if ( jQuery.isFunction( params ) ) {
				// We assume that it's the callback
				callback = params;
				params = null;

			// Otherwise, build a param string
			} else {
				params = jQuery.param( params );
				type = "POST";
			}

		var self = this;

		// Request the remote document
		jQuery.ajax({
			url: url,
			type: type,
			dataType: "html",
			data: params,
			complete: function(res, status){
				// If successful, inject the HTML into all the matched elements
				if ( status == "success" || status == "notmodified" )
					// See if a selector was specified
					self.html( selector ?
						// Create a dummy div to hold the results
						jQuery("<div/>")
							// inject the contents of the document in, removing the scripts
							// to avoid any 'Permission Denied' errors in IE
							.append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))

							// Locate the specified elements
							.find(selector) :

						// If not, just inject the full result
						res.responseText );

				self.each( callback, [res.responseText, status, res] );
			}
		});
		return this;
	},

	serialize: function() {
		return jQuery.param(this.serializeArray());
	},
	serializeArray: function() {
		return this.map(function(){
			return jQuery.nodeName(this, "form") ?
				jQuery.makeArray(this.elements) : this;
		})
		.filter(function(){
			return this.name && !this.disabled && 
				(this.checked || /select|textarea/i.test(this.nodeName) || 
					/text|hidden|password/i.test(this.type));
		})
		.map(function(i, elem){
			var val = jQuery(this).val();
			return val == null ? null :
				val.constructor == Array ?
					jQuery.map( val, function(val, i){
						return {name: elem.name, value: val};
					}) :
					{name: elem.name, value: val};
		}).get();
	}
});

// Attach a bunch of functions for handling common AJAX events
jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
	jQuery.fn[o] = function(f){
		return this.bind(o, f);
	};
});

var jsc = (new Date).getTime();

jQuery.extend({
	get: function( url, data, callback, type ) {
		// shift arguments if data argument was ommited
		if ( jQuery.isFunction( data ) ) {
			callback = data;
			data = null;
		}
		
		return jQuery.ajax({
			type: "GET",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	},

	getScript: function( url, callback ) {
		return jQuery.get(url, null, callback, "script");
	},

	getJSON: function( url, data, callback ) {
		return jQuery.get(url, data, callback, "json");
	},

	post: function( url, data, callback, type ) {
		if ( jQuery.isFunction( data ) ) {
			callback = data;
			data = {};
		}

		return jQuery.ajax({
			type: "POST",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	},

	ajaxSetup: function( settings ) {
		jQuery.extend( jQuery.ajaxSettings, settings );
	},

	ajaxSettings: {
		global: true,
		type: "GET",
		timeout: 0,
		contentType: "application/x-www-form-urlencoded",
		processData: true,
		async: true,
		data: null,
		username: null,
		password: null,
		accepts: {
			xml: "application/xml, text/xml",
			html: "text/html",
			script: "text/javascript, application/javascript",
			json: "application/json, text/javascript",
			text: "text/plain",
			_default: "*/*"
		}
	},
	
	// Last-Modified header cache for next request
	lastModified: {},

	ajax: function( s ) {
		var jsonp, jsre = /=\?(&|$)/g, status, data;

		// Extend the settings, but re-extend 's' so that it can be
		// checked again later (in the test suite, specifically)
		s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));

		// convert data if not already a string
		if ( s.data && s.processData && typeof s.data != "string" )
			s.data = jQuery.param(s.data);

		// Handle JSONP Parameter Callbacks
		if ( s.dataType == "jsonp" ) {
			if ( s.type.toLowerCase() == "get" ) {
				if ( !s.url.match(jsre) )
					s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
			} else if ( !s.data || !s.data.match(jsre) )
				s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
			s.dataType = "json";
		}

		// Build temporary JSONP function
		if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
			jsonp = "jsonp" + jsc++;

			// Replace the =? sequence both in the query string and the data
			if ( s.data )
				s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
			s.url = s.url.replace(jsre, "=" + jsonp + "$1");

			// We need to make sure
			// that a JSONP style response is executed properly
			s.dataType = "script";

			// Handle JSONP-style loading
			window[ jsonp ] = function(tmp){
				data = tmp;
				success();
				complete();
				// Garbage collect
				window[ jsonp ] = undefined;
				try{ delete window[ jsonp ]; } catch(e){}
				if ( head )
					head.removeChild( script );
			};
		}

		if ( s.dataType == "script" && s.cache == null )
			s.cache = false;

		if ( s.cache === false && s.type.toLowerCase() == "get" ) {
			var ts = (new Date()).getTime();
			// try replacing _= if it is there
			var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
			// if nothing was replaced, add timestamp to the end
			s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
		}

		// If data is available, append data to url for get requests
		if ( s.data && s.type.toLowerCase() == "get" ) {
			s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;

			// IE likes to send both get and post data, prevent this
			s.data = null;
		}

		// Watch for a new set of requests
		if ( s.global && ! jQuery.active++ )
			jQuery.event.trigger( "ajaxStart" );

		// If we're requesting a remote document
		// and trying to load JSON or Script with a GET
		if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && s.dataType == "script" && s.type.toLowerCase() == "get" ) {
			var head = document.getElementsByTagName("head")[0];
			var script = document.createElement("script");
			script.src = s.url;
			if (s.scriptCharset)
				script.charset = s.scriptCharset;

			// Handle Script loading
			if ( !jsonp ) {
				var done = false;

				// Attach handlers for all browsers
				script.onload = script.onreadystatechange = function(){
					if ( !done && (!this.readyState || 
							this.readyState == "loaded" || this.readyState == "complete") ) {
						done = true;
						success();
						complete();
						head.removeChild( script );
					}
				};
			}

			head.appendChild(script);

			// We handle everything using the script element injection
			return undefined;
		}

		var requestDone = false;

		// Create the request object; Microsoft failed to properly
		// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
		var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

		// Open the socket
		xml.open(s.type, s.url, s.async, s.username, s.password);

		// Need an extra try/catch for cross domain requests in Firefox 3
		try {
			// Set the correct header, if data is being sent
			if ( s.data )
				xml.setRequestHeader("Content-Type", s.contentType);

			// Set the If-Modified-Since header, if ifModified mode.
			if ( s.ifModified )
				xml.setRequestHeader("If-Modified-Since",
					jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );

			// Set header so the called script knows that it's an XMLHttpRequest
			xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");

			// Set the Accepts header for the server, depending on the dataType
			xml.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
				s.accepts[ s.dataType ] + ", */*" :
				s.accepts._default );
		} catch(e){}

		// Allow custom headers/mimetypes
		if ( s.beforeSend )
			s.beforeSend(xml);
			
		if ( s.global )
			jQuery.event.trigger("ajaxSend", [xml, s]);

		// Wait for a response to come back
		var onreadystatechange = function(isTimeout){
			// The transfer is complete and the data is available, or the request timed out
			if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
				requestDone = true;
				
				// clear poll interval
				if (ival) {
					clearInterval(ival);
					ival = null;
				}
				
				status = isTimeout == "timeout" && "timeout" ||
					!jQuery.httpSuccess( xml ) && "error" ||
					s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
					"success";

				if ( status == "success" ) {
					// Watch for, and catch, XML document parse errors
					try {
						// process the data (runs the xml through httpData regardless of callback)
						data = jQuery.httpData( xml, s.dataType );
					} catch(e) {
						status = "parsererror";
					}
				}

				// Make sure that the request was successful or notmodified
				if ( status == "success" ) {
					// Cache Last-Modified header, if ifModified mode.
					var modRes;
					try {
						modRes = xml.getResponseHeader("Last-Modified");
					} catch(e) {} // swallow exception thrown by FF if header is not available
	
					if ( s.ifModified && modRes )
						jQuery.lastModified[s.url] = modRes;

					// JSONP handles its own success callback
					if ( !jsonp )
						success();	
				} else
					jQuery.handleError(s, xml, status);

				// Fire the complete handlers
				complete();

				// Stop memory leaks
				if ( s.async )
					xml = null;
			}
		};
		
		if ( s.async ) {
			// don't attach the handler to the request, just poll it instead
			var ival = setInterval(onreadystatechange, 13); 

			// Timeout checker
			if ( s.timeout > 0 )
				setTimeout(function(){
					// Check to see if the request is still happening
					if ( xml ) {
						// Cancel the request
						xml.abort();
	
						if( !requestDone )
							onreadystatechange( "timeout" );
					}
				}, s.timeout);
		}
			
		// Send the data
		try {
			xml.send(s.data);
		} catch(e) {
			jQuery.handleError(s, xml, null, e);
		}
		
		// firefox 1.5 doesn't fire statechange for sync requests
		if ( !s.async )
			onreadystatechange();

		function success(){
			// If a local callback was specified, fire it and pass it the data
			if ( s.success )
				s.success( data, status );

			// Fire the global callback
			if ( s.global )
				jQuery.event.trigger( "ajaxSuccess", [xml, s] );
		}

		function complete(){
			// Process result
			if ( s.complete )
				s.complete(xml, status);

			// The request was completed
			if ( s.global )
				jQuery.event.trigger( "ajaxComplete", [xml, s] );

			// Handle the global AJAX counter
			if ( s.global && ! --jQuery.active )
				jQuery.event.trigger( "ajaxStop" );
		}
		
		// return XMLHttpRequest to allow aborting the request etc.
		return xml;
	},

	handleError: function( s, xml, status, e ) {
		// If a local callback was specified, fire it
		if ( s.error ) s.error( xml, status, e );

		// Fire the global callback
		if ( s.global )
			jQuery.event.trigger( "ajaxError", [xml, s, e] );
	},

	// Counter for holding the number of active queries
	active: 0,

	// Determines if an XMLHttpRequest was successful or not
	httpSuccess: function( r ) {
		try {
			// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
			return !r.status && location.protocol == "file:" ||
				( r.status >= 200 && r.status < 300 ) || r.status == 304 || r.status == 1223 ||
				jQuery.browser.safari && r.status == undefined;
		} catch(e){}
		return false;
	},

	// Determines if an XMLHttpRequest returns NotModified
	httpNotModified: function( xml, url ) {
		try {
			var xmlRes = xml.getResponseHeader("Last-Modified");

			// Firefox always returns 200. check Last-Modified date
			return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
				jQuery.browser.safari && xml.status == undefined;
		} catch(e){}
		return false;
	},

	httpData: function( r, type ) {
		var ct = r.getResponseHeader("content-type");
		var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
		var data = xml ? r.responseXML : r.responseText;

		if ( xml && data.documentElement.tagName == "parsererror" )
			throw "parsererror";

		// If the type is "script", eval it in global context
		if ( type == "script" )
			jQuery.globalEval( data );

		// Get the JavaScript object, if JSON is used.
		if ( type == "json" )
			data = eval("(" + data + ")");

		return data;
	},

	// Serialize an array of form elements or a set of
	// key/values into a query string
	param: function( a ) {
		var s = [];

		// If an array was passed in, assume that it is an array
		// of form elements
		if ( a.constructor == Array || a.jquery )
			// Serialize the form elements
			jQuery.each( a, function(){
				s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
			});

		// Otherwise, assume that it's an object of key/value pairs
		else
			// Serialize the key/values
			for ( var j in a )
				// If the value is an array then the key names need to be repeated
				if ( a[j] && a[j].constructor == Array )
					jQuery.each( a[j], function(){
						s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
					});
				else
					s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );

		// Return the resulting serialization
		return s.join("&").replace(/%20/g, "+");
	}

});
jQuery.fn.extend({
	show: function(speed,callback){
		return speed ?
			this.animate({
				height: "show", width: "show", opacity: "show"
			}, speed, callback) :
			
			this.filter(":hidden").each(function(){
				this.style.display = this.oldblock || "";
				if ( jQuery.css(this,"display") == "none" ) {
					var elem = jQuery("<" + this.tagName + " />").appendTo("body");
					this.style.display = elem.css("display");
					// handle an edge condition where css is - div { display:none; } or similar
					if (this.style.display == "none")
						this.style.display = "block";
					elem.remove();
				}
			}).end();
	},
	
	hide: function(speed,callback){
		return speed ?
			this.animate({
				height: "hide", width: "hide", opacity: "hide"
			}, speed, callback) :
			
			this.filter(":visible").each(function(){
				this.oldblock = this.oldblock || jQuery.css(this,"display");
				this.style.display = "none";
			}).end();
	},

	// Save the old toggle function
	_toggle: jQuery.fn.toggle,
	
	toggle: function( fn, fn2 ){
		return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
			this._toggle( fn, fn2 ) :
			fn ?
				this.animate({
					height: "toggle", width: "toggle", opacity: "toggle"
				}, fn, fn2) :
				this.each(function(){
					jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
				});
	},
	
	slideDown: function(speed,callback){
		return this.animate({height: "show"}, speed, callback);
	},
	
	slideUp: function(speed,callback){
		return this.animate({height: "hide"}, speed, callback);
	},

	slideToggle: function(speed, callback){
		return this.animate({height: "toggle"}, speed, callback);
	},
	
	fadeIn: function(speed, callback){
		return this.animate({opacity: "show"}, speed, callback);
	},
	
	fadeOut: function(speed, callback){
		return this.animate({opacity: "hide"}, speed, callback);
	},
	
	fadeTo: function(speed,to,callback){
		return this.animate({opacity: to}, speed, callback);
	},
	
	animate: function( prop, speed, easing, callback ) {
		var optall = jQuery.speed(speed, easing, callback);

		return this[ optall.queue === false ? "each" : "queue" ](function(){
			if ( this.nodeType != 1)
				return false;

			var opt = jQuery.extend({}, optall);
			var hidden = jQuery(this).is(":hidden"), self = this;
			
			for ( var p in prop ) {
				if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
					return jQuery.isFunction(opt.complete) && opt.complete.apply(this);

				if ( p == "height" || p == "width" ) {
					// Store display property
					opt.display = jQuery.css(this, "display");

					// Make sure that nothing sneaks out
					opt.overflow = this.style.overflow;
				}
			}

			if ( opt.overflow != null )
				this.style.overflow = "hidden";

			opt.curAnim = jQuery.extend({}, prop);
			
			jQuery.each( prop, function(name, val){
				var e = new jQuery.fx( self, opt, name );

				if ( /toggle|show|hide/.test(val) )
					e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
				else {
					var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
						start = e.cur(true) || 0;

					if ( parts ) {
						var end = parseFloat(parts[2]),
							unit = parts[3] || "px";

						// We need to compute starting value
						if ( unit != "px" ) {
							self.style[ name ] = (end || 1) + unit;
							start = ((end || 1) / e.cur(true)) * start;
							self.style[ name ] = start + unit;
						}

						// If a +=/-= token was provided, we're doing a relative animation
						if ( parts[1] )
							end = ((parts[1] == "-=" ? -1 : 1) * end) + start;

						e.custom( start, end, unit );
					} else
						e.custom( start, val, "" );
				}
			});

			// For JS strict compliance
			return true;
		});
	},
	
	queue: function(type, fn){
		if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
			fn = type;
			type = "fx";
		}

		if ( !type || (typeof type == "string" && !fn) )
			return queue( this[0], type );

		return this.each(function(){
			if ( fn.constructor == Array )
				queue(this, type, fn);
			else {
				queue(this, type).push( fn );
			
				if ( queue(this, type).length == 1 )
					fn.apply(this);
			}
		});
	},

	stop: function(clearQueue, gotoEnd){
		var timers = jQuery.timers;

		if (clearQueue)
			this.queue([]);

		this.each(function(){
			// go in reverse order so anything added to the queue during the loop is ignored
			for ( var i = timers.length - 1; i >= 0; i-- )
				if ( timers[i].elem == this ) {
					if (gotoEnd)
						// force the next step to be the last
						timers[i](true);
					timers.splice(i, 1);
				}
		});

		// start the next in the queue if the last step wasn't forced
		if (!gotoEnd)
			this.dequeue();

		return this;
	}

});

var queue = function( elem, type, array ) {
	if ( !elem )
		return undefined;

	type = type || "fx";

	var q = jQuery.data( elem, type + "queue" );

	if ( !q || array )
		q = jQuery.data( elem, type + "queue", 
			array ? jQuery.makeArray(array) : [] );

	return q;
};

jQuery.fn.dequeue = function(type){
	type = type || "fx";

	return this.each(function(){
		var q = queue(this, type);

		q.shift();

		if ( q.length )
			q[0].apply( this );
	});
};

jQuery.extend({
	
	speed: function(speed, easing, fn) {
		var opt = speed && speed.constructor == Object ? speed : {
			complete: fn || !fn && easing || 
				jQuery.isFunction( speed ) && speed,
			duration: speed,
			easing: fn && easing || easing && easing.constructor != Function && easing
		};

		opt.duration = (opt.duration && opt.duration.constructor == Number ? 
			opt.duration : 
			{ slow: 600, fast: 200 }[opt.duration]) || 400;
	
		// Queueing
		opt.old = opt.complete;
		opt.complete = function(){
			if ( opt.queue !== false )
				jQuery(this).dequeue();
			if ( jQuery.isFunction( opt.old ) )
				opt.old.apply( this );
		};
	
		return opt;
	},
	
	easing: {
		linear: function( p, n, firstNum, diff ) {
			return firstNum + diff * p;
		},
		swing: function( p, n, firstNum, diff ) {
			return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
		}
	},
	
	timers: [],
	timerId: null,

	fx: function( elem, options, prop ){
		this.options = options;
		this.elem = elem;
		this.prop = prop;

		if ( !options.orig )
			options.orig = {};
	}

});

jQuery.fx.prototype = {

	// Simple function for setting a style value
	update: function(){
		if ( this.options.step )
			this.options.step.apply( this.elem, [ this.now, this ] );

		(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );

		// Set display property to block for height/width animations
		if ( this.prop == "height" || this.prop == "width" )
			this.elem.style.display = "block";
	},

	// Get the current size
	cur: function(force){
		if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
			return this.elem[ this.prop ];

		var r = parseFloat(jQuery.css(this.elem, this.prop, force));
		return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
	},

	// Start an animation from one number to another
	custom: function(from, to, unit){
		this.startTime = (new Date()).getTime();
		this.start = from;
		this.end = to;
		this.unit = unit || this.unit || "px";
		this.now = this.start;
		this.pos = this.state = 0;
		this.update();

		var self = this;
		function t(gotoEnd){
			return self.step(gotoEnd);
		}

		t.elem = this.elem;

		jQuery.timers.push(t);

		if ( jQuery.timerId == null ) {
			jQuery.timerId = setInterval(function(){
				var timers = jQuery.timers;
				
				for ( var i = 0; i < timers.length; i++ )
					if ( !timers[i]() )
						timers.splice(i--, 1);

				if ( !timers.length ) {
					clearInterval( jQuery.timerId );
					jQuery.timerId = null;
				}
			}, 13);
		}
	},

	// Simple 'show' function
	show: function(){
		// Remember where we started, so that we can go back to it later
		this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
		this.options.show = true;

		// Begin the animation
		this.custom(0, this.cur());

		// Make sure that we start at a small width/height to avoid any
		// flash of content
		if ( this.prop == "width" || this.prop == "height" )
			this.elem.style[this.prop] = "1px";
		
		// Start by showing the element
		jQuery(this.elem).show();
	},

	// Simple 'hide' function
	hide: function(){
		// Remember where we started, so that we can go back to it later
		this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
		this.options.hide = true;

		// Begin the animation
		this.custom(this.cur(), 0);
	},

	// Each step of an animation
	step: function(gotoEnd){
		var t = (new Date()).getTime();

		if ( gotoEnd || t > this.options.duration + this.startTime ) {
			this.now = this.end;
			this.pos = this.state = 1;
			this.update();

			this.options.curAnim[ this.prop ] = true;

			var done = true;
			for ( var i in this.options.curAnim )
				if ( this.options.curAnim[i] !== true )
					done = false;

			if ( done ) {
				if ( this.options.display != null ) {
					// Reset the overflow
					this.elem.style.overflow = this.options.overflow;
				
					// Reset the display
					this.elem.style.display = this.options.display;
					if ( jQuery.css(this.elem, "display") == "none" )
						this.elem.style.display = "block";
				}

				// Hide the element if the "hide" operation was done
				if ( this.options.hide )
					this.elem.style.display = "none";

				// Reset the properties, if the item has been hidden or shown
				if ( this.options.hide || this.options.show )
					for ( var p in this.options.curAnim )
						jQuery.attr(this.elem.style, p, this.options.orig[p]);
			}

			// If a callback was provided, execute it
			if ( done && jQuery.isFunction( this.options.complete ) )
				// Execute the complete function
				this.options.complete.apply( this.elem );

			return false;
		} else {
			var n = t - this.startTime;
			this.state = n / this.options.duration;

			// Perform the easing function, defaults to swing
			this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
			this.now = this.start + ((this.end - this.start) * this.pos);

			// Perform the next step of the animation
			this.update();
		}

		return true;
	}

};

jQuery.fx.step = {
	scrollLeft: function(fx){
		fx.elem.scrollLeft = fx.now;
	},

	scrollTop: function(fx){
		fx.elem.scrollTop = fx.now;
	},

	opacity: function(fx){
		jQuery.attr(fx.elem.style, "opacity", fx.now);
	},

	_default: function(fx){
		fx.elem.style[ fx.prop ] = fx.now + fx.unit;
	}
};
// The Offset Method
// Originally By Brandon Aaron, part of the Dimension Plugin
// http://jquery.com/plugins/project/dimensions
jQuery.fn.offset = function() {
	var left = 0, top = 0, elem = this[0], results;
	
	if ( elem ) with ( jQuery.browser ) {
		var parent       = elem.parentNode, 
		    offsetChild  = elem,
		    offsetParent = elem.offsetParent, 
		    doc          = elem.ownerDocument,
		    safari2      = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent),
		    fixed        = jQuery.css(elem, "position") == "fixed";
	
		// Use getBoundingClientRect if available
		if ( elem.getBoundingClientRect ) {
			var box = elem.getBoundingClientRect();
		
			// Add the document scroll offsets
			add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
				box.top  + Math.max(doc.documentElement.scrollTop,  doc.body.scrollTop));
		
			// IE adds the HTML element's border, by default it is medium which is 2px
			// IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
			// IE 7 standards mode, the border is always 2px
			// This border/offset is typically represented by the clientLeft and clientTop properties
			// However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
			// Therefore this method will be off by 2px in IE while in quirksmode
			add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop );
	
		// Otherwise loop through the offsetParents and parentNodes
		} else {
		
			// Initial element offsets
			add( elem.offsetLeft, elem.offsetTop );
			
			// Get parent offsets
			while ( offsetParent ) {
				// Add offsetParent offsets
				add( offsetParent.offsetLeft, offsetParent.offsetTop );
			
				// Mozilla and Safari > 2 does not include the border on offset parents
				// However Mozilla adds the border for table or table cells
				if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
					border( offsetParent );
					
				// Add the document scroll offsets if position is fixed on any offsetParent
				if ( !fixed && jQuery.css(offsetParent, "position") == "fixed" )
					fixed = true;
			
				// Set offsetChild to previous offsetParent unless it is the body element
				offsetChild  = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
				// Get next offsetParent
				offsetParent = offsetParent.offsetParent;
			}
		
			// Get parent scroll offsets
			while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
				// Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
				if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) )
					// Subtract parent scroll offsets
					add( -parent.scrollLeft, -parent.scrollTop );
			
				// Mozilla does not add the border for a parent that has overflow != visible
				if ( mozilla && jQuery.css(parent, "overflow") != "visible" )
					border( parent );
			
				// Get next parent
				parent = parent.parentNode;
			}
		
			// Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
			// Mozilla doubles body offsets with a non-absolutely positioned offsetChild
			if ( (safari2 && (fixed || jQuery.css(offsetChild, "position") == "absolute")) || 
				(mozilla && jQuery.css(offsetChild, "position") != "absolute") )
					add( -doc.body.offsetLeft, -doc.body.offsetTop );
			
			// Add the document scroll offsets if position is fixed
			if ( fixed )
				add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
					Math.max(doc.documentElement.scrollTop,  doc.body.scrollTop));
		}

		// Return an object with top and left properties
		results = { top: top, left: left };
	}

	function border(elem) {
		add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) );
	}

	function add(l, t) {
		left += parseInt(l) || 0;
		top += parseInt(t) || 0;
	}

	return results;
};
})();

/* NEXT FILE : D:\WWWSource\Site\App_Scripts\UI\Render.js************************************************************/

/**
* @class render 1.2.3: custom render controls - http://labs.easy-forex.com
* author: (basil@easy-forex.com)
* description: developed and tested on jQuery 1.2.1, support and fixes from jQuery 1.2.3
* 
* $date: 2008-02-13 12:33:25 -0500 (wed, 13 feb 2008) $
* $rev: 11355 $
*/

// global variables bug #4536
var messageShowen = false;
var animationProcess = false;
var isFreezed = false;

jQuery.fn.render = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    var controlType = arg.controlType;

    var body = $('body');

    var dataSource = arg.dataSource;
    var updateSource = arg.updateSource;
    var dataValue = arg.dataValue;
    var onChange = arg.onChange;
    var onCheck = arg.onCheck;
    var onSet = arg.onSet;
    var onClick = arg.onClick;
    var onComplete = arg.onComplete;
    var onDefault = arg.onDefault;
    var onUp = arg.onUp;
    var onDown = arg.onDown;
    var checkedStatus = arg.checkedStatus;
    var startScrollAfterItem = arg.startScrollAfterItem;
    var scrollStep = arg.scrollStep;
    var visibleWidth = arg.visibleWidth;
    var visibleHeight = arg.visibleHeight;
    var specificHeight = arg.specificHeight;
    var specificWidth = arg.specificWidth;
    var selectedIndex = arg.selectedIndex;
    var buttonText = arg.buttonText;
    var freezeTime = arg.freezeTime;
    var disableMode = arg.disableMode;
    var fixedSize = arg.fixedSize;
    var customizeErrorTitle = arg.customizeErrorTitle;
    var smallNumeric = arg.smallNumeric;
    var customizeMax = arg.customizeMax;
    var minValue = arg.minValue;
    var maxValue = arg.maxValue;
    var startDate = arg.startDate;
    var endDate = arg.endDate;
    var defaultDate = arg.defaultDate;
    var nonBusinessDates = arg.nonBusinessDates;
    var nonWeekEndDates = arg.nonWeekEndDates;

    if (controlType != null && controlType.toLowerCase() == 'combobox') {

        var _width = 78; // default width
        var _itemHeight = 18;
        var _durationTime = 36;

        var obj = $(this[0]);

        // option for html direction
        var _left = 'left';
        var _right = 'right';

        if (body.css('direction') == 'rtl') { _left = 'right'; _right = 'left'; }

        // clear html
        obj.empty();
        var next = obj.siblings('.combo-box-box');
        if (next != null) next.remove();

        if (!obj.hasClass('combo-box')) obj.addClass('combo-box render');
        obj.css({ 'width': visibleWidth != null ? visibleWidth : _width });

        var selected = $.create('div', { 'class': 'combo-box-selected render' }, []);
        var button = $.create('div', { 'class': 'combo-box-button render' }, []);
        var box = $.create('div', { 'class': 'combo-box-box' }, []);
        var _box = $(box);
        var container = $.create('div', { 'class': 'render' }, []);
        var _container = $(container);
        var scroller = $.create('div', { 'class': 'combo-scroller render' }, []);

        var up = $.create('div', { 'class': 'combo-box-wheel-up render' }, []);
        var knob = $.create('div', { 'class': 'combo-box-wheel-knob render' }, []);
        var down = $.create('div', { 'class': 'combo-box-wheel-down render' }, []);

        var shaft = $.create('div', { 'style': 'position:absolute;width:15px;', 'class': 'render' }, []);

        // get dataSource
        if (!jQuery.isArray(dataSource)) return; // exception
        var node = dataSource;
        if (node.length > 0) {
            for (i = 0; i < node.length; i++) {
                var temp = node[i];
                if (temp.length > 1) {
                    var el = $('<div class="combo-box-item render" key=' + temp[0].toString() + ' index=' + i + '>' + temp[1].toString() + '</div>');
                    var last = null;
                    el.bind('click', function() {
                        selected.innerHTML = $(this)[0].innerHTML;

                        var t = obj.attr('selectedText');
                        var v = obj.attr('selectedValue');
                        obj.attr({ 'selectedText': $(this)[0].innerHTML, 'selectedValue': $(this).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': $(this).attr('index') }); // Add attribute value as selectedValue

                        // fix bug background 251007
                        if (!jQuery.isNull(startScrollAfterItem)) _container.children().css({ 'background': 'none' });
                        else _box.children().css({ 'background': 'none' });

                        $(this).css({ 'background': '#b5d690' });

                        _container.css({ 'top': 0 });

                        // callback
                        preventCallback(obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex'), obj.attr('selectedValue'), obj.attr('selectedText'))

                    });
                    if (selectedIndex != null && selectedIndex >= 0 && selectedIndex < node.length) {
                        if (i == selectedIndex) { $(el).css({ 'background': '#b5d690' }); }
                    }
                    if (!jQuery.isNull(startScrollAfterItem)) _box.append(_container.append(el));
                    else _box.append(el);
                }
            }

            if (selectedIndex != null && selectedIndex >= 0 && selectedIndex < node.length) {
                var i = parseInt(selectedIndex);
                obj.append($(selected).html(node[i][1])).attr({ 'selectedText': node[i][1], 'selectedValue': node[i][0], 'selectedIndex': i }); // add attribute value as selectedValue
            } else obj.attr({ 'selectedText': node[0][1], 'selectedValue': node[0][0], 'selectedIndex': 0 }).append($(selected).html(node[0][1])); // append selected
            // append button
            obj.append($(button));

            if (!jQuery.isNull(visibleWidth)) $(selected).css({ 'width': (visibleWidth - 20) });
            else $(selected).css({ 'width': ((obj.width() - $(button).width() || 15) - 4) });

            // temp variables
            var temped = null;
            var character = '';
            var z = 0;
            var t = obj.attr('selectedText');
            var v = obj.attr('selectedValue');

            var observableTrack = function(count) {
                if (!jQuery.isNull(startScrollAfterItem)) {

                    var invisibleHeight = $(container)[0].offsetHeight - (18 * startScrollAfterItem);
                    if (invisibleHeight <= 0) return;

                    var scrollHeight = (($(box).height() - $(up).height() - $(down).height()) - $(knob)[0].offsetHeight) - 4;
                    var currentTop = 0;

                    var newTop = currentTop - ((scrollStep * count) + (currentTop % scrollStep));

                    if (newTop > (-invisibleHeight)) {
                        _container.animate({ top: newTop }, 10);
                        $(knob).animate({ top: -((newTop / invisibleHeight) * scrollHeight) }, 10);
                    } else {
                        _container.animate({ top: -invisibleHeight }, 10);
                        $(knob).animate({ top: scrollHeight }, 10);
                    }
                }
            };

            var handle = function(delta) {
                if (delta < 0) {
                    if ((node.length - 1) != z) {
                        z = obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex')
                        if (z != -1 && z < node.length - 1) {
                            z++;
                            obj.attr({ 'selectedIndex': z });

                            observableTrack(z);
                            $(selected).html(node[z][1]).attr({ 'selectedText': node[z][1], 'selectedValue': node[z][0] }); // add attribute value as selectedValue

                            if (!jQuery.isNull(startScrollAfterItem)) {
                                _container.children().each(function(i, el) {
                                    if (i == z) {
                                        $(el).css({ 'background': '#b5d690' });
                                        obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                        // dispose and save to temped data
                                        temped = null
                                        temped = $(el);

                                    } else { $(el).css({ 'background': 'none' }); }
                                });
                            } else {
                                // reference if control don't have scroll
                                _box.children().each(function(i, el) {
                                    if (i == z) {
                                        $(el).css({ 'background': '#b5d690' });
                                        obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                        // dispose and save to temped data
                                        temped = null
                                        temped = $(el);
                                    } else { $(el).css({ 'background': 'none' }); }
                                });
                            }
                        }
                    }

                } else {

                    // upper wheel
                    if (obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex') >= 0) {

                        z = obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex')
                        z--;

                        obj.attr({ 'selectedIndex': z });

                        observableTrack(z);
                        $(selected).html(node[z][1]).attr({ 'selectedText': node[z][1], 'selectedValue': node[z][0] }); // add attribute value as selectedValue

                        if (!jQuery.isNull(startScrollAfterItem)) {
                            _container.children().each(function(i, el) {
                                if (i == z) {
                                    $(el).css({ 'background': '#b5d690' });
                                    obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                    // dispose and save to temped data
                                    temped = null
                                    temped = $(el);

                                } else { $(el).css({ 'background': 'none' }); }
                            });
                        } else {
                            // Reference if control don't have scroll
                            _box.children().each(function(i, el) {
                                if (i == z) {
                                    $(el).css({ 'background': '#b5d690' });
                                    obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                    // Dispose and save to temped data
                                    temped = null
                                    temped = $(el);

                                } else { $(el).css({ 'background': 'none' }); }
                            });
                        }
                    }
                }
            };

            var wheel = function(event) {
                var delta = 0;
                if (!event)
                    event = window.event;
                if (event.wheelDelta) {
                    delta = event.wheelDelta / 120;
                    // in Opera 9, delta differs in sign as compared to IE.
                    if (window.opera)
                        delta = -delta;
                } else if (event.detail) { // Mozilla case.
                    // in Mozilla, sign of delta is different than in IE. also, delta is multiple of 3.
                    delta = -event.detail / 3;
                }
                // if delta is nonzero, handle it. basically, delta is now positive if wheel was scrolled up,
                // and negative, if wheel was scrolled down.
                if (delta)
                    handle(delta);
                // prevent default actions caused by mouse wheel. that might be ugly, but we handle scrolls somehow
                // anyway, so don't bother here..
                if (event.preventDefault)
                    event.preventDefault();
                event.returnValue = false;
            };

            var preventCallback = function(preventIndex, preventKey, preventValue) {

                _box.hide();

                jQuery().unbind('click');
                jQuery().unbind('keypress');
                jQuery().unbind('keydown');

                jQuery().unmousewheel();

                if (onChange != null) {
                    onChange(preventIndex, preventKey, preventValue, obj);
                }
            };

            $([selected, button]).click(function() {

                if (arg.onClick != null) {
                    arg.onClick();
                    return;
                }

                jQuery().unbind('click');
                jQuery().unbind('keypress');
                jQuery().unbind('keydown');

                jQuery().unmousewheel();

                var elements = $('div.combo-box-box');
                elements.each(function(i, el) {
                    if (el != box) $(el).hide();
                });

                if (!_box.is(':visible')) {

                    _box.show();

                    var _last = null;
                    var index = 0;
                    var repeated = 0;

                    // Prototype function find element in array
                    Array.find = function(array, element) {
                        for (var i = index; i < array.length; i++) {
                            if (array[i][1].toString().substring(0, 1).toLowerCase() == element) {
                                return i;
                            }
                        }
                        return -1;
                    };

                    jQuery().mousewheel(function(e) { wheel(e) });

                    jQuery().bind('keydown', function(e) {
                        var code;
                        if (!e) var e = window.event;
                        if (e.keyCode) code = e.keyCode;
                        else if (e.which) code = e.which;

                        // Arrow up
                        if (code == 38) {
                            if (obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex') >= 0) {

                                z = obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex')
                                z--;

                                obj.attr({ 'selectedIndex': z });

                                observableTrack(z);

                                $(selected).html(node[z][1]).attr({ 'selectedText': node[z][1], 'selectedValue': node[z][0] }); // add attribute value as selectedValue

                                if (!jQuery.isNull(startScrollAfterItem)) {
                                    _container.children().each(function(i, el) {
                                        if (i == z) {
                                            $(el).css({ 'background': '#b5d690' });
                                            obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                            // Dispose and save to temped data
                                            temped = null
                                            temped = $(el);

                                        } else { $(el).css({ 'background': 'none' }); }
                                    });
                                } else {
                                    // Reference if control don't have scroll
                                    _box.children().each(function(i, el) {
                                        if (i == z) {
                                            $(el).css({ 'background': '#b5d690' });
                                            obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                            // dispose and save to temped data
                                            temped = null
                                            temped = $(el);

                                        } else { $(el).css({ 'background': 'none' }); }
                                    });
                                }
                            }
                        }

                        // arrow down
                        if (code == 40) {
                            if ((node.length - 1) != z) {

                                z = obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex')
                                if (z != -1 && z < node.length - 1) {
                                    z++;

                                    obj.attr({ 'selectedIndex': z });

                                    observableTrack(z);
                                    $(selected).html(node[z][1]).attr({ 'selectedText': node[z][1], 'selectedValue': node[z][0] }); // add attribute value as selectedValue

                                    if (!jQuery.isNull(startScrollAfterItem)) {
                                        _container.children().each(function(i, el) {
                                            if (i == z) {
                                                $(el).css({ 'background': '#b5d690' });
                                                obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                                // dispose and save to temped data
                                                temped = null
                                                temped = $(el);

                                            } else { $(el).css({ 'background': 'none' }); }
                                        });
                                    } else {
                                        // reference if control don't have scroll
                                        _box.children().each(function(i, el) {
                                            if (i == z) {
                                                $(el).css({ 'background': '#b5d690' });
                                                obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                                // dispose and save to temped data
                                                temped = null
                                                temped = $(el);
                                            } else { $(el).css({ 'background': 'none' }); }
                                        });
                                    }
                                }
                            }
                        }

                    });

                    jQuery().bind('keypress', function(e) {

                        var code;
                        if (!e) var e = window.event;
                        if (e.keyCode) code = e.keyCode;
                        else if (e.which) code = e.which;

                        if (code == 27 || code == 13) {
                            preventCallback(obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex'), obj.attr('selectedValue'), obj.attr('selectedText'))
                            z = 0;
                        }

                        character = String.fromCharCode(code);

                        if (_last != null && _last != character.toLowerCase()) {
                            index = 0;
                        }
                        _last = character.toLowerCase();

                        if (Array.find(node, character) != -1) {

                            var y = Array.find(node, character);
                            index = y + 1;

                            $(selected).html(node[y][1]).attr({ 'selectedText': node[y][1], 'selectedValue': node[y][0] }); // add attribute value as selectedValue

                            /*
                            *@ select item in list may be set
                            */

                            if (!jQuery.isNull(startScrollAfterItem)) {
                                _container.children().each(function(i, el) {
                                    if (i == y) {
                                        $(el).css({ 'background': '#b5d690' });
                                        obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                        observableTrack(i); // 

                                        // dispose and save to temped data
                                        temped = null
                                        temped = $(el);
                                    } else { $(el).css({ 'background': 'none' }); }
                                });
                            } else {

                                // reference if control don't have scroll
                                _box.children().each(function(i, el) {
                                    if (i == y) {
                                        $(el).css({ 'background': '#b5d690' });
                                        obj.attr({ 'selectedText': $(el).text(), 'selectedValue': $(el).attr('key'), 'prevText': t, 'prevValue': v, 'selectedIndex': i }); // add attribute value as selectedValue

                                        // dispose and save to temped data
                                        temped = null
                                        temped = $(el);
                                    } else { $(el).css({ 'background': 'none' }); }
                                });
                            }
                        }
                    });

                    jQuery().click(function(e) {
                        if (!e) var e = window.event;
                        var target = e.target != null ? e.target : e.srcElement;

                        // target point of mouse don't like to css class by specific unbind window events then close box
                        if (!$(target).hasClass('render')) {
                            preventCallback(obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex'), obj.attr('selectedValue'), obj.attr('selectedText'))
                            z = 0;
                        }
                    });

                    // reposition container + knob to current index or last selected index
                    if (!jQuery.isNull(selectedIndex)) {
                        if (obj.attr('selectedIndex') > 0) {
                            observableTrack(obj.attr('selectedIndex'));
                        }
                    }

                } else {

                    preventCallback(obj.attr('selectedIndex') == undefined ? 0 : obj.attr('selectedIndex'), obj.attr('selectedValue'), obj.attr('selectedText'))
                    z = 0;
                }

                // by default up container + knob to top
                _container.css({ 'top': 0 });
                $(knob)[0].style.top = '0px';

            });

            // 
            if (!jQuery.isNull(startScrollAfterItem)) {
                var s = parseInt(startScrollAfterItem);

                if (s == node.length
                        || s > node.length) {
                    _container.children().hover(function() {
                        $(this).addClass("hover")
                    }, function() { $(this).removeClass("hover") });
                } else {
                    $(container).children().hover(function() {
                        $(this).addClass("hover")
                    }, function() { $(this).removeClass("hover") });

                    if (!jQuery.isNull(visibleWidth)) {

                        _container.css({ 'width': (visibleWidth - 20), 'float': _left });
                    } else _container.css({ 'width': ((obj.width() - $(button).width() || 15) - 4), 'float': _left });

                    $(scroller).append(shaft).append(up).append(knob).append(down);
                    $(shaft).css({ 'margin-top': 15, 'height': (_itemHeight * s) - 34 });

                    var ignoreFunction = function() { return false };
                    var mouseDown = function(e) {
                        if (e == null) e = window.event;
                        var target = e.target != null ? e.target : e.srcElement;
                        if (e.button == 1 && window.event != null || e.button == 0) {
                            startY = e.clientY;
                            offsetY = jQuery.num(target.style.top);
                            body.mouseup(mouseUp).mousemove(mouseMove);
                            this.blur();
                            return false;
                        }
                    };

                    var mouseUp = function() {
                        body.unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
                    };

                    $(knob).css({ 'position': 'relative' });
                    _container.css({ 'position': 'absolute' });

                    var mouseMove = function(e) {
                        if (e == null) var e = window.event;
                        var newTop = (offsetY + e.clientY - startY);
                        newTop = newTop < 0 ? 0 : (newTop > ((_itemHeight * s - 4) - 50) ? ((_itemHeight * s - 4) - 50) : newTop);

                        // drag knob
                        $(knob)[0].style.top = newTop + 'px';
                        var invisibleHeight = $(container)[0].offsetHeight - (_itemHeight * s - 4);
                        var temp = ((_itemHeight * s - 4) - 50);

                        $(container)[0].style.top = (-((newTop / temp) * invisibleHeight)) + 'px'; // drag container
                    };

                    $(knob).mousedown(mouseDown); // start knob
                    $(down).css({ 'position': 'relative', 'top': ((_itemHeight * s) - 4) - 50 });

                    var trackIt = function(o, p, stepNumber) {
                        var invisibleHeight = $(container)[0].offsetHeight - (18 * startScrollAfterItem);
                        if (p != undefined) {
                            if (p == 'down') { o = $(down)[0]; } else { o = $(up)[0]; }
                        }
                        if (invisibleHeight <= 0) return;

                        var scrollHeight = (($(box).height() - $(up).height() - $(down).height()) - $(knob)[0].offsetHeight) - 4;
                        var stepOver = !jQuery.isNull(stepNumber) ? (stepNumber * scrollStep) : scrollStep;


                        var containerTop = jQuery.num($(container)[0].style.top);
                        if ((containerTop == 0 && o == $(up)[0]) || (containerTop == -invisibleHeight && o == $(down)[0])) return;

                        var newTop = (o == $(down)[0] ? containerTop - (stepOver + (containerTop % stepOver)) : containerTop + (containerTop % stepOver == 0 ? stepOver : -(containerTop % stepOver)));
                        newTop = (o == $(up)[0] ? Math.min(newTop, 0) : Math.max(newTop, -invisibleHeight));
                        var thumbTop = -((newTop / invisibleHeight) * scrollHeight);

                        _container.animate({ top: newTop }, _durationTime, function() {
                            $(shaft).css({ 'background': '' });
                        });
                        $(knob).animate({ top: thumbTop }, _durationTime);
                    };

                    $.each([$(up), $(down)], function(i, el) {
                        el.mousehold(function() {
                            trackIt(this, undefined, 1);
                        });
                    });

                    var stepNumber = 0;
                    if (!jQuery.isNull(startScrollAfterItem))
                        stepNumber = startScrollAfterItem;

                    $(shaft).mousedown(function(e) {
                        $(shaft).css({ 'background': '#B5D690' });
                        if (e == null) e = window.event;
                        var target = e.target != null ? e.target : e.srcElement;
                        if (e.button == 1 && window.event != null || e.button == 0) {
                            startY = e.clientY;
                            offsetY = $(target).offset().top;

                            if (startY > $(knob).offset().top) {
                                trackIt(this, 'down', stepNumber);
                            } else {
                                trackIt(this, 'up', stepNumber);
                            }
                        }
                    }).mouseup(function() {
                        $(shaft).css({ 'background': '' });
                    });

                    _box.append($(scroller)).css({ 'height': (_itemHeight * s), 'overflow': 'hidden' });
                    $(scroller).css({ 'float': _right, 'height': (_itemHeight * s) - 4 });
                }
            } else {
                _box.children().hover(function() {
                    $(this).addClass("hover")
                }, function() { $(this).removeClass("hover") });
            }

            if (!jQuery.isNull(visibleWidth)) {
                if (!jQuery.isNull(startScrollAfterItem)) {
                    var s = parseInt(startScrollAfterItem);
                    if (s == node.length
                                || s > node.length) {
                        // do nothing
                    } else {
                        $(selected).css({ 'width': (visibleWidth - 20) });
                        _container.css({ 'width': (visibleWidth - 18) });
                    }
                }

                $(selected).css({ 'width': (visibleWidth - 20) });
                obj.after($(box).css({ 'position': 'absolute', 'width': visibleWidth }));
                // Fix for Google Chrome (BETA)
                $(box).hide();
            } else {
                obj.after($(box).css({ 'position': 'absolute', 'width': obj.width() }));
                // Fix for Google Chrome (BETA)
                $(box).hide();
            }

            obj.attr({ 'isEmpty': 'false' });

        } else {

            /*
            * @ fix by Basil
            */

            obj.css({ 'background': '#cccccc', 'line-height': '18px' }).html("No Data").attr({ 'isEmpty': 'true', 'selectedText': 'No Data', 'selectedValue': '0' });
        }
    }

    // ui checkBox
    if (controlType != null && controlType.toLowerCase() == 'checkbox') {
        //            var obj = $(this[0]);
        //            $(obj).empty(); // clear html
        //            if(!$(obj).hasClass('check-box')) $(obj).addClass('check-box');
        //            if(!jQuery.isNull(checkedStatus)) $(obj).addClass('checked').attr({'checked':'true'});

        //            $(obj).bind('click', function(e){
        //                    if($(this).hasClass('checked')) {
        //                            $(this).removeClass('checked').attr({'checked':'false'});
        //                    } else { $(this).addClass('checked').attr({'checked':'true'}); 
        //                        if(!jQuery.isNull(onCheck)) { onCheck(); }}
        //            });
    }

    // ui scrollBar
    if (controlType != null && controlType.toLowerCase() == 'scrollbar') {

        var obj = $(this[0]);
        var context = obj.html();

        obj.empty(); // clear html
        var _durationTime = 90;

        var box = $.create('div', { 'class': 'scrollbar-box' }, []); // box
        var container = $.create('div', { 'class': 'scrollbar-container' }, []); // container
        var _container = $(container);
        var scroller = $.create('div', { 'class': 'scrollbar-scroller' }, []); // scroller
        var _scroller = $(scroller);

        var shaft = $.create('div', { 'style': 'position:absolute;width:15px;' }, []);
        // wheels
        var up = $.create('div', { 'class': 'wheel-up' }, []);
        var knob = null;
        if (visibleHeight < 120) {
            knob = $.create('div', { 'class': 'wheel-knob-medium' }, []);
        } else { knob = $.create('div', { 'class': 'wheel-knob-large' }, []); }
        var down = $.create('div', { 'class': 'wheel-down' }, []);

        var _knob = $(knob)

        $(scroller).append(shaft).append(up).append(_knob.css({ 'position': 'relative' })).append(down);

        if (_container[0].offsetHeight != 0 && specificHeight == null) {
            var invisibleHeight = _container[0].offsetHeight - visibleHeight;
            obj.css({ 'height': visibleHeight });
            _scroller.css({ 'height': visibleHeight });
            $(down).css({ 'position': 'relative', 'top': visibleHeight - 28 - _knob.height() });
            $(shaft).css({ 'margin-top': 14, 'height': visibleHeight - 28 });
        } else {
            var invisibleHeight = specificHeight - visibleHeight;
            obj.css({ 'height': visibleHeight });
            _scroller.css({ 'height': visibleHeight });
            $(shaft).css({ 'margin-top': 14, 'height': visibleHeight - 28 });
            if (visibleHeight < 120) $(down).css({ 'position': 'relative', 'top': (visibleHeight - 59) });
            else $(down).css({ 'position': 'relative', 'top': (visibleHeight - 87) });
        }

        obj.append(_scroller).append(box);

        $(box).css({ 'height': visibleHeight });

        var ignoreFunction = function() { return false };
        var mouseDown = function(e) {
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = jQuery.num(target.style.top);
                body.mouseup(mouseUp).mousemove(mouseMove);
                //if (jQuery.browser.msie) $body.bind('dragstart', ignoreFunction).bind('selectstart', ignoreFunction);
                this.blur();
                return false;
            }
        };

        var mouseUp = function() {
            body.unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
            //if (jQuery.browser.msie) $body.unbind('dragstart', ignoreFunction).unbind('selectstart', ignoreFunction);
        };

        var mouseMove = function(e) {
            var invisibleHeight = (_container[0].offsetHeight != 0 && specificHeight == null ? _container[0].offsetHeight : specificHeight) - visibleHeight;
            if (invisibleHeight <= 0) return;

            if (e == null) var e = window.event;
            var newTop = (offsetY + e.clientY - startY);
            var temp = visibleHeight - $(up).height() - $(down).height() - $(knob).height();
            newTop = newTop < 0 ? 0 : (newTop > temp ? temp : newTop);
            knob.style.top = newTop + 'px'; // drag knob
            container.style.top = (-((newTop / temp) * invisibleHeight)) + 'px';    //(-((newTop / temp) * invisibleHeight)) + 'px'; // drag container
        };

        _knob.mousedown(mouseDown);

        var trackIt = function(o, p, stepNumber) {
            var invisibleHeight = null;
            if (parseInt(_container[0].offsetHeight) != 0 && specificHeight == null) {
                invisibleHeight = _container[0].offsetHeight - visibleHeight;
            } else {
                invisibleHeight = specificHeight - visibleHeight;
            }

            if (p != undefined) {
                if (p == 'down') { o = $(down)[0]; } else { o = $(up)[0]; }
            }

            if (invisibleHeight <= 0) return;
            //var scrollHeight = (parseInt(visibleHeight)-0)-$(up).height()-$(down).height()-$(knob).height();
            var scrollHeight = (visibleHeight - $(up).height() - $(down).height()) - $(knob)[0].offsetHeight;

            var stepOver = !jQuery.isNull(stepNumber) ? (stepNumber * scrollStep) : scrollStep;
            var containerTop = jQuery.num($(container)[0].style.top);
            if ((containerTop == 0 && o == $(up)[0]) || (containerTop == -invisibleHeight && o == $(down)[0])) return;

            var newTop = (o == $(down)[0] ? containerTop - (stepOver + (containerTop % stepOver)) : containerTop + (containerTop % stepOver == 0 ? stepOver : -(containerTop % stepOver)));
            newTop = (o == $(up)[0] ? Math.min(newTop, 0) : Math.max(newTop, -invisibleHeight));
            var thumbTop = -((newTop / invisibleHeight) * scrollHeight);

            _container.animate({ top: newTop }, _durationTime, function() {
                $(shaft).css({ 'background': '' });
            });
            $(knob).animate({ top: thumbTop }, _durationTime);
        };

        $.each([$(up), $(down)], function(i, el) {
            el.mousehold(function() {
                trackIt(this, undefined, 1);
            });
        });

        $(shaft).mousedown(function(e) {
            $(shaft).css({ 'background': '#dfdfdf' });
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = $(target).offset().top;

                if (startY > $(knob).offset().top) {
                    trackIt(this, 'down', 6);
                } else {
                    trackIt(this, 'up', 6);
                }
            }
        }).mouseup(function(e) {
            $(shaft).css({ 'background': '' });
        });

        if (!jQuery.isNull(specificWidth)) { _container.css({ 'width': (specificWidth - 17) }); }
        else {
            if (obj.width() != 0 && $(scroller).width() != 0) _container.css({ 'width': (obj.width() - $(scroller).width() - 3) });
        }

        $(box).append(_container.html(context));

        _container.width();
    }

    if (controlType != null && controlType.toLowerCase() == 'textscroll') {

        var _durationTimer = 90;
        //var $body = jQuery('body');
        var context = $(this[0]).html();
        var obj = $(this[0]);
        obj.empty(); // clear html
        obj.css({ 'width': parseInt(visibleWidth), 'height': parseInt(visibleHeight) });

        var box = $.create('div', { 'class': 'text-scroller-box' }, []); // box
        var container = $.create('div', { 'class': 'text-scroller-container' }, []); // container
        var _container = $(container);
        var scroller = $.create('div', { 'class': 'text-scroller-scroller' }, []); // scroller

        // wheels
        var up = $.create('div', { 'class': 'wheel-up' }, []);
        var knob = $.create('div', { 'class': 'wheel-knob' }, []);
        var down = $.create('div', { 'class': 'wheel-down' }, []);

        $(scroller).append(up).append($(knob).css({ 'position': 'relative' })).append(down);

        var ignoreFunction = function() { return false };
        var mouseDown = function(e) {
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = jQuery.num(target.style.top);
                body.mouseup(mouseUp).mousemove(mouseMove);

                this.blur();
                return false;
            }
        };

        var mouseUp = function(e) {
            body.unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
        };

        var mouseMove = function(e) {
            var invisibleHeight = $(container)[0].offsetHeight - $(scroller).height()
            if (invisibleHeight <= 0) return;

            if (e == null) var e = window.event;
            var newTop = (offsetY + e.clientY - startY);
            var temp = $(scroller).height() - $(up).height() - $(down).height() - $(knob).height();
            newTop = newTop < 0 ? 0 : (newTop > temp ? temp : newTop);
            $(knob)[0].style.top = newTop + 'px'; // drag knob
            $(container)[0].style.top = (-((newTop / temp) * invisibleHeight)) + 'px'; // move container
        };

        $(knob).mousedown(mouseDown); // start knob

        var trackIt = function(obj) {
            var invisibleHeight = $(container)[0].offsetHeight - 80;
            if (invisibleHeight <= 0) return;
            var scrollHeight = ($(scroller).height() - $(up).height() - $(down).height()) - $(knob)[0].offsetHeight;
            var curTop = jQuery.num($(container)[0].style.top);
            if ((curTop == 0 && obj == $(up)[0]) || (curTop == -invisibleHeight && obj == $(down)[0])) return;
            var newTop = (obj == $(down)[0] ? curTop - (18 + (curTop % 18)) : curTop + (curTop % 18 == 0 ? 18 : -(curTop % 18)));
            newTop = (obj == $(up)[0] ? Math.min(newTop, 0) : Math.max(newTop, -invisibleHeight));
            var newTop2 = -((newTop / invisibleHeight) * scrollHeight);
            // move
            _container.animate({ top: newTop }, _durationTime);
            $(knob).animate({ top: newTop2 }, _durationTime);
        };

        $.each([$(up), $(down)], function(i, obj) {
            obj.mousehold(function() {
                trackIt(this);
            });
        });

        $(down).css({ 'position': 'relative', 'top': (visibleHeight - 52) });
        $(box).append($(container).html(context));

        obj.append(box).append(scroller);
        $(box).css({ 'height': visibleHeight, 'width': (visibleWidth - 17) });
        $(scroller).css({ 'height': (visibleHeight - 2) });
    }

    // Only left scroller (for Reuters News)
    if (controlType != null && controlType.toLowerCase() == 'textscrollleft') {
        var _durationTimer = 90;
        //var $body = jQuery('body');
        var context = $(this[0]).html();
        var obj = $(this[0]);
        obj.empty(); // clear html
        obj.css({ 'width': parseInt(visibleWidth), 'height': parseInt(visibleHeight) });

        var box = $.create('div', { 'class': 'text-scroller-box-left' }, []); // box
        var container = $.create('div', { 'class': 'text-scroller-container-left' }, []); // container
        var _container = $(container);
        var scroller = $.create('div', { 'class': 'text-scroller-scroller-left' }, []); // scroller

        // wheels
        var up = $.create('div', { 'class': 'wheel-up' }, []);
        var knob = $.create('div', { 'class': 'wheel-knob' }, []);
        var down = $.create('div', { 'class': 'wheel-down' }, []);

        $(scroller).append(up).append($(knob).css({ 'position': 'relative' })).append(down);

        var ignoreFunction = function() { return false };
        var mouseDown = function(e) {
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = jQuery.num(target.style.top);
                body.mouseup(mouseUp).mousemove(mouseMove);

                this.blur();
                return false;
            }
        };

        var mouseUp = function(e) {
            body.unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
        };

        var mouseMove = function(e) {
            var invisibleHeight = $(container)[0].offsetHeight - $(scroller).height()
            if (invisibleHeight <= 0) return;

            if (e == null) var e = window.event;
            var newTop = (offsetY + e.clientY - startY);
            var temp = $(scroller).height() - $(up).height() - $(down).height() - $(knob).height();
            newTop = newTop < 0 ? 0 : (newTop > temp ? temp : newTop);
            $(knob)[0].style.top = newTop + 'px'; // drag knob
            $(container)[0].style.top = (-((newTop / temp) * invisibleHeight)) + 'px'; // move container
        };

        $(knob).mousedown(mouseDown); // start knob

        var trackIt = function(obj) {
            var invisibleHeight = $(container)[0].offsetHeight - 80;
            if (invisibleHeight <= 0) return;
            var scrollHeight = ($(scroller).height() - $(up).height() - $(down).height()) - $(knob)[0].offsetHeight;
            var curTop = jQuery.num($(container)[0].style.top);
            if ((curTop == 0 && obj == $(up)[0]) || (curTop == -invisibleHeight && obj == $(down)[0])) return;
            var newTop = (obj == $(down)[0] ? curTop - (18 + (curTop % 18)) : curTop + (curTop % 18 == 0 ? 18 : -(curTop % 18)));
            newTop = (obj == $(up)[0] ? Math.min(newTop, 0) : Math.max(newTop, -invisibleHeight));
            var newTop2 = -((newTop / invisibleHeight) * scrollHeight);
            // move
            _container.animate({ top: newTop }, _durationTime);
            $(knob).animate({ top: newTop2 }, _durationTime);
        };

        $.each([$(up), $(down)], function(i, obj) {
            obj.mousehold(function() {
                trackIt(this);
            });
        });

        $(down).css({ 'position': 'relative', 'top': (visibleHeight - 52) });
        $(box).append($(container).html(context));

        obj.append(box).append(scroller);
        $(box).css({ 'height': visibleHeight, 'width': (visibleWidth - 17) });
        $(scroller).css({ 'height': (visibleHeight - 2) });
    }

    // ui customize
    if (controlType != null && controlType.toLowerCase() == 'customize') {
        var scrollStep = 18;
        var _durationTime = 90;
        var $body = jQuery('body');

        $(this[0]).empty();
        $(this[1]).empty();

        $(this[0]).css({ 'width': parseInt(visibleWidth), 'height': parseInt(visibleHeight) });
        $(this[1]).css({ 'width': parseInt(visibleWidth), 'height': parseInt(visibleHeight) });

        // elements
        var box1 = $.create('div', { 'class': 'text-scroller-box' }, []);
        var box2 = $.create('div', { 'class': 'text-scroller-box' }, []);
        var container1 = $.create('div', { 'class': 'text-scroller-container container1' }, []);
        var container2 = $.create('div', { 'class': 'text-scroller-container container2' }, []);
        var scroller1 = $.create('div', { 'class': 'text-scroller-scroller' }, []);
        var scroller2 = $.create('div', { 'class': 'text-scroller-scroller' }, []);

        // wheels
        var up1 = $.create('div', { 'class': 'wheel-up' }, []);
        var up2 = $.create('div', { 'class': 'wheel-up' }, []);
        var knob1 = $.create('div', { 'class': 'wheel-knob' }, []);
        var knob2 = $.create('div', { 'class': 'wheel-knob' }, []);
        var down1 = $.create('div', { 'class': 'wheel-down' }, []);
        var down2 = $.create('div', { 'class': 'wheel-down' }, []);
        var shaft1 = $.create('div', { 'style': 'position:absolute;width:15px;' }, []);
        var shaft2 = $.create('div', { 'style': 'position:absolute;width:15px;' }, []);

        $(scroller1).append(shaft1);
        $(scroller2).append(shaft2);

        $(scroller1).append(up1);
        $(scroller2).append(up2);
        $(scroller1).append($(knob1).css({ 'position': 'relative' }));
        $(scroller2).append($(knob2).css({ 'position': 'relative' }));
        $(scroller1).append(down1);
        $(scroller2).append(down2);

        var addButton = $('#add-button');
        var removeButton = $('#remove-button');
        var upButton = $('#up-button');
        var downButton = $('#down-button');

        var setButton = $('#set-button');
        setButton.unbind('click');
        setButton.bind('click', function(e) {
            if ($(container2).children().length > 0) {
                var array = [];
                $(container2).children().each(function() {
                    array.push($(this).attr('key'));
                });
                // return updateSource
                if (onSet != null && onSet != undefined) onSet(array);
            } else {
                // return updateSource [empty]
                if (onSet != null && onSet != undefined) onSet([]);
            }
        });

        var elementLast = null;
        var elementRedirect = function(el) {
            if (elementLast != null && elementLast != el) {
                $(elementLast).css({ 'background': 'none' });

                if ($(elementLast).parent().hasClass('container1')) {
                    addButton.unbind('click');
                }
                if ($(elementLast).parent().hasClass('container2')) {
                    removeButton.unbind('click');
                }
            }
            elementLast = el;

            upButton.unbind('click');
            downButton.unbind('click');
            $(el).css({ 'background': '#b5d690' });
            if ($(el).parent().hasClass('container1')) {
                addButton.bind('click', function() {
                    if ($(container2).children().length > 9) {
                        $.message(allMsgs["CustomizeErrorTitle"], allMsgs["CustomizeMax"]);
                        return;
                    }
                    $(container2).append(el); addButton.unbind('click'); $(el).css({ 'background': 'none' });
                    // scroll
                    $(container1).animate({ top: 0 }, _durationTime);
                    $(knob1).animate({ top: 0 }, _durationTime);

                    // scroll down
                    if ($(container2)[0].offsetHeight > visibleHeight) {
                        $(container2).animate({ top: -($(container2)[0].offsetHeight - visibleHeight) }, _durationTime);
                        $(knob2).animate({ top: 20 }, _durationTime);
                    }
                });
            }
            if ($(el).parent().hasClass('container2')) {
                removeButton.bind('click', function() {
                    $(container1).append(el); removeButton.unbind('click'); $(el).css({ 'background': 'none' });
                    // scroll
                    $(container2).animate({ top: 0 }, _durationTime);
                    $(knob2).animate({ top: 0 }, _durationTime);

                    // scroll down
                    if ($(container1)[0].offsetHeight > visibleHeight) {
                        $(container1).animate({ top: -($(container1)[0].offsetHeight - visibleHeight) }, _durationTime);
                        $(knob1).animate({ top: 20 }, _durationTime);
                    }
                });
                upButton.bind('click', function(e) {
                    if ($(el).prev() != null && $(el).parent().hasClass('container2') == true) {
                        $(el).insertBefore($(el).prev());
                    }
                });
                downButton.bind('click', function(e) {
                    if ($(el).next() != null && $(el).parent().hasClass('container2') == true) {
                        $(el).insertAfter($(el).next());
                    }
                });
            }
        };

        var defaultButton = $('#default-button');
        defaultButton.unbind('click');
        defaultButton.bind('click', function(e) {
            if (onDefault != null && onDefault != undefined) {
                onDefault();
                $(container2).children().empty();
                addButton.unbind('click');
            }

        });

        // get dataSource
        if (!jQuery.isArray(dataSource)) return; // exception
        var node1 = dataSource;
        if (node1.length > 0) {
            for (i = 0; i < node1.length; i++) {
                var temp = node1[i];
                if (temp.length > 1) {
                    var el = $('<div class="item" key=' + temp[0] + ' index=' + i + '>' + temp[1] + '</div>');
                    el.bind('mousedown', function(e) { elementRedirect(this); });
                    $(container1).append(el); // append items to container
                }
            }
        }

        // get updateSource
        if (!jQuery.isArray(updateSource)) return; // exception
        var node2 = updateSource;
        if (node2.length > 0) {
            for (i = 0; i < node2.length; i++) {
                var temp = node2[i];
                if (temp.length > 1) {
                    var el = $('<div class="item" key=' + temp[0] + ' index=' + i + '>' + temp[1] + '</div>');
                    el.bind('mousedown', function(e) { elementRedirect(this); });
                    $(container2).append(el);
                }
            }
        }

        // hover
        $(container1).children().hover(function() { $(this).addClass("hover") }, function() { $(this).removeClass("hover") });
        $(container2).children().hover(function() { $(this).addClass("hover") }, function() { $(this).removeClass("hover") });

        var ignoreFunction = function() { return false };
        var mouseDown1 = function(e) {
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = jQuery.num(target.style.top);
                body.mouseup(mouseUp1).mousemove(mouseMove1);

                this.blur();
                return false;
            }
        };

        var mouseDown2 = function(e) {
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = jQuery.num(target.style.top);
                body.mouseup(mouseUp2).mousemove(mouseMove2);

                this.blur();
                return false;
            }
        };

        var mouseUp1 = function(e) {
            body.unbind('mouseup', mouseUp1).unbind('mousemove', mouseMove1);
        };

        var mouseUp2 = function(e) {
            body.unbind('mouseup', mouseUp2).unbind('mousemove', mouseMove2);
        };

        var mouseMove1 = function(e) {
            var invisibleHeight = $(container1)[0].offsetHeight - $(scroller1).height()
            if (invisibleHeight <= 0) return;

            if (e == null) var e = window.event;
            var newTop = (offsetY + e.clientY - startY);
            var temp = $(scroller1).height() - $(up1).height() - $(down1).height() - $(knob1).height();
            newTop = newTop < 0 ? 0 : (newTop > temp ? temp : newTop);

            $(knob1)[0].style.top = newTop + 'px';
            $(container1)[0].style.top = (-((newTop / temp) * invisibleHeight)) + 'px'; // move container
        };

        var mouseMove2 = function(e) {
            var invisibleHeight = $(container2)[0].offsetHeight - $(scroller2).height()
            if (invisibleHeight <= 0) return;

            if (e == null) var e = window.event;
            var newTop = (offsetY + e.clientY - startY);
            var temp = $(scroller2).height() - $(up2).height() - $(down2).height() - $(knob2).height();
            newTop = newTop < 0 ? 0 : (newTop > temp ? temp : newTop);

            $(knob2)[0].style.top = newTop + 'px';
            $(container2)[0].style.top = (-((newTop / temp) * invisibleHeight)) + 'px'; // move container
        };

        $(knob1).bind('mousedown', mouseDown1); // start knob 1
        $(knob2).bind('mousedown', mouseDown2); // start knob 2

        var trackIt1 = function(obj, p, stepNumber) {
            var invisibleHeight = $(container1)[0].offsetHeight - visibleHeight;
            if (p != undefined) {
                if (p == 'down') { obj = $(down1)[0]; } else { obj = $(up1)[0]; }
            }
            if (invisibleHeight <= 0) return;
            var scrollHeight = ($(scroller1).height() - $(up1).height() - $(down1).height()) - $(knob1)[0].offsetHeight;
            var stepOver = !jQuery.isNull(stepNumber) ? (stepNumber * scrollStep) : scrollStep;
            var curTop = jQuery.num($(container1)[0].style.top);
            if ((curTop == 0 && obj == $(up1)[0]) || (curTop == -invisibleHeight && obj == $(down1)[0])) return;

            var newTop = (obj == $(down1)[0] ? curTop - (stepOver + (curTop % stepOver)) : curTop + (curTop % stepOver == 0 ? stepOver : -(curTop % stepOver)));
            newTop = (obj == $(up1)[0] ? Math.min(newTop, 0) : Math.max(newTop, -invisibleHeight));
            var newTop2 = -((newTop / invisibleHeight) * scrollHeight);
            // move
            $(container1).animate({ top: newTop }, _durationTime, function() {
                $(shaft1).css({ 'background': '' });
            });
            $(knob1).animate({ top: newTop2 }, _durationTime);
        };

        var trackIt2 = function(obj, p, stepNumber) {
            var invisibleHeight = $(container2)[0].offsetHeight - visibleHeight;

            if (p != undefined) {
                if (p == 'down') { obj = $(down2)[0]; } else { obj = $(up2)[0]; }
            }

            if (invisibleHeight <= 0) return;

            var scrollHeight = ($(scroller2).height() - $(up2).height() - $(down2).height()) - $(knob2)[0].offsetHeight;

            var stepOver = !jQuery.isNull(stepNumber) ? (stepNumber * scrollStep) : scrollStep;

            var curTop = jQuery.num($(container2)[0].style.top);
            if ((curTop == 0 && obj == $(up2)[0]) || (curTop == -invisibleHeight && obj == $(down2)[0])) return;

            var newTop = (obj == $(down2)[0] ? curTop - (stepOver + (curTop % stepOver)) : curTop + (curTop % stepOver == 0 ? stepOver : -(curTop % stepOver)));
            newTop = (obj == $(up2)[0] ? Math.min(newTop, 0) : Math.max(newTop, -invisibleHeight));
            var newTop2 = -((newTop / invisibleHeight) * scrollHeight);
            // move
            $(container2).animate({ top: newTop }, _durationTime, function() {
                $(shaft2).css({ 'background': '' });
            });
            $(knob2).animate({ top: newTop2 }, _durationTime);
        };

        $.each([$(up1), $(down1)], function(i, obj) {
            obj.mousehold(function() {
                trackIt1(this, undefined, 1);
            });
        });

        $.each([$(up2), $(down2)], function(i, obj) {
            obj.mousehold(function() {
                trackIt2(this, undefined, 1);
            });
        });

        $(shaft1).mousedown(function(e) {
            $(shaft1).css({ 'background': '#B5D690' });
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = $(target).offset().top;

                if (startY > $(knob1).offset().top) {
                    trackIt1(this, 'down', 5);
                } else {
                    trackIt1(this, 'up', 5);
                }
            }
        });
        $(shaft1).mouseup(function(e) {
            $(shaft1).css({ 'background': '' });
        });

        $(shaft2).mousedown(function(e) {
            $(shaft2).css({ 'background': '#B5D690' });
            if (e == null) e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            if (e.button == 1 && window.event != null || e.button == 0) {
                startY = e.clientY;
                offsetY = $(target).offset().top;

                if (startY > $(knob2).offset().top) {
                    trackIt2(this, 'down', 5);
                } else {
                    trackIt2(this, 'up', 5);
                }
            }
        });
        $(shaft2).mouseup(function(e) {
            $(shaft2).css({ 'background': '' });
        });

        // down
        $(down1).css({ 'position': 'relative', 'top': parseInt(visibleHeight) - 52 });
        $(down2).css({ 'position': 'relative', 'top': parseInt(visibleHeight) - 52 });

        $(box1).append(container1);
        $(box2).append(container2);

        $(this[0]).append(box1);
        $(this[1]).append(box2);

        $(this[0]).append(scroller1);
        $(this[1]).append(scroller2);

        $(box1).css({ 'height': parseInt(visibleHeight) + 'px', 'width': parseInt(visibleWidth) - 17 });
        $(box2).css({ 'height': parseInt(visibleHeight) + 'px', 'width': parseInt(visibleWidth) - 17 });

        $(scroller1).css({ 'height': parseInt(visibleHeight) - 2 });
        $(scroller2).css({ 'height': parseInt(visibleHeight) - 2 });
        $(shaft1).css({ 'margin-top': 15, 'height': visibleHeight - 32 });
        $(shaft2).css({ 'margin-top': 15, 'height': visibleHeight - 32 });
    }

    // ui freezeButton
    if (controlType != null && controlType.toLowerCase() == 'freezebutton') {
        var o = $(this[0]);

        o.empty().attr({ 'disableMode': 'false' });
        
        if (!o.hasClass('freeze-button')) 
            o.addClass('freeze-button');

        var loader = $.create('div', { 'class': 'freeze-button-loader' }, []);
        var context = $.create('div', { 'class': 'freeze-button-context' }, []);

        if (!jQuery.isNull(buttonText))
            $(context).text(buttonText);
        else
            $(context).text('Button');

        if (!jQuery.isNull(disableMode) && disableMode == true) {
            o.attr({ 'disableMode': 'true' }).addClass('freeze-button-disable'); 
        }

        if (!jQuery.isNull(onClick)) {
            o.bind('click', function() {
                if (!jQuery.isNull(animationProcess)) 
                    animationProcess = true;
                
                if ($(this).attr('disableMode') == 'false') {
                    onClick();
                    $(loader).stop();
                    $(loader).css({ 'width': 0 }).removeClass('freeze-button-loader').addClass('freeze-button-loader-action');
                    o.addClass('freeze-button-action');
                    $(context).hide();
                    
                    var _duration = 300;
                    if (!jQuery.isNull(freezeTime))
                        _duration = parseInt(freezeTime);
                    
                    $(loader).animate({ width: '68px' }, _duration, function() {
                        if (!jQuery.isNull(onComplete)) onComplete();
                        $(loader).removeClass('freeze-button-loader-action').addClass('freeze-button-loader');
                        o.removeClass('freeze-button-action');
                        $(loader).css({ 'width': '0px' });
                        $(context).show();
                        if (!jQuery.isNull(animationProcess)) animationProcess = false;
                    });
                }
            });
        }

        o.append(loader).append(context);
    }

    // ui tradeButton
    if (controlType != null && controlType.toLowerCase() == 'tradebutton') {
        var obj = $(this[0]);
        obj.empty();

        if (!obj.hasClass('trade-button')) obj.addClass('trade-button');

        var context = $.create('div', { 'class': 'trade-button-context' }, []);
        if (!jQuery.isNull(buttonText)) {
            $(context).text(buttonText);
        } else { $(context).text('Button'); }

        if (!jQuery.isNull(disableMode) && disableMode == true) { obj.addClass('trade-button-disable').unbind('click'); } else {
            if (!jQuery.isNull(onClick)) {
                obj.bind('click', function() {
                    if (!obj.hasClass('trade-button-disable')) {
                        //obj.addClass('button-animate');
                        onClick();
                        //                            $.timer(1300, function (timer) {
                        //                                obj.removeClass('button-animate');	
                        //                                timer.stop();
                        //                            });
                    }
                });
            }
        }

        obj.append(context);
    }

    // ui datepicker
    if (controlType != null && controlType.toLowerCase() == 'datepicker') {

        var obj = $(this[0]);
        obj.empty();

        // controller
        var context = $.create('div', { 'class': 'date-picker-context render_beta' }, []);
        var button = $.create('div', { 'class': 'date-picker-button render_beta' }, []);

        // date-picker
        var datePicker = $.create('div', { 'class': 'date-picker render_beta' }, []);
        var datePickerTop = $.create('div', { 'class': 'date-picker-top render_beta' }, []);
        var datePickerMain = $.create('div', { 'class': 'date-picker-main render_beta' }, []);
        var datePickerBottom = $.create('div', { 'class': 'date-picker-bottom render_beta' }, []);
        var datePickerLeft = $.create('div', { 'class': 'date-picker-left render_beta' }, []);
        var datePickerContent = $.create('div', { 'class': 'date-picker-content render_beta' }, []);
        var datePickerRight = $.create('div', { 'class': 'date-picker-right render_beta' }, []);
        var closeButton = $.create('div', { 'class': 'date-picker-content-close-button render_beta' }, []);
        var flow = $.create('div', { 'class': 'date-picker-content-flow render_beta' }, []);

        var prevButtonFlow = $.create('div', { 'class': 'date-picker-content-arrow-prev-flow render_beta' }, []);
        var monthTitleFlow = $.create('div', { 'class': 'date-picker-content-month-title-flow render_beta' }, []);
        var nextButtonFlow = $.create('div', { 'class': 'date-picker-content-arrow-next-flow render_beta' }, []);

        var prevButton = $.create('div', { 'class': 'date-picker-content-arrow-prev render_beta' }, []);
        var monthTitle = $.create('div', { 'class': 'date-picker-content-month-title render_beta' }, []);
        var nextButton = $.create('div', { 'class': 'date-picker-content-arrow-next render_beta' }, []);

        var weekTitle = $.create('div', { 'class': 'date-picker-content-week-title render_beta' }, []);
        $(weekTitle).html("<div class=\"week-day render_beta\">S</div><div class=\"week-day render_beta\">M</div><div class=\"week-day render_beta\">T</div><div class=\"week-day render_beta\">W</div><div class=\"week-day render_beta\">T</div><div class=\"week-day render_beta\">F</div><div class=\"week-end render_beta\">S</div>");
        var weekDays = $.create('div', { 'class': 'date-picker-content-weekdays render_beta' }, []);

        var _today = (new Date()).zeroTime();
        var _month = _today.getMonth();
        var _year = _today.getFullYear();

        if (!jQuery.isNull(defaultDate)) {
            _today = Date.fromString(defaultDate);
        }

        $(context).text(_today.getDate() + '-' + Date.abbrMonthNames[_today.getMonth()] + '-' + String(_today.getFullYear()).slice(2));
        obj.attr({ 'displayDay': _today.getDate() }).attr({ 'displayMonth': _today.getMonth() + 1 }).attr({ 'displayYear': _today.getFullYear() });

        var _startDate = (new Date()).zeroTime();
        var _endDate = (new Date()).zeroTime();
        if (!jQuery.isNull(startDate)) {
            _startDate = Date.fromString(startDate);
        }
        if (!jQuery.isNull(endDate)) {
            _endDate = Date.fromString(endDate);
        }

        var _renderDate = function(m) {

            var displayMonth = null;
            var displayYear = null;

            if ($(weekDays).attr('displayMonth') != null) {
                if ((parseInt($(weekDays).attr('displayMonth')) + m) == 12) {
                    displayMonth = 0;
                    displayYear = parseInt($(weekDays).attr('displayYear')) + 1;
                } else if ((parseInt($(weekDays).attr('displayMonth')) + m) < 0) {
                    displayMonth = 11;
                    displayYear = parseInt($(weekDays).attr('displayYear')) - 1
                } else {
                    displayMonth = parseInt($(weekDays).attr('displayMonth')) + m;
                    displayYear = parseInt($(weekDays).attr('displayYear'));
                }
            }

            var today = (new Date()).zeroTime();
            if (!jQuery.isNull(defaultDate)) {
                today = Date.fromString(defaultDate);
            }
            var month = displayMonth == undefined ? today.getMonth() : displayMonth;
            var year = displayYear || today.getFullYear();

            var currentDate = new Date(year, month, 1);
            var firstDayOffset = Date.firstDayOfWeek - currentDate.getDay();
            if (firstDayOffset > 1) firstDayOffset -= 7;
            var weeksToDraw = Math.ceil(((-1 * firstDayOffset + 1) + currentDate.getDaysInMonth()) / 7);

            currentDate.addDays(firstDayOffset - 1);

            var dc = function(a) { return document.createElement(a); }; // remove
            $(weekDays).empty();

            var w = 0;
            while (w++ < weeksToDraw) {

                var r = $.create('div', { 'class': 'null' }, []);
                for (var i = 0; i < 7; i++) {
                    var thisMonth = currentDate.getMonth() == month;
                    var d = $.create('div', { 'class': 'null' }, []);
                    $(d).text(currentDate.getDate() + '').attr('className', (thisMonth ? 'current-month ' : 'other-month render_beta ') +
											        (currentDate.isWeekend() ? 'weekend render_beta ' : 'weekday ')
						        );

                    if (!jQuery.isNull(defaultDate)) {
                        if (currentDate.getDate() == _today.getDate() && currentDate.getFullYear() == _today.getFullYear() && currentDate.getMonth() == _today.getMonth()) {
                            $(d).addClass('today');
                        }
                    } else { $(d).addClass((thisMonth && currentDate.getTime() == today.getTime() ? 'today ' : '')); }
                    if (!jQuery.isNull(endDate)) {
                        if (currentDate.getDate() > _endDate.getDate() && currentDate.getFullYear() == _endDate.getFullYear() && _endDate.getMonth() == (displayMonth == undefined ? today.getMonth() : displayMonth)) {
                            $(d).addClass('other-month render_beta');
                        }
                        if (_endDate.getMonth() == (displayMonth == undefined ? today.getMonth() : displayMonth) && _endDate.getFullYear() == year) { $(nextButton).hide(); } else { $(nextButton).show(); }
                    }
                    if (!jQuery.isNull(startDate)) {
                        if (currentDate.getDate() < _startDate.getDate() && currentDate.getFullYear() == _startDate.getFullYear() && _startDate.getMonth() == (displayMonth == undefined ? today.getMonth() : displayMonth)) {
                            $(d).addClass('other-month render_beta');
                        }
                        if (_startDate.getMonth() == (displayMonth == undefined ? today.getMonth() : displayMonth) && _startDate.getFullYear() == year) {
                            $(prevButton).hide();
                        } else { $(prevButton).show(); }
                    }
                    if (!jQuery.isNull(nonBusinessDates)) {
                        if (!jQuery.isArray(nonBusinessDates)) return;
                        for (var x = 0; x < nonBusinessDates.length; x++) {
                            if ((Date.fromString(nonBusinessDates[x].toString()).getDate()) == currentDate.getDate() && (Date.fromString(nonBusinessDates[x].toString()).getMonth()) == currentDate.getMonth() && (Date.fromString(nonBusinessDates[x].toString()).getFullYear()) == currentDate.getFullYear()) {
                                $(d).addClass('other-month render_beta');
                            }
                        }
                    }

                    /**
                    *@fix 31/12/2007
                    */
                    if (!jQuery.isNull(nonWeekEndDates) && nonWeekEndDates == true) {
                        if (!$(d).hasClass('other-month')) {
                            $(d).bind('click', function(e) {

                                $(context)[0].innerHTML = ($(this).html() + "-" + Date.abbrMonthNames[month] + "-" + String(year).slice(2));
                                obj.attr({ 'displayDay': $(this).html() }).attr({ 'displayMonth': parseInt(((displayMonth == undefined ? today.getMonth() : displayMonth) + 1)) }).attr({ 'displayYear': year });
                                if (!jQuery.isNull(onChange)) onChange();
                                $(datePicker).hide();
                            }).hover(function() { $(this).css({ 'background': '#fff' }) }, function() { $(this).css({ 'background': '#f4fbe8' }) });
                        }
                    } else {
                        if (!$(d).hasClass('weekend') && !$(d).hasClass('other-month')) {
                            $(d).bind('click', function(e) {

                                $(context)[0].innerHTML = ($(this).html() + "-" + Date.abbrMonthNames[month] + "-" + String(year).slice(2));
                                obj.attr({ 'displayDay': $(this).html() }).attr({ 'displayMonth': parseInt(((displayMonth == undefined ? today.getMonth() : displayMonth) + 1)) }).attr({ 'displayYear': year });
                                if (!jQuery.isNull(onChange)) onChange();
                                $(datePicker).hide();
                            }).hover(function() { $(this).css({ 'background': '#fff' }) }, function() { $(this).css({ 'background': '#f4fbe8' }) });
                        } else if ($(d).hasClass('weekend')) { $(d).css({ 'cursor': 'default' }) }
                    }

                    $(r).append($(d));
                    currentDate.addDays(1);
                }

                $(weekDays).append(r);
            }

            $(monthTitle).text(Date.monthNames[displayMonth == undefined ? today.getMonth() : displayMonth] + " " + year);
            $(weekDays).attr({ 'displayMonth': (displayMonth == undefined ? today.getMonth() : displayMonth).toString() }).attr({ 'displayYear': year });
        }

        $(prevButton).bind('click', function(e) { _renderDate(-1); }); // prev month
        $(nextButton).bind('click', function(e) { _renderDate(1); }); // next month

        $(button).bind('click', function(e) {

            // utility method
            var _zeroPad = function(num) {
                var s = '0' + num;
                return s.substring(s.length - 2)
                //return ('0'+num).substring(-2); // doesn't work on IE :(
            };

            _today = Date.fromString(_zeroPad(obj.attr('displayDay')) + "/" + _zeroPad(obj.attr('displayMonth')) + "/" + obj.attr('displayYear'));
            $(datePicker).css({ 'top': $(this).offset().top + 'px', 'left': $(this).offset().left + 'px' }).show();
            _renderDate(0);

            jQuery().bind('click', function(e) {
                if (e == null) e = window.event;
                var target = e.target != null ? e.target : e.srcElement;
                if (!$(target).hasClass('render_beta')) {
                    $(datePicker).hide();
                    jQuery().unbind('click');
                }
            });
        });

        // output
        obj.append(context).append(button);

        //$('#base').after($(datePicker).css({'display':'none'}));
        $('#base').empty();
        $('#base').append($(datePicker).css({ 'display': 'none' }));

        $(datePicker).append(datePickerTop).append(datePickerMain).append(datePickerBottom);

        $(datePickerMain).append(datePickerLeft).append(datePickerContent).append(datePickerRight);
        $(datePickerContent).append($(closeButton).bind('click', function() {
            $(datePicker).hide();
        }));

        $(datePickerContent).append(flow);
        $(flow).append($(prevButtonFlow).append(prevButton)).append($(monthTitleFlow).append(monthTitle)).append($(nextButtonFlow).append(nextButton)).append(weekTitle).append(weekDays);

        //_renderDate();
    }

    // numeric
    if (controlType != null && controlType.toLowerCase() == 'numeric') {

        var obj = $(this[0]);
        obj.empty();
        obj.addClass('numeric-list');

        var context = $.create('div', { 'class': 'numeric-list-context' }, []);
        var buttons = $.create('div', { 'class': 'numeric-list-buttons' }, []);
        var numericInput = $.create('input', { 'class': '' }, []);
        var _numericInput = $(numericInput);
        var buttonUp = $.create('div', { 'class': 'numeric-up' }, []);
        var buttonDown = $.create('div', { 'class': 'numeric-down' }, []);

        // declaring required variables
        var digits = "0123456789";

        // non-digit characters which are allowed in float number
        var delimiters = ".";

        // characters which are allowed in float numbers
        var validChars = delimiters + "+";

        function isInteger(s) {
            var i;
            for (i = 0; i < s.length; i++) {
                // check that current character is number.
                var c = s.charAt(i);
                if (((c < "0") || (c > "9"))) return false;
            }
            // all characters are numbers.
            return true;
        }

        function stripCharsInBag(s, bag) {
            var i;
            var output = "";
            // search through string's characters one by one.
            // if character is not in bag, append to returnString.
            for (i = 0; i < s.length; i++) {
                // check that current character isn't whitespace.
                var c = s.charAt(i);
                if (bag.indexOf(c) == -1) output += c;
            }
            return output;
        }

        function checkFloatNumber(str) {
            s = stripCharsInBag(str, validChars);
            return (isInteger(s));
        }

        var size = 4;
        obj.attr({ 'fixedSize': size });
        if (!jQuery.isNull(fixedSize)) {
            if (fixedSize != size && fixedSize != 0) {
                size = fixedSize;
                obj.attr({ 'fixedSize': size });
            }
        }

        if (!jQuery.isNull(dataValue)) {
            if (checkFloatNumber(dataValue)) {
                if (!jQuery.isNull(maxValue)) {
                    obj.attr({ 'maxValue': maxValue.toFixed(size) }); // max attr
                    if (parseFloat(dataValue).toFixed(size) < obj.attr('maxValue')) {
                        _numericInput[0].value = dataValue.toFixed(size);
                        obj.attr({ 'dataValue': dataValue.toFixed(size) }); //attr
                    }
                } else {
                    _numericInput[0].value = dataValue.toFixed(size);
                    obj.attr({ 'dataValue': dataValue.toFixed(size) });
                }

                if (!jQuery.isNull(minValue)) {
                    obj.attr({ 'minValue': minValue.toFixed(size) }); // min attr
                    if (parseFloat(dataValue).toFixed(size) > obj.attr('minValue')) {
                        _numericInput[0].value = dataValue.toFixed(size);
                        obj.attr({ 'dataValue': dataValue.toFixed(size) }); // attr
                    }
                } else {
                    _numericInput[0].value = dataValue.toFixed(size);
                    obj.attr({ 'dataValue': dataValue.toFixed(size) });
                }
            }
        }

        var x = null;

        _numericInput.keyup(function(e) {
            if (checkFloatNumber($(this)[0].value)) {
                obj.attr({ 'dataValue': $(this)[0].value });
                //                var u = $(numericInput)[0].value.length - ($(numericInput)[0].value).indexOf('.')-1; 
                //                        size = u;
                //                        $(elementObj).attr({'fixedSize':size});
                x = null

            } else { _numericInput[0].value = ""; }
        });

        _numericInput.blur(function() {
            if (!jQuery.isNull(onChange)) onChange(_numericInput[0].value);
        });

        _numericInput.bind('myChange', function() { onChange(_numericInput[0].value); });

        $(buttonUp).bind('click', function() {
            if (_numericInput[0].value != "") {
                if (!jQuery.isNull(maxValue)) {
                    if (parseFloat(_numericInput[0].value).toFixed(size) < parseFloat(maxValue.toFixed(size)) - (1 / Math.pow(10, size))) {

                        var n = parseFloat(_numericInput[0].value).toFixed(size);
                        if (x == null) {
                            x = n.length - n.indexOf('.') - 1;
                        }

                        _numericInput[0].value = (Math.round(((parseFloat(n)) + (1 / Math.pow(10, x))) * Math.pow(10, x)) / Math.pow(10, x)).toFixed(size);
                        obj.attr({ 'dataValue': _numericInput[0].value });
                        if (!jQuery.isNull(onUp)) onUp(_numericInput[0].value);
                    }
                } else {
                    var n = parseFloat(_numericInput[0].value).toFixed(size);
                    if (x == null) {
                        x = n.length - n.indexOf('.') - 1;
                    }
                    _numericInput[0].value = (Math.round(((parseFloat(n)) + (1 / Math.pow(10, x))) * Math.pow(10, x)) / Math.pow(10, x)).toFixed(size);
                    obj.attr({ 'dataValue': _numericInput[0].value });
                    if (!jQuery.isNull(onUp)) onUp(_numericInput[0].value);
                }
            }
        });

        $(buttonDown).bind('click', function() {
            if ($(numericInput)[0].value != "") {
                if (!jQuery.isNull(minValue)) {
                    if (parseFloat(_numericInput[0].value).toFixed(size) > parseFloat(minValue.toFixed(size)) + (1 / Math.pow(10, size))) {
                        var n = parseFloat(_numericInput[0].value).toFixed(size);
                        if (x == null) {
                            x = n.length - n.indexOf('.') - 1;
                        }
                        _numericInput[0].value = (Math.round(((parseFloat(n)) - (1 / Math.pow(10, x))) * Math.pow(10, x)) / Math.pow(10, x)).toFixed(size);
                        obj.attr({ 'dataValue': _numericInput[0].value });
                        if (!jQuery.isNull(onDown)) onDown(_numericInput[0].value);
                    }
                } else {
                    var n = parseFloat(_numericInput[0].value).toFixed(size);
                    if (x == null) {
                        x = n.length - n.indexOf('.') - 1;
                    }
                    _numericInput[0].value = (Math.round(((parseFloat(n)) - (1 / Math.pow(10, x))) * Math.pow(10, x)) / Math.pow(10, x)).toFixed(size);
                    obj.attr({ 'dataValue': _numericInput[0].value });
                    if (!jQuery.isNull(onDown)) onDown(_numericInput[0].value);
                }
            }
        });

        // output
        obj.append($(context).append(_numericInput));
        $(buttons).append(buttonUp).append(buttonDown);
        obj.append(buttons);
    }

    // ui calculatebutton
    if (controlType != null && controlType.toLowerCase() == 'calculatebutton') {
        var obj = $(this[0]);
        obj.empty(); // clear html

        obj.attr({ 'disableMode': 'false' });
        if (!obj.hasClass('calculate-button')) obj.addClass('calculate-button');

        var context = $.create('div', { 'class': 'calculate-button-context' }, []);
        if (!jQuery.isNull(buttonText)) { $(context).text(buttonText); } else { $(context).text('Button'); }

        if (!jQuery.isNull(disableMode) && disableMode == true) obj.attr({ 'disableMode': 'true' }).addClass('calculate-button-disable');
        if (!jQuery.isNull(onClick)) {
            obj.bind('click', function() {
                if ($(this).attr('disableMode') == 'false') {
                    onClick();
                }
            });
        }

        obj.append(context); // output
    }
};

// option
jQuery.fn.option = function() {
    
    if (arguments.length == 0) return [];
	var args = arguments[0];
	var selectedValue = args.selectedValue;
	var selectedText = args.selectedText;
	
	// validation
    var obj = $(this[0]);
    if(!obj.hasClass('combo-box')) return; // return if not comboBox
    
    if(!jQuery.isNull(obj.next()[0])) {
        if(obj.next()[0].className == 'combo-box-box') {
            
            var q = obj.children('.combo-box-selected');
            var box = obj.next()[0];
            if($(box).children()[0].className == 'item') {
                var el = $(box)[0];
                array = [];
                for(var i = 0; i < $(el).children().length; i++) {
                    var o = $(el).children()[i];
                    array[i] = $(o).attr('key') + "," + $(o).text(); // <param> value, text </param>
                    if(!jQuery.isNull(selectedValue)){
                        if($(o).attr('key') == selectedValue) {
                            
                            q[0].innerHTML = $(o).text(); // selected
                            $(el).children().css({'background':'none'});
                            $(o).css({'background':'#b5d690'}); // background
                            var t = obj.attr('selectedText');
                            var v = obj.attr('selectedValue');
                            obj.attr({'selectedText':$(o).text(),'selectedValue':$(o).attr('key'), 'prevText':t, 'prevValue':v, 'selectedIndex':i}); // attributes
                        }
                    }
                    if(!jQuery.isNull(selectedText)){
                        if($(o).text() == selectedText) {
                            // settings
                            q[0].innerHTML = $(o).text(); // selected
                            $(el).children().css({'background':'none'});
                            $(o).css({'background':'#b5d690'}); // background
                            var t = obj.attr('selectedText');
                            var v = obj.attr('selectedValue');
                            obj.attr({'selectedText':$(o).text(),'selectedValue':$(o).attr('key'), 'prevText':t, 'prevValue':v, 'selectedIndex':i}); // attributes
                        }
                    }
                }
            } else {
                var el = $(box).children()[0];
                array = [];
                for(var i = 0; i < $(el).children().length; i++) {
                    var o = $(el).children()[i];
                    array[i] = $(o).attr('key') + "," + $(o).text(); // <param> value, text </param>
                    if(!jQuery.isNull(selectedValue)){
                        if($(o).attr('key') == selectedValue) {
                            // settings
                            q[0].innerHTML = $(o).text(); // selected
                            $(el).children().css({'background':'none'});
                            $(o).css({'background':'#b5d690'}); // background
                            var t = obj.attr('selectedText');
                            var v = obj.attr('selectedValue');
                            obj.attr({'selectedText':$(o).text(),'selectedValue':$(o).attr('key'), 'prevText':t, 'prevValue':v, 'selectedIndex':i}); // attributes
                        }
                    }
                    if(!jQuery.isNull(selectedText)){
                        if($(o).text() == selectedText) {
                            // settings
                            q[0].innerHTML = $(o).text(); // selected
                            $(el).children().css({'background':'none'});
                            $(o).css({'background':'#b5d690'}); // background
                            var t = obj.attr('selectedText');
                            var v = obj.attr('selectedValue');
                            obj.attr({'selectedText':$(o).text(),'selectedValue':$(o).attr('key'), 'prevText':t, 'prevValue':v, 'selectedIndex':i}); // attributes
                        }
                    }
                }
            }
        }
    }
};

// rollback
jQuery.fn.rollback = function() {
    if(!$(this[0]).hasClass('combo-box')) return; // return if not comboBox
    var obj = $(this[0]);
    if(obj.attr('prevText') != undefined && obj.attr('prevValue') != undefined){
        var t = obj.attr('prevText');
        var v = obj.attr('prevValue');
        obj.option({selectedValue:v, selectedText:t}); 
    }
};

// mode
jQuery.fn.mode = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    var disableMode = arg.disableMode;
    
    var obj = $(this[0]);
    /**
    *@desc
    */
    if(!obj) return;
    if(obj.hasClass('freeze-button')) {
        if(!jQuery.isNull(disableMode) && disableMode == true) {
            obj.addClass('freeze-button-disable').attr({'disableMode':'true'}); } else { if(obj.hasClass('freeze-button-disable')) { obj.removeClass('freeze-button-disable').attr({'disableMode':'false'}); }}
    } else if(obj.hasClass('calculate-button')){
        if(!jQuery.isNull(disableMode) && disableMode == true) {
            obj.addClass('calculate-button-disable').attr({'disableMode':'true'}); } else {if(obj.hasClass('calculate-button-disable')) { obj.removeClass('calculate-button-disable').attr({'disableMode':'false'}); } }
    } else {
        if(!jQuery.isNull(disableMode) && disableMode == true) { 
            obj.addClass('trade-button-disable'); } else { if(obj.hasClass('trade-button-disable')) { obj.removeClass('trade-button-disable'); }}
    }
};

// cancel
jQuery.fn.cancel = function() {
    /**
    *@desc at this time compatible only for freezButton control 
    */
    if($(this[0]).hasClass('freeze-button')) {
        var obj = $(this[0]);
        var loader = obj.children()[0];
        var context = obj.children()[1];

        $(loader).stop(); // stop	        
        $(loader).css({'width':0}); // return to 0
        $(loader).addClass('freeze-button-loader').removeClass('freeze-button-loader-action');
        obj.removeClass('freeze-button-action');
        $(context).show();
    }
};

/**
*@param 
*$.message('error 1033','message',function(){ alert('ok') });
*/
var __flagMessage = false;
jQuery.message = function(header, message, _ok) {
    var overlay = $('#overlay');
    var box = $('#message-box');
    
    if(!animationProcess) {
    
        $.timer(100, function(timer) {
            if(!__flagMessage) {
                
                jQuery().bind('keypress', function(e){
                    var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;
                    
                    if(code == 9) {
                        return false;
                    }
                });
                
                jQuery().bind('keydown', function(e) {
                   var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;
                    
                    if(code == 13) {
                        $('#message-box-ok-button').trigger('click');
                    }
                });
            
                overlay.show();
                $('#message-box-header').text(header);
                $('#message-box-context')[0].innerHTML = message;
                box.show(); // show
                __flagMessage = true;
                messageShowen = true; // #4536
                $('#message-box-ok-button,#message-box-close-button').bind('click',function() {
                    __flagMessage = false;
                    if(!jQuery.isNull(_ok)) { _ok(); };
                    $('#message-box-ok-button,#message-box-close-button').unbind('click');
                    $('#overlay,#message-box').hide(); // hide
                    messageShowen = false; // #4536
                    
                    jQuery().unbind('keydown');
                    jQuery().unbind('keypress');
                });
                
                var _h = $('#message-box-context').height();
                $('.message-box-left,.message-box-content,.message-box-right').css({'height':76+_h});
                
                // timer stop
                timer.stop()
            }
        });
    }
};

// Extend for $.message function to hide
// Example: $.message.hide();
jQuery.message.hide = function() {
    if($('#message-box').is(':visible')) {
        __flagMessage = false;
        $('#overlay,#message-box').hide();
    }
};


jQuery.loginBox = function() {
    var overlay = $('#overlay');
    var box = $('#login-box');

    //var step1 = $('#login-box-step-1');
    //var step2 = $('#login-box-step-2');

    if (!animationProcess) {
        $.timer(100, function(timer) {
            if (!__flagMessage) {

                jQuery().bind('keypress', function(e) {
                    var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;

                    if (code == 9) {
                        return false;
                    }
                });

                overlay.show();

                /*
                switch (step) {
                    case 1:
                        step1.show();
                        step2.hide();
                        break;
                    case 2:
                        step1.hide();
                        step2.show();
                        break;
                    default:
                        step1.show();
                        step2.hide();
                }
                */

                box.show();

                __flagMessage = true;
                messageShowen = true; // #4536

                // close
                $('#popup_ok, #login-box-close-button').bind('click', function() {
                    __flagMessage = false;
                    $('#login-box-close-button').unbind('click');
                    $('#overlay,#login-box').hide();
                    messageShowen = false; // #4536

                    jQuery().unbind('keydown');
                    jQuery().unbind('keypress');
                });


                var _h = $('#login-box-context').height();
                if (_h < 30) {
                    $('.login-box-left,.login-box-content,.login-box-right').css({ 'height': 100 + _h });
                } else {
                    $('.login-box-left,.login-box-content,.login-box-right').css({ 'height': 44 + _h });
                }

            }


            timer.stop();
        });
    }

};

/**
*
* @test javascript:$.optional('sdsddsdsd<br />sfdsfsdfgdsg dgdsfhksdhfuk dfjshdfdsf sduhfkosdf <br />ghkhsdfkhdkfs!!!', function() {alert('submit')}, function() {alert('leave')}, function() {alert('close')}, "Submit me...", "Leave me...");
*/

jQuery.optional = function(message, __submit, __leave, __close, __submitText, __leaveText, isDisposed) {
    var overlay = $('#overlay');
    var box = $('#optional-box');
    if(!animationProcess) {
        $.timer(100, function(timer) {
            if(!__flagMessage) {
                
                jQuery().bind('keypress', function(e){
                    var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;
                    
                    if(code == 9) {
                        return false;
                    }
                });
            
                overlay.show();
                jQuery().bind('keydown', function(e) {
                   var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;
                    
                    if(code == 13) {
                        $('#optional-box-submit-button').trigger('click');
                    }
                });
                
                $('#optional-box-context').html(message);
               
                box.show();
                
                if(isDisposed == false) {
                     $('#optional-box-leave-button').hide();
                     $('#optional-box-submit-button').css({'margin':0});
                } else {
                     $('#optional-box-leave-button').show();
                     $('#optional-box-submit-button').css({'margin-right':12, 'margin-left': 12});
                }
                
                $('#optional-box-child-leave-button').text(__leaveText);
                $('#optional-box-child-submit-button').text(__submitText);
                
                __flagMessage = true;
                messageShowen = true; // #4536
                
                
                // submit
                $('#optional-box-submit-button').bind('click',function() {
                    __flagMessage = false;
                    if(!jQuery.isNull(__submit)) { __submit(); };
                    $('#optional-box-submit-button').unbind('click');
                    $('#overlay,#optional-box').hide();
                    messageShowen = false; // #4536
                    
                    jQuery().unbind('keydown');
                    jQuery().unbind('keypress');
                });
                
                // leave
                $('#optional-box-leave-button').bind('click', function() {
                    __flagMessage = false;
                    if(!jQuery.isNull(__leave)) { __leave(); };
                    $('#optional-box-leave-button').unbind('click');
                    $('#overlay,#optional-box').hide();
                    messageShowen = false; // #4536
                    
                    jQuery().unbind('keydown');
                    jQuery().unbind('keypress');
                });
                
                // close
                $('#optional-box-close-button').bind('click', function() {
                    __flagMessage = false;
                    if(!jQuery.isNull(__close)) { __close(); };
                    $('#optional-box-close-button').unbind('click');
                    $('#overlay,#optional-box').hide();
                    messageShowen = false; // #4536
                    
                    jQuery().unbind('keydown');
                    jQuery().unbind('keypress');
                });
                
                
                var _h = $('#optional-box-context').height();
                if(_h < 30) {
                    $('.optional-box-left,.optional-box-content,.optional-box-right').css({'height':100+_h});
                } else {
                    $('.optional-box-left,.optional-box-content,.optional-box-right').css({'height':76+_h});
                }
                    
            }
            
            
            timer.stop();
        });
    }    
};

/**
*@param 
*$._confirm('header','message',function(){ alert('ok') },function(){ alert('cancel') });
*/
jQuery._confirm = function(header, message, _ok,_cancel, _ok_content, _cancel_content, _cancelOnClose) {
    var overlay = $('#overlay');
    var box = $('#confirm-box');
    
    if(!animationProcess) {
        $.timer(100, function(timer) {
            if(!__flagMessage) {
            
                jQuery().bind('keypress', function(e){
                    var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;
                    
                    if(code == 9) {
                        return false;
                    }
                });
            
                overlay.show();
                jQuery().bind('keydown', function(e) {
                   var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;
                    
                    if(code == 13) {
                        $('#confirm-box-ok-button').trigger('click');
                    }
                });
                $('#confirm-box-header').text(header);
                $('#confirm-box-context').html(message);
                box.show(); // show
                __flagMessage = true;
                messageShowen = true; // #4536
                $('#confirm-box-close-button').bind('click',function() {
                    if(!jQuery.isNull(_cancelOnClose) && !_cancelOnClose)
                    {
                        __flagMessage = false;
                        $('#confirm-box-ok-button,#confirm-box-cancel-button,#confirm-box-close-button').unbind('click');
                        $('#overlay,#confirm-box').hide(); // hide
                        messageShowen = false; // #4536
                        
                        jQuery().unbind('keydown');
                        jQuery().unbind('keypress');
                    }
                    else
                    {
                        $('#confirm-box-cancel-button').trigger('click');
                    }
                });
                $('#confirm-box-cancel-button').bind('click',function() {
                    __flagMessage = false;
                    if(!jQuery.isNull(_cancel)) _cancel();
                    $('#confirm-box-ok-button,#confirm-box-cancel-button,#confirm-box-close-button').unbind('click');
                    $('#overlay,#confirm-box').hide(); // hide
                    messageShowen = false; // #4536
                    
                    jQuery().unbind('keydown');
                    jQuery().unbind('keypress');
                });
                
                $('#confirm-box-ok-button').bind('click',function() {
                    __flagMessage = false;
                    if(!jQuery.isNull(_ok)) _ok();
                    $('#confirm-box-ok-button,#confirm-box-cancel-button,#confirm-box-close-button').unbind('click');
                    $('#overlay,#confirm-box').hide(); // hide
                    messageShowen = false; // #4536
                    
                    jQuery().unbind('keydown');
                    jQuery().unbind('keypress');
                });
                
                if(_ok_content != undefined) { $('#confirm-box-ok-button-content').text('').text(_ok_content); }
                if(_cancel_content != undefined) { $('#confirm-box-cancel-button-content').text('').text(_cancel_content); }
                
                //var _c = $('#confirm-box-header').height();
                var _h = $('#confirm-box-context').height();
                if(_h < 30) {
                    $('.confirm-box-left,.confirm-box-content,.confirm-box-right').css({'height':100+_h});
                } else {
                    $('.confirm-box-left,.confirm-box-content,.confirm-box-right').css({'height':76+_h});
                }
                
                // timer stop
                timer.stop()
            }
        });
    }
};

// Extend for $._confirm function to hide
// Example: $._confirm.hide();
jQuery._confirm.hide = function() {
    if($('#confirm-box').is(':visible')) {
        __flagMessage = false;
        $('#overlay,#confirm-box').hide();
    }
};

/**
*@param 
*$.lightBox('header','context may be html');
*/
jQuery.lightBox = function(header, context) {
    var overlay = $('#overlay');
    var box = $('#light-box');
    
    if(!animationProcess) {
        $.timer(100, function(timer) {
            if(!__flagMessage) {
            
                jQuery().bind('keypress', function(e){
                    var code;
                    if (!e) var e = window.event;
                    if (e.keyCode) code = e.keyCode;
                    else if (e.which) code = e.which;
                    
                    if(code == 9) {
                        return false;
                    }
                });
                
                __flagMessage = true;
                messageShowen = true; // #4536
                overlay.show();
                $('#light-box-header').text(header);
                $('#light-box-context')[0].innerHTML = context;
                box.show(); // show
                $('#lightbox-close-button').bind('click', function() {
                    __flagMessage = false;
                    $('#lightbox-close-button').unbind('click');
                    $('#overlay,#light-box').hide(); // hide
                    messageShowen = false; // #4536
                    
                    jQuery().unbind('keypress');
                });
                
                var _cH = $('#light-box-context').height();
                box.css({'height':_cH+70});
                $('.light-box-left,.light-box-right').css({'height':_cH+54});
                
                // timer stop
                timer.stop()
             }
        });
    }
};

// Extend for $.lightBox function to hide
// Example: $.lightBox.hide();
jQuery.lightBox.hide = function() {
    if ($('#light-box').is(':visible')) {
        __flagMessage = false;
        $('#overlay,#light-box').hide();
    }
};

/**
*@param 
*$.customeBox(element)
* Description: If u are work with yhis function add jQuery().unbind('keypress'); to the button OK 
* 23/04/2008 Basil & Lior
*/
jQuery.customeBox = function(el, clientW, clientH, childElement) {

    el=$(el);
    
    // bind tab key
    jQuery().bind('keypress', function(e){
        var code;
        if (!e) var e = window.event;
        if (e.keyCode) code = e.keyCode;
        else if (e.which) code = e.which;
        
        if(code == 9) {
            return false;
        }
    });
    
    if(childElement != undefined) {
        // bind enter key
        jQuery().bind('keydown', function(e) {
           var code;
            if (!e) var e = window.event;
            if (e.keyCode) code = e.keyCode;
            else if (e.which) code = e.which;
            
            if(code == 13) {
                $(childElement).trigger('click');
                jQuery().unbind('keydown');
                jQuery().unbind('keypress');
            }
        });
    }
    
    $('#overlay-custom').show();
    $('#custome-box').show();     
    $('#custome-box-context .context').empty().append(el).css({width:el.width()});
    $('#custome-box-context').css({width:el.width()})
    el.show(); 
    $('#overlay-custom').focus();
    $('#custome-box').css({
        top: -10000,
        left: -10000
    });
                
    var t,l;

    if(clientW != null && clientH != null) 
    {
        t = (document.documentElement.clientHeight - clientH) / 2;
        l = ($('#overlay-custom')[0].offsetWidth - el[0].offsetWidth) / 2;
        
        $('#cl').css({'height':clientH});
        $('#cr').css({'height':clientH});
        
        $('#ct').css({'width':clientW});
        $('#cb').css({'width':clientW});
    } 
    else 
    {
        var h = $('#custome-box-context').height();
        var w = $('#custome-box-context').width();
        t = (document.documentElement.clientHeight - el[0].offsetHeight) / 2;
        l = ($('#overlay-custom')[0].offsetWidth - el[0].offsetWidth) / 2;
    
        $('#cl').css({'height':h});
        $('#cr').css({'height':h});
        
        $('#ct').css({'width':w});
        $('#cb').css({'width':w});
    }
    
    $('#custome-box').css({width:$('#custome-box-context').width()+16});
    
    $('#custome-box').css({
        top: t + "px",
        left: l + "px"
    });
};


/**
*@param 
*$.lightBox('header','context may be html');
*/
jQuery._CCDetailsBox = function() {
    var overlay = $('#overlay');
    var box = $('#ccdetails-box');
    
    overlay.show();
    
    box.show();
    var _cH = $('#ccdetails-box-context').height();
    box.css({'height':_cH+70});
    $('.ccdetails-box-left,.ccdetails-box-right').css({'height':_cH+54});
};

// screen
jQuery.screen = function(id) {
    if($('#'+id)) {
        $('#'+id).show();
    }
};

// bannner
jQuery.banner = function(bannerMode, bannerPath) {
    if(bannerMode == 'default') {
        /**
        *@default 864x218
        */
        $('#banner-box').removeClass('banner-box-external').addClass('banner-box-default');
        var n = bannerPath.lastIndexOf('.');
        if(bannerPath.substring(n) != '.swf') {
            $('#banner-platform').html('<img src=\''+bannerPath+'\' />');
        } else {
            var so = new SWFObject(bannerPath, "banner_", "864", "218", "8", "#FFFFFF");               
            so.addParam('wmode', 'transparent');
            so.write('banner-platform'); 
        }
        $('#banner-box').toggle();
    } else {
        /**
        *@external 250x300
        */
        $('#banner-box').removeClass('banner-box-default').addClass('banner-box-external');
        var n = bannerPath.lastIndexOf('.');
        if(bannerPath.substring(n) != '.swf') {
            $('#banner-platform').html('<img src=\''+bannerPath+'\' />');
        } else {
            var so = new SWFObject(bannerPath, "banner_", "250", "300", "8", "#FFFFFF");               
            so.addParam('wmode', 'transparent');
            so.write('banner-platform'); 
        }
        $('#banner-box').toggle();
    }
};

// shlif
jQuery.shlif = function(header, text) {
    if($('#shlif')) {
        $('#shlif').animate({top: 86}, 800, function(){
            $('#shlif-close').bind('click',function() {
                $('#shlif').animate({top: 204}, 800);
            });
            
            $('#shlif-header').text(header);
            $('#shlif-body').text(text);
        });
        $('#shlif-open').bind('click',function(){
                $.shlif(header, text);
            });
    }
};

// loader
jQuery.loader = function(text) {
    if($('#loader')) {
        if(!$('#alert-box').is(':visible')) {
            $('#loader,#loader-overlay').toggle();
            $('#loader-text').text(text);
        }
    }
};

//var automaticCancel = false;
//jQuery.loader = function(text) {
//    if( !jQuery.isNull($('#loader')) ) {
//          automaticCancel = true;
////          $.timer(2000, function(timer) {
////              if(automaticCancel) {
////                  if( !$('#alert-box').is(':visible') ) {
////                      $('#loader,#loader-overlay').show();
////                      $('#loader-text').text(text);
////                  }
////              }
////              timer.stop();
////          });
//    }
//};

//// To hide loader call $.loader.hide();
//jQuery.loader.constructor.prototype.hide = function() {
//    if( !jQuery.isNull($('#loader')) ) {
//        automaticCancel = false;
//        $('#loader,#loader-overlay').hide();
//    }
//};

// timer
jQuery.timer = function (interval, callback) {
    /**
    *
    * timer() provides a cleaner way to handle intervals  
    *
    *@usage
    * $.timer(interval, callback);
    *
    *
    * @example
    * $.timer(1000, function (timer) {
    * 	alert("hello");
    * 	timer.stop();
    * });
    * @desc Show an alert box after 1 second and stop
    * 
    * @example
    * var second = false;
    *	$.timer(1000, function (timer) {
    *		if (!second) {
    *			alert('First time!');
    *			second = true;
    *			timer.reset(3000);
    *		}
    *		else {
    *			alert('Second time');
    *			timer.stop();
    *		}
    *	});
    * @desc show an alert box after 1 second and show another after 3 seconds
    *
    * 
    */
	var interval = interval || 100;
	if (!callback)
		return false;
	
	_timer = function (interval, callback) {
		this.stop = function () {
			clearInterval(self.id);
		};
		
		this.internalCallback = function () {
			callback(self);
		};
		
		this.reset = function (val) {
			if (self.id)
				clearInterval(self.id);
			
			var val = val || 100;
			this.id = setInterval(this.internalCallback, val);
		};
		
		this.interval = interval;
		this.id = setInterval(this.internalCallback, this.interval);
		
		var self = this;
    };
    
	return new _timer(interval, callback);
};

(function($) {

$.fn.extend({
	/**
	 * Apply the mousewheel event to the elements in the jQuery object.
	 * The handler function should be prepared to take the event object
	 * and a param called 'delta'. The 'delta' param is a number
	 * either > 0 or < 0. > 0 = up and < 0 = down.
	 *
	 * @example $("p").mousewheel(function(event, delta){
	 *   if (delta > 0)
	 *     // do something on mousewheel scroll up
	 *   else if (delta < 0)
	 *     //do something on mousewheel scroll down
	 * });
	 *
	 */
	mousewheel: function(f) {
		if (!f.guid) f.guid = $.event.guid++;
		if (!$.event._mwCache) $.event._mwCache = [];
		
		return this.each( function() {
			if (this._mwHandlers) return this._mwHandlers.push(f);
			else this._mwHandlers = [];
			
			this._mwHandlers.push(f);
			
			var s = this;
			
			this._mwHandler = function(e) {
				e = $.event.fix(e || window.event);
				var delta = 0, returnValue = true;
				
				if (e.wheelDelta)  delta = e.wheelDelta/120;
				if (e.detail)      delta = -e.detail/3;
				if (window.opera)  delta = -e.wheelDelta;
				
				for (var i=0; i<s._mwHandlers.length; i++)
					if (s._mwHandlers[i])
						if ( s._mwHandlers[i].call(s, e, delta) === false ) {
							returnValue = false;
							e.preventDefault();
							e.stopPropagation();
						}
				
				return returnValue;
			};
			
			if (this.addEventListener)
				if ($.browser.mozilla) this.addEventListener('DOMMouseScroll', this._mwHandler, false);
				else                   this.addEventListener('mousewheel',     this._mwHandler, false);
			else
				this.onmousewheel = this._mwHandler;
			
			$.event._mwCache.push( $(this) );
		});
	},
	
	/**
	 * This method removes one or all applied mousewheel events from the elements.
	 * You can remove a single handler function by passing it as the first param.
	 * If you do not pass anything, it will remove all handlers.
	 */
	unmousewheel: function(f) {
		return this.each( function() {
			if ( f && this._mwHandlers ) {
				for (var i=0; i<this._mwHandlers.length; i++)
					if (this._mwHandlers[i] && this._mwHandlers[i].guid == f.guid)
						delete this._mwHandlers[i];
			} else {
				if (this.addEventListener)
					if ($.browser.mozilla) this.removeEventListener('DOMMouseScroll', this._mwHandler, false);
					else                   this.removeEventListener('mousewheel',     this._mwHandler, false);
				else
					this.onmousewheel = null;
					
				this._mwHandlers = this._mwHandler = null;
			}
		});
	}
});

// Clean-up
$(window)
	.one('unload', function() {
		var els = $.event._mwCache || [];
		for (var i=0; i<els.length; i++)
			els[i].unmousewheel();
	});
	
})(jQuery);

jQuery.fn.mousehold = function(timeout, f) {
	if (timeout && typeof timeout == 'function') {
		f = timeout;
		timeout = 100;
	}
	if (f && typeof f == 'function') {
		var timer = 0;
		var fireStep = 0;
		return this.each(function() {
			jQuery(this).mousedown(function() {
				fireStep = 1;
				var ctr = 0;
				var t = this;
				timer = setInterval(function() {
					ctr++;
					f.call(t, ctr);
					fireStep = 2;
				}, timeout);
			})

			clearMousehold = function() {
				clearInterval(timer);
				if (fireStep == 1) f.call(this, 1);
				fireStep = 0;
			}

			jQuery(this).mouseout(clearMousehold);
			jQuery(this).mouseup(clearMousehold);
		})
	}
}


/* NEXT FILE : D:\WWWSource\Site\js\Puma\Utils\Utils.js************************************************************/

jQuery.addToQueryString=function (toadd , qs){
   if(!toadd || toadd=="")
        return qs;
    if(!qs || qs=="")
        return "?" +toadd;
    if(/\?/.test(qs))
        return  qs+"&"+toadd;
    return "?" + qs + "&" + toadd;
};

// create element
jQuery.create = function() {
	if (arguments.length == 0) return [];
	var first_arg = arguments[0];

	// in case someone passes in a null object, assume that they want an empty string.
	if (first_arg == null) first_arg = "";
	if (first_arg.constructor == String) {
		if (arguments.length > 1) {
			var second_arg = arguments[1];
			if (second_arg.constructor == String) {
				var elt = document.createTextNode(first_arg);
				var elts = [];
				elts.push(elt);
				var siblings = jQuery.create.apply(null, Array.prototype.slice.call(arguments, 1));
				elts = elts.concat(siblings);
				return elts;

			} else {
				var elt = document.createElement(first_arg);

				// set element attributes.
				var attributes = arguments[1];
				for (var attr in attributes) jQuery(elt).attr(attr, attributes[attr]);

				// add children of this element.
				var children = arguments[2];
				children = jQuery.create.apply(null, children);
				jQuery(elt).append(children);

				// if there are more siblings, render those too.
				if (arguments.length > 3) {
					var siblings = jQuery.create.apply(null, Array.prototype.slice.call(arguments, 3));
					return [elt].concat(siblings);
				}
				return elt;
			}
		} else return document.createTextNode(first_arg);
	} else {
		var elts = [];
		elts.push(first_arg);
		var siblings = jQuery.create.apply(null, (Array.prototype.slice.call(arguments, 1)));
		elts = elts.concat(siblings);
		return elts;
	}
};

jQuery.extend({
	num: function(v) {
		var n = parseInt(v);
		return n == null || isNaN(n) ? 0 : n;
	},
	
	toUniqArr: function(arr) {
		var r = [],d = {};
		for(var i=0, l=arr.length; i < l; i++) {
			var id = arr[i];
			if (!done[id]){
				done[id] = true;
				r.push(arr[i]);
			}
		}
		return r;
	},

	isArray: function(v){
		return typeof(v) == 'object' && v != null && typeof(v.length) == 'number';
	},
	
	isNullOrEmpty: function(o) {
	    if(o == null 
	        && o == '') return true;
	    return false
	},
	
	isNull: function(o) {if(o == null && o == undefined) { return true; } return false },
	
	addCommas: function(num) {
	    num += '';
	    x = num.split('.');
	    x1 = x[0];
	    x2 = x.length > 1 ? '.' + x[1] : '';
	    var rgx = /(\d+)(\d{3})/;
	    while (rgx.test(x1))
		    x1 = x1.replace(rgx, '$1' + ',' + '$2');
	    return x1 + x2;
    },
    
    getUrlParam: function(name) {  
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var res = (new RegExp("[\\?&]"+name+"=([^&#]*)")).exec(window.location.href);
        return res ? decodeURIComponent(res[1]) : '';
    }
});

/**
*@grid-scroll-position
* description (addPositionItem, updatePositionItem, removePositionItem) dataItem [] - array
* created 03/01/2008
*/

jQuery.fn.addPositionItem = function(){
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    
    /**
	*@data
	*/
    var dataItem = arg.dataItem;

    /**
	*@callback's
	*/
    var onModify = arg.onModify;
    var onClose = arg.onClose;
    
    /**
    *@param's
    */
    var flowId = $(lastTab)[0].id; // need to change take this param from arguments
    var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');
    
    var item = $.create('div',{'class' : 'grid-scroll-item item-'+flowId},[]); // item
    var visible = $.create('div',{'class' : 'visible'},[]);
    
    var expand = $.create('span',{'class' : 'expand'},[]);
    var checkbox = $.create('input',{'type' : 'checkbox'},[]);
    
    $(visible).css({'background':'#f8f7f7'}).hover(function(){
           $(this).addClass('grid-hover') 
        }, function(){ $(this).removeClass('grid-hover') });
    
    var a = $.create('div',{'class' : 'a'},[]);
    var b = $.create('div',{'class' : 'b'},[]);
    var c = $.create('div',{'class' : 'c'},[]);
    var d = $.create('div',{'class' : 'd'},[]);
    var e = $.create('div',{'class' : 'e'},[]);
    var f = $.create('div',{'class' : 'f'},[]);
    var g = $.create('div',{'class' : 'g'},[]);
    var i = $.create('div',{'class' : 'i'},[]);
    var j = $.create('div',{'class' : 'j profit-loss-'+flowId},[]);
    
    var unnamed = $.create('div',{'class':'unnamed'},[]);
    
    var k = $.create('div',{'class' : 'k'},[]);
    var l = $.create('div',{'class' : 'l'},[]);
    
    var bell = $.create('div',{'class':'bell'},[]);
    
    var modify = $.create('span',{'class':'modify modify-'+flowId},[]);

    var close = $.create('span',{'class':'close close-'+flowId},[]);
    
    var hidden = $.create('div',{'class' : 'hidden hidden-'+flowId},[]);
    $(hidden)[0].style.display = 'none';
    
    if(dataItem != null && dataItem.length > 0) {
        if($(t)[0].innerHTML != "") {
            if(flowId != 'limit' && flowId != 'sms') {
                $(b).text(dataItem[0]);
                $(c).text(dataItem[1]);
                $(d).text(dataItem[2]);
                $(e).text(dataItem[3]);
                $(f).text(dataItem[4]);
                $(g).text(dataItem[5]);
                $(i).html(dataItem[6]);
                $(j).text(dataItem[7]);
                
                $(unnamed).append($(bell)); //
                
                if(!jQuery.isNull(onModify)) {
                    $(modify).unbind('click').bind('click',function(){
                        onModify($(b).text()); 
                    });
                }

                $(k).append($(modify).text('Modify')); 
                 
                if(!jQuery.isNull(onClose)) {
                    $(close).unbind('click').bind('click',function(){
                        onClose($(b).text()); 
                    });
                }
                $(l).append(close);
                
                $(hidden).attr({'dataRate':dataItem[8],'dataLoss':dataItem[9],'dataAverage':dataItem[10],'dataProfit':dataItem[11]}).hide();
                $($(t).children()[0]).before($(item).append($(visible).append($(a).append(expand).append(checkbox)).append(b).append(c).append(d).append(e).append(f).append(g).append(i).append(j).append(unnamed).append(k).append(l)).append(hidden));
            } else {
                if(flowId == 'sms') {
                    $(b).text(dataItem[0]);
                    $(c).text(dataItem[1]);
                    $(d).text(dataItem[2]);
                    $(e).text(dataItem[3]);
                    $(f).text(dataItem[4]);
                    
                    if(!jQuery.isNull(onModify)) {
                        $(modify).unbind('click').bind('click',function(){
                            onModify($(b).text()); 
                        });
                    }
                    
                    $(k).append($(modify).text('Modify'));
                     
                    if(!jQuery.isNull(onClose)) {
                        $(close).unbind('click').bind('click',function(){
                            onClose($(b).text()); 
                        });
                    }
                    $(l).append(close);
                    
                    $($(t).children()[0]).before($(item).append($(visible).append($(a).append(checkbox)).append(b).append(c).append(d).append(e).append(f).append(k).append(l)));
                } else {
                    $(b).text(dataItem[0]);
                    $(c).text(dataItem[1]);
                    $(d).text(dataItem[2]);
                    $(e).text(dataItem[3]);
                    $(f).text(dataItem[4]);
                    $(g).text(dataItem[5]);
                    $(i).html(dataItem[6]);
                    
                    $(unnamed).append($(bell)); //
                    
                    if(!jQuery.isNull(onModify)) {
                        $(modify).unbind('click').bind('click',function(){
                            onModify($(b).text()); 
                        });
                    }
                    $(k).append($(modify).text('Modify'));
                     
                    if(!jQuery.isNull(onClose)) {
                        $(close).unbind('click').bind('click',function(){
                            onClose($(b).text()); 
                        });
                    }
                    $(l).append(close);
                    
                    $(hidden).attr({'dataRate':dataItem[8],'dataLoss':dataItem[9],'dataAverage':dataItem[10],'dataProfit':dataItem[11]}).hide();
                    $($(t).children()[0]).before($(item).append($(visible).append($(a).append(expand).append(checkbox)).append(b).append(c).append(d).append(e).append(f).append(g).append(i).append(unnamed).append(k).append(l)).append(hidden));
                }
            }
        } else {
            if(flowId != 'limit' && flowId != 'sms') {
            
                $(b).text(dataItem[0]);
                $(c).text(dataItem[1]);
                $(d).text(dataItem[2]);
                $(e).text(dataItem[3]);
                $(f).text(dataItem[4]);
                $(g).text(dataItem[5]);
                $(i).html(dataItem[6]);
                $(j).text(dataItem[7]);
                
                $(unnamed).append($(bell)); // 
                
                if(!jQuery.isNull(onModify)) {
                    $(modify).unbind('click').bind('click',function(){
                        onModify($(b).text()); 
                    });
                }
                $(k).append($(modify).text('Modify'));
                 
                if(!jQuery.isNull(onClose)) {
                    $(close).unbind('click').bind('click',function(){
                        onClose($(b).text()); 
                    });
                }
                $(l).append(close);
                
                $(hidden).attr({'dataRate':dataItem[8],'dataLoss':dataItem[9],'dataAverage':dataItem[10],'dataProfit':dataItem[11]}).hide();
                $(t).append($(item).append($(visible).append($(a).append(expand).append(checkbox)).append(b).append(c).append(d).append(e).append(f).append(g).append(i).append(j).append(unnamed).append(k).append(l)).append(hidden));
            } else {
                if(flowId == 'sms') {
                    $(b).text(dataItem[0]);
                    $(c).text(dataItem[1]);
                    $(d).text(dataItem[2]);
                    $(e).text(dataItem[3]);
                    $(f).text(dataItem[4]);
                    
                    if(!jQuery.isNull(onModify)) {
                        $(modify).unbind('click').bind('click',function(){
                            onModify($(b).text()); 
                        });
                    }
                    $(k).append($(modify).text('Modify'));
                     
                    if(!jQuery.isNull(onClose)) {
                        $(close).unbind('click').bind('click',function(){
                            onClose($(b).text()); 
                        });
                    }
                    $(l).append(close);
                    
                    $(t).append($(item).append($(visible).append($(a).append(checkbox)).append(b).append(c).append(d).append(e).append(f).append(k).append(l)));
                 } else {
                    $(b).text(dataItem[0]);
                    $(c).text(dataItem[1]);
                    $(d).text(dataItem[2]);
                    $(e).text(dataItem[3]);
                    $(f).text(dataItem[4]);
                    $(g).text(dataItem[5]);
                    $(i).html(dataItem[6]);
                    
                    $(unnamed).append($(bell)); //
                    
                    if(!jQuery.isNull(onModify)) {
                        $(modify).unbind('click').bind('click',function(){
                            onModify($(b).text()); 
                        });
                    }
                    $(k).append($(modify).text('Modify'));
                     
                    if(!jQuery.isNull(onClose)) {
                        $(close).unbind('click').bind('click',function(){
                            onClose($(b).text()); 
                        });
                    }
                    $(l).append(close);
                    
                    $(hidden).attr({'dataRate':dataItem[8],'dataLoss':dataItem[9],'dataAverage':dataItem[10],'dataProfit':dataItem[11]}).hide();
                    $(t).append($(item).append($(visible).append($(a).append(expand).append(checkbox)).append(b).append(c).append(d).append(e).append(f).append(g).append(i).append(unnamed).append(k).append(l)).append(hidden));
                 }
            }
        }
        
        /**
        *@expand properties
        */
        $(expand).click(function(){
            if($(hidden)[0].style.display == 'none'){
                
                $('.item-'+flowId).each(function(i,el){
                    if(el != item){ $(el).hide(); }
                });
                
                $(this).addClass('dxp');
                
                var box = $(t).parent().parent();
                var container = $(box).children();
                var knob = $(container).children()[1];
                
                $(t).animate({top:0},400);
                $(knob).animate({top:0},400);
                
                var properties = $.create('div',{'class':'expand-prop'},[]);
                
                var row1 = $.create('div',{'class':'prop-row'},[]);
                var row2 = $.create('div',{'class':'prop-row'},[]);
                var row3 = $.create('div',{'class':'prop-row'},[]);
                
                var cell1_1 = $.create('div',{'class':'prop-cell-1'},[]);
                var cell2_1 = $.create('div',{'class':'prop-cell-2'},[]);
                var cell1_2 = $.create('div',{'class':'prop-cell-1'},[]);
                var cell2_2 = $.create('div',{'class':'prop-cell-2'},[]);
                var cell1_3 = $.create('div',{'class':'prop-cell-1'},[]);
                var cell2_3 = $.create('div',{'class':'prop-cell-2'},[]);
                
                $(properties).append(
                    $(row1).append($(cell1_1).text('Open date:')).append($(cell2_1).text('30-Nov-07'))).append(
                    $(row2).append($(cell1_2).text('Rolling Until:')).append($(cell2_2).text('30-Nov-07'))).append(
                    $(row3).append($(cell1_3).text('Amount to risk:')).append($(cell2_3).text('1,000.000.00 USD'))
                    )
                
                var o = $.create('div',{'class':'expand-flash'},[]);
                $(o).attr({'id':'flashbar4'});
                
                $(hidden).empty().append(properties).append(o);
                var so = new SWFObject("../../app_resources/activeX/deal_detail.swf", "deal_detail", "400", "35", "8", "#FFFFFF");
                so.addParam('FlashVars', '');
                so.addParam("scale", "noscale");
                so.addParam("wmode", "transparent");
                so.addParam('salign', 'lt');
                so.write("flashbar4");
                
                if(document.getElementById('deal_detail')) {
//                    $.timer(1200, function(timer){
//                        try{
//                            document.getElementById('deal_detail').updateStructure($(obj).attr('dataRate'), $(obj).attr('dataLoss'), $(obj).attr('dataAverage'), $(obj).attr('dataProfit'));
//                        } catch(exception) { $.message('Error Exception','@updateStructure(), the ActiveX Object is not loaded...') }
//                        timer.stop();
//                    });
                }
                lastExpand = $(hidden);
                $(hidden).show();
            } else {
                $(this).removeClass('dxp');
                $(hidden).hide()
                
                $('.item-'+flowId).each(function(i,el){
                    if(el != item){ $(el).show(); }
                });
            }
            
        });
    }
};

jQuery.fn.updatePositionItem = function(){
    if (arguments.length == 0) return [];
	var arg = arguments[0];	
	
	/**
	*@data
	*/
	var dataItem = arg.dataItem;

	var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');

    /*
    *@warning: not for sms grid
    */
    if(dataItem != null && dataItem.length > 0) {
        for(var i = 0; i < $(t).children().length; i++){
            var o = $(t).children()[i];
            var id = $(o).children()[0];
            if(parseInt($(id).children()[1].innerHTML) == dataItem[0]) {
                   
                if(!jQuery.isNull($(id).children()[5])) {
                    var el = $($(id).children()[5]);
                    if(el.text() < dataItem[1]) { el.removeClass('down-rate').addClass('up-rate')
                    } else if (el.text() > dataItem[1]) { el.removeClass('up-rate').addClass('down-rate') } else {
                        el.removeClass('down-rate').removeClass('up-rate'); }
                    el[0].innerHTML = dataItem[1] == undefined ? '&nbsp;' : dataItem[1];}
                
                if(!$(o).hasClass('item-limit')){
                    if(!jQuery.isNull($(id).children()[8])){
                        var el = $($(id).children()[8]);
                        if(el.text() < dataItem[2]) { el.removeClass('down-rate').addClass('up-rate') 
                        } else if(el.text() > dataItem[2]) { el.removeClass('up-rate').addClass('down-rate') } else {
                            el.removeClass('down-rate').removeClass('up-rate'); }
                        el[0].innerHTML = dataItem[2] == undefined ? '&nbsp;' : dataItem[2]; }
                }
            }
        }
    } 
};

jQuery.fn.removePositionItem = function(){
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    
    /**
	*@data
	*/
    var tradeId = arg.tradeId;
        
    var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');
    
    for(var i = 0; i < $(t).children().length; i++){
        var o = $(t).children()[i];
        var id = $(o).children()[0];
        if(parseInt($(id).children()[1].innerHTML) == tradeId) { 
            $(o).remove();
            
            var box = $(t).parent().parent();
            var container = $(box).children();
            var knob = $(container).children()[1];
            
            $(t).animate({top:0},400);
            $(knob).animate({top:0},400);  
        } 
    }
};

jQuery.fn.bindData = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    var dataSource = arg.dataSource;
    var gridType = arg.gridType;
    
    var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');
    
    // get dataSource
	if(!jQuery.isArray(dataSource)) return; // exception
	if(dataSource.length > 0) {
	    var _temp = [];
	    _temp = dataSource;
	    for(var i = 0; i < _temp.length; i++) {
	        if(gridType != null && gridType != undefined) {
	             $(t).append("<div class=\"multi-thank-you-grid-scroll-item\">"+
	            "<div class=\"a\">"+_temp[i][0]+"</div><div class=\"b\">"+_temp[i][1]+"</div><div class=\"c\">"+_temp[i][2]+"</div>"+
	            "</div>");
	        } else {
	            if(_temp[i][6] != 0) {
	                $(t).append("<div class=\"multi-grid-scroll-item grey\">"+
	                "<div class=\"a\">"+_temp[i][0]+"</div><div class=\"b\">"+_temp[i][1]+"</div><div class=\"c\">"+_temp[i][2]+"</div><div class=\"d\">"+_temp[i][3]+"</div><div class=\"e\">"+_temp[i][4]+"</div><div class=\"f\">"+_temp[i][5]+"</div>"+
	                "</div>");
	            } else {
	                $(t).append("<div class=\"multi-grid-scroll-item\">"+
	                "<div class=\"a\">"+_temp[i][0]+"</div><div class=\"b\">"+_temp[i][1]+"</div><div class=\"c\">"+_temp[i][2]+"</div><div class=\"d\">"+_temp[i][3]+"</div><div class=\"e\">"+_temp[i][4]+"</div><div class=\"f\">"+_temp[i][5]+"</div>"+
	                "</div>");
	            }
	        }
	    }
	}
};

jQuery.fn.updateData = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    var dataSource = arg.dataSource;
    var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');
    
    for(var i = 0; i < $(t).children().length; i++){
        var o = $(t).children()[i];
        // get dataSource for update re-write
        if(!jQuery.isArray(dataSource)) return; // exception
        if(dataSource.length > 0) {
            var _temp = [];
	        _temp = dataSource;
	        for(var x = 0; x < _temp.length; x++) {
	            if($(o).children()[0].innerHTML == _temp[x][0]) {
                    var el= $(o).children()[4];
                    if($(o).children()[4].innerHTML > _temp[x][1]) {
                        $(el).css({'color':'#DB1B56'}); // red
                    } else if ($(o).children()[4].innerHTML < _temp[x][1]) { $(el).css({'color':'#00B54B'}); // green
                    } else { $(el).css({'color':'#333'}); }  
                    $(o).children()[4].innerHTML = _temp[x][1];	                
	                
	                if(_temp[x][4] != 0) {
	                    $(o).addClass('grey');
	                } else {
	                    $(o).removeClass('grey');
	                }
	                
	                $(o).children()[5].innerHTML = _temp[x][2];
	            }
	        }     
        }
    }
};

jQuery.fn.updateMode = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    var dataSource = arg.dataSource;
    var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');
    
    for(var i = 0; i < $(t).children().length; i++){
        var o = $(t).children()[i];
        // get dataSource for update re-write
        if(!jQuery.isArray(dataSource)) return; // exception
        if(dataSource.length > 0) {
            var _temp = [];
	        _temp = dataSource;
	        for(var x = 0; x < _temp.length; x++) {
	            if($(o).children()[0].innerHTML == _temp[x][0]) {
	                if(_temp[x][1] != 0) {
	                    $(o).addClass('grey');
	                } else {
	                    $(o).removeClass('grey');
	                }
	            }
	        }
	    }
	}
};

jQuery.fn.removeData = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    var dataSource = arg.dataSource;
    var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');
    
    for(var i = 0; i < $(t).children().length; i++){
        var o = $(t).children()[i];
        // get dataSource for update re-write
        if(!jQuery.isArray(dataSource)) return; // exception
        if(dataSource.length > 0) {
            var _temp = [];
	        _temp = dataSource;
	        for(var x = 0; x < _temp.length; x++) {
	            if($(o).children()[0].innerHTML == _temp[x][0]) $(o).remove(); // remove element
	        }
	    }
    }
};

jQuery.fn.trashData = function() {
    var t = $(this[0]).children('.scrollbar-box').children('.scrollbar-container');
    $(t).empty();
};

jQuery.getSelectedItems = function(id, callback) {
    if($(id)) {
        array = [];
        var t = $(id).children('.scrollbar-box').children('.scrollbar-container');
        for(var i = 0; i < $(t).children().length; i++){
            var o = $(t).children()[i];
            var f = $(o).children().children();
           
            if($(f).children()[1].checked || $(f).children()[0].checked){
                var tradeId = $(o).children()[0];
                array.push($(tradeId).children()[1].innerHTML);
            }
        }
        if(!jQuery.isNull(callback) && array.length > 0) callback(array)
    } 
};

/**
*@numeric setValue
*/
jQuery.fn.setValue = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    
    /**
    *@arguments
    */
    var dataValue = arg.dataValue;
    var fixedSize = arg.fixedSize;
    
    var obj = $(this[0]);
    var size = parseInt(obj.attr('fixedSize'));
    if(!jQuery.isNull(fixedSize)) {
        if(fixedSize != size && fixedSize != 0) size = fixedSize;
    }
    
    if(dataValue != null) {
        var numberInput = obj.children('.numeric-list-context').children();
        $(numberInput)[0].value = dataValue.toFixed(size);
        $(numberInput).blur();
        
        obj.attr({'dataValue':$(numberInput)[0].value}); // attr
    } else { 
        var numberInput = obj.children('.numeric-list-context').children().empty();
        $(numberInput)[0].value = '';
        obj.attr({'dataValue':null}); // attr
    }
};

/**
*@numeric setMinMax
*/
jQuery.fn.setMinMax = function() {
    if (arguments.length == 0) return [];
    var arg = arguments[0];
    
    /**
    *@arguments
    */
    var minValue = arg.minValue;
    var maxValue = arg.maxValue;
    var fixedSize = arg.fixedSize;

    var obj = $(this[0]);
    var size = parseInt(obj.attr('fixedSize'));
    if(!jQuery.isNull(fixedSize)) {
        if(fixedSize != size && fixedSize != 0) size = fixedSize;
    }
    
    obj.attr({'minValue':minValue.toFixed(size)}).attr({'maxValue':maxValue.toFixed(size)});
};

/**
*@quots version beta
*/

jQuery.getQuots = function() { 
    var _temp = null;
    $.getJSON("http://localhost/EFLabs/App_Generic/Quots.ashx", { method: 'GetQuots'}, function(json) {
        if(_temp != null && _temp != json) {  }
        _temp = json;
        
        if(_temp != null) { $.timer(2000, function(timer){ $.getQuots(); timer.stop(); }) }
    });
};

jQuery.fn.efUpdate = function(flag)
{
	return this.each(function(i){
		var load = $(this).children('.easy-load');
		if(typeof flag == 'boolean' ? flag : load.length == 0)
		{
			if(load.length != 0) return;
			var style = 'width:' + this.clientWidth + 'px;height:' + this.clientHeight + 'px;position:absolute;top:0;left:0;z-index:100;';
			$(this).prepend('<div class="easy-load" style="' + style + '">&nbsp;<div style="' + style + '"></div></div>');
		}
		else
		{
			if(load.length == 0) return;
			load.remove();
		}
	});
};

jQuery.stringFormat = function(str)
{
    for (var i=0,j=arguments.length-1;i<j;i++)      
        str = str.replace('{'+i+'}',arguments[i+1]);
    return str;
};
/* NEXT FILE : D:\WWWSource\Site\js\Puma\validation.js************************************************************/
/*all validation functions:*/

var ValidationManager = {
    
	/*checks whthear field is empty*/
    RequiredFieldIsValid:function(value)
	{
        return !ValidationManager.IsEmpty(value);
    },
    IsEmpty:function(value)
	{
        return !/\S{1,}/.test($.trim(value));
    },
    
    /*checks wheather field is between min and max range*/
	/*default:do trim on value. to remove trim action send 0 for trim param */
	/*default min=0*/
    RequiredLengthRange:function(value, max, min)
	{
        var val = $.trim(value);
        if (!min) 
            min = 0;
        return new RegExp("^.{" + min + "," + max + "}$").test(val);
    },
    
    isValidFirstLastName: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return true;
    },
    isValidEmailAddress: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/.test(value);
    },
    isValidCountryCode: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^\d{1,3}$/.test(value);
    },
    isValidAreaCode: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        
        return /^\d{1,5}$/.test(value);
    },
    isValidPhone: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^\d{5,15}$/.test(value);
    },
    isValidStreet: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^[a-zA-Z0-9\-. \/]{1,}$/.test(value);
    },
    isValidAddress: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^[a-zA-Z0-9\-. ]{1,}$/.test(value);
    },
    IsOnlyEnglishLettersAndNumbers: function(value){
        return /^[a-zA-Z0-9]{1,}$/.test(value);
    },
    IsValidZipCode: function(value) {
        return /^[a-zA-Z0-9\s]{1,}$/.test(value);
    },
    IsValidUsername: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^[a-zA-Z0-9!_.-]{6,20}$/.test(value);
    },
    IsValidPassword: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^[a-zA-Z0-9!_.-]{6,12}$/.test(value);
    },
    IsValidSecretAnswer: function(value){
        if (!ValidationManager._checkIfParamEmpty(value)) 
            return false;
        return /^[A-Za-z0-9:\/]{2,15}$/.test(value);
    },
    
    /*internal function*/
    _checkIfParamEmpty: function(value){
        if (!value) 
            return false;
        return /\S{1,}/.test(value);
    },
	onKeypressCheckAmount:function(event)
    { 
	    var num,a,WasPoint=false;
	    event.cancelBubble=true;
	    num=event.keyCode-48;
	    for (a=0;a<$(this).val().length;a++)
		    if ($(this).val().charAt(a)=='.') WasPoint=true;
	    if (event.keyCode==46 && (!WasPoint)) return true; //Point
	    if (event.keyCode<48 || event.keyCode>57) return false;
	    return true;
    }
    
};

var KeypressValidation = {
    /*attach input enter press to function*/
    attachDefault: function(inputId, func){
        $(inputId).unbind('keypress').keypress(function(e){
            var e = e || window.event;
            var key = e.keyCode ? e.keyCode : e.which;
            if (key == 13){ 
                func();
                return false;
                }
        });
    },
    userNameAndPasswordChars: function(e){
        var e = e || window.event;
        var key = e.keyCode ? e.keyCode : e.which;
        if (KeypressValidation._isNavigationKey(e)) 
            return true;
        if (!(key >= 65 && key <= 90) && !(key >= 97 && key <= 122) && !(key >= 48 && key <= 57) && (key != 95) && (key != 45) && (key != 46) && (key != 33) && (key != 127) && (key != 0) && (key != 8)) 
            e.preventDefault();
    },
     zipChars:function(e){
        var e = e || window.event;
        var key = e.keyCode ? e.keyCode : e.which;
        if (KeypressValidation._isNavigationKey(e)) 
            return true;
        if(!(key>=65 && key <=90) && !(key>=97 && key <=122) && !(key>=48 && key<=57) && !(key == 32))
            return false;
        return true;
    },
    secretAnswerChars:function(e)
    {
        var e = e || window.event;
        var key = e.keyCode ? e.keyCode : e.which;
        if (KeypressValidation._isNavigationKey(e)) 
            return true;
        var ch = String.fromCharCode(key);
        if(!(key>=65 && key <=90) && !(key>=97 && key <=122) && !(key>=48 && key<=57) && (ch!='/') && (ch!=':'))
            return false;
           return true;
    },
    emailChars: function(e){
        var e = e || window.event;
        
        if ($(e.target).val().length >= 70) 
            return false;
        
        var key = e.keyCode ? e.keyCode : e.which;
        if (KeypressValidation._isNavigationKey(e)) 
            return true;
        if ((key == 64) && /@/.test($(e.target).val()))/*not allows two '@'*/ {
            return false;
        }
        else 
            if (!(key >= 65 && key <= 90) && !(key >= 97 && key <= 122) && !(key >= 48 && key <= 57) && (key != 95) && (key != 45) && (key != 46) && (key != 33) && (key != 127) && (key != 0) && (key != 8) && (key != 64)) {
                return false;
            }
        return true;
    },
    firstLastnameChars: function(e){
        var e = e || window.event;
        var key = e.keyCode ? e.keyCode : e.which;
        if (KeypressValidation._isNavigationKey(e)) 
            return true;
        if (!(key >= 65 && key <= 90) && !(key >= 97 && key <= 122) && (key != 32) && (key != 45)) 
            return false;
        return true;
        
    },
    streetChars: function(e){
        var e = e || window.event;
        var key = e.keyCode ? e.keyCode : e.which;
        if (KeypressValidation._isNavigationKey(e)) 
            return true;
        var c = String.fromCharCode(key);
        if (!ValidationManager.isValidStreet(c) && key != 32) 
            return false;
        return true;
    },
    cityChars: function(e){
        var e = e || window.event;
        var key = e.keyCode ? e.keyCode : e.which;
        if (KeypressValidation._isNavigationKey(e)) 
            return true;
        var c = String.fromCharCode(key);
        if (!ValidationManager.isValidAddress(c) && key != 32) 
            return false;
        
    },
    
    _isNavigationKey: function(e) /*for firefox - doesnt automatically allow like explorer*/{
        var e = e || window.event;
        var key = e.keyCode ? e.keyCode : e.which;
        if ((key == 9 //tab
 ||
        key == 35 //End
 ||
        key == 36 //Home
 ||
        key == 37 // <-
 ||
        key == 39 // ->
 ||
        key == 0 // Del
 ||
        key == 8 //BackSpace
) &&
        e.charCode == 0) 
            return true;
        return false;
    }
    
};


function NumberFormat(num)
{
	this.num;
	this.numOriginal;
	this.isCommas;
	this.isCurrency;
	this.currencyPrefix;
	this.places;
	this.setNumber = setNumberNF;
	this.toUnformatted = toUnformattedNF;
	this.setCommas = setCommasNF;
	this.setCurrency = setCurrencyNF;
	this.setCurrencyPrefix = setCurrencyPrefixNF;
	this.setPlaces = setPlacesNF;
	this.toFormatted = toFormattedNF;
	this.getOriginal = getOriginalNF;
	this.getRounded = getRoundedNF;
	this.preserveZeros = preserveZerosNF;
	this.justNumber = justNumberNF;
	this.setNumber(num);
	this.setCommas(true);
	this.setCurrency(true);
	this.setCurrencyPrefix('$');
	this.setPlaces(2);
    function setNumberNF(num)
    {
	    this.numOriginal = num;
	    this.num = this.justNumber(num);
    }
    function toUnformattedNF(){return (this.num);}
    function getOriginalNF(){return (this.numOriginal);}
    function setCommasNF(isC){this.isCommas = isC;}
    function setCurrencyNF(isC){this.isCurrency = isC;}
    function setCurrencyPrefixNF(cp){this.currencyPrefix = cp;}
    function setPlacesNF(p){this.places = p;}
    function toFormattedNF()
    {
	    var pos;
	    var nNum = this.num;
	    var nStr;
	    nNum = this.getRounded(nNum);
	    nStr = this.preserveZeros(Math.abs(nNum));
	    if (this.isCommas)
	    {
		    pos = nStr.indexOf('.');
		    if (pos == -1){pos = nStr.length;}
		    while (pos > 0)
		    {
			    pos -= 3;
			    if (pos <= 0) break;
			    nStr = nStr.substring(0,pos) + ',' + nStr.substring(pos, nStr.length);
		    }
	    }
	    nStr = (nNum < 0) ? '-' + nStr : nStr; // v1.0.1

	    if (this.isCurrency){nStr = this.currencyPrefix + nStr;}
	    return (nStr);
    }
    function getRoundedNF(val)
    {
	    var factor;
	    var i;
	    factor = 1;
	    for (i=0; i<this.places; i++)
	    {	factor *= 10; }
	    val *= factor;
	    val = Math.round(val);
	    val /= factor;
	    return (val);
    }
    function preserveZerosNF(val)
    {
	    var i;
	    val = val + '';
	    if (this.places <= 0) return val;
	    var decimalPos = val.indexOf('.');
	    if (decimalPos == -1)
	    {
		    val += '.';
		    for (i=0; i<this.places; i++){val += '0';}
	    }
	    else
	    {
		    var actualDecimals = (val.length - 1) - decimalPos;
		    var difference = this.places - actualDecimals;
		    for (i=0; i<difference; i++){val += '0';}
	    }
	    return val;
    }
    function justNumberNF(val)
    {
	    val = (val==null) ? 0 : val;
	    if (isNaN(val))
	    {
		    var newVal = parseFloat(val.replace(/[^\d\.\-]/g, ''));
		    return (isNaN(newVal) ? 0 : newVal); 
	    }
	    else if (!isFinite(val)){return 0;}
	    return val;
    }
}


//The object to check fields for input values from site http://itgroup.com.ph/alphanumeric/
//Samples:
//$('.sample5').numeric({allow:"."}); //just numbers and dot
//$('.sample6').alphanumeric({ichars:'.1a'});//all symbols exept . 1 a
(function($){

    $.fn.alphanumeric = function(p){
    
        p = $.extend({
            ichars: "!@#$%^&*()+=[]\\\';,/{}|\":<>?~`.- ",
            nchars: "",
            allow: ""
        }, p);
        
        return this.each(function(){
        
            if (p.nocaps) 
                p.nchars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            if (p.allcaps) 
                p.nchars += "abcdefghijklmnopqrstuvwxyz";
            
            s = p.allow.split('');
            for (i = 0; i < s.length; i++) 
                if (p.ichars.indexOf(s[i]) != -1) 
                    s[i] = "\\" + s[i];
            p.allow = s.join('|');
            
            var reg = new RegExp(p.allow, 'gi');
            var ch = p.ichars + p.nchars;
            ch = ch.replace(reg, '');
            
            $(this).keypress(function(e){
            
                if (!e.charCode) 
                    k = String.fromCharCode(e.which);
                else 
                    k = String.fromCharCode(e.charCode);
                
                if (ch.indexOf(k) != -1) 
                    e.preventDefault();                
            });
                        
        });
        
    };
    
    /// lior: 25/03/2008 - this numeric function has problem with non - english letters. i added another plugin at the bottom.
//    $.fn.numeric = function(p){
//    
//        var az = "abcdefghijklmnopqrstuvwxyz";
//        az += az.toUpperCase();
//        
//        p = $.extend({
//            nchars: az
//        }, p);
//        
//        return this.each(function(){
//            $(this).alphanumeric(p);
//        });
//        
//    };
    
    $.fn.alpha = function(p){
    
        var nm = "1234567890";
        
        p = $.extend({
            nchars: nm
        }, p);
        
        return this.each(function(){
            $(this).alphanumeric(p);
        });
        
    };
    
})(jQuery);


/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Version 1.0
 * Demo: http://www.texotela.co.uk/code/jquery/numeric/
 *
 * $LastChangedDate$
 * $Rev$
 */
 
/*
 * Allows only valid characters to be entered into input boxes.
 * Note: does not validate that the final text is a valid number
 * (that could be done by another script, or server-side)
 *
 * @name     numeric
 * @param    decimal      Decimal separator (e.g. '.' or ',')
 * @param    callback     A function that runs if the number is not valid (fires onblur)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $(".numeric").numeric();
 * @example  $(".numeric").numeric(",");
 * @example  $(".numeric").numeric(null, callback);
 *
 */
jQuery.fn.numeric = function(decimal, callback)
{
	decimal = decimal || "";
	callback = typeof callback == "function" ? callback : function(){};
	this.keypress(
		function(e)
		{
			var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
			// allow enter/return key (only when in an input box)
			if(key == 13 && this.nodeName.toLowerCase() == "input")
			{
				return true;
			}
			else if(key == 13)
			{
				return false;
			}
			var allow = false;
			// allow Ctrl+A
			if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) return true;
			// allow Ctrl+X (cut)
			if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) return true;
			// allow Ctrl+C (copy)
			if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) return true;
			// allow Ctrl+Z (undo)
			if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) return true;
			// allow or deny Ctrl+V (paste), Shift+Ins
			if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */
			|| (e.shiftKey && key == 45)) return true;
			// if a number was not pressed
			if(key < 48 || key > 57)
			{
				/* '-' only allowed at start */
				if(key == 45 && this.value.length == 0) return true;
				/* only one decimal separator allowed */
				if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) != -1)
				{
					allow = false;
				}
				// check for other keys that have special purposes
				if(
					key != 8 /* backspace */ &&
					key != 9 /* tab */ &&
					key != 13 /* enter */ &&
					key != 35 /* end */ &&
					key != 36 /* home */ &&
					key != 37 /* left */ &&
					key != 39 /* right */ &&
					key != 46 /* del */
				)
				{
					allow = false;
				}
				else
				{
					// for detecting special keys (listed above)
					// IE does not support 'charCode' and ignores them in keypress anyway
					if(typeof e.charCode != "undefined")
					{
						// special keys have 'keyCode' and 'which' the same (e.g. backspace)
						if(e.keyCode == e.which && e.which != 0)
						{
							allow = true;
						}
						// or keyCode != 0 and 'charCode'/'which' = 0
						else if(e.keyCode != 0 && e.charCode == 0 && e.which == 0)
						{
							allow = true;
						}
					}
				}
				// if key pressed is the decimal and it is not already in the field
				if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) == -1)
				{
					allow = true;
				}
			}
			else
			{
				allow = true;
			}
			return allow;
		}
	)
	.blur(
		function()
		{
			var val = jQuery(this).val();
			if(val != "")
			{
				var re = new RegExp("^\\d+$|\\d*" + decimal + "\\d+");
				if(!re.exec(val))
				{
					callback.apply(this);
				}
			}
		}
	);
	return this;
}

/* NEXT FILE : D:\WWWSource\Site\js\Puma\Site.js************************************************************/

var Site = {
    url: null,
    machineUrl: null,
    direction: null,
    ContactUs: function() {
        window.location.href = Site.contactUsURL;
    },
    destWindowEnum: { machine: 1, simulator: 2 },

    OpenTradeWindow: function(buy, sell, destWin, returnUrl) {
        if (!destWin) /*as default open the machine.*/
            destWin = Site.destWindowEnum.machine;

        var qs;
        if (buy && sell) {
            qs = new Object();
            qs.buy = buy;
            qs.sell = sell;
        }
        machineUtils.go('_trade', null, qs, destWin, returnUrl);
    },

    HandleErr: function() {
        try {
            $.loader('');
        } catch (ex) { }

        window.location.href = Site.ErrorPage;
    },
    getKey: function(e) {
        try {
            var e = e || window.event;
            return e.keyCode ? e.keyCode : e.which;
        }
        catch (ex) {
            return null;
        }
    }
};

function stopEvent(e) {
    var e = e || window.event;

    e.cancelBubble = true;
    e.returnValue = false;

    if (e.stopPropagation) e.stopPropagation();

    return false;
}

// shlif
jQuery.shlif = function(header, text) {
    if ($('#shlif')) {
        $('.shlif-header').text(header);
        $('.shlif-body').html(text);
        $('#warraper-shlif').toggle();
        $('.shlif-open').bind('click', function() {
            $('#shlif').animate({ top: 0 }, 800);
            $.cookie('GShlif', 'Show', { expires: 30 });
        });
        $('.shlif-close').bind('click', function() {
            $('#shlif').animate({ top: 122 }, 800);
            $.cookie('GShlif', 'Off', { expires: 30 });
        });
        if ($.cookie("GShlif") != "Off") {
            $('#shlif').animate({ top: 0 }, 800);
        }
    }
}
var expressInstallFlashUrl = '../../Flash/expressinstall.swf';
// bannner
jQuery.banner = function(bannerMode, bannerId, BannerName, height, ResUrl) {
    if (bannerMode == 'Home') {
        
        /**
        *@default 864x218
        *@changes basil@easy-forex.com
        *@create date 16/03/2009
        */

        $('#banner-box').removeClass('banner-box-external').addClass('banner-box-default');
        var n = BannerName.lastIndexOf('.');
        if (BannerName.substring(n) != '.swf') {
            $('#banner-platform').html('<img src="' + ResUrl + 'SiteBannerDownload.aspx?bid=' + bannerId + '" />');
        } else {
            var so = new SWFObject(ResUrl + "SiteBannerDownload.aspx?bid=" + bannerId, "banner_", "864", height, "9", "#FFFFFF", "false");
            so.useExpressInstall(expressInstallFlashUrl);
            so.addParam('wmode', 'transparent');
            so.write('banner-platform');
        }
        $('#banner-box').toggle();
        $('#bnrX').bind('click', function() {
            $("#banner-box").hide();
        });
        
        /*@end */
        
    } else if (bannerMode == 'RegisterJoin') {
        /**
        *@external 250x300
        */
        $('#banner-box').removeClass('banner-box-default').addClass('banner-box-external');
        var n = BannerName.lastIndexOf('.');
        if (BannerName.substring(n) != '.swf') {
            $('#banner-platform').html('<img src="' + ResUrl + 'SiteBannerDownload.aspx?bid=' + bannerId + '" />');
        } else {

            //alert(ResUrl)

            var so = new SWFObject("/App_Resources/ActiveX/BannerLoader.swf", "banner_", "500", height, "9", "#FFFFFF", "false"/*Skip Flash Detect*/);
            so.useExpressInstall(expressInstallFlashUrl);
            so.addParam('wmode', 'transparent');
            so.addVariable('path', ResUrl + "SiteBannerDownload.aspx?bid=" + bannerId);
            so.write('banner-platform');

            //var so = new SWFObject(ResUrl + "SiteBannerDownload.aspx?bid=" + bannerId, "banner_", "500", height, "8", "#FFFFFF", "false"/*Skip Flash Detect*/);
            //so.useExpressInstall(expressInstallFlashUrl);
            //so.addParam('wmode', 'transparent');
            //so.write('banner-platform');
        }
        $('#banner-box').toggle();
    }
    else if (bannerMode == 'RegisterJoinTop') {
        /**
        *@external 500x300
        */
        //$('#banner-box').removeClass('banner-box-default').addClass('banner-box-external');
        var n = BannerName.lastIndexOf('.');
        if (BannerName.substring(n) != '.swf') {
            $('#banner-platformTop').html('<img src="' + ResUrl + 'SiteBannerDownload.aspx?bid=' + bannerId + '" />');
        } else {
            var so = new SWFObject("/App_Resources/ActiveX/BannerLoader.swf", "banner_", "864", height, "9", "#FFFFFF", "false"/*Skip Flash Detect*/);
            so.useExpressInstall(expressInstallFlashUrl);
            so.addVariable('path', ResUrl + "SiteBannerDownload.aspx?bid=" + bannerId);
            so.addParam('wmode', 'transparent');
            so.write('banner-platformTop');
        }
        $('#RegBannerTop').toggle();
    }
};

function runshlif(shlifheader, shlifmessage, LinkText, LinkHref) {
    shlifmessage += "<br /><a href='" + LinkHref + "'>" + LinkText + "</a>";
    $.shlif(shlifheader, shlifmessage);
}
function runBanner(page, bid, bannerName, height, ResUrl) {
    $.banner(page, bid, bannerName, height, ResUrl);
}

function Removeshlif() {
    $(".shlif-hidden-box").remove();
    $("#warraper-shlif").remove();
    $("#shlif").remove();
}



/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
 
* @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
* @desc Create a cookie with all available options.
 
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
 
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
*                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
*                             If set to null or omitted, the cookie will be a session cookie and will not be retained
*                             when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
*                        require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options, doc, getaction) {
    if (!doc) doc = document;
    if (typeof value != 'undefined' && getaction !== true) { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        doc.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (doc.cookie && doc.cookie != '') {
            var cookies = doc.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
}

/***********************************************************************************************************************************/
function _machineUtils() { return this.constructor(); }
_machineUtils.prototype = {

    getDefaultPath: function() {
        return 'Machine/TradingZone/default';
    },
    constants: {
        trade: '_trade', none: '_none', simulator: 'simulator'
    },
    refresh: function() {

    },
    isMachineOpen: function() {
        var cookieMio = $.cookie('mio'); /*mio = machine is open*/
        return (cookieMio && cookieMio == "1")
    },
    isSimulatorOpen: function() {
        var cookieSimio = $.cookie('simio'); /*simio = simulator is open*/
        return (cookieSimio && cookieSimio == "1")
    },
    close: function() {

        if (this.isMachineOpen() || this.isSimulatorOpen()) {
            var wnd = window.open('', machineWindowName)
            if (wnd && !wnd.closed)
                wnd.close();
        }
    },
    getMachineRef: function() {
        if (!this.isMachineOpen()) return null;
        var wnd = window.open('', machineWindowName)
        if (wnd && !wnd.closed) return wnd;
        return null;
    },


    /*
    @summary : goes to page in machine.
    @relativePath - example:  'Machine/TradingZone/default' or 'MyAccount/Deposit' - no aspx needed
    @dontSetFocuse - focus new window
    @qs -object(!) example:{buy:'usd',sell:'ILS'}.portalid and cultureid will be added always!
    @destWin:number- one of values of Site.destWindowEnum.
    */
    go: function(relativePath, dontSetFocuse, qs, destWin, returnUrl) {
        var mWin = Site.destWindowEnum.machine.machine || 1;
        var simWin = Site.destWindowEnum.simulator || 2;
        if (!destWin) /*as default open the machine.*/
            destWin = mWin;
        var specs = '';
        var machineIsOpen = this.isMachineOpen() || this.isSimulatorOpen();

        if (!machineIsOpen) {
            specs = 'status=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=1000,height=700,resizable=yes,scrollbars=yes';
        }
        var url = '';

        /*just want to switch - not specific page*/
        if (!relativePath || new RegExp(this.constants.none, 'i').test(relativePath)) {
            if (machineIsOpen) {
                url = 'none';
            }
            else relativePath = this.getDefaultPath(); /*if machine is closed open trading zone as default*/
        }
        /* want to go to home or homepage by login status*/
        else if (new RegExp(this.constants.trade, 'i').test(relativePath))
            relativePath = this.getDefaultPath();

        var query = '';

        if (qs && qs != '') {
            jQuery.each(qs, function(key, value) {
                query = $.addToQueryString(key + '=' + value, query);
            });
        }
        if (returnUrl) {
            if (query)
                query += '&returnurl=' + encodeURIComponent(returnUrl)
            else query = '?returnurl=' + encodeURIComponent(returnUrl)
        }
        /*just focus no url to redirect to*/
        if (url !== 'none') {
            url = this.getTradingWindowUrl(destWin) + relativePath + '.aspx' + query;
            if (destWin !== simWin && (new RegExp('Login.aspx', 'i').test(url) === false && !UserLogin.isAuthenticated()))
                url = Site.loginUrl + '?returnurl=' + encodeURIComponent(url) + (simWin == Site.destWindowEnum.simulator && UserLogin.isAuthenticated() ? '&sr=' + 'sz' : '');
        } else url = '';


        if (destWin == simWin) {
            $.cookie('sessionendSimulator5Min', null, { path: '/', domain: __cookieDomain });
            $.cookie('EZFXAuthSIM', null, { path: '/', domain: __cookieDomain });
        }
        try {
            var wnd = window.open(url, machineWindowName, specs);

            if (wnd && !dontSetFocuse) {
                wnd.focus();
            }
            if (!/\/\/secure./.test(window.location.href) || document.location.protocol != 'https:') {
                window.location.href = CurrentSecured;
            }
        } catch (ex) {

        }
    },
    /*url of machine or simulator*/
    getTradingWindowUrl: function(destWin) {
        /*as default open the machine.*/
        destWin = destWin || this.getOpenedTradingWindowUrl();

        if (destWin == Site.destWindowEnum.machine) {
            return Site.machineUrl;
        }
        else if (destWin == Site.destWindowEnum.simulator) {
            if (UserLogin.isAuthenticated())
                return Site.simulatorSecuredUrl;
            return Site.simulatorUrl;
        }
        throw "getTradingWindowUrl Error: Invlaid destWin parameter value";
    },
    getOpenedTradingWindowUrl: function() {

        if (this.isSimulatorOpen())
            return Site.destWindowEnum.simulator;
        return Site.destWindowEnum.machine;
    },
    /*initiates the html element with attribute machine_path*/
    setMachinePagesUrl: function() {
        try {
            var _self = this;
            var elements = $("[machine_path]");    /* 'Machine/TradingZone/default' or 'MyAccount/Deposit' - no aspx needed*/
            elements.each(function(i, el) {
                var relPath = $(el).attr('machine_path');
                $(el).click(function() {
                    if (relPath == _self.constants.simulator)
                        _self.go(_self.getDefaultPath(), false, null, Site.destWindowEnum.simulator)
                    else _self.go(relPath)
                });
                if (jQuery.nodeName(el, "a")) { /*if anchor set href*/
                    $(el).attr('href', 'javascript:void(0);');
                }
            });
        } catch (ex) {
            //alert(ex);
        }
    },
    constructor: function() { this.setMachinePagesUrl(); }
};
var machineUtils = null;
$(document).ready(function() {
    machineUtils = new _machineUtils();
});
/*************************************************************************************************************************************/
jQuery.landingPixel = function(PageFlag) {
    //var src = "http://www.easy-forex.info/track/visits.php?c=pixel_test_system&r=test1&subid=Puma6";
    //var LandUrl = "?r=" + PageFlag + "&gid=" + gatewayparams[0] + "&subid=" + (haveSar == true ? gatewayparams[2] : "") + "&uv=0|0";
    if (($.cookie('LandingPage') == 'true') && !$.isNull($.cookie("de4fe6"))) {
        $.cookie(' LandingPage', 'false', { path: '/', domain: __cookieDomain });
        var gatewayparams = $.getGatewayDetails();
        jQuery.getHiddenPixel(PageFlag, gatewayparams, "0|0");
    }
};
jQuery.getGatewayDetails = function() {
    var gatewayparams = null;
    var gatewayArr = null;
    if (!$.isNull($.cookie("de4fe6"))) {
        gatewayArr = $.cookie("de4fe6").split('&');
        gatewayparams = {
            gatewayId: $.trim(gatewayArr[0].replace("TAR=", "")),
            GatewaySubId: ''
        };
        if (gatewayArr.length >= 3) {
            gatewayparams.GatewaySubId = $.trim(gatewayArr[2].replace("SAR=", ""));
        }
    };
    return gatewayparams;
};
jQuery.getHiddenPixel = function(flagType, gatewayparams, uv) {
    var src = "";
    if ($.isNull(gatewayparams)) {
        src = "https://alpha.easy-forex.info/~ezforex/track/pixel_EF.php?r=" + flagType + "&gid=&subid=&uv=" + uv;
    }
    else {
        src = "https://alpha.easy-forex.info/~ezforex/track/pixel_EF.php?r=" + flagType + "&gid=" + ($.isNull(gatewayparams.gatewayId) ? '' : gatewayparams.gatewayId) + "&subid=" + ($.isNull(gatewayparams.GatewaySubId) ? '' : gatewayparams.GatewaySubId) + "&uv=" + uv;
    }
    var script = document.createElement("iframe");
    script.setAttribute('src', src);
    script.setAttribute('id', 'frameScriptHidden');
    $(script).css({ "with": '1px', 'height': '1px', 'display': 'none' });
    document.body.appendChild(script);
};

jQuery.pixelseclvl = function() {
    for (var i = 0; i <= PixelsArr.length - 1; ++i) {
        if (!$.isNull(PixelsArr[i])) {
            var imgpix = document.createElement("img");
            imgpix.setAttribute('src', '/baaaapixel.aspx?r=' + PixelsArr[i]);
            imgpix.setAttribute('id', 'HiddenPixel' + i);
            imgpix.setAttribute('style', 'width:1px;height:1px;');
            var x = document.body.appendChild(imgpix);
        }
    }
};

var simulator = {
    msg: '',
    msgs: {},
    openSimulatorWindow: function() {
        $.cookie('sessionendSimulator5Min', null, { path: '/', domain: __cookieDomain });
        $.cookie('EZFXAuthSIM', null, { path: '/', domain: __cookieDomain });
        this.msg = null;
        if (UserLogin.isDemoOrTest) {
            $.message('', simulator.msgs.simDemoTestMessage);
            return;
        }
        /*user logged in?*/
        if (UserLogin.isAuthenticated()) {
            /*is machine open ?*/
            if (machineUtils.isMachineOpen()) {
                this.msg = simulator.msgs.simOpenCloseMachine;
                this.btn1Text = simulator.msgs.simOpenBtnOK;
                this.btn2Text = simulator.msgs.simOpenBtnCancel;
            }
        }
        if (this.msg) {
            this.alertBeforeOpenSimilator();
        }
        else this.openSimulatorLogin()
    },
    openSimulatorLogin: function() {
        var qs = new Object();
        qs.buy = $('#dtr-buy').attr('selectedValue');
        qs.sell = $('#dtr-sell').attr('selectedValue');
        machineUtils.go('SimulatorLogin', null, qs);
    },
    alertBeforeOpenSimilator: function() {
        if (simulator.msg) {
            $.optional(simulator.msg, this.openSimulatorLogin, this.fnBtn2, this.fnBtn2, this.btn1Text, this.btn2Text);
        }

    }
};
/* NEXT FILE : D:\WWWSource\Site\js\Puma\Formating.js************************************************************/
// JScript File

function dateFormating(dtm)
{
    if (!dtm.toGMTString)
        dtm = new Date(dtm);
    if (dtm.toGMTString)
        return dtm.format("dd-MMM-yy");
}

/*
    
*/
function localDateFormating(utcDate)
{
    if (!utcDate.toLocaleTimeString)
    utcDate = new Date(utcDate);
	var utcMill = utcDate.getTime();
	var offsetMill = (utcDate.getTimezoneOffset())*60*1000;
	var localMill = utcMill - offsetMill;
	var localDate = new Date(localMill);

    return dateFormating(localDate);
}
function localDateTimeFormating(utcDate)
{
    if (!utcDate.toLocaleTimeString)
    utcDate = new Date(utcDate);
	var utcMill = utcDate.getTime();
	var offsetMill = (utcDate.getTimezoneOffset())*60*1000;
	var localMill = utcMill - offsetMill;
	var localDate = new Date(localMill);

    return dateTimeFormating(localDate);
}

function dateTimeFormating(dtm)
{
    if (!dtm.toGMTString)
        dtm = new Date(dtm);
    if (dtm.toGMTString)
        return dtm.format("dd-MMM-yy HH:mm");
}

function numberFormating(num)
{
    var tmpNumber = num.toString().split(".");
    var strtmp=new String("");
    var i = 0;
    
    while((tmpNumber[0].length - i)>3)
    {
        strtmp="," + tmpNumber[0].substr(tmpNumber[0].length-i-3,3)+strtmp;
        i+=3;
    }
    
    strtmp=tmpNumber[0].substr(0,tmpNumber[0].length - i) + strtmp;
    
    if (tmpNumber[1] != null)
    {
        if (tmpNumber[1][0] != null)
            strtmp+="." + tmpNumber[1][0];
        else
            strtmp+=".0";
        if (tmpNumber[1][1] != null)
            strtmp+=tmpNumber[1][1];
        else
            strtmp+="0";
    }
    else
    {
        strtmp+=".00";
    }
    return strtmp;
}
/* NEXT FILE : D:\WWWSource\Site\js\Puma\Login.js************************************************************/

var UserLogin = {

    openLoginInMachine: function(queryString) {
        if (!/secure.easy-forex.com/.test(window.location.href) || document.location.protocol != 'https:') {
            $.cookie("preLogin", true, { path: '/', domain: __cookieDomain });
            window.location.href = CurrentSecured;
        }

        machineUtils.go('Login', null, queryString);
    },

    beforeLogout: null,
    beforeLogoutCancel: null,

    isAuthenticated: function() {
        var username = $.cookie('EZFXUsername')
        return (username && username != '')
    },
    onLogoClick: function() {
        var url = '';
        if (UserLogin.isAuthenticated()) {
            if (Site.homePageUrl && Site.homePageUrl != '')
                url = Site.homePageUrl.replace(/Home.aspx/i, "HomePage.aspx");
        }
        else {
            if (Site.homePageUrl && Site.homePageUrl != '')
                url = Site.homePageUrl;
        }
        if (url != '')
            window.location.href = url;
    },

    askBeforeLogout: function(e) {
        /*verify user is not logged in.*/
        if (!UserLogin.isAuthenticated()) return;

        if (UserLogin.beforeLogout) UserLogin.beforeLogout();
        var fnOk = function() {
            /*close machine*/
            machineUtils.close();

            /*Machine logout*/
            var machineHandlerUrl = '/utp/MyAccount/Services/LoginService.ashx';
            $.getJSON(machineHandlerUrl, { action: "RemoveMachineSession" });

            /*server logout*/
            $.getJSON(UserLogin.LoginServiceUrl,
                { action: "Logout" }
                 , function(result) {
                     if (!result.ErrorOccured) {
                         window.location.href = Site.logoutUrl.replace(/homepage.aspx/i, "home.aspx");
                     }
                 }, Site.HandleErr);
            return;
        };
        var fnCancel = function() {
            //do nothing.
        };

        $._confirm("", UserLogin.logoutMsg, fnOk, fnCancel);
        return false;
    },


    openLoginTradeDialog: function(buy, sell) {
        window.location.href = Site.loginReturnUrlBuySell.replace('TOBUYY', buy).replace('TOSELLL', sell);
    }



};
 
 
/************************************************************************************************************************************************
                                                        @session time out manager.
*************************************************************************************************************************************************/

function _sessionTimeout() {return this.constructor(); }
_sessionTimeout.prototype={
    sessionTimeOutProgressCounter:0,
    sessionTimeOutMintues : 41,//default value
    timeOutHeader : null,
    timeOutMsg : null,
	timeOutMsgSeconds : 60,//default value
	sessionTimeOutOkFunction:function(){
            $.ajax({
                async: false,
                type: "GET",
                dataType: "json",
                url:UserLogin.LoginServiceUrl,
                data:{action:"SessionTimeout"},
                success: function(result){
			    if(!result.ErrorOccured){
			        machineUtils.close();
			        window.location.href = Site.logoutUrl.replace(/homepage.aspx/i,"home.aspx");
				    }
			    }
		    });
		},
    objTimer:null,  /*time out timer 41 minutes*/
    countdownTimer:null, /*message timer - default 60 seconds*/
    flagPopupIsActive:false, /*the confirm of disconnect / stay connected in up*/
	setsessionTimeOutProgressCounterZero:function(){
	   sessionTimeoutManager.sessionTimeOutProgressCounter=0;
	}  ,
	initTimer:function(){
		this.objTimer = $.timer(1000 * 60 ,this.fnTimerCallback);	
		if(this.countdownTimer)this.countdownTimer.stop();
		
	},
	
	/*
	    the callback function uses a cookie named EzfxSTO_Sync_Site , to syncronize between site and machine, in session time out states - sends message to the machine.
	    cookie with name EzfxSTO_Sync_Machine used to get messages from machine
	    cookie values maybe:
	        0: no special message
	        1: got signal from user (click or stay connected button) - reset the session time out timer.
	*/
    fnTimerCallback :function(){
            var mgr=sessionTimeoutManager;
            
            if(mgr.flagPopupIsActive)return;
             
             
            /*see if a message from the machine is waiting*/
            var syncMsg = $.cookie('EzfxSTO_Sync_Machine');
            
            /*a message is waiting*/
            if(syncMsg && syncMsg=='1'){
				mgr.setsessionTimeOutProgressCounterZero();
				/*message has been read delete it*/
				$.cookie('EzfxSTO_Sync_Machine', '0', { path: '/', domain: __cookieDomain});
				return;
            }
            
			/*if session has ended in site */
            if(parseInt(mgr.sessionTimeOutProgressCounter) >= parseInt(mgr.sessionTimeOutMintues) - 1){ 
               mgr.flagPopupIsActive=true;
               $.cookie('EzfxSTO_Sync_Site', '1', { path: '/', domain: __cookieDomain}); /*flag the machine not to pop up the lightbox again*/
			   
               var fnCancel=function(){
                    /*stop 60 seconds countdown*/  
                    if(sessionTimeoutManager.countdownTimer){
                       sessionTimeoutManager.countdownTimer.stop();
                    }
                    if(window.sto_counter)
                        window.sto_counter=null; 
                         
                    $.cookie('EzfxSTO_Sync_Site', '1', { path: '/', domain: __cookieDomain});
                    mgr.flagPopupIsActive=false;
                    sessionTimeoutManager.setsessionTimeOutProgressCounterZero();/*restart timer*/
               };
                               
			   //show count down confirm:
                window.self.focus();
			   
			   $._confirm(mgr.timeOutHeader,mgr.timeOutMsg.replace('{0}',mgr.timeOutMsgSeconds),sessionTimeoutManager.sessionTimeOutOkFunction,fnCancel,mgr.okText,mgr.cancelText);
               			   
			   mgr.countdownTimer = $.timer(1100 ,function(){
					if(!this.sto_counter)
						this.sto_counter= parseInt(mgr.timeOutMsgSeconds);
						
					 /*a message is waiting*/
					var syncMsg = $.cookie('EzfxSTO_Sync_Machine');
                    if(syncMsg && syncMsg=='1'){
			            mgr.setsessionTimeOutProgressCounterZero();
			            $._confirm.hide()
			            /*message has been read delete it*/
			            $.cookie('EzfxSTO_Sync_Machine', '0', { path: '/', domain: __cookieDomain});
			            return;
                    }
					
					$('#confirm-box-context').html(mgr.timeOutMsg.replace('{0}',this.sto_counter));
					
					this.sto_counter-=1;
					if(this.sto_counter<=0){
					   sessionTimeoutManager.sessionTimeOutOkFunction(); 
					}
			   });
            }
            else mgr.sessionTimeOutProgressCounter=parseInt(mgr.sessionTimeOutProgressCounter)+ 1;
            
        },
    constructor: function() {
        this.initTimer();
        jQuery().bind('mousedown',function(){
           sessionTimeoutManager.setsessionTimeOutProgressCounterZero();
            $.cookie('EzfxSTO_Sync_Site', '1', { path: '/', domain: __cookieDomain}); 
        });
    }

};

var sessionTimeoutManager=null;

$(document).ready(function(){
    if(!machineUtils.isSimulatorOpen() && UserLogin.isAuthenticated()){/*start counting down only if user is authenticated.*/
        sessionTimeoutManager = new _sessionTimeout();
        }

});




/* NEXT FILE : D:\WWWSource\Site\app_scripts\modules\dropdownmenu.js************************************************************/

/**
* @title:
* @author: basil@easy-forex.com
* @description: 
* @create date: 04/02/2009
*/ 
function drop() { return this.constructor(); }
drop.prototype = {
    o: '.drop',

    initialize: function() {
	//$(this.o).hide().css({'margin':0});
	var __blocked = true;
        var __deffer = 0;
        var __ie8 = false;
        var __opera = false;
        jQuery.each(jQuery.browser, function(i, val) {
	        if (i == 'mozilla' && val == true) {
		    __deffer = 1;
		        if(jQuery.browser.version.split(".")[1] < 9) {
			        __deffer = 0;
			        __blocked = false;
		        }
                if (culture == "int-ar") {
                    __deffer = 0;
                }
            }
            
            if(jQuery.browser.version.split(".")[0] == 8) __ie8 = true;
            if(i == 'opera' && val == true) __opera = true;
            
        });

        $('.header-navigation').children().each(function(i, el) {
            var box = $(el).children()[0];
            var child = $(box).children().attr('toggle');

            $(el).hover(function() {
                if (direction == true) {
                    if (jQuery.browser.msie) {
                        if(__ie8 == true) {
                            $('.' + child + '-group')
                                .show()
                                .css({ 'left': ($(el).offset().left - $(el).parent().offset().left) + 42 + $(el).width() + __deffer, 'top': ($(el).offset().top + $(el).height() + 5) });
                        } else {
                            if ($(el).children().children().hasClass('last-item')) {
                                $('.' + child + '-group')
                                    .show()
                                    .css({ 'margin-right': -$(el).width(), 'padding-top': 20 });
                            } else {
                                $('.' + child + '-group')
                                    .show()
                                    .css({ 'margin-right': -($(el).width() + 5), 'padding-top': 20 });
                            }
                        }
                    } else {
                        var __f = 2;
                        if(__opera == true) __f = -2;
                        $('.' + child + '-group')
                            .show()
                            .css({ 'left': ($(el).offset().left - $(el).parent().offset().left) + 42 + $(el).width() + __deffer, 'top': ($(el).offset().top + $(el).height() + __f) });
                    }
                } else {
                    if (jQuery.browser.msie) {
                        if(__ie8 == true) {
                            $('.' + child + '-group') 
                                .show()
                                .css({ 'left': ($(el).offset().left - $(el).parent().offset().left) + 250 + __deffer, 'top': ($(el).offset().top + $(el).height()) + 5 });
                        } else {
                            if ($(el).children().children().hasClass('last-item')) {
                                $('.' + child + '-group')
                                    .show()
                                    .css({ 'margin-left': -$(el).width(), 'padding-top': 20 });
                            } else {
                                $('.' + child + '-group')
                                    .show()
                                    .css({ 'margin-left': -($(el).width() + 5), 'padding-top': 20 });
                            }    
                        }
                    } else {
                        var __f = 2;
                        if(__opera == true) __f = -2;
                        $('.' + child + '-group') 
                            .show()
                            .css({ 'left': ($(el).offset().left - $(el).parent().offset().left) + 250 + __deffer, 'top': ($(el).offset().top + $(el).height()) + __f });  
                    }
                }

                var forward = $(el).children()[0];
                var next = $(el).parent().children()[i + 1];
                var temp = $(next).children()[0];
                if ($(temp).children().hasClass('drop-down-button')) {
                    if (direction == true) {
                        if(__blocked)
				            $(temp).children().css({ 'padding-right': '1px' });
                    } else {
                        if(__blocked)
				            $(temp).children().css({ 'padding-left': '1px' }); 
		            }
                }

                var end = null;
                if (direction == true)
                    end = $(forward).children().css({ 'padding-left': '11px' });
                else
                    end = $(forward).children().css({ 'padding-right': '11px' });

                $(end).addClass('top-back-end');
                $(forward).addClass('top-back-forward');
            }, function() {
                $('.' + child + '-group').hide();

                var forward = $(el).children()[0];
                var next = $(el).parent().children()[i + 1];
                var temp = $(next).children()[0];

                if ($(temp).children().hasClass('drop-down-button')) {
                    if (direction == true) {
                        $(temp)
                            .children()
                            .css({ 'padding-right': '6px' });
                    } else {
                        $(temp)
                            .children()
                            .css({ 'padding-left': '6px' });
			        }
                }

                var end = null;
                if (direction == true) {
                    end = $(forward)
                                .children();
                    if ($(end).hasClass('last-item'))
                        $(end).css({ 'padding-left': '11px' });
                    else
                        $(end).css({ 'padding-left': '6px' });
                } else {
                    end = $(forward)
                                .children();
                    if ($(end).hasClass('last-item'))
                        $(end).css({ 'padding-right': '11px' });
                    else
                        $(end).css({ 'padding-right': '6px' });
                }

                $(end).removeClass('top-back-end');
                $(forward).removeClass('top-back-forward');
            });
        });

    },
    constructor: function() { }
}
/* NEXT FILE : D:\WWWSource\Site\js\Puma\LanguageSelection.js************************************************************/
function ChangeShadowLength(pixNum) {
	    $("#ShadowSites-up-ltr").height($("#ShadowSites-up-ltr").height() + pixNum);
	}

 function AddDiv()
    {                
        var langStr = "<div id=\"lang-selection\">" + content + "</div>";  
        var shadowSitesStr = "<div id=\"ShadowSites\"><div id=\"ShadowSites-up-ltr\"></div><div id=\"ShadowSites-bottom-ltr\" class=\"SkinFloat\"></div><div id=\"ShadowSites-corner-ltr\" class=\"SkinFloat\"></div></div>";
        var shadowLangStr = "<div id=\"ShadowLang\"><div id=\"ShadowLang-up-ltr\"></div><div id=\"ShadowLang-bottom-ltr\" class=\"SkinFloat\"></div><div id=\"ShadowLang-corner-ltr\" class=\"SkinFloat\"></div></div>";
        
        
                       
        if($('#wrapper').length == 0) 
        {
            $("body").append(langStr + shadowSites);
        }
        else
        {
            $('#wrapper').append(langStr + shadowSitesStr + shadowLangStr);
        }    
        
        var langTop = $("#HeaderLeft").offset().top - $('#wrapper').offset().top;
        
        $("#ShadowSites ").css('top', (langTop + 8 + 2) + 'px');
        $("#lang-selection").css('top', langTop + 'px');
        
                  
        if(ltrOrRtl == 'right')
        {
            var rightOff = $('#wrapper').width() - $('#lang-selection').width();  
            
            //$("#ShadowSites").css('left',  (- 8 - 2 + rightOff) + 'px');
            //$("#lang-selection").css('left',  rightOff  + 'px');                                   
            
            if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) 
            {
                //$("#ShadowSites-up-ltr").css('background','url(../images/Puma/news_l.png) repeat-y left');     
                //$("#ShadowSites-corner-ltr").css('background','url(../images/Puma/news_lb.png)');  
                
                //$("#ShadowLang-up-ltr").css('background','url(../images/Puma/news_l.png) repeat-y left'); 
                //$("#ShadowLang-corner-ltr").css('background','url(../images/Puma/news_lb.png)');            
            }                             
        }
        else {
            $("#ShadowSites").css('left', 8 + 2 + 'px');
        }
    } 

    $(document).ready(function(){  
        AddDiv();  
        
        $('.LangFirstLi').css("border-" +  "<%= ltrOrRtl %>", "1px #fff solid");
        $('.second').each(function(i, el){ $(el).hide();});
		
		$('.SiteLiOneLang').hover(
			function() { 
				var el = $(this);
				
				el.css('border-top',   '1px solid #669933');
				if(this.id != 'LastLiId') { el.css('border-bottom','1px solid #669933');}
				el.children('.SiteSpan').css('color', '#003366');
			}, 
			function() {
				var el = $(this);				
				el.css('border','none');
				el.children('.SiteSpan').css('color', '#336699');
			});
			
		$('.SiteLi').hover(
			function() { 			
				var el = $(this);
				el.css('border-top', '1px solid #669933');
				if(this.id != 'LastLiId') 
				{ 
				    el.css('border-bottom','1px solid #669933');
				    ChangeShadowLength(2);
				}
				else ChangeShadowLength(1);
				
				el.children('.SiteSpan').css('color', '#003366');
				
				var offset = el.offset();	
																
			    el.children('.second').show();
			    el.children('.second').css('top', -23);		
			    el.children('.second').css('left', 135 - 165)
			    
			    if(ltrOrRtl == 'left') 
				     el.children('.second').css("left", 120);                      
                else el.children('.second').css("left", -103);	                     
                			
				// Shadow to second level menu							
				if(!el.hasClass("SiteLiOneLang"))
				{
				    var height =  el.children('.second').height();
				    
				    $("#ShadowLang").css('top', offset.top + 8 - $('.ControlPanel').height());
				    $("#ShadowLang").height(height);
                    $("#ShadowLang-up-ltr").height(height - 8);
                                      
                    
                    if(ltrOrRtl == 'left')  // 11 = 8 + 3  
                         $("#ShadowLang").css('left', 120 + 11);
                    else $("#ShadowLang").css('left', $('#wrapper').width() - 2 * $('#lang-selection').width() - 6 );
                    
                    $('#ShadowLang').show();
				}
			}, 
			function() {
				var el = $(this);
				
				if(this.id != 'LastLiId') 
				{ 				    
				    ChangeShadowLength(-2);
				}
				else ChangeShadowLength(-1);
								
				el.css('border','none');
				el.children('.SiteSpan').css('color', '#336699');
				el.children('.second').hide();
				
				$('#ShadowLang').hide();
			});
			
			
			$('.second').children().children().hover(
			function() { 			
				var el = $(this);
				
				if(el[0].className != 'License LangSpanFirst')
					el.css('color', '#003366');
			}, 
			function() {
				var el = $(this);
				
				if(el[0].className != 'License LangSpanFirst')
					el.css('color', '#336699');				
				
			});	
	});
jQuery().click(function(e){	    
	if (e == null) e = window.event;
    var target = e.target != null ? e.target : e.srcElement; 
	
	var allSites = $("#first");
	var strt = $('#Starter');		
					
	if(target.id == 'StarterIMG')
    {	           
    	if(allSites.css("display") =="none") {
    	    
		    strt.css('background-image',  'url(' + Site.url + ("images/line_130x1.gif") + ')');
		    strt.css('background-repeat','no-repeat');
		    strt.css('background-position','bottom center');
		     
			strt.css('border-top','1px solid #669933');
			strt.css('border-left','1px solid #669933');
			strt.css('border-right','1px solid #669933');
			
			$("#ShadowSites").show();
			
		}
		else { 
		    strt.css('border', 'none');  strt.css('background-image', 'none');
		    $("#ShadowSites").hide();
		}			
		allSites.toggle();
		
		var divHeight = $("#LanguageSelection").height() - 2;
			
	    $("#ShadowSites").height(divHeight);
	    $("#ShadowSites-up-ltr").height(divHeight - 8);
	}		
	else if(target.id != 'Starter' && target.id != 'StarterSpan' && target.className  != 'SiteLi' &&  target.className  != 'SiteLiOneLang' && target.className  != 'second' && target.className != 'SiteSpan' && target.className != 'LangFirstLi' && target.className != 'LangSpan' && target.className != 'LangLastLi' && target.className != 'LangOtherLi' && target.className != 'LangSpanFirst' && target.className != 'License LangSpanFirst')  
	{
		allSites.hide();
		strt.css('border', 'none');
		strt.css('background-image', 'none');
		$("#ShadowSites").hide();
    }
});


/* NEXT FILE : D:\WWWSource\Site\App_Scripts\UI\Animation.js************************************************************/

/**
*@animation v1.0: - http://
*/

var animationProcess = false;

jQuery.rateFly = function(obj, callBack){
    var fly = $('#position-fly'); 
    if(!animationProcess){
        if (!jQuery.browser.msie) {
            if($('body').css('direction') != 'rtl'){
                animationProcess = true;
                fly.show().css({'width':120,'height':21,'border':'1px #669933 solid','background':'#e5ebd3','z-index':10000,marginLeft:86,'top':parseInt($(obj).offset().top) - 477,'position': 'absolute','opacity':0.1});
                fly.animate({'top':-170,marginLeft:250,'width':364,'opacity':0.5}, 1100, function(){
                   fly.css({'background':'#ffffff'}).animate({'top':-288,'height':300,'opacity':1}, 1100, function(){
                        fly.fadeOut('slow');
                        if(!jQuery.isNull(callBack)) callBack();
                        animationProcess = false;
                   });
                });
            } else {
                animationProcess = true;
                fly.show().css({'width':120,'height':21,'border':'1px #669933 solid','background':'#e5ebd3','z-index':10000,marginRight:15,'top':parseInt($(obj).offset().top) - 477,'position': 'absolute','opacity':0.1});
                fly.animate({'top':-170,marginRight:250,'width':364,'opacity':0.5}, 1100, function(){
                   fly.css({'background':'#ffffff'}).animate({'top':-288,'height':300,'opacity':1}, 1100, function(){
                        fly.fadeOut('slow');
                        if(!jQuery.isNull(callBack)) callBack();
                        animationProcess = false;
                   });
                });
            }
        } else {
            if($('body').css('direction') != 'rtl'){
                animationProcess = true;
                fly.show().css({'width':120,'height':21,'border':'1px #669933 solid','background':'#e5ebd3','z-index':10000,marginLeft:86,'top':parseInt($(obj).offset().top) - 477,'position': 'absolute','opacity':0.2});
                fly.animate({'top':-170,marginLeft:250,'width':364,'opacity':0.5}, 1100, function(){
                   fly.css({'background':'#ffffff'}).animate({'top':-288,'height':300,'opacity':1}, 1100, function(){
                        fly.fadeOut('slow');
                        if(!jQuery.isNull(callBack)) callBack();
                        animationProcess = false;
                   });
                });
            } else {
                animationProcess = true;
                fly.show().css({'width':120,'height':21,'border':'1px #669933 solid','background':'#e5ebd3','z-index':10000,marginRight:15,'top':parseInt($(obj).offset().top) - 477,'position': 'absolute','opacity':0.2});
                fly.animate({'top':-170,marginRight:250,'width':364,'opacity':0.5}, 1100, function(){
                   fly.css({'background':'#ffffff'}).animate({'top':-288,'height':300,'opacity':1}, 1100, function(){
                        fly.fadeOut('slow');
                        if(!jQuery.isNull(callBack)) callBack();
                        animationProcess = false;
                   });
                });
            }
        }
    }
};
