/*
 * Ajax plugin & utilities
 * -------------------------------------------------------------
 * Purpose:  create a Ajax web site
 * Version:  1.0
 * Date:     Nov 22, 2008
 * Install:  Drop into the Html directory and add *.js link
 * Author:   S.A.Hashemi <info at atf dot ir>
 * -------------------------------------------------------------
 *
 */
onloadW = function()
{
	//setHttpAll();
	//setHttpAll('body', '&style=p');
	getZoom();
	inputFocus();
}
if (window.attachEvent)
{
	window.attachEvent("onload", onloadW);
}
else
{
	window.onload = onloadW;
}
//------------------------------------------
function isFirefox(){if (navigator.appName != 'Netscape'){return false;}else{return true;}}

function getNavigator(){return window.navigator.appName+' '+window.navigator.appVersion;}

function getLanguage()
{   
    if (isFirefox())    
    {
        return navigator.language.substring(0, 2);        
    }
    else
    {        
        if (navigator.userLanguage != 'undefined'){return navigator.userLanguage.substring(0, 2);}
        else if (navigator.browserLanguage != 'undefined'){return navigator.browserLanguage.substring(0, 2);}
        else if (navigator.systemLanguage != 'undefined'){return navigator.systemLanguage.substring(0, 2);}
        else {return 'en';}
    }        
}

function isEmpty(val){return (val == null) || (val.length == 0);}

function isValidEmail(val){return (val.indexOf(".") > 2) && (val.indexOf("@") > 0);}

function trim(val){return val.replace(/^\s+|\s+$/g,"");}
function ltrim(val){return val.replace(/^\s+/,"");}
function rtrim(val){return val.replace(/\s+$/,"");}

String.prototype.trim = function(){return trim(this);}
String.prototype.ltrim = function(){return ltrim(this);}
String.prototype.rtrim = function(){return rtrim(this);}

function inputFocus()
{
	var els = new Array("INPUT", "SELECT", "TEXTAREA", "BUTTON", "IFRAME");
	for (k in els)
	{
        var el = document.getElementsByTagName(els[k]);
        for (var i=0; i<el.length; i++)
        {
	        if (el[i].onfocus == null && el[i].onblur == null)
		    {
      	        elb = '';
      	        if (!isFirefox())
      	        {
      		        elb = '2px inset';
      	        }
      	        if(el[i].style.border)
      	        {
      		        elb = el[i].style.border;
      	        }
      	        el[i].onfocus = function()
      	        {
      		        this.style.border = '1px solid red';
      	        }
      	        el[i].onblur = function()
      	        {
      		        this.style.border = elb;
      	        }
		    }
        }
	}
}

function setInnerHtml(el, content)
{
    if ((el != null) && (el != ''))
    {
        if (typeof(el) != "object")
        {
            el = document.getElementById(el);
        }
	    if (isFirefox())
	    {
		    rng = document.createRange();
		    rng.setStartBefore(el);
		    htmlFrag = rng.createContextualFragment(content);
		    while (el.hasChildNodes())
			    el.removeChild(el.lastChild);
		    el.appendChild(htmlFrag);
	    }
	    else
	    {
		    el.innerHTML = content;
	    }	
	}
}

function openWindow(url, ww, wh, st)
{
	var url = typeof(url) != 'undefined' ? url : window.location ;			
	var ww = typeof(ww) != 'undefined' ? ww : screen.width / 2 ;	
	var wh = typeof(wh) != 'undefined' ? wh : screen.height / 2 ;	
	var st = typeof(st) != 'undefined' ? st : window.status ;	
	var wx = (screen.width/2) - (ww/2);
	var wy = (screen.height/2) - (wh/2);
	window.status = st;
	return window.open(url, null, "height="+wh+",width="+ww+",scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,resizable=no,top="+wy+",left="+wx);
}
					
