﻿/*=======================================================================*\
|  JLibrary Version 1.0                                                   |
|  Created By Randolphe Jacques                                           |
|  Usage: $(); OR j();                                                    |
|-------------------------------------------------------------------------|
|  Created       2009-07-15                                               |
|  Last modified 2009-11-18                                               |
|                                                                         |
|  2009-07-15 - Added Get(), Text(), Clear()                              |
|  2009-07-17 - Added Ready(), $.Post()                                   |
|  2009-07-18 - Added $("#Div").Post()                                    |
|  2009-08-04 - Changed Ready() to j().Ready()                            |
|             - Added Click(), AddListener(), RemoveListener()            |
|             - Added Exit(), CSS()                                       |
|             - Added AddNode(), RemoveNode(), Kill()                     |
|  2009-08-04 - Added Variable _refElementViewState                       |
|             - Added Show(), Hide()                                      |
|  2009-09-28 - Added j.File.Save()                                       |
|  2009-10-27 - Added j.Stage() -- REMOVED AS OF 2010-02-08               |
|  2009-11-06 - Added j.Tab(TABS, ACTIVE);								  |
|  2009-11-18 - Added j.AutoSuggest(URL, DELIMATER, POSITION);            |
|  2010-02-08 - Added Overlay()                                           |
\*=======================================================================*/

/* Fix */
function g() {
	return document.getElementById(arguments[0]);
}

// Reference to getElementById;
var _refElement;

// Reference for Show(), Hide() functions
var _refElementViewState;

// Reference for .Tab()
var _refActiveTab;

// Constructor
var j = function(selector) {
    return j.fn.init(selector);
}

