function displayDiv(targetDiv,sourceDiv) {
    document.getElementById(targetDiv).innerHTML=document.getElementById(sourceDiv).innerHTML;
}

function showDiv(targetDiv,sourceDiv) {
    document.getElementById(targetDiv).innerHTML=document.getElementById(sourceDiv).innerHTML;
}

function openScript(str) { 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    // var url="submit.asp";
    // url=url+"?q="+str;
    // url=url+"&sid="+Math.random();
    url=str;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChanged() { 
    if (xmlHttp.readyState==4) { 
        document.getElementById("ajax").innerHTML=xmlHttp.responseText;
    }
}

function GetXmlHttpObject() {
    var xmlHttp=null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

var http_request = false;
function makePOSTRequest(url, parameters) {
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
        }
    }
    else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {}
        }
    }
    if (!http_request) {
        alert('Cannot create XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents();
    http_request.open('POST', url, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
}

function alertContents() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            //document.getElementById('myspan').innerHTML = result;
            displayDiv('body','contacts_thankyou');            
        }
        else {
            alert('There was a problem with the request.');
        }
    }
}

function get(obj) {
    var poststr = "mytextarea1=" + escape(encodeURI( document.getElementById("Service1").value )) +
            "&mytextarea2=" + escape(encodeURI( document.getElementById("Service2").value));
    makePOSTRequest('submit.asp', poststr);
}

function content(Id) {
    document.getElementById("content").innerHTML=document.getElementById(Id).innerHTML;
}

function mapValue() {
    mapStr="<iframe width=380 height=312 frameborder=0 scrolling=no marginheight=0 marginwidth=0 src='http://maps.google.com/maps?f=q&hl=en&geocode=&time=&date=&ttype=&q=9000+w.+olive+ave.+peoria+az+85345&sll=37.0625,-95.677068&sspn=34.313287,58.974609&ie=UTF8&ll=33.575798,-112.248774&spn=0.008815,0.014398&z=14&iwloc=addr&om=1&output=embed&s=AARTsJoBPHyilJmGjO_d-wIXPDbeqYnQeg'></iframe><br/><small><a href='http://maps.google.com/maps?f=q&hl=en&geocode=&time=&date=&ttype=&q=9000+w.+olive+ave.+peoria+az+85345&sll=37.0625,-95.677068&sspn=34.313287,58.974609&ie=UTF8&ll=33.575798,-112.248774&spn=0.008815,0.014398&z=14&iwloc=addr&om=1&source=embed' style='color:#0000FF;text-align:left;'>View Larger Map</a></small>";
    document.getElementById("mapFrame").innerHTML=mapStr;
}

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	this.get=Querystring_get;
	
	if (qs == null);
		qs=location.search.substring(1,location.search.length);

	if (qs.length == 0) 
		return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var pair = args[i].split('=');
		var name = unescape(pair[0]);
		
		var value = (pair.length==2)
			? unescape(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

function Querystring_get(key, default_) {
	var value=this.params[key];
	return (value!=null) ? value : default_;
}


function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
