﻿


// GURUASP CLASS
///////////////////////////////////////////////////////
//
GuruAsp = {};
//
// ALL CLASSES MUST BE CREATED FROM GuruAsp.Class
//
// crete new class, option one:
//var MyClassOne = new GuruAsp.Class( "className", [baseClass, baseClass2...], onDispose function );
//create new class, option two:
//var MyClassOne = new GuruAsp.Class( {__class: "className", __inherits:[new classone(), new class two()...], __onDispose: function(){....} } );
GuruAsp.Class = function(className, baseClasses, onDispose)
{
	if( typeof(arguments[0]) == "object")
	{
		baseClasses = arguments[0].__inherits; // base classes
		onDispose  = arguments[0].__dispose; //on dispose function
		className = arguments[0].__class; // class name
	}
	
	//create object instance with className
	var __this = new Object( className );
	
	// array of _base classes
	__this._base = new Array();
	
		//destructor, must be called explicitly since JS doesn't have destructor property
	__this.Dispose = function()
	{
		//iterate base classes and call their OnDispose() methods
		for(var nbase in __this._base)
		{
			__this._base[ nbase ].Dispose();
		}
		//call current class OnDispose()
		//__this.Dispose.OnDispose();
		onDispose();
	};
	
	if( typeof(onDispose) != "function")
	{
		onDispose = function(){};
	}
		
		//default handler, may be overriden in the __this class
	//__this.Dispose.OnDispose = onDispose;

	// helper methods, extends __this object with properties from srcObj 
	__this.Extend = function( srcObj )
	{	
		for(var prop in srcObj) 
		{
			if(__this[prop] == null) //if property doesn't exist in __this copy it from _base class
			{
				__this[prop] = srcObj[prop];
			}
		}
	};
	__this.Initialize = __this.Extend;
	
	// replace existing properties with new ones from srcObj
	__this.ReplaceProperties = function( srcObj )
	{
		for(var prop in srcObj)
		{
			__this[prop] = srcObj[prop];
		}
	};
	//copy _base classes into _base array and copy their properties into __this class
	for(var nn in baseClasses) //baseClasses is an Array
	{
		__this._base[__this._base.length] = baseClasses[ nn ];
		__this.Extend( baseClasses[ nn ] );
	}
	return __this;
};
/////////////////////////////////////////////////////////
//multiple inheritance supported
//class may inherit from 2 or more base classes
////////////////////////////////////////////////////////



GuruAsp.System = function()
{
	var __this = new GuruAsp.Class( "GuruAsp.System" );
	
	__this.version = 1.44;
	
	return __this;
};


//paramEventName without "on", example: mousemove
GuruAsp.System.Event = function(paramObjectListener, paramEventName, paramCallbackFunc)
{
	var __this = new GuruAsp.Class( 
		{
			__class: "GuruAsp.System.Event",
			//__inherits: null
			__dispose: function()
			{
				__this.Stop(); //stop events
				__this.callbackFunc = function(){}; //remove callBackFunc reference
			}
		});
					
	__this.m = //private members
	{	
		mBrowserId: (paramObjectListener.attachEvent ? 0 : 1),
		mPrefix: ["on", ""],
		mActionAdd: ["attachEvent", "addEventListener"],
		mActionRemove: ["detachEvent", "removeEventListener"]
	};
	__this.Extend(
	{
		isActive: false,
		objectListener: paramObjectListener,
		callbackFunc: paramCallbackFunc,
		actionAdd: (__this.m.mActionAdd[__this.m.mBrowserId]),
		actionRemove:  (__this.m.mActionRemove[__this.m.mBrowserId]),
		eventName: (__this.m.mPrefix[__this.m.mBrowserId] + paramEventName)
	});
	__this.Start = function()
	{
		__this.objectListener[__this.actionAdd](__this.eventName, __this.callbackFunc, true);
		__this.isActive = true;
	};
	__this.Stop = function()
	{
		__this.objectListener[__this.actionRemove](__this.eventName, __this.callbackFunc, true);
		__this.isActive = false;
	};
	
	return __this;
};

