<!--
/***************************************************************************
 *	 This Software based on ajax tutorial found in Sams.Ajax.for.Web.Application.Developers book
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
Ajax = {};
Ajax.ini=function(){
	Ajax.update=false;
	Ajax.headers=new Array();
	Ajax.messageObj = new DHTML_modalMessage();	// We only create one object of this class
	Ajax.messageObj.setShadowOffset(5);	// Large shadow
	try {
	// Firefox, Opera 8.0+, Safari
		Ajax.request=new XMLHttpRequest();
	} catch(e) {
		try {
			Ajax.request=new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				Ajax.request=new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
}
Ajax.ini();
Ajax.makeHeaders = function(key, val){
	Ajax.headers[key]=val;
}
Ajax.makeRequest = function(method, url, callbackMethod, parameters){
	if(!Ajax.update){
		Ajax.update=true;
		Ajax.request.open(method, url, true);
		for(var par in Ajax.headers){
			if(typeof Ajax.headers[par] !='function'){
				Ajax.request.setRequestHeader(par,Ajax.headers[par]);			
			}
		}
		Ajax.request.onreadystatechange = callbackMethod;
		if(parameters!=null){
			Ajax.request.send(encodeURI(parameters));
		}
		else{
			Ajax.request.send(null);
		}
	}
}
Ajax.checkReadyState = function(_id,loading){
    ok=false;
	switch(Ajax.request.readyState){
	   case 1:
           document.getElementById(_id).innerHTML = loading;
			break;
       case 2:
           document.getElementById(_id).innerHTML = loading;
           break;
       case 3:
           document.getElementById(_id).innerHTML = loading;
           break;
       case 4:
		   Ajax.update = false;
           document.getElementById(_id).innerHTML = '';
           ok=true;
		   break;
       default:
           document.getElementById(_id).innerHTML = "An unexpected error has occurred.";
   }
   return ok;
}
Ajax.removeChildren=function(Node){
	if(Node==null){
		return;
	}
	else{
		while(Node.hasChildNodes()){
			Node.removeChild(Node.firstChild);
		}
	}	
}
Ajax.getResponse = function(){
    if(this.request.getResponseHeader('Content-Type').indexOf('xml') != -1){
        return Ajax.request.responseXML.documentElement;
    }
    else{
        return Ajax.request.responseText;
    }
}
function changeClass(el, cl) {
	dom=document.getElementById?1:0;
	if(dom){
		element=document.getElementById(el);
		element.className=cl;
	}
}
function swapImg(img_name,img_src) {
	document[img_name].src=img_src;
}
 function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
 }
popupWindow=function(url,width,height){
	 width=width;
	 height=height;	 
	 myw=window.open(url,'heplwin','width='+width+',height='+height+',menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
	 myw.focus();
}
adPreview=function(url,width,height){
	 width=width;
	 height=height;
	 fwidth=width;
	 fheight=height;
	 window.open(url+'&width='+width+'&height='+height,'welcome','width='+fwidth+',height='+fheight+',menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
}
Redirect = function(url){
	document.location.href = url;
}
Ajax.displayStaticMessage=function(width,height,messageContent,bg){	
	Ajax.messageObj.setHtmlContent(messageContent);
	Ajax.messageObj.setSize(width,height);
	Ajax.messageObj.setSource(false);
	Ajax.messageObj.setShadowDivVisible(true);	
	Ajax.messageObj.display(bg);
}
Ajax.closeMessage=function(){
	Ajax.messageObj.close();	
}
function errorHandler(message, url, line){
	var errorMessage = "Error: "+ message +"\n";
	errorMessage += "URL: "+ url +"\n";
	errorMessage += "Line Number: "+ line +"\n";
	alert(errorMessage);
	return true;
}
//onerror=errorHandler;   

//-->

