var xmlHttp
var theObj
var toRefresh
var theWindow

function showpage(TheUrl, extra, sObj, RefreshObject)
{
theObj = sObj
toRefresh = RefreshObject

if (TheUrl.length==0)
{ 
document.getElementById(theObj).innerHTML=""
return
}

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url=TheUrl
url=url+extra
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url+ "&ms=" + new Date().getTime(),true)
xmlHttp.send(null)
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	document.getElementById(theObj).innerHTML=xmlHttp.responseText 	
	xmlHttp = null
	if (toRefresh.length > 0) {
		refreshObject(toRefresh)
	}
	document.getElementById("theComment").innerHTML=""
} 
else
{
	document.getElementById("theComment").innerHTML="<font style='padding:2px;background:red' color=white>Loading...<\/font>"
}
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 

function createStringFromForm(docForm) {

  var strSubmitContent = '';
  var formElem;
  var strLastElemName = '';

  for (i = 0; i < docForm.elements.length; i++) {

    formElem = docForm.elements[i];
    switch (formElem.type) {
      case 'text':
      case 'hidden':
      case 'password':
      case 'textarea':
      case 'select-one':
        strSubmitContent += formElem.name + '=' + escape(formElem.value) + '&'
        break;
      case 'radio':
        if (formElem.checked) {
          strSubmitContent += formElem.name + '=' + escape(formElem.value) + '&'
        }
        break;
      case 'checkbox':
        if (formElem.checked) {
          if (formElem.name == strLastElemName) {
            if (strSubmitContent.lastIndexOf('&') == strSubmitContent.length-1) {
              strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
            }
            strSubmitContent += ',' + escape(formElem.value);
          }
          else {
            strSubmitContent += formElem.name + '=' + escape(formElem.value);
          }
          strSubmitContent += '&';
        }
        break;

    }
    strLastElemName = formElem.name;
  }
  strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
  return strSubmitContent;
}

function AjaxViewChartsFormSubmit(encoded_data, url, sav_id, form, objT)
{
	var ids;
	ids = selectedPropids(objT);
	
	document.getElementById(sav_id).innerHTML="";	
  
	var xmlreq = GetXmlHttpObject();
	xmlreq.open("GET", url + encoded_data + ids, true);
	xmlreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlreq.send(null);
	 xmlreq.onreadystatechange = function () {
	if(xmlreq.readyState==4)
		{
			document.getElementById(sav_id).innerHTML=xmlreq.responseText;
	}
  }

}

   function selectedPropids(objTargetElement)
   {
	 var tmpStr;
	 tmpStr = "";
     for (var i = 0; i < objTargetElement.length; i++) {
	  tmpStr = tmpStr + objTargetElement.options[i].value + ",";
     }  
 
     return "&property_id=" + String(tmpStr).substring(0,tmpStr.length-1);
	 
   }	 
	 
	 



function doAjaxFormSubmit(encoded_data, url, sav_id, form)
{
	document.getElementById(sav_id).innerHTML="";
	  
	var xmlreq = GetXmlHttpObject();

	xmlreq.open("GET", url + encoded_data, true);
	xmlreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlreq.send(null);
	 xmlreq.onreadystatechange = function () {
	if(xmlreq.readyState==4)
		{
			document.getElementById(sav_id).innerHTML=xmlreq.responseText;
	}
  }

}

function AddtoSelection(objTarget, theName, theValue)
{ 	
    var intTargetLen = objTarget.length++;

    objTarget.options[intTargetLen].text = theName;
    objTarget.options[intTargetLen].value = theValue;
}
//Add to selection


