var req;
var XMLResultElementId = '';
var XMLEditBoxId       = '';
var redirectLocation   = '';

try {
	req = new XMLHttpRequest();
} catch (trymicrosoft) {
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (othermicrosoft) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
			req = false;
		}
	}
}

function quicklink_toggle(tag,toggle)
{
	loadXMLDoc('/tag/link/' + tag + '/' + toggle,'','quicklink');
	setTimeout("loadXMLDoc('/tag/echo_links','','quicktags_list');",1000);
	if (element('quicktags_list').style.display='none')
	{
		element('quicktags_list').style.display='block';
	} 

	return null;
}

function loadPreview(id)
{
	loadXMLDoc('http://rebuildphoto.com/photos/location_ajax/' + id,'','rollover_info_div');
}


function processReqChangeGET() {
 	// only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status) {
			if (req.status == 200) {
				// ...processing statements go here...
	//			alert(XMLResultElementId);
				var result_element = document.getElementById(XMLResultElementId);
				result_element.innerHTML = req.responseText;
	//            alert(req.responseText);
			 } else {
				alert("There was a problem retrieving the XML data:\n" +
					req.statusText);
			}
		}
    }
    return null;
}


function loadXMLDoc(url,postData,resultElementId,processingEngine) {
	if (!processingEngine) processingEngine = 'processReqChangeGET';
	XMLResultElementId=resultElementId;

	if (postData)
	{
		var method      = 'POST';
		var contentType = 'application/x-www-form-urlencoded';
	}
	else
	{
		var method      = 'GET';
		var contentType = 'text/html';
	}

	if (req) {
		eval("req.onreadystatechange = " + processingEngine + ";");
		req.open(method, url, true);
		req.setRequestHeader('Content-Type', contentType);
		req.send(postData);
	}
}