// Special functions that can be used as follow: j("#div").Clear();
j.fn = {
    init: function(selector) {
        try {
            if (selector.substring(0, 1) == "#") {   // Handles IDs
                _refElement = document.getElementById(selector.substring(1));
            }
        } catch (e) {                                // Handles DOMElements
            _refElement = selector;
        }
        
        return j.fn;
    },
    
    // Gets handler
    Get: function() {
        return _refElement;
    },
    
    // Sets the text property
    Text: function(value) {
        switch(_refElement.tagName.toLowerCase()) {
            case "div":
			case "span":
            case "textarea":
                if (typeof(value) != "undefined") {
                    _refElement.innerHTML = value;
                } else {
                    return _refElement.innerHTML;
                } break;
            case "input":
                if (typeof(value) != "undefined") {
                    _refElement.value = value;
                } else {
                    return _refElement.value;
                } break;
        }
    },
    
    // Clears text property
    Clear: function() {
        switch(_refElement.tagName.toLowerCase()) {
            case "div":
            case "textarea":
                _refElement.innerHTML = ""; break;
            case "input":
                _refElement.value = ""; break;
        }
    },
    
    CSS: function(css) {
        for (style in css) _refElement.style[style] = css[style];
    },
    
    // AJAX - Post
    Post: function(URL, Params) {
        j.Post(URL, Params, function(data) {
            j.fn.Text(data);
        });
    },
    
    Click: function(fn) {
        if (_refElement.addEventListener) {
            _refElement.addEventListener("click", fn, false);
        } else {
            _refElement.attachEvent("onclick", fn);
        }
    },
    
    AddListener: function(e, fn, b) {
        if (_refElement.addEventListener) {
            _refElement.addEventListener(e, fn, b);
        } else {
            _refElement.attachEvent("on" + e, fn);
        }
    },
    
    RemoveListener: function(e, fn, b) {
        if (_refElement.removeEventListener) {
            _refElement.removeEventListener(e, fn, b);
        } else {
            _refElement.detachEvent("on" + e, fn);
        }
    },
    
    AddNode: function(id, child) {
    	var container;
    	
    	switch (_refElement.tagName.toLowerCase()) {
    		case "table":
    			container = document.createElement("tr");
    			var data = document.createElement("td");
    			data.innerHTML = child;
    			
    			container.appendChild(data);
    			
    			// Checks for table body (tbody)
    			if (_refElement.getElementsByTagName("tbody")[0]) {
    				_refElement.getElementsByTagName("tbody")[0].appendChild(container);
    			} else {
    				var tbody = document.createElement("tbody");
    				
    				tbody.appendChild(container);
    				_refElement.appendChild(tbody);
    			}
    			break;
    			
			case "ol":
			case "ul":
				container = document.createElement("li");
				container.innerHTML = child;
				
				_refElement.appendChild(container);
				break;
				
			case "p":
			case "label":
				container = document.createTextNode(child);
				_refElement.appendChild(container);
				break;
    		
			default:
				container = document.createElement("div");
				container.innerHTML = child;
				
				_refElement.appendChild(container);
				break;
    		
    	}
    	
    	// Set ID
    	container.setAttribute("id", id);
    },
    
    RemoveNode: function(child) {
        if (typeof(child) == "number") {
            _refElement.removeChild(_refElement.childNodes[child]);
        } else {
            var node = document.getElementById(child);
            _refElement.removeChild(node);
        }
    },
	
	Show: function() {
		if(_refElementViewState == "") _refElementViewState = "block";
		_refElement.style.display = _refElementViewState;
	},
	
	Hide: function() {
		_refElementViewState = _refElement.style.display;
		_refElement.style.display = "none";
	},
	
	FadeIn: function(SPEED, COUNT) {	
	    var _Speed = 0;
	    
	    switch(SPEED) {
	        case "fast":
	            _Speed = 50; break;
	        case "normal":
	            _Speed = 75; break;
	        case "slow":
	            _Speed = 100; break;
	            
	        default:
	            _Speed = 75; break;
	    }
	    
	    if (COUNT == null) COUNT = 0;
		
		if (COUNT == 0) {
			_refElement.style.opacity = (COUNT / 100); //FF
			_refElement.style.filter = 'alpha(opacity=' + COUNT + ')'; // IR
			
			_refElement.style.display = "block";
		}
		
		_refElement.style.opacity = (COUNT / 100); //FF
		_refElement.style.filter = 'alpha(opacity=' + COUNT + ')'; // IR
		
		COUNT = parseInt(COUNT) + 5;
		
		if (COUNT <= 100) setTimeout("j('#" + _refElement.id + "').FadeIn('" + SPEED + "', '" + COUNT + "');", _Speed);
	},
				
	FadeOut: function(SPEED, COUNT) {	
	    var _Speed = 0;
	    
	    switch(SPEED) {
	        case "fast":
	            _Speed = 50; break;
	        case "normal":
	            _Speed = 75; break;
	        case "slow":
	            _Speed = 100; break;
	            
	        default:
	            _Speed = 75; break;
	    }
	    
	    if (COUNT == null) COUNT = 100;
					
		_refElement.style.opacity = (COUNT / 100); //FF
		_refElement.style.filter = 'alpha(opacity=' + COUNT + ')'; // IR
		
		COUNT = parseInt(COUNT) - 5;
		
		if (COUNT >= 0) {
			setTimeout("j('#" + _refElement.id + "').FadeOut('" + SPEED + "', '" + COUNT + "');", _Speed);
		} else {
			_refElement.style.display = "none";
		}
	},
	
	ToolTip: function(X, Y, WIDTH, TITLE, BODY) {
		var tooltip = document.createElement("div");
		var header = document.createElement("div");
		var title = document.createElement("b");
		var WinClose = document.createElement("a");
		var hr = document.createElement("div");
		var content = document.createElement("div");
		
		var txt = document.createTextNode("X");
		
		WinClose.appendChild(txt);
		WinClose.setAttribute("style", "float: right;");
		
		WinClose.style.color = "#F00";
		WinClose.style.float = "right";
		WinClose.style.padding = "3px 5px";
		WinClose.style.textDecoration = "none";
		WinClose.style.font = "bold 13px arial";
		WinClose.style.backgroundColor = "#CCC";
		WinClose.style.border = "1px solid #333";
		
		WinClose.setAttribute("href", "javascript:void(document.getElementById('_JTOOLTIP').style.visibility = 'hidden');");
		
		txt = document.createTextNode(TITLE);
		
		title.appendChild(txt);
		title.style.float = "left";
		title.style.font = "bold 16px arial";
		
		var line = document.createElement("hr");
		line.style.margin = "8px 0 0 0";
		
		hr.appendChild(line);
		hr.style.clear = "both";
		hr.style.width = "100%";
		
		header.appendChild(title);
		header.appendChild(WinClose);
		
		header.appendChild(hr);
		header.style.padding = "3px 5px";
		
		BODY = document.getElementById(BODY);
		
		content.style.padding = "3px 5px";
		content.innerHTML = BODY.innerHTML;
		
		tooltip.appendChild(header);
		tooltip.appendChild(content);
		
		tooltip.style.left = X + " px";
		tooltip.style.top = Y + " px";
		tooltip.style.width = WIDTH + "px";
		tooltip.style.position = "absolute";
		tooltip.style.visibility = "hidden";
		tooltip.style.backgroundColor = "#FFF";
		tooltip.style.border = "2px solid #A5A2A5";
		
		var Show = function() {
			tooltip.style.visibility = "visible";
		}
		
		_refElement.parentNode.appendChild(tooltip);
		tooltip.setAttribute("name", "_JTOOLTIP");
		tooltip.setAttribute("id", "_JTOOLTIP");
		
		_refElement.onmouseover = Show;
	},
	
	/*Stage: [{
		Overlay: function() {
			var screen = document.createElement("div");
			screen.setAttribute("id", "_JSCREEN");
			
			screen.style.top = 0;
			screen.style.left = 0;
			screen.style.zIndex = 98;
			screen.style.width = "100%";
			screen.style.height = "100%";
			screen.style.position = "fixed";
			
			screen.style.backgroundColor = "#CCC";
			
			screen.style.opacity = 0.45; // FF
			screen.style.filter = "alpha(opacity=45)"; // IE
			
			document.body.appendChild(screen);
			
			j.fn.Click(function() {
				document.body.removeChild(screen);
			});
		}
    }],*/
	
	Overlay: function(OKBUTTON, CANCELBUTTON) {
		_refElement.style.zIndex = 99;
		_refElement.style.position = "fixed";
		
		_refElement.style.display = "";
		_refElement.style.left = ((window.screen.availWidth - _refElement.offsetWidth) / 2) + "px";
		
		var height = (document.documentElement)? document.documentElement.clientHeight : window.innerHeight;
		_refElement.style.top = ((height - _refElement.offsetHeight) / 2) + "px";
		
		var screen = document.createElement("div");
		screen.setAttribute("id", "_JSCREEN");
		
		screen.style.top = 0;
		screen.style.left = 0;
		screen.style.zIndex = 98;
		screen.style.width = "100%";
		screen.style.height = "100%";
		screen.style.position = "fixed";
		
		screen.style.backgroundColor = "#000";//"#CCC";
		
		screen.style.opacity = 0.45; // FF
		screen.style.filter = "alpha(opacity=45)"; // IE

//-----------------------------------------------------------------------------------------------------------------------------------------------------

		// Browser detection
		var ua = navigator.userAgent;
   		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    	if (re.exec(ua) != null) {
			rv = parseFloat(RegExp.$1);
			
			if (rv > 7) document.body.appendChild(screen);
		} else {
			document.body.appendChild(screen);
		}

//-----------------------------------------------------------------------------------------------------------------------------------------------------

		var _PANEL = _refElement;
		
		if (OKBUTTON != null && typeof(OKBUTTON) != "undefined") {
			// Reset refElement
			_refElement = document.getElementById(OKBUTTON);
			
			j.fn.Click(function() {
				_PANEL.style.display = "none";
				document.body.removeChild(screen);
			});
		}
		
		if (typeof(CANCELBUTTON) != "undefined") {
			// Reset refElement
			_refElement = document.getElementById(CANCELBUTTON);
			
			j.fn.Click(function() {
				_PANEL.style.display = "none";
				document.body.removeChild(screen);
			});
		}
	},
    
    Tabs: function(tabs, active) {
		_refActiveTab = active;
		
		// CSS
    	var css = document.createElement("style");
    	css.setAttribute("type", "text/css");
    	
    	var code7 = /* For IE 7 */
			"#TabNavigator ul { margin: 0; padding: 0; }" +
			
			"#TabNavigator li { /*margin: 0; padding: 0;*/ float: left; list-style: none; display: block; }" +
			
			"#TabNavigator li { padding: 5px; margin-right: 5px; border: 1px solid #CCC; border-bottom-color: #EEE; }" + 
			
			"#TabNavigator li a { color: #CCC; display: block; font-size: 22px; cursor: pointer; text-decoration: none; }" + 
			
			"#TabNavigator li a:hover { color: Gold; }" + 
			
			"#TabNavigator li { background-color: #EEE; border: 1px solid #A5A2A5; border-bottom-color: #EEE; }" +
			
			"#TabNavigator li a { color: DarkBlue; }" + 
			
			"#TabNavigator li#last { margin-right: 0; }" + 
			
			"#TabNavigator { }" +
			
			"#TabBody { padding: 5px; background-color: #EEE; border: 1px solid #A5A2A5; border-top: 0; clear: left; }" +
			
			"#TabBody #TabBodyContainer { border: 1px solid #A5A2A5; background-color: #FFFFFF; }";
			
    	var code =
			"#TabNavigator ul { margin: 0; padding: 0; }" +
			
			"#TabNavigator li { margin: 0; padding: 0; float: left; list-style: none; }" +
			
			"#TabNavigator li.tab { padding: 5px; margin-right: 5px; border: 1px solid #CCC; border-bottom-color: #EEE; }" + 
			
			"#TabNavigator li.tab a { color: #CCC; display: block; font-size: 22px; cursor: pointer; text-decoration: none; }" + 
			
			"#TabNavigator li.tab a:hover { color: Gold; }" + 
			
			"#TabNavigator li.active { background-color: #EEE; border: 1px solid #A5A2A5; border-bottom-color: #EEE; }" +
			
			"#TabNavigator li.active a { color: DarkBlue; }" + 
			
			"#TabNavigator li#last { margin-right: 0; }" + 
			
			"#TabNavigator { }" +
			
			"#TabBody { padding: 5px; background-color: #EEE; border: 1px solid #A5A2A5; border-top: 0; }" +
			
			"#TabBody #TabBodyContainer { border: 1px solid #A5A2A5; background-color: #FFFFFF; }";
    	
    	var style = document.createTextNode(code);
    	
    	if (css.styleSheet) { // IE
			if (/MSIE 7.0/.test(navigator.appVersion)) {
    			css.styleSheet.cssText = code7;
			} else {
				css.styleSheet.cssText = code;
			}
    	} else { // W3C
    		css.appendChild(style);
    	}
    	
    	_refElement.appendChild(css);
    	    	
    	// Divs
    	var TabContainer = document.createElement("div");
    	TabContainer.setAttribute("id", "TabContainer");
    	
    	var TabNavigator = document.createElement("div");
    	TabNavigator.setAttribute("id", "TabNavigator");
    	
    	var UL = document.createElement("ul");
    	
    	var i = 0;
    	for (title in tabs) {
    		var LI = document.createElement("li");
    		LI.setAttribute("class", "tab");
    		
    		var A = document.createElement("A");
    		A.setAttribute("id", "TabNavigatorTitle" + i++);
    		
    		var Title = document.createTextNode(title);
    		A.appendChild(Title);
    		
    		LI.appendChild(A);
    		UL.appendChild(LI);
    	}
    	
    	UL.firstChild.setAttribute("id", "first");
    	UL.lastChild.setAttribute("id", "last");
    	TabNavigator.appendChild(UL);
    	
    	var TabBody = document.createElement("div");
    	TabBody.setAttribute("id", "TabBody");
    	
    	var TabBodyContainer = document.createElement("div");
    	TabBodyContainer.setAttribute("id", "TabBodyContainer");
    	
    	TabBody.appendChild(TabBodyContainer);
    	
    	TabContainer.appendChild(TabNavigator);
    	TabContainer.appendChild(TabBody);
    	
    	_refElement.appendChild(TabContainer);
    	 
    	for (title in tabs) {
    		for (var i = 0; i < UL.childNodes.length; i++) {
    			if (UL.childNodes[i].childNodes[0].getAttribute("onclick") == null) {
    				
    				// Set Active Tab
    				if (_refActiveTab == null) {
    					active = title;
						_refActiveTab = UL.childNodes[i].childNodes[0];
    				} else if(_refActiveTab == title) {
    					_refActiveTab = UL.childNodes[i].childNodes[0];
    				}
    				
					// IF 7 fix
    				UL.childNodes[i].childNodes[0].onclick = function() {
						if (typeof(_Active) != 'undefined') {
							_Active.setAttribute('class', 'tab');
						}
					
						if (this.tagName == 'LI') {
							_Active = this;
						} else {
							_Active = this.parentNode;
						}
						
						_Active.setAttribute('class', 'tab active');
						
						var e = this.innerHTML.split(" ");
						
						j('#TabBodyContainer').Get().innerHTML = j('#' + e[0] + e[1]).Text();
					}//setAttribute("onclick", "FetchBody(this, '" + tabs[title] + "');");
    				break;
    			}
    		}
    	}
    	
    	// JavaScript Functions
    	var js = document.createElement("script");
    	js.setAttribute("type", "text/javascript");
    	
    	code = 
    		"var _Active;" +
    		
    		"function FetchBody(sender, e) {" +
    			"if (typeof(_Active) != 'undefined') {" +
    				"_Active.setAttribute('class', 'tab');" +
    			"}" +
    		
	    		"if (sender.tagName == 'LI') {" +
	    			"_Active = sender;" +
	    		"} else {" +
	    			"_Active = sender.parentNode;" +
	    		"}" +
	    		
	    		"_Active.setAttribute('class', 'tab active');" +
	    		
	    		"j('#TabBodyContainer').Get().innerHTML = j('#' + e).Text();" +
    		"}";
    	
    	var script = document.createTextNode(code);
    	
    	if (js.canHaveChildren) {
    		js.appendChild(script);
    	} else {
    		js.text = code;
    	}
    	
    	_refElement.appendChild(js);
    	
    	FetchBody(_refActiveTab, tabs[active]);
	},
	
	AutoSuggest: function(URL, DELIMATER, AUTOCOMPLETE, POSITION) {
		// TODO: Find fix for Microsoft Internet Explorer position,
		// that way I won't need to use the POSITION variable.
		
		// Create list container
		var div = document.createElement("div");
		div.setAttribute("id", "JAUTOCOMPLETE");
		_refElement.parentNode.appendChild(div);

		// Style
		div.style.padding = "5px";
		div.style.display = "none";
		
		if (POSITION) div.style.position = "absolute";
		
		div.style.backgroundColor = "#FFF";
		div.style.border = "1px solid Blue";
		div.style.width = (_refElement.offsetWidth - 13) + "px";
		
		// Positioning
		if (POSITION) {
			var x = _refElement.offsetLeft, y = _refElement.offsetTop;
			
			var node = _refElement.parentNode;
			
			x += node.offsetLeft;
			y += node.offsetTop;
			
			// Get total X & Y (offset of parent containers)
			while (node = node.parentNode) {
				if (typeof(node.offsetLeft) == "number") x += node.offsetLeft;
				if (typeof(node.offsetTop) == "number") y += node.offsetTop;
			}
			
			div.style.left = x;
			div.style.top = (y + _refElement.offsetHeight);
		} /*else {
			div.style.height = "250px";
			div.style.overflow = "scroll";
			
			div.parentNode.style.position = "relative";
			
			div.style.zIndex = "100";
			div.style.position = "absolute";
			div.style.left = div.parentNode.clientLeft + "px";
			div.style.top = (div.parentNode.clientTop + div.parentNode.clientHeight) + "px";
		}*/
		
		var ID = _refElement.id;
		
		// Function
		var fn = function KeyUpEventHandler(e) {
			if (!e) {
				e = window.event;
			}
			
			var key = e.KeyCode;
			
			// Ignore anything less then 46 but not 32, and those between 112 and 123
			if (key < 32 || (key >= 33 && key <= 46) || (key >= 123 && key <= 123)) {
				// Ignore other keys
			} else {
				var _refObject = document.getElementById(ID);
				
				// Do search Request
				j.Post(URL, {q : _refObject.value}, function(data) {
					var collection = data.split(DELIMATER);
					
					// Text Completion (Type ahead)
					if (AUTOCOMPLETE) {
						var index = _refObject.value.length;
						_refObject.value += collection[0].substring(index);
						
						// Do selection
						if (_refObject.createTextRange) { // IE
							var range = _refObject.createTextRange();
							range.moveStart("character", index);
							range.moveEnd("character", 0);
							range.select();	
						} else { // FF
							_refObject.setSelectionRange(index, _refObject.value.length);
						}
					}
					
					// Build List (of 24)
					// TODO: Allow more control
					var limit = (collection.length > 24)? 24 : collection.length;
					
					// Clear list
					div.innerHTML = "<a href='javascript:void%28document.getElementById(%27JAUTOCOMPLETE%27).style.display=%27none%27%29%3b'" + 
					"style='color: Red; font-weight: bold; display: block; margin-bottom: 7px;'>Close</a>";
					
					for (i = 0; i < limit; i++) {
						div.innerHTML += "<a href='javascript:void%28document.getElementById(%27" + ID + "%27).value=%27" + collection[i] + 
						"%27%29%3b" + "void%28document.getElementById(%27JAUTOCOMPLETE%27).style.display=%27none%27%29%3b'>" + collection[i] + 
						"</a><br />";
					}
					
					// Do not show is 1 or less is returned
					if (limit > 0) {
						div.style.display = "block";
					} else {
						div.style.display = "none"
					}
				});
			}
		}
		
		if (_refElement.addEventListener) {
			_refElement.addEventListener("keyup", fn, false);
		} else {
			_refElement.attachEvent("onkeyup", fn);
		}
	},
	
	Kill: function() {
        if (_refElement.removeNode) {
            _refElement.removeNode(true) // IE
        } else {
            _refElement.parentNode.removeChild(_refElement); // FF
        }
    },
    
    // Add's Event Handler to object's onload Event
    Ready: function(fn) {
        if (_refElement.addEventListener) {
            _refElement.addEventListener("load", fn, false); // W3C
        } else {
            _refElement.attachEvent("onload", fn) // IE
        }
    },
    
    // Add's Event Handler to object's onunload Event
    Exit: function(fn) {
        if (_refElement.addEventListener) {
            _refElement.addEventListener("unload", fn, false);   
        } else {
            _refElement.attachEvent("onunload", fn);
        }
    }
}

