window.onload = initialize;

	location.querystring = (function() {

    // The return is a collection of key/value pairs

    var queryStringDictionary = {};

    // Gets the query string, starts with '?'

    var querystring = decodeURI(location.search);

    // document.location.search is empty if no query string

    if (!querystring) {
        return {};
    }

    // Remove the '?' via substring(1)

    querystring = querystring.substring(1);

    // '&' seperates key/value pairs

    var pairs = querystring.split("&");

    // Load the key/values of the return collection

    for (var i = 0; i < pairs.length; i++) {
        var keyValuePair = pairs[i].split("=");
        queryStringDictionary[keyValuePair[0]]
                = keyValuePair[1];
    }

    // toString() returns the key/value pairs concatenated

    queryStringDictionary.toString = function() {

        if (queryStringDictionary.length == 0) {
            return "";
        }

        var toString = "?";

        for (var key in queryStringDictionary) {
            toString += key + "=" +
                queryStringDictionary[key];
        }

        return toString;
    };

    // Return the key/value dictionary

    return queryStringDictionary;
})();

function initialize(){
	popWindow();
	highlight();
}

function popWindow(){
	if (!document.getElementsByTagName) return false;
	links = document.getElementsByTagName("a");
	for(i=0; i<links.length; i++){
		anchor = links[i];
		if(anchor.getAttribute("rel") == "external"){
			anchor.onclick = function(){
				var targetUrl = this.href;
				 window.open(targetUrl,'popup','resizable=1, scrollbars=1 toolbar=1, width=800,height=600');
				return false;	
			}
		}
		else if(anchor.className == "print"){
			anchor.onclick = function(){
				window.print();
				return false;	
			}
		}
		else if(anchor.className == "pin"){
			anchor.onclick = function(){
				var targetUrl = this.href;
				 window.open(targetUrl,'popup','width=400,height=320');
				return false;	
			}
		}
		
		else if(anchor.className == "back"){
			anchor.onclick = function(){
				var targetUrl = this.href;
				 history.back(0);
				return false;	
			}
		}
	}
}

function highlight(){
	if(!document.getElementsByTagName) return false;
	tables = document.getElementsByTagName("table");
	for(var j=0; j<tables.length; j++){
		if((tables[j].className == "adminTable") || (tables[j].className =="quoteTable")){
		var rows = tables[j].getElementsByTagName("tr");
		for(var i=0; i<rows.length; i++){
			var currColor;
			var textColor;
			rows[i].onmouseover = function(){
				currColor = this.style.backgroundColor;
				textColor = this.style.color;
				this.style.backgroundColor = "#FFF6DF";
				this.style.color = "#000000";
			}//end of mouseover
			rows[i].onmouseout = function(){
				this.style.backgroundColor = currColor;
				this.style.color = textColor;
			}//end of mouseout
		}//end of i loop
	  }
	}
}