function setOpacity(el, oOpacity) 
{
	var el = typeof(el) != 'undefined' ? el : null ;	
	var oOpacity = typeof(oOpacity) != 'undefined' ? oOpacity : 100 ;	
    if (el != null && el != '')
    {
        if (typeof(el) != "object")
        {
            el = document.getElementById(el);
        }
	    if (isFirefox())
	    {		
		    el.style.MozOpacity = oOpacity / 101;	
	    }
	    else
	    {	    	
	        //el.style.filters.alpha.opacity = oOpacity;
	        el.style.opacity = oOpacity;	
		    el.style.filter = 'alpha(opacity=' + oOpacity + ')';
	    }		
	}
}
					
function getCookie(name) 
{
    var name = typeof(name) != 'undefined' ? name : null ;	
    if (name != null)
	{
	    var start = document.cookie.indexOf(name + "=");
	    var len = start + name.length + 1;
	    if (start != true && name != document.cookie.substring(0, name.length)) return null;	
	    if (start == -1) return null;
	    var end = document.cookie.indexOf(";", len);
	    if (end == -1) end = document.cookie.length;
	    return unescape(document.cookie.substring(len, end));
	}    
	else
	{
	    return null;
	}
}

function setCookie(name, value) 
{			
    var name = typeof(name) != 'undefined' ? name : null ;	
    var value = typeof(value) != 'undefined' ? value : null ;	    
    if (name != null && value != null)
	{    
	    if (window.navigator.cookieEnabled == true)
	    {
		    expiresDay = 1;
		    var today = new Date();
		    today.setTime(today.getTime());
		    expires = (30 * 24 * 60 * 60) * expiresDay; // 30 day = (30 days * 24 hours * 60 mins * 60 secs)		
		    var expiresDate = new Date(today.getTime() + (expires));		
		    document.cookie = name + "=" + escape(value) + ((expires) ? ";expires=" + expiresDate.toGMTString() : "");
	    }
	}    
}

function getZoom()
{
	var zoom = getCookie("zoom");
	if (zoom != null)
	{
		window.parent.document.body.style.zoom = zoom;
	}
	return zoom;
}

function setZoom(i) 
{			
	i = escape(i);
	if (i == "-")
	{
		//	zoomin 	
		if(window.parent.document.body.style.zoom != 0) 
		{
			window.parent.document.body.style.zoom *= 0.8;
		} 		
		else 
		{
			window.parent.document.body.style.zoom = 0.8;
		} 
	}
	else if (i == "+")
	{
		//	zoomout
		if(window.parent.document.body.style.zoom != 0) 
		{
			window.parent.document.body.style.zoom *= 1.25;
		} 
		else 
		{
			window.parent.document.body.style.zoom = 1.25;
		} 
	} 
	else
	{
		//	reset
		window.parent.document.body.style.zoom = 1;
	} 
	
	setCookie("zoom", window.parent.document.body.style.zoom);	
}

function isValidObject(el)
{
	var isValid = false;
    if ((el != null) && (el != ''))
    {    
        if (typeof(el) != "undefined")
        {
            if (typeof(el) == "object")
            {  	     
			    isValid = true;
            }            
            else if (document.getElementById(el) != null)
            {
                if (typeof(document.getElementById(el)) == "object")
                {
                    isValid = true;                
                }    
            }                    
        }    
    }
	return isValid;
}

function getEval(val)
{
	if(val != null)
	{
		eval("var val =" + val);
	}
	return val;
}

function createDiv(content, className, css) 
{
    var content = typeof(content) != 'undefined' ? content: '';
    var css = typeof(css) != 'undefined' ? css: '';
    var className = typeof(className) != 'undefined' ? className: null;
	var el = document.createElement("div");		
	el.style.cssText = "position:absolute; z-index:1; display:none; visibility:hidden; width:auto; height:20px; left:45%; top:0px; font:normal 9pt Tahoma; background-color:#CC0000; border:0px solid #FFFFFF; color:#FFFFFF; padding:5px; text-align:center; vertical-align:middle; filter:alpha(opacity=80); -moz-opacity:0.8;" + css;		
	el.className = className;
	document.body.appendChild(el);	
	setInnerHtml(el, content);
	return el;
}

