function AjaxReqClass () {
	function _createRequest () {
		try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
		try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
		try { return new XMLHttpRequest(); } catch(e) {}
		window.alert("XMLHttpRequest not supported");
		return null;
	}
	var _request = _createRequest();
	this.getReadyState = function () {return _request.readyState;} //0 = uninitialized,1 = loading,2 = loaded,3 = interactive,4 = complete
	this.getResponseXML = function () {return _request.responseXML;}
	this.getResponseText = function () {return _request.responseText;}
	this.getStatus = function () {return _request.status;}
	this.abort = function () {_request.abort();}
	// ---
	this.requestXML = function (url,method,data,handle) {//method,data can be empty
		if (typeof(method) == 'undefined') {
			method = 'POST';
		}
		var async = true;
		if (typeof(handle) == 'undefined') {
			async = false;
		}
		else{
			handle._request = _request;
		}
		if (_request) {
			_request.open(method, url, async);
			if (async) {
				_request.onreadystatechange = handle;
			}
			_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			_request.send(data);
			return _request.responseXML;
		}
	}
	// ---
	this.requestText = function (url,method,data,handle) {//method,data can be empty
		if (typeof(method) == 'undefined') {
			method = 'POST';
		}
		var async = true;
		if (typeof(handle) == 'undefined') {
			async = false;
		}
		else{
			handle._request = _request;
		}		
		if (_request) {
			_request.open(method, url, async);
			if (async) {
				_request.onreadystatechange = handle;
			}
			_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			_request.send(data);
			return _request.responseText;
		}
	}
}

function openw(urlarg, winname){
	var w = window.open(urlarg, winname);
	w.focus();
}

/*-----------------------------------------------------------*\ 
 * Write Cookie 
 *----------------------------- 
 * cookie: old cookie value
 * overwrite: if overwrite the old cookie 
 * value: cookie value
 * encode: if to encode cookie
 * identifier: cookie identifier 
 * separate: cookie separator
 * expires: cookie expires time
 * path: cookie effect path
 * domain: cookie effect domain
 * secure: if use SSL
\*-----------------------------------------------------------*/ 
//----------------Begin function fWriteCookie-----------------// 
function writeCookie(cookie, overwrite, value, encode, expires, path, domain, secure){ 
    if(cookie.length>0&&!overwrite)return false; 
    if(!value)return false; 
    var temp=''; 
     
    if(encode){
    	temp=value.split('='); 
      value=temp[0]+'='+escape(temp[1]); 
    } 
     
    cookie=value;
     
    if(expires!=undefined) cookie+=';expires='+expires; 
    if(path!=undefined) cookie+=';path='+path; 
    if(domain!=undefined) if(domain!=''){cookie+=';domain='+domain;}; 
    if(secure!=undefined) if(secure){cookie+=';secure='+secure;}; 
    cookie+=';';
     
    document.cookie=cookie; 
}
/*-----------------------------------------------------------*\                                
 * Read Cookie
 *-----------------------------                                                                                                                                        
 * cookie: old cookie                                                                  
 * identifier: identifier
 * separate: separator
 * decode: if decode the cookie
\*-----------------------------------------------------------*/                            
//----------------Begin function fReadCookie-----------------//                            
function readCookie(cookie, decode){                                                                                                               
    var array=cookie.split(';');                                                      
    var temp='';                                                                           
    for(var i=0; i<array.length; i++){                             
        if(array[i].indexOf('=')==-1)continue;                                             
                                                                                           
        temp=array[i].split('=');                                                          
        if(decode!=undefined){if(decode){temp[1]=unescape(temp[1]);}}                      
        temp[0]=temp[0].replace(/^[\s]+|[\s]+$/,'');                                       
        temp[1]=temp[1].replace(/^[\s]+|[\s]+$/,''); 
        if(temp[0]=='TKCDB_' || temp[0] == 'TKCDT' || temp[0] == 'p'){                                    
        	eval(temp[0]+"=temp[1]");                   
      	}                                       
    }                                                                                      
}                 

function setRowColor(row,arg){	
	if(arg == "over"){
		bg = row.style.background;
		row.style.background="#DDECFA";
	}
	else{
		row.style.background=bg;		
	}
}  

function setRowColor2(row,arg){	
	if(arg == "over"){		
		row.style.background="#DDECFA";
	}
	else{
		row.style.background="#FFFFFF";		
	}
}     

function isEmailAddress (string) {
	var addressPattern =
				/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	return addressPattern.test(string);
}  

function isZip(str){
	var exp = /^\d{5}$/;
	return exp.test(str);
}

function isZip4(str){
	var exp = /^\d{4}$/;
	return exp.test(str);
}

function isDate(str){
	var exp = /^\d{4}-\d{2}-\d{2}$/;
	return exp.test(str);
}

function isArray(o) {  
  return Object.prototype.toString.call(o) === '[object Array]';   
}      

function isPhoneNumber(str){
	var exp = /^\d{3}(-| )?\d{3}(-| )?\d{4}$/;
	return exp.test(str);
}   

function isNaics(str){
	var exp = /^\d{2,6}$/;
	return exp.test(str);
}                                                          