GuruAsp.System.Drawing = function()
{
	var __this = new GuruAsp.Class( "GuruAsp.System.Drawing" );
	
	__this.GetClientCenter = function()
	{
		var elem;
		if(window.opera)
		{
			elem = document.body;
		}
		else
		{
			elem = document.getElementsByTagName("html")[0]; 
		}
		return new GuruAsp.System.Drawing.Point( (elem.clientWidth/2) + elem.scrollLeft , (elem.clientHeight/2) + elem.scrollTop );
	};
	
	__this.GetClientRectangle = function()
	{
		var elem;
		if(window.opera)
		{
			elem = document.body;
		}
		else
		{
			elem = document.getElementsByTagName("html")[0]; 
		}
		return new GuruAsp.System.Drawing.Rectangle(
				new GuruAsp.System.Drawing.Point( elem.scrollLeft, elem.scrollTop), //top left corner
				new GuruAsp.System.Drawing.Point( elem.clientWidth + elem.scrollLeft,  	elem.clientHeight + elem.scrollTop  )); //bottom right corner
	};
	
	return __this;
};

GuruAsp.System.Drawing.Rectangle = function(topLeftPoint, bottomRightPoint)
{
	var __this = new GuruAsp.Class( "GuruAsp.System.Drawing.Rectangle" );
	__this.topLeft = topLeftPoint;
	__this.botRight = bottomRightPoint;
	return __this;
};

GuruAsp.System.Drawing.Point = function(left, top)
{
	var __this = new GuruAsp.Class( "GuruAsp.System.Drawing.Point" );
	
	__this.x = (left == null) ? 0 : left;
	__this.y = (top == null) ? 0 : top;

	return __this;
};

GuruAsp.System.Drawing.Size = function(width, height)
{
	var __this = new GuruAsp.Class( "GuruAsp.System.Drawing.Size" );
	
	__this.width = (width == null) ? 0 : width;
	__this.height = (height == null) ? 0 : height;

	return __this;
};



GuruAsp.System.Mouse = function()
{
	var __this = new GuruAsp.Class( 
			{	
				// class name
				__class: "GuruAsp.System.Mouse",
				// inherits from classes
				__inherits: null,
				// will call on Dispose()
				__dispose: function()
				{
					__this.moveMoveEvent.Dispose();
					__this.mouseDownEvent.Dispose();
				}
			});

		//public propery
	__this.Position=  new GuruAsp.System.Drawing.Point();
	
	__this.Listen = function(startListening)
	{
		if(startListening)
		{
			this.moveMoveEvent.Start();
			this.mouseDownEvent.Start();
		}
		else
		{
			this.moveMoveEvent.Stop();
			this.mouseDownEvent.Stop();
		}
	};
	
	__this.GetMousePositionCallback = function(evnt)
	{
		__this.Position.x = evnt.clientX;
		__this.Position.y = evnt.clientY;
	};

	__this.moveMoveEvent = new GuruAsp.System.Event(document, "mousemove", __this.GetMousePositionCallback);
	__this.mouseDownEvent = new GuruAsp.System.Event(document, "mousedown", __this.GetMousePositionCallback);

	return __this;
};
	
GuruAsp.System.Text = function()
{
	var __this = new GuruAsp.Class( "GuruAsp.System.Text" );
	
	return __this;
};

GuruAsp.System.Text.String = function(stringValue)
{
	var __this = new GuruAsp.Class( "GuruAsp.System.Text.String" );
		
	__this.value = stringValue;

		//public method, returns substring between startStr and endStr, excluding startStr and endStr
	__this.GetSubstring = function(startStr, endStr)
	{
		var startIndex = __this.value.indexOf(startStr) + startStr.length;
		var endIndex = __this.value.indexOf(endStr);
		if(startIndex < endIndex)
		{
			return __this.value.substring(startIndex, endIndex);
		}
		else
		{
			return "";
		}
	};
	return __this;
};