function setOptionsOfSelect(el, val, evalState)
{ 
	var evalState = typeof(evalState) != 'undefined' ? evalState: false;
	if ((val != null || val != "") && isValidObject(el) == true)
	{
		if (typeof(el) != "object")
		{
		           el = document.getElementById(el);
		}		 
		el.length = 0;
		if (evalState == true)
		{				
			list = getEval(val);
		}
		else
		{					
			list = val;
		}
		i = 0;					
		for (key in list)
		{
			el.options[i] = new Option(list[key], key);							
			i++;
		}		
		if (list[0] == 'undefined')
		{		
			el.options[0] = null;															
		}
	}
}
														
function getForm(thisform, withAction)
{
	var withAction = typeof(withAction) != 'undefined' ? withAction : true;
	var url = "";
	for(i=0; i<thisform.elements.length; i++)
	{
		if((thisform.elements[i].type=="checkbox" || thisform.elements[i].type=="radio") && thisform.elements[i].name!="")
		{
			if(thisform.elements[i].checked==true)
			{
				url += "&"+thisform.elements[i].name+"="+thisform.elements[i].value;
			}
		}
		else if(thisform.elements[i].type=="text")
		{
			if(thisform.elements[i].value!="" && thisform.elements[i].name!="")
			{
				url += "&"+thisform.elements[i].name+"="+thisform.elements[i].value;
			}
		}
		else if(thisform.elements[i].type=="textarea")
		{
			if(thisform.elements[i].value!="" && thisform.elements[i].name!="")
			{
				url += "&"+thisform.elements[i].name+"="+escape(encodeURI(thisform.elements[i].value));
			}
		}
		else if(thisform.elements[i].type=="select-multiple")
		{
			if(thisform.elements[i].value!=null && thisform.elements[i].name!="")
			{
				url += "&"+thisform.elements[i].name+"="+thisform.elements[i].value.toString();
			}
		}
		else if(thisform.elements[i].type=="reset")
		{
				url += "";
		}
		else
		{
			if(thisform.elements[i].value!="" && thisform.elements[i].name!="")
			{
				url += "&"+thisform.elements[i].name+"="+thisform.elements[i].value;
			}
		}
	}

	if ( withAction != false)
	{
		url = thisform.action+"?"+url;
	}

	return url;
}

var xmlHttp = null;
var xmlHttpSetElementObject = null;
var xmlHttpStatusElementID = "getHttpStatus";
var xmlHttpDisableElementID = "getHttpDisable";

