var IDC_Core = function(document, parentObject){ this.Document = document; this.ParentObject = parentObject; this.isIE = document.all?true:false; this.Mouse = new IDC_Mouse(document, parentObject); this.Keyboard = new IDC_Keyboard(document, parentObject); this.DOM = new IDC_DOM(document); }; var IDC_Mouse = function(document, parentObject){ this.isIE = document.all?true:false; this.Document = document; this.ParentObject = parentObject; this.X=0; this.Y=0; this.CaptureMouse(parentObject); }; IDC_Mouse.prototype.CaptureMouse = function(parentObject){ if (!this.isIE) document.captureEvents(Event.MOUSEMOVE); else { parentObject.onselectstart=function(){ return event.srcElement.tagName == 'INPUT' || event.srcElement.tagName == 'TEXTAREA' || event.srcElement.tagName == 'SELECT'; }; parentObject.ondragstart=function(){ return false; }; } parentObject.IDCMouse = this; parentObject.onmousemove = function(e){ if (this.IDCMouse.isIE){ this.IDCMouse.X = event.clientX; this.IDCMouse.Y = event.clientY; } else { if(e){ this.IDCMouse.X = e.pageX; this.IDCMouse.Y = e.pageY; } } }; parentObject.onmousedown = function(e){ if(!e) e = window.event; if(e){ var tg = e.srcElement || e.target; return tg.tagName == 'INPUT' || tg.tagName == 'TEXTAREA' || tg.tagName == 'SELECT'; } else return false; }; }; IDC_Mouse.prototype.RefreshMousePosition = function(e){ if (this.isIE){ this.X = event.clientX; this.Y = event.clientY; } else { if(e){ this.X = e.pageX; this.Y = e.pageY; } } }; var IDC_Keyboard = function(document, parentObject){ this.isIE = document.all?true:false; this.Document = document; this.ParentObject = parentObject; this.KeyControlPressed = false; this.KeyAltPressed = false; this.KeyShiftPressed = false; this.LastKeyCode = null; if (!this.isIE){ document.captureEvents(Event.KEYDOWN); document.captureEvents(Event.KEYUP); } this.CaptureKeyboard(parentObject); }; IDC_Keyboard.prototype.CaptureKeyboard = function(parentObject){ if(this.isIE){ parentObject.IDC_Keyboard = this; parentObject.onkeydown = function(){ return this.IDC_Keyboard.KeyDownEvent(event); }; parentObject.onkeyup = function(){ return this.IDC_Keyboard.KeyUpEvent(event); }; } else { document.IDC_Keyboard = this; document.onkeydown = function(e){ return this.IDC_Keyboard.KeyDownEvent(e); }; document.onkeyup = function(e){ return this.IDC_Keyboard.KeyUpEvent(e); }; } }; IDC_Keyboard.prototype.KeyDownEvent = function(e){ var keynum=null; if(this.isIE) keynum = e.keyCode; else if(e.which) keynum = e.which; this.KeyAltPressed=keynum==18; this.KeyControlPressed=keynum==17; this.KeyShiftPressed=keynum==16; this.LastKeyCode=keynum; return null; }; IDC_Keyboard.prototype.KeyUpEvent = function(e){ var keynum=null; if(this.isIE) keynum = e.keyCode; else if(e.which) keynum = e.which; this.KeyAltPressed=!keynum==18; this.KeyControlPressed=!keynum==17; this.KeyShiftPressed=!keynum==16; this.LastKeyCode=keynum; return null; }; IDC_Core.prototype.Ajax = function(url){ this.xmlhttp = null; this.Dispose = function(){ this.OnLoading = null; this.OnLoaded = null; this.OnInteractive = null; this.OnCompletion = null; this.OnError = null; this.OnFail = null; this.method = null; this.queryStringSeparator = null; this.argumentSeparator = null; this.URLString = null; this.encodeURIString = null; this.execute = null; this.element = null; this.elementObj = null; this.requestFile = null; this.vars.length=0; this.vars =null; this.ResponseStatus =null; this.xmlhttp = null; this.Dispose = null; }; this.ResetData = function(){ this.method = "POST"; this.queryStringSeparator = "?"; this.argumentSeparator = "&"; this.URLString = ""; this.encodeURIString = true; this.execute = false; this.element = null; this.elementObj = null; this.requestFile = url; this.vars = {}; this.ResponseStatus = new Array(2); }; this.ResetFunctions = function(){ this.OnLoading = function(){ }; this.OnLoaded = function(){ }; this.OnInteractive = function(){ }; this.OnCompletion = function(){ }; this.OnError = function(){ }; this.OnFail = function(){ }; }; this.Reset = function(){ this.ResetFunctions(); this.ResetData(); }; this.CreateAJAX = function(){ try { this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e1){ try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2){ this.xmlhttp = null; } } if (! this.xmlhttp){ if (typeof XMLHttpRequest != "undefined"){ this.xmlhttp = new XMLHttpRequest(); } else { this.failed = true; } } }; this.setVar = function(name, value){ this.vars[name] = Array(value, false); }; this.encVar = function(name, value, returnvars){ if (true == returnvars){ return Array(encodeURIComponent(name), encodeURIComponent(value)); } else { this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true); } }; this.processURLString = function(string, encode){ encoded = encodeURIComponent(this.argumentSeparator); regexp = new RegExp(this.argumentSeparator + "|" + encoded); varArray = string.split(regexp); for (i = 0; i < varArray.length; i++){ urlVars = varArray[i].split("="); if (true == encode){ this.encVar(urlVars[0], urlVars[1]); } else { this.setVar(urlVars[0], urlVars[1]); } } }; this.createURLString = function(urlstring){ if (this.encodeURIString && this.URLString.length){ this.processURLString(this.URLString, true); } if (urlstring){ if (this.URLString.length){ this.URLString += this.argumentSeparator + urlstring; } else { this.URLString = urlstring; } } this.setVar("rndval", new Date().getTime()); urlstringtemp = []; for (key in this.vars){ if (false == this.vars[key][1] && true == this.encodeURIString){ encoded = this.encVar(key, this.vars[key][0], true); delete this.vars[key]; this.vars[encoded[0]] = Array(encoded[1], true); key = encoded[0]; } urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0]; } if (urlstring){ this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator); } else { this.URLString += urlstringtemp.join(this.argumentSeparator); } }; this.runResponse = function(){ eval(this.Response); }; this.RunAJAX = function(urlstring){ if (this.failed){ this.OnFail(); } else { this.createURLString(urlstring); if (this.element){ this.elementObj = document.getElementById(this.element); } if (this.xmlhttp){ var self = this; if (this.method == "GET"){ totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString; this.xmlhttp.open(this.method, totalurlstring, true); } else { this.xmlhttp.open(this.method, this.requestFile, true); try { this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") } catch (e){ } } this.xmlhttp.onreadystatechange = function(){ switch (self.xmlhttp.readyState){ case 1: self.OnLoading(); break; case 2: self.OnLoaded(); break; case 3: var tempText = ''; try { tempText = self.xmlhttp.responseText; } catch(exp){ tempText = ''; } self.Response = tempText; self.OnInteractive(); break; case 4: self.Response = self.xmlhttp.responseText; self.ResponseXML = self.xmlhttp.responseXML; self.ResponseStatus[0] = self.xmlhttp.status; self.ResponseStatus[1] = self.xmlhttp.statusText; if (self.execute){ self.runResponse(); } if (self.elementObj){ elemNodeName = self.elementObj.nodeName; elemNodeName.toLowerCase(); if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){ self.elementObj.value = self.Response; } else { self.elementObj.innerHTML = self.Response; } } if (self.ResponseStatus[0] == "200" || self.ResponseStatus[0] == "0"){ self.OnCompletion(); } else { self.OnError(); } self.URLString = ""; break; } }; this.xmlhttp.send(this.URLString); } } }; this.Reset(); this.CreateAJAX(); }; var IDC_DOM = function(document){ }; IDC_DOM.prototype.GetObjectPosition = function(obj){ var x=0; var y=0; if (obj.offsetParent){ do { x += obj.offsetLeft; y += obj.offsetTop; } while (obj = obj.offsetParent); } var retval=new Array(); retval[0] = x; retval[1] = y; return retval; }; 