<!--
// AJAX library

function createRequestObject() 
{
	var ro;
	var browser = navigator.appName;	
	if(browser == "Microsoft Internet Explorer" && !window.XMLHttpRequest)  // <= IE6
	{
		ro = new ActiveXObject("Microsoft.XMLHTTP");		
	}
	else
	{	    
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();

function sndReq(action, arg) 
{
	http.open('get', '/Common/Ajax.aspx?action='+action+'&args='+arg);
	http.onreadystatechange = handleResponse;
	http.send(null);	
}

String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/, ''); };

function handleResponse() 
{
	if(http.readyState == 4)
	{		
		var response = http.responseText;
		var pipeIndex = response.indexOf('|');
		
		if(pipeIndex != -1) 
		{
			var command = response.substr(0, pipeIndex);
			var body = response.substr(pipeIndex+1);
           
            switch(command)
			{
				case 'sendDockContent':
				    // fill dockable window with returned HTML
					$0('rightDockObj').innerHTML = body;  
					break;
				case 'redirect':
				    // redirect user to login page
					window.top.location.replace(body);
					break;
                case 'renewClientSession':
                    startKeepAlive();
                    break;
				case 'askRenewSession':
                    countdownStart(body);
				    killKeepAlive();
				    break;
                default:
					//alert('unrecognized response: "'+response+'"');
					break;
			}
		}		
	}
}



// Custom Ajax functions

function submitFeedback(txtId, infoId, phoneId, emailId, typeId, contactId)
{
    var feedback = $0(infoId).value;
    feedback += '&_FeedbackComment_=' + $0(txtId).value;
    feedback += '&_Phone_=' + $0(phoneId).value;
    feedback += '&_Email_=' + $0(emailId).value;
    feedback += '&_FeedbackType_=' + $0(typeId).value;
    feedback += '&_ContactMe_=' + ($0(contactId).checked==true ? 'True' : 'False');

    feedback = escape(feedback);
    
    sndReq('submitFeedback', feedback);
    
    clearFeedback(true, txtId);
    showHide('tblFeedback', false);
    showHide('feedbackStatus', true);
    setTimeout('clearFeedback()', 1500);
}

function clearFeedback(keepOpen, clearTextId)
{
    var elem = $0(clearTextId);
    if(elem != null)
    {
        elem.value = '';
    }
    
    if(keepOpen != true)
    {
        showHide('tblFeedback', true);
        showHide('feedbackStatus', false);
        showHide('boxFeedback', false);        
    }
}

//-->