///////////////////////////////////////////////////////////////////////////////////////////////
//////EXAMPLE
////// INHERIT - EXAMPLE
////// HOW TO CREATE A NEW CUSTOM CLASS
//User = {};
//User.Class = {};

//// OPTION ONE
//User.Class.My = function()
//{
//	var __this = new GuruAsp.Class( "User.My" ,    /*class name: */
//		[ new GuruAsp.System(), new GuruAsp.System.Mouse() ] /*array of base classes (inherits from classes)*/
//	);
//	//OR INHERIT LIKE THIS:
//	// __this.Inherit( new GuruAsp.System.Drawing.Point( 10, 30 ));
//	
//	//private
//	var osdf = "fsdg"; //private variable
//	var TestOne = function(){return 100;};
//	
//	//public
//	__this.name = "Krunoslav";
//	
//	//destructor (__this.Dispose() has to be called explicitly)
//	__this.OnDispose = function()
//	{
//		return "fdsa";
//	};
//		
//	return __this;
//};


//// OPTION TWO
//User.Class.Test = function()
//{
//	var __this = new GuruAsp.Class(
//	{
//		// class name
//		__class: "User.Test",
//		// inherits from classes
//		__inherits:	
//		[					
//			new GuruAsp.System() ,
//			new GuruAsp.System.Mouse()
//		] ,
//		// executes when __this.Dispose() called, 
//		__dispose:	function()
//		{
//			__this.cleanUp();
//		}
//	});
//	
//	__this.cleanUp = function(){ return 10; };
//	
//	return __this;
//};

//var gg = new User.Class.Test();

//gg.Dispose();

////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////






GuruAsp.Xml = {};