j.Post = function(URL, Params, Callback) {
    // Appends  parameters if any was supplied
    if (typeof(Params) == "object" && Params !== null) {
        URL += "?";
        
        // Loops through all the Parameters
        for (obj in Params) URL += obj + "=" + eval("Params." + obj) + "&";
        
        // Combines while triming off the last &
        URL = URL.substring(0, URL.length - 1);
    }
    
    // AJAX - Browser Support Code
    var xmlHttp;
    
    try {  // Firefox, Opera 8.0+, Safari  
        xmlHttp = new XMLHttpRequest();  
    } catch (e) {  // Internet Explorer  
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");    
        } catch (e) {    
            try {      
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");      
            } catch (e) {      
                alert("Your browser does not support AJAX!");   
            }    
        }  
    }
    
    xmlHttp.onreadystatechange = function() {
        if(xmlHttp.readyState == 4) {
            if (typeof(Callback) == "function") {
                // Pass it to the Callback function if one has been set
                Callback(xmlHttp.responseText);
            }
        }
    }

    xmlHttp.open("GET", URL, true);
    xmlHttp.send(null);
}

j.File = {
    Save: function(obj_form, CALLBACK_FUNCTION) {
    	obj_form = document.getElementById(obj_form);
        
        // Creates random number (0 - 9)
        var num = Math.floor(Math.random() * 10);
        
        var container = document.createElement("div");
        container.setAttribute("id", "_JFILE" + num);
        
        // Attach it to the document's body
        document.body.appendChild(container);
        
        // Create tmp iframe
        var iframe = document.createElement("iframe");
        
        // Styles
        iframe.width = "0px";
        iframe.height = "0px";
        iframe.frameborder = "0";
        iframe.style.display = "none";
        
        iframe.id = "_JIFRAME";
        iframe.name = "_JIFRAME";
        
        // Attach it to container
        container.appendChild(iframe);
        
        var func = function() {
            var message = window.frames[iframe.name].document.body.innerHTML;
        	
            CALLBACK_FUNCTION(message);
            
            // Removes the conatiner containing the IFRAME
            document.body.removeChild(container);
        };
        
        if (iframe.addEventListener) {
        	iframe.addEventListener("load", func, false);
        } else {
        	iframe.attachEvent("onload", func);
        }
            
        // Set the target of the form
        obj_form.target = iframe.name;
        
        // Submit Form
        obj_form.submit();
    }
}

// Cloning function, sets $ = j
function _Clone() {
    if (typeof($) == "undefined") $ = j;
} _Clone();