/* <![CDATA[ */

var onLoadChain = "";
var htmlBase = "";
var req;

function loadXMLDoc(url, f) {
    req = false;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch (e) {
            req = false;
        }
        // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                req = false;
            }
        }
    }
    if (req) {
        req.onreadystatechange = f;
        req.open("GET", url, true);
        req.send("");
    }
}

function processQuote() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            var items = req.responseXML.getElementsByTagName("row2");
            document.getElementById("qrow").innerHTML = items[0].firstChild.nodeValue;
        } else {
            alert("There was a problem retrieving the XML data:\n" +
      req.statusText);
        }
    }
}

function showQuote() {
    loadXMLDoc("/custom/quote/quote.aspx?id=6", processQuote);
}


function __doPostBack(eventTarget, eventArgument) {
	var f = document.getElementById("z4");
	f.__EVENTTARGET.value = eventTarget.split("$").join(":");
	f.__EVENTARGUMENT.value = eventArgument;
	f.submit();
}

function getBase() {
	if (!document.getElementsByTagName) return;
	var b = document.getElementsByTagName("base")[0];
	htmlBase = b.getAttribute("href");
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var as = document.getElementsByTagName("a");
	for (var i=0; i < as.length; i++) {
		var a = as[i];
		if (a.getAttribute("href") && a.getAttribute("rel") == "external")
			a.target = "_blank";
	}
}

function zmail(a) {
	var b = "";
	for (var i=0; i < a.length/2; i++) {
		b += String.fromCharCode(parseInt("0x" + a.substring(i*2,i*2+2)));
	}
	location.href = "ma" + "i" + "lto:" + b;
}

function ajaxRequest(type, url, handler, postparams) {
	this.url = url;
	this.xmlhandler = handler;
	this.postparams = postparams;
	this.httpobject = this.getObject();
	if (type == 'GET')
		this.getContent();
	else
		this.postContent();
}

ajaxRequest.prototype.getObject=function() {
	var xmlhttp;
	try {
	  	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		try {
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
	    catch(e) {
    		xmlhttp=null;
    	}
  	}
  	if (!xmlhttp&&typeof XMLHttpRequest!="undefined")
  		xmlhttp=new XMLHttpRequest();
	return xmlhttp;
}

ajaxRequest.prototype.getContent=function(){
	if (this.httpobject) {
		var that = this;
		this.httpobject.onreadystatechange = function(){that.statehandler()};
		this.httpobject.open("GET", this.url, true);
		this.httpobject.send(null);
	}
}
	
ajaxRequest.prototype.postContent=function(){
	if (this.httpobject) {
		var that = this;
		this.httpobject.onreadystatechange = function(){that.statehandler()};
		this.httpobject.open("POST", this.url, true);
		this.httpobject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      	this.httpobject.setRequestHeader("Content-length", this.postparams.length);
      	this.httpobject.setRequestHeader("Connection", "close");
		this.httpobject.send(this.postparams);
	}
}
	
ajaxRequest.prototype.statehandler = function() {
	if (this.httpobject.readyState == 4)
		if (this.httpobject.status == 200)
			this.xmlhandler(this.httpobject.responseXML);
		else
			this.xmlhandler(null);
}

function logInsert(id) {

	var ua = navigator.userAgent.toLowerCase();
	is_ie = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1)
	is_safari = ua.indexOf("safari") != -1
	is_opera = ua.indexOf("opera") != -1
	is_mac = ua.indexOf("mac") != -1

	var e = document.getElementById("LogBox");

	if (is_ie && is_mac) {
		e.innerHTML	= "<img src='public/zebra/log.aspx?id=" + id + "&amp;width=" + screen.width + "&amp;height=" + screen.height + "' style='display: none;' alt='' />";
	} else if (is_ie || is_safari) {
		e.innerHTML	= "<img src='public/zebra/log.aspx?id=" + id + "&amp;width=" + screen.width + "&amp;height=" + screen.height + "' style='display: none;' alt='' />";	
	} else if (is_opera) {
		var p = document.createElementNS("http://www.w3.org/1999/xhtml", "img")
		p.setAttribute("src", "public/zebra/log.aspx?id=" + id + "&width=" + screen.width + "&height=" + screen.height);
		p.style.display = "none";
		e.appendChild(p);
	} else {
		var p = document.createElement("img");
		p.src = "public/zebra/log.aspx?id=" + id + "&width=" + screen.width + "&height=" + screen.height;
		e.appendChild(p);
		p.style.display = "none";
	}
}

window.onload = function() { eval(onLoadChain); } 

onLoadChain += "getBase(); externalLinks();"

/* ]]> */