function CopyOption(objTarget, theName, theValue)
{ 	
    var intTargetLen = objTarget.length++;
    var aryTempTargetOptions = new Array();
    var x = 0;
	
    objTarget.options[intTargetLen].text = theName;
    objTarget.options[intTargetLen].value = theValue;
}
 <!--
   function MoveOption(objSourceElement, objTargetElement)
     {
   var aryTempSourceOptions = new Array();
   var aryTempTargetOptions = new Array();
   var x = 0;
   
   //looping through source element to find selected options
   for (var i = 0; i < objSourceElement.length; i++) {
    if (objSourceElement.options[i].selected) {
     //need to move this option to target element
     var intTargetLen = objTargetElement.length++;
     objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
     objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
    }
    else {
     //storing options that stay to recreate select element
     var objTempValues = new Object();
     objTempValues.text = objSourceElement.options[i].text;
     objTempValues.value = objSourceElement.options[i].value;
     aryTempSourceOptions[x] = objTempValues;
     x++;
    }
   }

   //sorting and refilling target list
   for (var i = 0; i < objTargetElement.length; i++) {
    var objTempValues = new Object();
    objTempValues.text = objTargetElement.options[i].text;
    objTempValues.value = objTargetElement.options[i].value;
    aryTempTargetOptions[i] = objTempValues;
   }

   //aryTempTargetOptions.sort(sortByText);

   for (var i = 0; i < objTargetElement.length; i++) {
    objTargetElement.options[i].text = aryTempTargetOptions[i].text;
    objTargetElement.options[i].value = aryTempTargetOptions[i].value;
    objTargetElement.options[i].selected = false;
   }
   
   //resetting length of source
   objSourceElement.length = aryTempSourceOptions.length;
   //looping through temp array to recreate source select element
   for (var i = 0; i < aryTempSourceOptions.length; i++) {
    objSourceElement.options[i].text = aryTempSourceOptions[i].text;
    objSourceElement.options[i].value = aryTempSourceOptions[i].value;
    objSourceElement.options[i].selected = false;
   }
     }

  function selectAll(objTargetElement)
     {
   for (var i = 0; i < objTargetElement.length; i++) {
    objTargetElement.options[i].selected = true;
   }
   return false;
  }

	
function showhide(id){
  if (document.getElementById){
	obj = document.getElementById(id);
	if (obj.style.display == "none"){
	obj.style.display = "";
  } else {
obj.style.display = "none";
}
}
}

function showhideSet(id, themode){
if (document.getElementById)
{
	obj = document.getElementById(id);
	if (obj != null) {
	if (themode == "hide") 
	{
		if (obj.style.display != "none")
		{
			obj.style.display = "none";
		}
	}
	if (themode == "show") 
	{
		if (obj.style.display != "")
		{
			obj.style.display = "";
		}	
	}
	}
}
}


function AddEffectEvents() {
    var attributes1 = {
		height: { to: 9 }
    };
	var attributes2 = {
		height: { to: 150 }	
    };
    var anim1 = new YAHOO.util.Anim('thesearchdiv', attributes1, 0.5, YAHOO.util.Easing.easeIn);
	var anim2 = new YAHOO.util.Anim('thesearchdiv', attributes2, 0.5, YAHOO.util.Easing.easeOut);

    YAHOO.util.Event.on('HideSearch', 'click', function() {
        anim1.animate();		
    });
	YAHOO.util.Event.on('AmendSearch', 'click', function() {
        anim2.animate();
    });
}

function refreshObjectwithEvents(theObject,theEvents)
{
	var thePage = document.getElementById(theObject + "_refresh");
	var theUrl = thePage.href;
	
	//alert(thePage.href);
		
		var handleFailure = function(o){
			if(o.responseText !== undefined){
				document.getElementById(theObject).innerHTML = "<li>Transaction id: " + o.tId + "</li>";
				document.getElementById(theObject).innerHTML += "<li>HTTP status: " + o.status + "</li>";
				document.getElementById(theObject).innerHTML += "<li>Status code message: " + o.statusText + "</li>";
			}
		}
		var callback=			
		{
		  success: function(o){				
			document.getElementById(theObject).innerHTML = o.responseText;
			eval(theEvents);
		  },
		  failure:handleFailure
		};		
		
	var request = YAHOO.util.Connect.asyncRequest('GET', theUrl + "&ms=" + new Date().getTime(), callback);								
	
}
		