function getHttp(xmlHttpUrl, xmlHttpMethode, xmlHttpJSMethodeName, xmlHttpElementID, xmlHttpShowStatus, xmlHttpStatusID, xmlHttpResponseEval, xmlHttpParameterS)
{
	var xmlHttpUrl = typeof(xmlHttpUrl) != 'undefined' ? xmlHttpUrl : '';
	var xmlHttpMethode = typeof(xmlHttpMethode) != 'undefined' ? xmlHttpMethode : 'POST';
	var xmlHttpJSMethodeName = typeof(xmlHttpJSMethodeName) != 'undefined' ? xmlHttpJSMethodeName : null;
	var xmlHttpElementID = typeof(xmlHttpElementID) != 'undefined' ? xmlHttpElementID : null;
	var xmlHttpShowStatus = typeof(xmlHttpShowStatus) != 'undefined' ? xmlHttpShowStatus : false;
	var xmlHttpMyStatusElementID = typeof(xmlHttpStatusID) != 'undefined' ? xmlHttpStatusID : null;
	var xmlHttpResponseEval = typeof(xmlHttpResponseEval) != 'undefined' ? xmlHttpResponseEval : false;
	var xmlHttpParameterS = typeof(xmlHttpParameterS) != 'undefined' ? xmlHttpParameterS : '';		
	
	if (window.XMLHttpRequest)
	{
		// If IE7, Mozilla, Safari, etc: Use native object
		xmlHttp = new XMLHttpRequest();

		if (xmlHttp.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			xmlHttp.overrideMimeType('text/html');
		}
		
	}
	else if (window.ActiveXObject)
	{
		// ...otherwise, use the ActiveX control for IE5.x and IE6
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	else
	{
		//	If the JavaScript version is greater than 5.
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");						
	}
	
	if (xmlHttp == null)
	{
		alert(" Not support Ajax ! ");
	}
	else
	{		
	    var xmlHttpMyStatusElement = null;	
		if (xmlHttpMyStatusElementID != null)
		{
			if (isValidObject(xmlHttpMyStatusElementID) == true)
			{		
				xmlHttpMyStatusElement = document.getElementById(xmlHttpMyStatusElementID);
			}
		}

		var xmlHttpStatusElement = null;
		if (isValidObject(xmlHttpStatusElementID) == true)
		{
			var xmlHttpStatusElement = document.getElementById(xmlHttpStatusElementID);
		}

		var xmlHttpDisableElement = null;
		if (isValidObject(xmlHttpDisableElementID) == true)
		{
			var xmlHttpDisableElement = document.getElementById(xmlHttpDisableElementID);
		}

        var isStatus = true;
        if (xmlHttpShowStatus == true && xmlHttpStatusElement == null && xmlHttpDisableElement == null && xmlHttpMyStatusElement == null)        
        {                  
	        var xmlHttpStatusElement = createDiv('', null, 'direction: ltr;');
	        isStatus = false;
        }

		var xmlHttpMethodeType = "POST";
		if (xmlHttpMethode != null)
		{
			xmlHttpMethode = trim(xmlHttpMethode.toUpperCase());
			if (xmlHttpMethode == "POST" || xmlHttpMethode == "GET")
			{
				xmlHttpMethodeType = xmlHttpMethode;
			}
		}
                
		if (isValidObject(xmlHttpElementID) == true)
		{		
		    if (typeof(xmlHttpElementID) != "object")
		    {			    
			    var xmlHttpSetElementObject = document.getElementById(trim(xmlHttpElementID));						
			}
			else
			{    
			    var xmlHttpSetElementObject = xmlHttpElementID;
			}    
		}
		else
		{
		    //var xmlHttpSetElementObject = window.parent.document.body;
			var xmlHttpSetElementObject = document.getElementsByTagName("BODY")[0];
		}		

		var isObject = false; 
		if (isValidObject(xmlHttpUrl) == true)
		{
            /*
            if (typeof(xmlHttpUrl) != "object")
            {
               xmlHttpUrl = document.getElementById(xmlHttpUrl);
            }
            */	
			if (xmlHttpUrl.tagName == "A")
			{
				xmlHttpUrlTemp = xmlHttpUrl.href;
				xmlHttpUrl = null;
				xmlHttpUrl = xmlHttpUrlTemp;
				isObject = true;
			}
			else if (xmlHttpUrl.tagName == "FORM")
			{
				xmlHttpUrlTemp = getForm(xmlHttpUrl, true);
				isObject = true;
				if (xmlHttpMethode == null)
				{
					xmlHttpMethodeType = trim(xmlHttpUrl.method);
					xmlHttpMethodeType = xmlHttpMethodeType.toUpperCase();
				}
				xmlHttpUrl = null;
				xmlHttpUrl = xmlHttpUrlTemp;				
			}
		}

		xmlHttpUrl = xmlHttpUrl + xmlHttpParameterS + "&sid=" + Math.random();		
		
		xmlHttp.onreadystatechange = function() 
		{
			/*
			Status:
			0 = uninitialized: Means it's ready to go (uninitialized)
			1 = loading: Loading
			2 = loaded: Finished loading
			3 = interactive: Almost ready for use
			4 = complete: Loading is complete and ready to be dealt with.
			*/
			
			if (document.documentElement && document.documentElement.scrollTop)
			{
				theTop = document.documentElement.scrollTop;
			}	
			else if (document.body)
			{
				theTop = document.body.scrollTop
			}	
			else
			{				
				theTop = window.pageYOffset;	
			}
				
			if (theTop > 0)
			{	
				if (isFirefox())
				{			
					theTop = theTop+'px';
				}
				
				if (isStatus == false)
				{
				    xmlHttpStatusElement.style.top  = theTop;
				} 
				else
				{
				    xmlHttpDisableElement.style.top = theTop;
				}   
			}
							

			if (xmlHttp.readyState == 0 || xmlHttp.readyState == "uninitialized")
			{
				if (xmlHttpMyStatusElementID == null)
				{			
					if (xmlHttpDisableElement != null)
					{			
						xmlHttpDisableElement.style.display = "none";
						xmlHttpDisableElement.style.visibility = "hidden";
					}
					if (xmlHttpStatusElement != null)
					{															
						xmlHttpStatusElement.style.display = "none";
						xmlHttpStatusElement.style.visibility = "hidden";
					}					
				}
				else
				{
					//xmlHttpMyStatusElement.style.display = "none";
					xmlHttpMyStatusElement.style.visibility = "hidden";
				}																		
			}		
			else if (xmlHttp.readyState == 1 || xmlHttp.readyState == "loading")
			{			
				if (xmlHttpShowStatus == null || xmlHttpShowStatus == true)
				{						
					if (xmlHttpMyStatusElementID == null)
					{									
  					    if (xmlHttpDisableElement != null)
  					    {					  					    
  						    xmlHttpDisableElement.style.display = "block";
  						    xmlHttpDisableElement.style.visibility = "visible";
  					    }			
  					    if (xmlHttpStatusElement != null)
  					    {					
						    xmlHttpStatusElement.style.display = "block";								
						    xmlHttpStatusElement.style.visibility = "visible";	  													
  						    xmlHttpStatusElement.innerHTML = " Loading ... ";
  					    }	
					}
					else
					{									    
						//xmlHttpMyStatusElement.style.display = "none";
						xmlHttpMyStatusElement.style.visibility = "hidden";
					}																					  
				}	
			}			
			else if (xmlHttp.readyState == 2 || xmlHttp.readyState == "loaded")
			{
				if (xmlHttpShowStatus == null || xmlHttpShowStatus == true)
				{	
					if (xmlHttpMyStatusElementID == null)
					{				
  					    if (xmlHttpDisableElement != null)
  					    {							
  						    xmlHttpDisableElement.style.display = "block";
  						    xmlHttpDisableElement.style.visibility = "visible";
  					    }	
  					    if (xmlHttpStatusElement != null)
  					    {							
						    xmlHttpStatusElement.style.display = "block";								
						    xmlHttpStatusElement.style.visibility = "visible";	  																				
  						    xmlHttpStatusElement.innerHTML = " Loaded ... ";
  					    }
					}
					else
					{
						//xmlHttpMyStatusElement.style.display = "none";
						xmlHttpMyStatusElement.style.visibility = "hidden";
					}																  
				}	
			}	
			else if (xmlHttp.readyState == 3 || xmlHttp.readyState == "interactive")
			{
				if (xmlHttpShowStatus == null || xmlHttpShowStatus == true)
				{				
					if (xmlHttpMyStatusElementID == null)
					{						
  					if (xmlHttpDisableElement != null)
  					{						
  						xmlHttpDisableElement.style.display = "block";
  						xmlHttpDisableElement.style.visibility = "visible";
  					}
  					if (xmlHttpStatusElement != null)
  					{								
						xmlHttpStatusElement.style.display = "block";								
						xmlHttpStatusElement.style.visibility = "visible";	  																				
  						xmlHttpStatusElement.innerHTML = " Interactive ... ";
  					}
					}
					else
					{
						//xmlHttpMyStatusElement.style.display = "none";
						xmlHttpMyStatusElement.style.visibility = "hidden";
					}																	  
				}
			}			
			else if ((xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") && xmlHttp.status == 200)
			{ 	
				if (xmlHttpMyStatusElementID == null)
				{			
  				    if (xmlHttpDisableElement != null)
  				    {			
  					    xmlHttpDisableElement.style.display = "none";
  					    xmlHttpDisableElement.style.visibility = "hidden";
  				    }
					if (xmlHttpStatusElement != null)
					{																			
						xmlHttpStatusElement.style.display = "none";
						xmlHttpStatusElement.style.visibility = "hidden";
					}	  																		
				}
				else
				{
					//xmlHttpMyStatusElement.style.display = "none";
					xmlHttpMyStatusElement.style.visibility = "hidden";
				}				
				
				if (xmlHttp.responseText == null || xmlHttp.responseText == "")
				{
					xmlHttp.abort();
					if (xmlHttpShowStatus == null || xmlHttpShowStatus == true)
					{							
						alert(" Not Response! ");
					}	
				}
				else
				{												
					//var xmlHttpResponse = xmlHttp.responseXml; 
					var xmlHttpResponse = xmlHttp.responseText; 
					if (xmlHttpSetElementObject != null && xmlHttpJSMethodeName == null)
					{				
						if (xmlHttpSetElementObject.tagName == "SELECT" && xmlHttpResponseEval == true)
						{
							setOptionsOfSelect(xmlHttpSetElementObject, xmlHttpResponse, true);																				
						}
						else if (xmlHttpSetElementObject.tagName == "INPUT" || xmlHttpSetElementObject.tagName == "TEXTAREA")
						{
							xmlHttpSetElementObject.value = xmlHttpResponse;														  								
						}	
						else if (xmlHttpSetElementObject.tagName == "IMG")
						{
							xmlHttpSetElementObject.src = xmlHttpResponse;														  
						}								
						else if (xmlHttpSetElementObject.tagName == "IFRAME")
						{		
                           if (isFirefox)
                           {
                               xmlHttpSetElementObject.contentWindow.document.body.innerHTML = xmlHttpResponse;
                           }
                           else
                           {
                               xmlHttpSetElementObject.document.body.innerHTML = xmlHttpResponse;		                            
                           }	
                           onloadW();																		   													   																								
						}    
						else
						{
							xmlHttpSetElementObject.innerHTML = xmlHttpResponse;														  
							onloadW();
						}
					}
					else
					{	
						if (xmlHttpJSMethodeName != null)
						{		
							xmlHttpJSMethodeName = trim(xmlHttpJSMethodeName);				
							if (xmlHttpJSMethodeName != "")
							{
								if (xmlHttpResponseEval == true)
								{
									xmlHttpResponse = getEval(xmlHttpResponse);
								}							
								//"+xmlHttpResponse+"
								eval(xmlHttpJSMethodeName+"(xmlHttpResponse)");
								//setHttp(xmlHttpResponse);
							}	
						}	
					}						
				}	
			} 		
		}			

		xmlHttp.open(xmlHttpMethodeType, xmlHttpUrl, true);
		
		if (xmlHttpMethodeType == "POST")
		{
			// only Post metod
			//xmlHttp.setRequestHeader("Method", "POST " + xmlHttpUrl + " HTTP/1.1");
			xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
			xmlHttp.setRequestHeader("Content-length", xmlHttpUrl.length);
			xmlHttp.setRequestHeader("Connection", "close");			
			
			xmlHttp.send(xmlHttpUrl);
		}				
		else if (xmlHttpMethodeType == "GET")
		{			
			var lm = new Date(); 
			lm = lm.toGMTString(); // GMT
			// Bust cache in the head
			xmlHttp.setRequestHeader("Content-Type", "charset=UTF-8"); 
			xmlHttp.setRequestHeader("Expires",	"Mon, 26 Jul 1997 05:00:00 GMT");  // Date in the past 
			xmlHttp.setRequestHeader("Last-Modified",	"" + lm + " GMT"); 
			// always modified
			xmlHttp.setRequestHeader("Cache-Control",	"no-cache, must-revalidate");  // HTTP/1.1
			xmlHttp.setRequestHeader("Pragma",	"no-cache");  // HTTP/1.1			
			
			xmlHttp.send(null);
		}						
		
		if (isObject == true)
		{
			return false;
		}
		/*
		else
		{
			if (xmlHttpSetElementObject == null && xmlHttpJSMethodeName == null)
			{
				return xmlHttpResponse;
			}
		}
		*/		
		
		/*	
		XMLHttpRequest Methods:	
		The open() method sets up a request to a web server. 
		The send() method sends a request to the server. 
		The abort() method aborts the current server request. 
		*/		
	}	
}

function setHttpAll(xmlHttpElementID, xmlHttpParameterS, xmlHttpMethode)
{
    var xmlHttpElementID = typeof(xmlHttpElementID) != 'undefined' ? xmlHttpElementID : null;
    var xmlHttpParameterS = typeof(xmlHttpParameterS) != 'undefined' ? xmlHttpParameterS : '';	    
	var xmlHttpMethode = typeof(xmlHttpMethode) != 'undefined' ? xmlHttpMethode : 'POST';			
	//for A tags
	var el = document.getElementsByTagName("A");
	for (var i=0; i<el.length; i++)
	{	
	    elHref = trim(el[i].href);
	    if (elHref != '' && el[i].onclick == null && elHref.indexOf("#") < 1 && elHref.indexOf("?") > 0)
 		{
			el[i].onclick = function()
			{ 	
	 			return getHttp(this, xmlHttpMethode, null, xmlHttpElementID, true, null, false, xmlHttpParameterS);
			}	 			
		}
	}
	//for Form tags	
	var el = document.getElementsByTagName("FORM");
	for (var i=0; i<el.length; i++)
	{
        if (el[i].onsubmit == null)
        {    
		    el[i].onsubmit = function()
		    {	
			    return getHttp(this, null, null, xmlHttpElementID, true, null, false, xmlHttpParameterS);
   			} 				
   		}	
	}	
}

/* for Example

--------------for header 
<script type="text/javascript" language="javascript" src="./ajx.js"></script>

--------------for status
<style type="text/css">
#getHttpDisable {		
	display: none;
	visibility: hidden;
	position: absolute;
	z-index: 1;
	top: 0px;		
	width: 100%;
	height: 100%;		
	left: 46%;	
	width: 130px;
	height: 20px;	
	border: 0px solid #FFFFFF;
	padding: 5px;
	margin: 0px;
	color: #FFFFFF;
	background-color: #CC0000;
	text-align: center;
	vertical-align: middle;	
	direction: ltr;	
	overflow: hidden;	
	filter: alpha(opacity=90);		
	-moz-opacity: 0.9;
}
#getHttpStatus {	
	color: #FFFFFF;
	text-align: center;
	vertical-align: middle;
	border: 0px solid #FFFFFF;	
	width: 70%;
	font-weight: normal;
	font-size: 9pt;
	font-family: "Tahoma", "Verdana", "Arial";	
	color:#FFFFFF;
	float: left;
	direction: ltr;
	overflow: hidden;		
}
</style>

<div id="getHttpDisable">
	<center><img src="images/loading.gif" alt="" style="float:left;" /><div id="getHttpStatus"></div></center>
</div>

--------------for method 
function setHttp(httpResponse)
{ 
	document.getElementById("getHttp").innerHTML = httpResponse; 
}

--------------or for link 
<a href="./?" onClick="getHttp(this.href+'&style=p', 'POST', null, 'body', true); return false;" >Test</a>

--------------or for link
<a href="./?" onClick="return getHttp(this, 'POST', null, 'body', true, null, false, '&style=p');" >Test</a>

--------------or for form 
onSubmit="getHttp(getForm(this)+'&style=p', this.method, null, 'body', true); return false;"

--------------or for form
onSubmit="return getHttp(this, null, null, 'body', true, null, false, '&style=p');"

--------------or for select
function setHttp(httpResponse)
{
	document.getElementById("getHttp").innerHTML = httpResponse;
}
onChange="getHttp('./?t='+this.value, 'POST', 'setHttp', null, true);"

php:
if (isset($_REQUEST["t"]))
{
    $a = array (1=>'a',2=>'b',3=>'c');
    echo json_encode($a);
}

--------------or for select
onChange="getHttp('./?t='+this.value, null, null, 'select2', true, null, true);"
<select id="select2">...</select>

--------------or for input validator
<input type="text" name="email" size="20" onBlur="getHttp('./?t='+this.value, null, null, 'getHttpMsg', false, 'getHttpImg', false,'&style=p');"/>
<img src="./loading.gif" style="visibility:hidden;" id="getHttpImg"/>
<div id="getHttpMsg"></div>


*/