//////////////////////////////////////////////////////////////
GuruAsp.Xml.XmlNode = function(outterXml, parentNode)
{
	var __this = new GuruAsp.Class( 
		{	
			// class name
			__class: "GuruAsp.Xml.XmlNode"
			// inherits from classes
			//__inherits: null,
			// will call on Dispose()
			//__dispose: function()	{}
		});

	__this.tagName = "";
	__this.attributes = "";
	__this.xml = GetOutterXml(outterXml);	 //clean start and end
	__this.data = GetInnerXml();

	__this.parentNode = parentNode;
	__this.childNodes = GetChildNodes();
	__this.childrenCount = __this.childNodes.length == null ? 0 : __this.childNodes.length;	
	__this.firstChild = __this.childNodes[0];
	__this.lastChild = __this.childNodes[__this.childNodes.length - 1];
	
	 GetTagName();
	
	function GetTagName()
	{
		var re = new RegExp("\\s*<([^> ]+)(.*?)>", "i");
		var m = __this.xml.match(re);
		if((m != null) && (m.length > 1))
		{
			__this.tagName = m[1];
			//remove white space at start and end
			re = new RegExp("^[\\s]*([^\\255]*?)[\\s]*$", "i");
			m = m[2].match(re);
			if((m != null) && (m.length > 1))
			{
				__this.attributes = m[1];
			}
		}
	}
	function GetOutterXml(outterXml)
	{
		var re = new RegExp( "<([^\\s]+)(.*?)>([^\\255]*?)<\\/\\1>", "i" );
		var m = outterXml.match(re);
		if( (m != null) && (m.length > 0))
		{
			return m[0];
		}
		return "";

	}
	
	function GetInnerXml()
	{
		var re = new RegExp( "<([^\\s]+)(.*?)>([^\\255]*?)<\\/\\1>", "i" );
		var m = __this.xml.match(re);
		if( (m != null) && (m.length > 3))
		{
			return m[3];
		}
		return "";
	}
	
	function GetChildNodes()
	{
		var re = new RegExp( "<([^\\s]+)(.*?)>[^\\255]*?<\\/\\1>", "ig" );
		//var re = /<([^\s]+)>[^\255]*?<\/\1>/ig;
		var m = __this.data.match(re);
		var arr = new Array();
		if(m != null)
		{
			for(var n = 0; n < m.length; n++)
			{
				arr[n] = new GuruAsp.Xml.XmlNode(m[n], __this);
			}
		}
		return arr;
	}
	
	__this.GetNodesByTagName = function(tagName)
	{
		//var re = new RegExp("<(" + tagName + ")>[^\\255]*?<\\/\\1>", "ig");
		var re = new RegExp( "<(" + tagName + ")(.*?)>[^\\255]*?<\\/\\1>", "ig" );
		var m = __this.data.match(re);
		var arr = new Array();
		if(m != null)
		{
			for(var n = 0; n < m.length; n++)
			{
				arr[n] = new GuruAsp.Xml.XmlNode(m[n], __this);
			}
		}
		return arr;
	};
	return __this;
};
/////////////////////////////////////////////////////////////////
GuruAsp.Xml.XmlParser = function(strXml)
{
		var __this = new GuruAsp.Class( 
		{	
			// class name
			__class: "GuruAsp.Xml.XmlParser"
			// inherits from classes
			//__inherits: null,
			// will call on Dispose()
			//__dispose: function()	{}
		});

	__this.xml = strXml;
	//__this.data = GetDocumentData(strXml);
	__this.doctype = GetDoctype(strXml);
	__this.root = new GuruAsp.Xml.XmlNode(GetDocumentData(strXml));
	
	function GetDoctype(strXml)
	{
		var re = new RegExp("^<\\?[^><]*?\\?>", "i");
		var m = strXml.match(re); 
		if((m != null) && (m.length > 0))
		{
			return m[0];
		}
		return "";
	}
	function GetDocumentData(outterXml)
	{
		var re = new RegExp("<([^\\s]+)[\\s]*[^>]*>[^\\255]*?<\\/\\1>", "i");
		var m = outterXml.match(re);
		if((m!=null) && (m.length > 0))
		{
			return m[0];
		}
		return "";
	}
	return __this;

};


	
//////////////////////////////////////////////////////////////////////////////////////////////////////
//supported methods GET, POST, POSTBACK
// <url>requesting url</url>
// <onResponseFunc>callback function on response received</onResponseFunc>
// <method>GET, POST, POSTBACK</method>
// <fixedImgLoading>if true, animation will be at the center of the screen, else it will be bound to the mouse</fixedImgLoading>
// <timeoutSeconds>request timeout in seconds</timeoutSeconds>
GuruAsp.System.AjaxRequest = function(url, onResponseFunc, method, fixedImgLoading, timeoutSeconds)
{
	var __this = new GuruAsp.Class(
		{
			__class: "GuruAsp.System.AjaxRequest",
		//	__inherits: null,
			__dispose: function()
			{
				mMoveMoveEvent.Dispose();
				mMouseDownEvent.Dispose();
				__this.mRequestObj.abort();
				__this.mRequestObj.onreadystatechange = function(){}; //remove reference to __this object
				__this.ShowImgLoading(false); 
				__this.mResponseReceived = true;
			}
		});

	__this.Initialize(
	{
		mRequestObj: null,
		mParams:	"",
		mResponseReceived: false,
		mBody: document.getElementsByTagName("body")[0],
		mHtml:  document.getElementsByTagName("html")[0],
		mUrl: url,
		mOnResponseFunc: onResponseFunc,
		mMethod: (method+"").toUpperCase(),
		mFixedImgLoading: (fixedImgLoading == true ? true : false), // if true, center image on the screen, else bind to mouse
		mTimeout: (timeoutSeconds != null ? (timeoutSeconds*1000) : 30000), //ms
		mImg: function()
		{
			var mImg = new Image(); // image loading
			mImg.src = GuruAsp.System.AjaxRequest.imgLoading.src;
			mImg.id = "loadingImg";
			mImg.style.position = "absolute";
			mImg.style.zIndex = "999999";
			mImg.style.top= "0px";
			mImg.style.left = "0px";
			mImg.style.display = "none";
			return mImg;
		}() //execute function at __this creation
	});
	
	__this.mBody.appendChild(__this.mImg);
	
	switch(__this.mMethod) //if no method passed-in, set GET as default
	{
		case "GET":
		case "POST":
		case "POSTBACK":
			break;
			
		default:
			__this.mMethod = "GET";
			break;
	}
	
		
	//////////////////////////////
		
	// MAKE A REQUEST
	__this.Submit = function()
	{
		__this.GetRequestObject();
		
		if(__this.mRequestObj != null)
		{
			__this.ShowImgLoading(true);
			
			window.setTimeout(__this.TimeoutCallbackFunc, __this.mTimeout); //<<< callback func

			__this.mRequestObj.onreadystatechange = __this.ReadyStateCallbackFunc; //<<< callback func
		
			try
			{
				var method = __this.mMethod;
				var reqParams;
				var reqUrl;

				if(method == "POSTBACK")
				{
					method = "POST";
				}
				
				// mParams is null if method is GET, if using POST set parameters in format: 
				//name=value&anothername=othervalue&so=on
				
				//remove & from the end
				if((__this.mParams.length > 0) && (__this.mParams.charAt(__this.mParams.length-1) == "&"))
				{
					__this.mParams = __this.mParams.substring(0, __this.mParams.length - 1);
				}
								
				//if GET, append parameters to the requesting url
				if((__this.mMethod == "GET") && (__this.mParams.length > 0 ))
				{
					reqUrl = __this.mUrl + "?" + __this.mParams;
					reqParams = null;
				}
				else
				{
					reqParams = __this.mParams;
					reqUrl = __this.mUrl;
				}
				
				//open request
				__this.mRequestObj.open(method,  reqUrl , true);//GET, POST, HEAD; domain; ASYNC request = true

				if(method == "POST")
				{
					__this.mRequestObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					//__this.mRequestObj.setRequestHeader('Content-Type', 'text/xml');
					//__this.mRequestObj.setRequestHeader('Content-Type', 'multipart/form-data');
				}
				//send request
				__this.mRequestObj.send( reqParams );
			}
			catch(e)
			{ 
				//alert(e.description + "\n" + e.message + "\n" + e.name + "\n" + e.number);
			}
		}
	};
	
	__this.GetRequestObject = function()
	{
		if (window.XMLHttpRequest) 
		{
			// Mozilla, Safari, ...
			__this.mRequestObj = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) 
		{ 
			try
			{
				__this.mRequestObj = new ActiveXObject("MSXML2.XMLHTTP.4.0");
			}
			catch(e)
			{
				try
				{
						__this.mRequestObj = new ActiveXObject("Microsoft.XMLHTTP");	
				}
				catch (e) 
				{
					try 
					{
						__this.mRequestObj = new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch (e) 
					{
						alert("Your browser doesn't support ajax. Please use Internet Explorer 4 and higher of Firefox 1.5 and higher");
					}
				}
			}
		}
	};
	
	// CALLBACK FUNCTIONS
	
	__this.ReadyStateCallbackFunc = function()
	{
		if((__this.mRequestObj.readyState == 4) && (__this.mRequestObj.status == 200))
		{
			// response received
			__this.mRequestObj.onreadystatechange = function(){}; //remove reference to __this object
			__this.ShowImgLoading(false); 
			__this.mResponseReceived = true;
			__this.mOnResponseFunc(__this); //user defined callback function, call __this.GetTagText("tagName")// the same as GetSubstring
		}
	};
	
	__this.TimeoutCallbackFunc = function()
	{
		if(__this.mResponseReceived == false) //if response already received, skip __this code
		{
			__this.mRequestObj.abort();	
			__this.mRequestObj.onreadystatechange = function(){}; //remove reference to __this object, enable garbage collector to collect __this		
			__this.ShowImgLoading(false);
			alert("Request timeout, server didn't respond in " + (__this.mTimeout/1000) + " seconds.");
		}
	};

	__this.ShowImgLoading = function(showImage)
	{
		if(showImage == true)
		{	
			GuruAsp.System.AjaxRequest.RequestsActive++; //increment counter
			__this.mImg.style.display = "";
			__this.SetImageLoadingPos();
			__this.SetWindowEvents();						
		}
		else //hide image loading
		{
			GuruAsp.System.AjaxRequest.RequestsActive--; //decrement counter
			__this.RemoveWindowEvents();
			__this.mImg.style.display = "none";
		}
	};
	

	__this.SetImageLoadingPos = function()
	{
		var topPos, leftPos;
		if(__this.mFixedImgLoading == true)
		{
			//show image "loading" at the center of the screen
			if(window.opera)
			{
				topPos =(__this.mBody.clientHeight/2) + __this.mBody.scrollTop;
				leftPos = (__this.mBody.clientWidth/2) + __this.mBody.scrollLeft;
			}
			else
			{
				topPos = (__this.mHtml.clientHeight/2) + __this.mHtml.scrollTop;
				leftPos = (__this.mHtml.clientWidth/2) + __this.mHtml.scrollLeft;
			}
			__this.mImg.style.top = (topPos - 40 ) + "px";
			__this.mImg.style.left = (leftPos) + "px";
		}
		else
		{
			// bind image 'loading' to mouse
			if(window.opera)
			{
				topPos = __this.mBody.scrollTop + GuruAsp.System.AjaxRequest.mouse.Position.y;
				leftPos = __this.mBody.scrollLeft + GuruAsp.System.AjaxRequest.mouse.Position.x;
			}
			else
			{
				topPos = __this.mHtml.scrollTop + GuruAsp.System.AjaxRequest.mouse.Position.y;
				leftPos = __this.mHtml.scrollLeft + GuruAsp.System.AjaxRequest.mouse.Position.x;
			}
			__this.mImg.style.top = (topPos + 15 ) + "px";
			__this.mImg.style.left = (leftPos + 15 ) + "px";
		}
	};

	var mMoveMoveEvent = new GuruAsp.System.Event(document, "mousemove", __this.SetImageLoadingPos);
	var mMouseDownEvent = new GuruAsp.System.Event(document, "mousedown", __this.SetImageLoadingPos);

	__this.SetWindowEvents = function()
	{
		window.onscroll = __this.SetImageLoadingPos;
		window.onresize = __this.SetImageLoadingPos;
		
		mMoveMoveEvent.Start();
		mMouseDownEvent.Start();
	};

	__this.RemoveWindowEvents = function()
	{
		window.onscroll = null;
		window.onresize = null;
		
		mMoveMoveEvent.Stop();
		mMouseDownEvent.Stop();
	};
	
	//returns Array of strings between <tagNam>...</tagName> tags  (in html or xml content: <param>some</param>)
	__this.GetTextsByTagName = function(tagName)
	{
		var texts = new Array();
		var currIndex = 0;
		var inputStr = __this.mRequestObj.responseText;
		var startStr = "<" + tagName + ">";
		var endStr = "</" + tagName + ">";
		
		while(true)
		{
			var startIndex = inputStr.indexOf(startStr, currIndex);
			if(startIndex < 0) //not found any more
			{
				return texts;
			}
			startIndex +=  startStr.length;
			currIndex = startIndex;
			var endIndex = inputStr.indexOf(endStr, currIndex);
			if(endIndex < 0) //not found any more
			{
				return texts;
			}
			currIndex = endIndex;
			if(startIndex < endIndex)
			{
				texts.push(inputStr.substring(startIndex, endIndex));
			}
		}
	};

//	__this.GetTextsByTagName = function(tagName)
//	{
//		var ddd = document.createElement("div");
//		ddd.innerHTML = __this.GetText();
//		return ddd.getElementsByTagName(tagName);
//	};
	
	//returns req.responseText
	__this.GetText = function()
	{
		return __this.mRequestObj.responseText;
	};
	
	//returns response text between tags <RespMessage>...</RespMessage>
	__this.GetRespMessage = function()
	{
		var texts = __this.GetTextsByTagName("RespMessage");
		if(texts.length > 0)
		{
			return texts[0];
		}
		return "";
	};

	//returns response text between tags <RespError>...</RespError>
	__this.GetRespError = function()
	{
		var texts = __this.GetTextsByTagName("RespError");
		if(texts.length > 0)
		{
			return texts[0];
		}
		return "";
	};

	//returns response text between tags <RespBody>...</RespBody>
	__this.GetRespBody = function()
	{
		var texts = __this.GetTextsByTagName("RespBody");
		if(texts.length > 0)
		{
			return texts[0];
		}
		return "";
	};
	
		__this.AddParameter 	= function(name, value)
	{
		__this.mParams += encodeURIComponent( name ) + "=" + encodeURIComponent ( value ) + "&";
	};

	__this.AddParametersWithSerialize = function(holder)//object which hold controls to be serialized
	{
		var inps = holder.getElementsByTagName("input");
		var textareas = holder.getElementsByTagName("textarea");
		var selects = holder.getElementsByTagName("select");
		
		__this.SerializeInputObjects( inps );
		__this.SerializeInputObjects( textareas );
		__this.SerializeInputObjects( selects );
	};

	__this.SerializeInputObjects = function(objCollection) //input, textarea
	{
		if(objCollection != null)
		{
			for(var n = 0; n < objCollection.length; n++)
			{
				var name = objCollection[n].name;
				var value = objCollection[n].value;
				
				if(name.length > 0)
				{
					var ttt = objCollection[n].type.toUpperCase();
					switch(ttt)
					{
						case "BUTTON":
						case "RESET":
						case "SUBMIT":
							break;
							
						case "RADIO":
						case "CHECKBOX":
							if(objCollection[n].checked == false)
							{
								//if not checked, don't post parameter at all
								break;
							}

						case "SELECT-ONE":
							if(objCollection[n].selectedIndex < 0)
							{
								//there is no <option> nodes, do not post parameter name at all
								break;
							}
							else if(__this.mMethod == "POSTBACK")
							{
								__this.AddParameter(name, value); //always send value, even if value==""
								break;
							}
							else if(value == "") //if not postback, use selectedIndex as value if value not set
							{
								//use selected index as value if method != postback
								__this.AddParameter(name, objCollection[n].selectedIndex + "");
								break;
							}
													
						default: // text, password, texarea, (FILE is NOT SUPPORTED)
							// form.submit() sends text and hidden fields parameter even if value="", 
							// but asp.net postback works ok even if we don't send parameters at all if value=""
							if(value.length > 0) 
							{
								__this.AddParameter(name, value); //the same as with form.submit()
							}
							break;
					}
				}
			}
		}
	};
	return __this;
};

//preload image
GuruAsp.System.AjaxRequest.imgLoading = new Image();
GuruAsp.System.AjaxRequest.imgLoading.src = "js/loading1.gif";

GuruAsp.System.AjaxRequest.mouse = new GuruAsp.System.Mouse();
GuruAsp.System.AjaxRequest.mouse.Listen(true);

//GuruAsp.System.AjaxRequest.mouse.Dispose();

GuruAsp.System.AjaxRequest.RequestsActive = 0;

