GC = new Object();
GC.onLoadFunctions = new Array();

GC.onLoad = function() {
	for (var i = 0; i < GC.onLoadFunctions.length; i++) {
		var func = GC.onLoadFunctions[i];
		func();
	}
};

GC.addOnLoad = function(func) {
	GC.onLoadFunctions.push(func);
};

GC.addOnLoadFocus = function(aFormID, aElemID) {
	var func = function() {
		var form = document.getElementById(func.formID);
		if (!form) {
			//alert('error - no form with id ' + func.formID);
			return;
		}
		var elem = eval('form.' + func.elemID);
		if (!elem) {
			//alert('error - no element on form ' + func.formID + ' with ID ' + func.elemID);
			return;
		}
		elem.focus();
	};
	func.formID = aFormID;
	func.elemID = aElemID;
	GC.addOnLoad(func);
};

GC.openTutorialWindow = function(tutName) {
	window.open('/tutorials/' + tutName, 'tutorialwindow', 'width=700,height=550,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
	// return false so that the link does not use the HREF to open - since we already have
	return false;
}

GC.prettyPrint = function(obj, indent) {
	var result = "";
	if (indent == null) indent = "";
	
	for (var property in obj) {
		var value = obj[property];
		if (typeof value == 'string') {
			value = "'" + value + "'";
		} else if (typeof value == 'object') {
			if (value instanceof Array) {
				// Just let JS convert the Array to a string!
				value = "[ " + value + " ]";
      		} else {
				// Recursive dump
				// (replace "  " by "\t" or something else if you prefer)
				var od = DumpObjectIndented(value, indent + "  ");
				// If you like { on the same line as the key
				//value = "{\n" + od + "\n" + indent + "}";
				// If you prefer { and } to be aligned
				value = "\n" + indent + "{\n" + od + "\n" + indent + "}";
			}
		}
		result += indent + "'" + property + "' : " + value + ",\n";
	}
	return result.replace(/,\n$/, "");
}

// had to use jQuery here because sfProtocolous uses protocol.js, which must override $
jQuery(document).ready(function(){
	jQuery(".openModalWindow").colorbox({
		width: '776px',
		height: '80%'
	});	
});

init_row_clickables = function(){
	// clickable rows on tables
	if( !$('.row_clickable') ) return;
	$('.row_clickable.hide_link tbody tr td:first-child, '+
	  '.row_clickable.hide_link tbody tr th:first-child').hide();
	$('.row_clickable tr').hover(function(){
		$(this).toggleClass('highlight');
	});
	$('.row_clickable tbody tr').click(function(e){
		if(e.originalTarget && e.originalTarget.nodeName != "A"){
			location.href = $(this).find('td a').attr('href');
		}
	});
};
$(function(){
	init_row_clickables();
});
  