function refreshObject(theObject)
{
	var thePage = document.getElementById(theObject + "_refresh");
	var theUrl = thePage.href;
	
	//alert(thePage.href);
		
		var handleFailure = function(o){
			if(o.responseText !== undefined){
				document.getElementById(theObject).innerHTML = "<li>Transaction id: " + o.tId + "</li>";
				document.getElementById(theObject).innerHTML += "<li>HTTP status: " + o.status + "</li>";
				document.getElementById(theObject).innerHTML += "<li>Status code message: " + o.statusText + "</li>";
			}
		}
		var callback=			
		{
		  success: function(o){				
			document.getElementById(theObject).innerHTML = o.responseText;
		  },
		  failure:handleFailure
		};		
		
	var request = YAHOO.util.Connect.asyncRequest('GET', theUrl + "&ms=" + new Date().getTime(), callback);								

}

function refreshObjects(theObject)
{
	var thePage = document.getElementById(theObject + "_refresh");
	var theUrl = thePage.href;
	
	//alert(thePage.href);
		
		var handleFailure = function(o){
			if(o.responseText !== undefined){
				document.getElementById(theObject).innerHTML = "<li>Transaction id: " + o.tId + "</li>";
				document.getElementById(theObject).innerHTML += "<li>HTTP status: " + o.status + "</li>";
				document.getElementById(theObject).innerHTML += "<li>Status code message: " + o.statusText + "</li>";
			}
		}
		var callback=			
		{
		  success: function(o){				
			var collection = document.getElementsByName(theObject);
			for (var i = 0; i < collection.length; i++){
				collection[i].innerHTML = o.responseText;
			}
		  },
		  failure:handleFailure
		};		
		
	var request = YAHOO.util.Connect.asyncRequest('GET', theUrl  + "&ms=" + new Date().getTime(), callback);								

}


function refreshOpenerObject(theObject)
{
	var thePage = window.opener.document.getElementById(theObject + "_refresh");
	var theUrl = thePage.href;
		
		var handleFailure = function(o){
			if(o.responseText !== undefined){
				window.opener.document.getElementById(theObject).innerHTML = "<li>Transaction id: " + o.tId + "</li>";
				window.opener.document.getElementById(theObject).innerHTML += "<li>HTTP status: " + o.status + "</li>";
				window.opener.document.getElementById(theObject).innerHTML += "<li>Status code message: " + o.statusText + "</li>";
			}
		}
		var callback=			
		{
		  success: function(o){				
			window.opener.document.getElementById(theObject).innerHTML = o.responseText;
			while (o.status != 200){
				//alert(o.status);
			}
			//window.close();
		  },
		  failure:handleFailure
		};		
		
		
		
	var request = window.opener.YAHOO.util.Connect.asyncRequest('GET', theUrl + "&ms=" + new Date().getTime(), callback);								

}


function refreshScreen(theObjects){
	var theArray = theObjects.split(" ");
	var thePage = new Array();
	var theObject = new Array();
	var responses = new Array();
	var requests = new Array();
	var x, y;
	y=0;		

	for (x in theArray){		
		//alert(theArray[x])
		thePage[x] = document.getElementById(theArray[x] + "_refresh");			
		
		var handleFailure = function(o){
			if(o.responseText !== undefined){
				theObject[x].innerHTML = "<li>Transaction id: " + o.tId + "</li>";
				theObject[x].innerHTML += "<li>HTTP status: " + o.status + "</li>";
				theObject[x].innerHTML += "<li>Status code message: " + o.statusText + "</li>";
			}
		}
		var callback=			
		{
		  success: function(o){				
			document.getElementById(theArray[y]).innerHTML = o.responseText;
			//alert(y)
			//responses[y] = o.responseText;
			y = y+1;

		  },
		  failure:handleFailure
		};
		
		var request = YAHOO.util.Connect.asyncRequest('GET', thePage[x].href, callback);				
	}			

}
 
 
 function ReadForm(ObjtoRefresh, thediv, Action, theDialog) {
	
	// Define various event handlers for Dialog
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
		var response = o.responseText;
		response = response.split("<!")[0];
		document.getElementById("theComment").innerHTML = response;		
		for (var i=0; i<10; i++) {
			if (ObjtoRefresh.split(",")[i] != undefined) {
			//alert(ObjtoRefresh.split(",")[i])
			refreshObject(ObjtoRefresh.split(",")[i]);
			} 
		}
		//eval(response);
	};
	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};

	// Instantiate the Dialog
	thediv = new YAHOO.widget.Dialog(theDialog, 
								{ width : "470px",
								  fixedcenter : true,
								  draggable: true, 
								  visible : true, 
								  constraintoviewport : true,
								  buttons : [ { text:"", handler:handleCancel } ]
								 } );
	
	// Validate the entries in the form to require that both first and last name are entered
	//YAHOO.example.container.dialog1.validate = function() {
	//	var data = this.getData();
	//	if (data.firstname == "" || data.lastname == "") {
	//		alert("Please enter your first and last names.");
	//		return false;
	//	} else {
	//		return true;
	//	}
	//};

	// Wire up the success and failure handlers
	thediv.callback = { success: handleSuccess,
						failure: handleFailure };
	
	// Render the Dialog
	thediv.render();

