
var SW1Ajax = {
	createXMLHttp: function (){
						var xmlHttp = false
						if (window.XMLHttpRequest){
							xmlHttp = new XMLHttpRequest(); // IE7, Firefox, Mozilla, etc.
						} else if (window.ActiveXObject){
							xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // code for IE5, IE6
						}
						return xmlHttp;
					},
	asyncLoad: function (url,id){
						var xmlHttp = this.createXMLHttp();
						if(!xmlHttp||!url||!id||(id.length==0)) {return;}
						xmlHttp.open("GET",url,true);
					  	document.getElementById(id).innerHTML = "<div class='loading'>Loading...</div>";
						xmlHttp.onreadystatechange = function(){
							if(xmlHttp.readyState==4){
								if(xmlHttp.status ==200){
                                    document.getElementById(id).innerHTML = xmlHttp.responseText;
								}else{
                                    document.getElementById(id).innerHTML = xmlHttp.statusText;
								}
							}
						}
						xmlHttp.send(null);
					},
	asyncLoadCallback: function (url,callback){
						var xmlHttp = this.createXMLHttp();
						if(!xmlHttp||!url) {return;}
						xmlHttp.open("GET",url,true);
						xmlHttp.onreadystatechange = function(){
							if(xmlHttp.readyState==4){
								if(xmlHttp.status ==200){
                                    callback(xmlHttp.responseText);
								}else{
                                    callback(xmlHttp.statusText);
								}
							}
						}
						xmlHttp.send(null);
					}
}


function createXMLHttp(){
	if (window.XMLHttpRequest){
		return new XMLHttpRequest(); // IE7, Firefox, Mozilla, etc.
	} else if (window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP"); // code for IE5, IE6
	} else {
		alert("Your browser does not support XMLHTTP.");
	}
}

function asyncLoad(url,id){
	var xmlHttp = createXMLHttp();
	
	xmlHttp.open("GET",url,true);
  document.getElementById(id).innerHTML = "<div class='loading'>Loading...</div>";
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState==4){
			if(xmlHttp.status ==200){
				document.getElementById(id).innerHTML = xmlHttp.responseText;
			}else{
				document.getElementById(id).innerHTML = xmlHttp.statusText;				
			}
		}
	}
	
	xmlHttp.send(null);
}

function resizeIframe(frameid){
	var currentfr=document.getElementById(frameid);
	if (currentfr && !window.opera){
	  if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight)
		currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
	  else if (currentfr.Document && currentfr.Document.body.scrollHeight)
		currentfr.height = currentfr.Document.body.scrollHeight;
	  if (currentfr.addEventListener)
		currentfr.addEventListener("load", readjustIframe, false);
	  else if (currentfr.attachEvent){
		currentfr.detachEvent("onload", readjustIframe);
		currentfr.attachEvent("onload", readjustIframe);
	  }
	}
}
				
function readjustIframe(loadevt){
	var crossevt=(window.event)? event : loadevt;
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement;
	if (iframeroot)
		resizeIframe(iframeroot.id);
}
