//AJAX
function ajaxObject(url, callbackFunction) 
{ 
    var that=this; 
    this.updating = false;
    this.abort = function() 
    { 
        if (that.updating) 
        { 
            that.updating=false; 
            that.AJAX.abort();
            that.AJAX=null; 
        } 
    } 
    this.update = function(passData,postMethod) 
    { 
        if (that.updating)
        { 
            return false; 
        } 
        
        that.AJAX = null; 
        
        if (window.XMLHttpRequest) 
        { 
            that.AJAX=new XMLHttpRequest();
        } 
        else
        { 
            that.AJAX=new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        
        if (that.AJAX==null)
        { 
            return false; 
        } 
        else 
        { 
            that.AJAX.onreadystatechange = function() 
            { 
                if (that.AJAX.readyState==4)
                { 
                    that.updating=false; 
                    that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);
                    that.AJAX=null; 
                } 
            } 
            that.updating = new Date(); 
            if (/post/i.test(postMethod)) 
            {
                var uri=urlCall+'?'+that.updating.getTime(); 
                that.AJAX.open("POST", uri, true);
                that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                that.AJAX.setRequestHeader("Content-Length", passData.length); 
                that.AJAX.send(passData);
            } 
            else 
            { 
                var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
                that.AJAX.open("GET",uri, true); 
                that.AJAX.send(null); 
            } 
            return true; 
        } 
    } 
    var urlCall = rootURL + url; 
    this.callback= callbackFunction || function () { };
}

function getFormValues(fname)
{ 
   var str = ""; 
   var valueArr = null; 
   var val = ""; 
   var cmd = ""; 
   
   for(var i = 0; i < document.forms[fname].elements.length; i++) 
   { 
       
       switch(document.forms[fname].elements[i].type) 
       { 
            case "text": 
                str += document.forms[fname].elements[i].name + "=" + escape(document.forms[fname].elements[i].value) + "&"; 
                break; 
           case "select-one": 
                str += document.forms[fname].elements[i].name + "=" + document.forms[fname].elements[i].options[document.forms[fname].elements[i].selectedIndex].value + "&"; 
                break; 
           case "radio":
                if(document.forms[fname].elements[i].checked)
                {
                    str += document.forms[fname].elements[i].name + "=" + document.forms[fname].elements[i].value + "&";    
                }
                break;
           case "checkbox":
				if(document.forms[fname].elements[i].checked)
                {
                    str += document.forms[fname].elements[i].name + "=" + document.forms[fname].elements[i].checked + "&";    
                }
                break;
           case "password":
                str += document.forms[fname].elements[i].name + "=" + escape(document.forms[fname].elements[i].value) + "&"; 
                break;
           case "textarea":
                str += document.forms[fname].elements[i].name + "=" + escape(document.forms[fname].elements[i].value) + "&"; 
                break;
           case "button":
                break;
           case "reset":
				break;
			case "hidden":	
				break;
			case "select-multiple":
				break;
			case "submit":
				break;
			case "file":
				break;
		   default:
                //alert(document.forms[fname].elements[i].type);
                break;
       } 
   }
   str = str.substr(0,(str.length - 1)); 
   
   return str;
}

function getURLParam(strParamName)
{
	var strReturn = "";
	var strHref = window.location.href;
	if ( strHref.indexOf("?") > -1 )
	{
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
		{
			if ( aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 )
			{
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return unescape(strReturn);
}

function DisplayImage(picURL,picWidth,picHeight)
{
	newWindow=window.open(picURL,'newWin','toolbar=no,width='+picWidth+', height='+picHeight);
	newWindow.document.write('<html><head><\/head><body style="padding: 0px; margin: 0px; border-width: 0px;" onclick="window.close();"><img src="'+picURL+'" height="' + picHeight + '" width="' + picWidth + '"><\/body><\/html>');
	newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth, picHeight-newWindow.document.body.clientHeight);
	newWindow.focus();
}

function IsNumeric(strString)
//  check for valid numeric strings	
{
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;

if (strString.length == 0) return false;

//  test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
  {
  strChar = strString.charAt(i);
  if (strValidChars.indexOf(strChar) == -1)
	 {
	 blnResult = false;
	 }
  }
return blnResult;
}


