/* 
-----------------------------------------------------------------
	CRESA - Good Homes for Good Lives
	CRE.2583
	css_helpers.js
	
	Description: 
 	Contains various CSS helper functions
	
	Created 14.10.2008 by AK
	Last Updated: See SVN	
-----------------------------------------------------------------
*/

/* Apply browser based CSS fixes for certain browsers (eg. Safari) */
function apply_browser_fixes_for_js_dependent_elements() {
	if (
				(whichbrowser.isNS && (whichbrowser.versionMinor == 7.1)) || 
				(whichbrowser.isNS && (whichbrowser.versionMinor == 8.1)) || 					
				(whichbrowser.isFirefox && (whichbrowser.versionMinor == 1))							
			)
	{
		//alert('phoenixed');
		document.body.className += ' phoenix'; /* for JS-enabled CSS fixes of JS-generated text-resizer element */
	}	
	if (
				(whichbrowser.isSafari) // && (!whichbrowser.isChrome)
			)
	{
		//alert('safari');
		document.body.className += ' safari'; /* for JS-enabled CSS fixes of JS-generated text-resizer element */
	}				
}

/* Table helper - applies a 'last' class to the last cell/rows to get around IE or Moz not being able to style table rows */
function tablerowhelper() {
		if (!document.getElementById) return false;
		var tables = document.getElementsByTagName("table"); // get tables
		for (var i=0; i<tables.length; i++) {
			if(!cssjs('check',tables[i],'layout_table')) {	// don't act on layout tables
				var tablerows = tables[i].getElementsByTagName("tr");
				//cssjs('add',tablerows[1],'first');  // add the 'first' class
				cssjs('add',tablerows[tablerows.length-1],'last');  // add the 'last' class
				for (var ii=0; ii<tablerows.length; ii++) { // get rows
					var tableheaders = tablerows[ii].getElementsByTagName("th");
					for (var iii=0; iii<tableheaders.length; iii++) {
						cssjs('add',tableheaders[tableheaders.length-1],'last');  // add the 'last' class
						cssjs('add',tableheaders[0],'first');  // add the 'first' class
					}
					var tablecells = tablerows[ii].getElementsByTagName("td");
					for (var iii=0; iii<tablecells.length; iii++) {
						cssjs('add',tablecells[tablecells.length-1],'last');  // add the 'last' class
						cssjs('add',tablecells[0],'first');  // add the 'first' class
					}
				}
			}
		}
}
