//printfly.com
function loadScript(scriptURL){
	var newScript = document.createElement("script");
	newScript.src = scriptURL;
	document.body.appendChild(newScript);
}


xmlDone = true;
function postFormData(id,URL,form_id){
	var formdata="";
	for(var i=0;i<document.getElementById(form_id).elements.length;i++){
		name =  document.getElementById(form_id).elements[i].name;
		value =  document.getElementById(form_id).elements[i].value;
		if(formdata!=""){
			formdata+="&";
		}
		formdata+=name+"="+value;
	}
	//setContent(id,'formdata='+formdata);
	makeAjaxRequest(id,URL,'POST',formdata);
}
function loadData(id,URL){
	makeAjaxRequest(id,URL,'GET',null);
}
function makeAjaxRequest(id,URL,type,data){
xmlDone; 
xmlReq = null;	
   
                try{
                    xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
                 } catch(e){
                 	try{
                                xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e){
							try{
								xmlReq = new XMLHttpRequest();
								
							} catch(e) {
								
									try{
										xmlReq = window.createRequest();
									}catch(e){
										//alert('no browser found');
										return(0);
									}
							 
							}
					 
   					}
               
        	}             
	//alert("xmlReq"+xmlReq);
	xmlReq.onreadystatechange = function(){	
	    i = xmlReq.readyState;
		//alert("xmlReq.readyState: "+xmlReq.readyState);
		switch(i){
		case 0:	 SetWindowAjaxStatus('Connection: Uninitialized',i);
			break;
		case 1: SetWindowAjaxStatus('Connection: Loading...',i);
			break;
		case 2: SetWindowAjaxStatus('Connection: Loaded',i);
			break;
		case 3: SetWindowAjaxStatus('Connection: Interactive',i);
			break;
		case 4:	SetWindowAjaxStatus('Connection: Done!',i);
			setContent(id,xmlReq.responseText);
            contentLoaded(id,xmlReq.responseText);
			break;
		default: SetWindowAjaxStatus('Connection: Error',i);
			break;
		}
	}

	try{
        xmlReq.open (type, URL, true);
    }catch(e){
	    xmlReq = null;    
    }
    
    if(xmlReq != null) {
		if(type=='POST'){
			xmlReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	
		}
        xmlDone = false;  
		xmlReq.send(data);
        //setTimeout('xmlReq.send(data);',10);
    }
}

function setContent(id,datastr){	
	if((window.document.getElementById(id) != undefined) && (window.document.getElementById(id) != null)){
		window.document.getElementById(id).innerHTML = datastr;
	}
}
function contentLoaded(id,responseText){
	//alert(responseText);
}
function SetWindowAjaxStatus(s,i){
xmlDone;
    if(i != 1 || i != 2 || i != 3){

        xmlDone = true;
        }
}