//					YAHOO.util.Event.addListener("show", "click", thediv.show, thediv, true);
//					YAHOO.util.Event.addListener("hide", "click", thediv.hide, thediv, true);
}

//YAHOO.util.Event.addListener(window, "load", ReadForm);

function ReadFormInOtherFrame(ObjtoRefresh, thediv, Action, theDialog, otherFrameName) {
	

	// Define various event handlers for Dialog
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
		var response = o.responseText;
		response = response.split("<!")[0];
		document.getElementById("theComment").innerHTML = response;		
		for (var i=0; i<10; i++) {
			if (ObjtoRefresh.split(",")[i] != undefined) {
			//alert(ObjtoRefresh.split(",")[i])
			refreshObject(ObjtoRefresh.split(",")[i]);
			} 
		}
		//eval(response);
	};
	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};

	// Instantiate the Dialog
	thediv = new YAHOO.widget.Dialog('parent.' + otherFrameName.name + '.'+ theDialog, 
								{ width : "470px",
								  fixedcenter : true,
								  visible : true, 
								  constraintoviewport : true,
								  buttons : [ { text:"", handler:handleCancel } ]
								 } );
	
	// Validate the entries in the form to require that both first and last name are entered
	//YAHOO.example.container.dialog1.validate = function() {
	//	var data = this.getData();
	//	if (data.firstname == "" || data.lastname == "") {
	//		alert("Please enter your first and last names.");
	//		return false;
	//	} else {
	//		return true;
	//	}
	//};

	// Wire up the success and failure handlers
	thediv.callback = { success: handleSuccess,
						failure: handleFailure };
	
	// Render the Dialog
	thediv.render();

//					YAHOO.util.Event.addListener("show", "click", thediv.show, thediv, true);
//					YAHOO.util.Event.addListener("hide", "click", thediv.hide, thediv, true);
}


function openFormDialog(theDialog, toRefresh, theUrl, Action) {

	var div = document.getElementById(theDialog);

	var handleSuccess = function(o){
		if(o.responseText !== undefined){
			div.innerHTML = o.responseText;
			ReadForm(toRefresh, div, Action, theDialog);
		}
	}
	
	var handleFailure = function(o){
		if(o.responseText !== undefined){
			div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
			div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
			div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
		}
	}

	var callback =
	{
	  success:handleSuccess,
	  failure:handleFailure,
	  argument: { foo:"foo", bar:"bar" }
	};

	var sUrl = theUrl + "&ajax=yes";
	
					
	var therequest = YAHOO.util.Connect.asyncRequest('GET', sUrl  + "&ms=" + new Date().getTime(), callback);
}

function openFormDialogInOtherFrame (theDialog, otherFrameName, toRefresh, theUrl, Action) {

	var div = otherFrameName.document.getElementById(theDialog);

	var handleSuccess = function(o){
		if(o.responseText !== undefined){
			div.innerHTML = o.responseText;
			ReadFormInOtherFrame(toRefresh, div, Action, theDialog, otherFrameName);
		}
	}
	
	var handleFailure = function(o){
		if(o.responseText !== undefined){
			div.innerHTML = "<li>Transaction id: " + o.tId + "</li>"
			div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
			div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
		}
	}

	var callback =
	{
	  success:handleSuccess,
	  failure:handleFailure,
	  argument: { foo:"foo", bar:"bar" }
	};

	var sUrl = theUrl + "&ajax=yes";
	
					
	var therequest = YAHOO.util.Connect.asyncRequest('GET', sUrl + "&ms=" + new Date().getTime(), callback);
}

 