util = new Object();
util.addEventListener = function(target_element, event_name, func) {
if (document.addEventListener) {
	$(target_element).addEventListener(event_name, func, true);
} else {
$(target_element).attachEvent("on" + event_name, func);
}
return func;
};
function l(str, val) {
alert(str + ": " + val);
}
function highlightNav() {
}
util.elementReport = function(t) {
var report     = "element id: " +t.id+ "<br />\n";
report        += "CSS:<br />" +t.style.cssText+ ":<br />\n";
var dims       = Element.getDimensions(t);
var offset     = Position.realOffset(t);
var cum_offset = Position.cumulativeOffset(t);
var pos_offset = Position.positionedOffset(t);
report        += "POSITIONING: ==============<br />";
report        += "width: " +dims.width+ " height: " +dims.height+ "<br />\n";
report        += "offsets: " +offset[0]+ " " +offset[1]+ "<br />\n";
report        += "cum offsets: " +cum_offset[0]+ " " +cum_offset[1]+ "<br />\n";
report        += "positioned offsets: " +pos_offset[0]+ " " +pos_offset[1]+ "\n";
return report;
};
function getCursorPosition(ev) {
e = ev || window.event;
var cursor = {x:0, y:0};
if (e.pageX || e.pageY) {
cursor.x = e.pageX;
cursor.y = e.pageY;
} 
else {
var ms_offset_left = 2;
var ms_offset_top = 2;
var de = document.documentElement;
var b = document.body;
cursor.x = e.clientX  + (de.scrollLeft || b.scrollLeft) - (b.clientLeft || 0);
cursor.y = e.clientY  + (de.scrollTop || b.scrollTop) - (b.clientTop || 0);
}
return cursor;
}
util.getCursorPosition = getCursorPosition;
function readCookie(name_string) {
var allcookies = document.cookie;
var pos = allcookies.indexOf(name_string + '=');
if (pos != -1) {
var start = pos + name_string.length + 1;
var end = allcookies.indexOf(";", start);
if (end == -1) { end = allcookies.length; }
var value = allcookies.substring(start, end);
return decodeURIComponent(value);
}
return false;
}
function readParam(name_string) {
var pattern = new RegExp("[\?\&]" +name_string+ "=([^\&]+)");
if (pattern.exec(document.location)) {
var results = pattern.exec(document.location);
return results[1];
}
return false;
}
function writeCookie(name_string, val) {
document.cookie = name_string + "=" + encodeURIComponent(val) + "; path=/";
}
util.addEventListener = function(target_element, event_name, func) {
if (document.addEventListener) {
	$(target_element).addEventListener(event_name, func, true);
} else {
$(target_element).attachEvent("on" + event_name, func);
}
};
util.loadJsonResponse = function(ajax_url, targetObjAccessor, nextFunction) {
getJsonResponse(ajax_url, function(request) {
val = targetObjAccessor(request);
nextFunction(val);
});
};
util.setUpScrollingText = function(container_div, html) {
var container_id = $(container_div).id;
var setUpDiv = function(cls) {
var new_div = document.createElement('div');
new_div.id  = container_id + '_' + cls;
Element.addClassName(new_div, cls);
return new_div;
}
var hold_div = setUpDiv('hold');
var wn_div   = setUpDiv('wn');
var lyr1_div = setUpDiv('lyr');
lyr1_div.innerHTML = '<p>' + html + '</p>';
var up_div   = setUpDiv('up_control');
up_div.innerHTML   = '<img src="/images/button/arrow_up.gif" width="11" height="12" alt="up" />';
var down_div = setUpDiv('down_control');
down_div.innerHTML = '<img src="/images/button/arrow_down.gif" width="11" height="12" alt="down" />';
wn_div.appendChild(lyr1_div);
hold_div.appendChild(wn_div);
hold_div.appendChild(up_div);
hold_div.appendChild(down_div);
container_div.innerHTML = '';
container_div.appendChild(hold_div);
initScrollLayer(wn_div.id, lyr1_div.id, up_div.id, down_div.id);
}
util.getImageDims = function(img_src) {
var ajax_url = "/data/imagedims.php?src=" + img_src;
var image_dims;
var callback = function(request) {
image_dims = eval('(' +request.responseText+ ')');
};
new Ajax.Request(ajax_url, {
method: 'get',
onComplete: callback,
asynchronous: false});
return $H(image_dims);
}
util.popup = function(img_src, caption) {
var image_dims = this.getImageDims(img_src);
if (!(image_dims["width"] && image_dims["height"])) {
image_dims["width"] = 500;
image_dims["height"] = 500;
}
var title = "Blindspot.com: " +caption;
var content = '<img src ="http://blindspot.com' +img_src+ '" alt="Popup image of ' +caption+ '" />';
content  += '<p>' + caption+ '</p>';
if (!(this.popup_counter)) {
this.popup_counter = 1;
} else {
this.popup_counter++;
}
var popup_dim_str = "height=" + (100 + parseInt(image_dims["height"])) +
",width=" + (50 + parseInt(image_dims["width"]));
var popup = window.open('',this.popup_counter,popup_dim_str);
popup_doc = popup.document;
popup_doc.open();
popup_doc.writeln("<html><head><title>" + title + "</title>");
popup_doc.writeln('<link rel="stylesheet" type="text/css" href="/css/global.css" />');
popup_doc.writeln('<link rel="stylesheet" type="text/css" href="/css/popup.css" />');
popup_doc.writeln("</head>");
popup_doc.writeln('<body>\n<div style="width:' +image_dims["width"]+ 'px">\n' + content + '\n</div>\n</body>');
popup_doc.close();
}
util.isEmptyField = function(str) {
if (this.strValueFor(str) && str.search(/\<!--/) == -1) {
return false;
}
return true;
};
util.readCookie = function(name_string) {
var allcookies = document.cookie;
var pos = allcookies.indexOf(name_string + '=');
if (pos != -1) {
var start = pos + name_string.length + 1;
var end = allcookies.indexOf(";", start);
if (end == -1) { end = allcookies.length; }
var value = allcookies.substring(start, end);
return decodeURIComponent(value);
}
return null;
}
util.readDsDiv = function(class_name, div) {
read_div = document.getElementsByClassName(class_name, div)[0]
if (read_div != undefined && read_div != null) {
var str = this.rmlines(this.rmbreaks(read_div.innerHTML));
return (this.isEmptyField(str)) ? "" : str;
}
return null;
}
util.rmbreaks = function(astring) {
astring = this.rmlines(astring);
astring = astring.replace(/^<br[^\>]*\>/i, '');
astring = astring.replace(/<br[^\>]*\>$/i, '');
return astring;
}
util.rmlines = function(astring) {
astring = astring.replace(/^\s+/, '');
astring = astring.replace(/\s+$/, '');
return astring;
}
util.splitOnce = function(astring, sep) {
var sep_index = astring.indexOf(sep);
return [astring.substring(0,sep_index), 
astring.substring(sep_index+1, astring.length)];
}
util.strValueFor = function(str_var) {
return (str_var != undefined && str_var != null && str_var != "");	
};
util.rmhtml = function(astring) {return astring.replace(/<\w[^\>]*\>/i, ' ');};