var DHTML = (document.getElementById || document.all || document.layers);

// for AJAX, contains the ID of the element that had focus before the AJAX called happed
// use OnFocus="ajax_id_with_focus = this;" or OnFocus="ajax_id_with_focus = null;"
// this will set the focus back to that element
// Note for items outside the AJAX div (mainly drop down boxes), ajax_id_with_focus should be set to null
// so the focus isn't changed after AJAX returns
var ajax_id_with_focus = null; 

// Returns the object identified by name
function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
	} else if (document.all)  {
		this.obj = document.all[name];
	} else if (document.layers)  {
		this.obj = document.layers[name];
	}
	return this.obj;
}

// returns true if the object identified by name exists
function objExist(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
	} else if (document.all)  {
		this.obj = document.all[name];
	} else if (document.layers)  {
		this.obj = document.layers[name];
	}
	if(this.obj) 
		return true;
	else 
		return false;
}

// hides or shows the object (does not have to be a div tag) identified by hideThis)
// dspState should be "inline" or "none"
// If dspState is not passed, then the visibily is toggeled between inline and none
function divDsp(hideThis,dspState)
{
	if (!DHTML) return;
	var x = new getObj(hideThis);
	x.style.display = (dspState)? (dspState=='inline'?'':dspState) : (x.style.display=='inline'||x.style.display=='') ? 'none' : '';
}

// hides or shows the object (does not have to be a div tag) identified by hideThis)
// dspState should be "inline" or "none"
// If dspState is not passed, then the visibily is toggeled between inline and none
function divVis(hideThis,dspState)
{
	if (!DHTML) return;
	if(dspState=='inline')	dspState="visible";
	if(dspState=='none')	dspState="hidden";
	var x = new getObj(hideThis);
	x.style.visibility = (dspState)? dspState : (x.style.visibility=='visible' || x.style.visibility=='') ? 'hidden' : 'visible';
}

//Additional String Functions:
/*
	Adds padding to the string
	l: length
	s: the pad string
	t: pad flag (0=left pad, 1=right pad,2=both)
	example:
		"testing".pad(10, "[]", 0);		// [][testing
		"testing".pad(10, "[====]", 1);	// testing[==
		"testing".pad(10, "~", 2);		// ~~testing~ 
*/
String.prototype.pad = function(l, s, t){
	return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
		+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
		+ this + s.substr(0, l - t) : this;
};

//get the left n characters from the string i.e. "testing".left(4); // test
String.prototype.left =function (n){
	if (n <= 0)
	    return "";
	else if (n > this.length)
	    return this;
	else
	    return this.substring(0,n);
};
//get the right n characters from the string i.e. "testing".right(3); // ing
String.prototype.right=function (n){
    if (n <= 0)
       return "";
    else if (n > this.length)
       return this;
    else {
       var iLen = this.length;
       return this.substring(iLen, iLen - n);
    }
}
//Trim spaces off the front and back of a string
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
String.prototype.ltrim = String.prototype.lTrim = function() { return this.replace(/^\s+/, ''); };
String.prototype.rtrim = String.prototype.rTrim = function() { return this.replace(/\s+$/, ''); };


// Make a new window popup
// href: the url the window should go to
// width: the width of the popup window
// height: the height of the popup window
// win_name (optional) the name of the new window (like <a href="url" target="name">)
function popup(href,width,height,win_name) {
	
	    if (!win_name) win_name = 'none';
	    var window_features = "height="+height+",width="+width+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,dependent=1,top=100,left=100";
	    
		var win = window.open(href,win_name,window_features);
		
		if(win) {win.focus();}
		return false;
}

// select every option in a select box (when the multiple flag is used in the select box)
// selectBox: the id/name of the Select Box
function selectAll(selectBox){
	for(var i=0;i<selectBox.options.length;i++){
		selectBox.options[i].selected = true;
	}
	return;
}

// unselect every option in a select box (when the multiple flag is used in the select box)
// selectBox: the id/name of the Select Box
function unSelectAll(selectBox){
	for(var i=0;i<selectBox.options.length;i++){
		selectBox.options[i].selected = false;
	}
	return;
}

// check every checkBox/radio button named checkBoxes
// checkBoxes: the id/name of the Select Box checkBoxs/radio buttons
function checkAll(checkBoxes){
	for(var i=0;i<checkBoxes.length;i++){
		checkBoxes[i].checked = true;
	}
	return;
}

// unselect every checkBox/radio button named checkBoxes
// checkBoxes: the id/name of the Select Box checkBoxs/radio buttons
function uncheckAll(checkBoxes){
	for(var i=0;i<checkBoxes.length;i++){
		checkBoxes[i].checked = false;
	}
	return;
}

// sets the value of the form element passed to only numbers, (and returns the value also)
function numOnly(el) {
	var tmp 	= el.value.replace(/[^0-9.]/g,'');
	var argv 	= numOnly.arguments;
	if (argv.length==2) {
		if(tmp.length >= argv[1]) {
			el.form[(getIndex(el)+1) % el.form.length].focus();
		}
	}
	return el.value=tmp;
}

//Returns the form index of the form element passed in (input)
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1){
		if (input.form[i] == input)		index = i;
		else 							i++;
	} 
	return index;
}


function Highlight(j,color) {
	if(!color) color 	= "#FFF8CB";
	var n 				= null;
	if (j.parentNode && j.parentNode.parentNode) {
		if (j.parentNode.parentNode.nodeName == 'TD') {
			n = j.parentNode.parentNode.parentNode;			
		} else {
			n = j.parentNode.parentNode;
		}
		//alert(n.nodeName);
	}
	else if (j.parentElement && j.parentElement.parentElement) {
		n = j.parentElement.parentElement;
	}
	if (n) {
		n.style.backgroundColor = color; //if (n.className == "row-color") {  } //E3F1FF //C1DDF2 //F4F6D3
	}
}

function Unhighlight(j) {
    var n = null;
	if (j.parentNode && j.parentNode.parentNode) {
		if (j.parentNode.parentNode.nodeName == 'TD' ) {
			n = j.parentNode.parentNode.parentNode;			
		} else {
			n = j.parentNode.parentNode;
		}		
	}
	else if (j.parentElement && j.parentElement.parentElement) {
		n = j.parentElement.parentElement;
	}
	if (n) {
		n.style.backgroundColor=n.getAttribute('bgcolor'); //if (n.className == "row-color") {  }
	}
}

function CheckRow(j,color) {
	if (j.checked) {
	    Highlight(j,color);
	} else {
	    Highlight(j,"#ffffff");
	}
}

function DrawMenu(obj,event) {

	thisObj 	= 'toolbar-menu';

	if (!objExist(thisObj)) return;
	var x = new getObj(thisObj);
	
	if (!(x.style.display=='inline' || x.style.display=='')) {
		x.style.display = 'inline';
	}
	
	x.style.position	= "absolute";
	x.style.zIndex 		= obj.style.zIndex + 1;
	
	if (navigator.appName=="Netscape") {
		showX = (event.pageX);
		showY = (event.pageY);
	} else {
		showX = (event.clientX);
		showY = (event.clientY);
	}
	newX = document.body.clientWidth-showX;
	x.style.right = newX;
	x.style.top = showY;
	
	obj.className = 'toolbar-hover';
}

function closeMenu() {
	thisObj 	= 'k-link';
	
	if (!objExist(thisObj)) return;
	var x = new getObj(thisObj);
	x.className = '';
	
	divDsp('toolbar-menu','none');
}
var timer;
function timeoutMenu() {
	timer = setTimeout("closeMenu()",800);
}

function clearMenuTimeout(){
		clearTimeout(timer);
}

function hoverDiv(t,classN) {
	t.className = classN;
}

// AJAX Functionality
/**
 * AJAX Call: submits parameters and call callback when request returns
 * @internal 7/26/06: Added abillity to run javascript from the response text
 * @param string:method		"POST" or "GET" (USE POST PLEASE, GET IS BUGGY DUE TO BROWSER CACHING)
 * @param string:url		the url to post to i.e. "?action=ajax_save_user" or "?system_action=user_ajax_save"
 * @param string:parameters	what gets passed to the handeler and url format i.e. "user_id=56&user_name=john&..."
 * @param string:callback	the function to call when the request returns i.e. "hollered(56)"
 */
function holler(method,url,parameters,callback) {
	method = method.toUpperCase();
	 try{
	    if (window.XMLHttpRequest) {
	        xmlhttp = new XMLHttpRequest();
	    } else if (window.ActiveXObject) {
	        //xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
	    }
		
		if(method=="POST"){
			xmlhttp.open(method, url, true);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");//application/x-www-form-urlencoded
			xmlhttp.setRequestHeader("Content-length", parameters.length);//parameters.length
			xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.send(parameters);
						
		} else{
			xmlhttp.open(method, url+'&'+parameters, true);
			xmlhttp.send(null);
		}
		
     } catch(e){
	 	alert('Error occurred while trying to process your request');
	 	return;
	 }
	
    xmlhttp.onreadystatechange = function () {
    		
    		
  		if (xmlhttp.readyState == 4 || xmlhttp.readyState == 'complete') {
			if (xmlhttp.status == 200) {
				RunScriptTag(xmlhttp.responseText); //run the first script tag found in the responce text
				if(typeof callback == "string")	
					eval(callback);
				else if (typeof callback == "function")
					callback(xmlhttp);
			} else{
				alert('An error occurred while trying to return your request. \nError '+xmlhttp.status+': '+xmlhttp.statusText);
				return;
			}
	    }
	};
	//xmlhttp.setRequestHeader("Content-Length", "66");
}

/**
 * AJAX Call: submits parameters and writes the response to thisObj
 * @internal 8/11/06: Added long as different loading image
 * @internal 7/26/06: Added abillity to run javascript from the response text
 *
 * @param string:method		"POST" or "GET" (USE POST PLEASE, GET IS BUGGY DUE TO BROWSER CACHING)
 * @param string:url		the url to post to i.e. "?action=ajax_save_user" or "?system_action=user_ajax_save"
 * @param string:parameters	what gets passed to the handeler and url format i.e. "user_id=56&user_name=john&..."
 * @param string:thisObj	the id of the html object to write back to i.e. "user_56_row" 
 * 							(NOTE: there are certian objects you cannot write back to, like <tr>)
 * @param string:LoadingTxt	"none", "long", some text you want to display, or leave it blank {see getLoadingDiv()}
 */
function hollerBack(method,url,parameters,thisObj,LoadingTxt) {
	 //alert(parameters);
	 method = method.toUpperCase();
	 try{
	    if (window.XMLHttpRequest) {
	        xmlhttp = new XMLHttpRequest();
	    } else if (window.ActiveXObject) {
	        //xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
	    }
		
		if(method=="POST"){
			xmlhttp.open(method, url, true);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");//application/x-www-form-urlencoded
			xmlhttp.setRequestHeader("Content-length", parameters.length);//parameters.length
			xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.send(parameters);
		} else{
			xmlhttp.open(method, url+'&'+parameters, true);
			xmlhttp.send(null);
		}
		if (objExist(thisObj)) { 
			var x = new getObj(thisObj);
			//set the loading text
	    	LoadingTxt = getLoadingDiv(LoadingTxt);
	    	if(LoadingTxt!="")		x.innerHTML = LoadingTxt;	
		} else {
			alert("the object '"+thisObj+"' does not exist,\n if you do not want to write your results to an object, then please use holler() without a 4th argument");
		}
		
     } catch(e){
	 	alert('Error occurred while trying to process your request');
	 	return;
	 }
	
    xmlhttp.onreadystatechange = function () {
			
    	
    	
		if (objExist(thisObj)) { 
			var x = new getObj(thisObj);
		}
		
		if (xmlhttp.readyState == 4 || xmlhttp.readyState == 'complete') {
			
			try {
				
				x.innerHTML = xmlhttp.responseText;
				RunScriptTag(xmlhttp.responseText); //run the first script tag found in the response text
				// ajax_id_with_focus: contains the ID of the element that had focus before the AJAX called happed
				// use OnFocus="ajax_id_with_focus = this;" or OnFocus="ajax_id_with_focus = null;"
				// this will set the focus back to that element
				// Note for items outside the AJAX div (mainly drop down boxes), ajax_id_with_focus should be set to null
				// so the focus isn't changed after AJAX returns
				if(ajax_id_with_focus != null){
					getObj(ajax_id_with_focus).focus();
					ajax_id_with_focus = null;
				}
			} catch (e) {
				alert('An error occurred while trying to return your request. \nError '+e.description);
			}
			
			if (xmlhttp.status != 200) {
				alert('An error occurred while trying to return your request. \nError '+xmlhttp.status+': '+xmlhttp.statusText);
				return;
			}
	    } else{
			//set the loading text
	    	LoadingTxt = getLoadingDiv(LoadingTxt);
	    	if(LoadingTxt!="")		x.innerHTML = LoadingTxt;
	    	
			return;
			//x.innerHTML = '<b>Loading...</b>';
		}
	};
	//xmlhttp.setRequestHeader("Content-Length", "66");
}


function getLoadingDiv(LoadingTxt){
	if(LoadingTxt=="none"){ //returns nothing
		return "";
	}else if(LoadingTxt=="long"){ //returns long loading gif
		return '<div><img src="/img/loading.gif" alt="" width="220" height="19" border="0"></div>';
	}else if(LoadingTxt){ //returns the text passed
		return '<div>'+LoadingTxt+'</div>';
	} else {//returns small loading gif
		return '<div><img src="/img/icon.indicator.gif" alt="" width="16" height="16" border="0"></div>';
	}
}

/**
 * AJAX Call: submits the whole form formObj and writes the response to thisObj
 * @internal 8/11/06: Added LoadingTxt
 * @internal Last Update 7/17/06
 *
 * @param string:method		"POST" or "GET" (USE POST PLEASE, GET IS BUGGY DUE TO BROWSER CACHING)
 * @param Form:formObj		the form object to submit i.e. document.user_form
 * @param string:url		the url to post to i.e. "?action=ajax_save_user" or "?system_action=user_ajax_save"
 * @param string:thisObj	the id of the html object to write back to i.e. "user_56_row"
 * 							(NOTE: there are certian objects you cannot write back to, like <tr>)
 * @param string:LoadingTxt	"none", "long", some text you want to display, or leave it blank {see getLoadingDiv()}
 */
function hollerAtMe(method,formObj,url,thisObj,LoadingTxt)
{
	this.uniqueId = new Date().getTime();
	this.frameName = 'frame_'+this.uniqueId;
	
	try{
		// Create New hidden iframe
		var divElm = document.createElement('DIV');
		divElm.style.display = 'none';
		document.body.appendChild(divElm);
		divElm.innerHTML = '<iframe name=\"'+this.frameName+'\" id=\"'+this.frameName+'\" src=\"about:blank\" onload=\"loadFrame(this,\''+thisObj+'\')\"></iframe>';
	} catch(e){
	 	alert('Error occurred while trying to create frame');
	 	return;
	 }
	
	try{
		
//		alert(formObj.action+"="+url);
		h_action = formObj.action;
		h_method = formObj.method;
		h_target = formObj.target;
		
		// Set target of ajax call to frame
		formObj.action 	= url;
		formObj.method 	= method;
		formObj.target = this.frameName;
		formObj.submit();
		
		formObj.action	= h_action;
		formObj.method 	= h_method;
		formObj.target 	= h_target;
		
	} catch(e){
	 	alert('Error occurred while trying to submit form');
	 	return;
	 }
	
	// the source div to swap out
	if (objExist(thisObj)) { 
		var x = new getObj(thisObj);
		
		//set the loading text
    	LoadingTxt = getLoadingDiv(LoadingTxt);
    	if(LoadingTxt!="")		x.innerHTML = LoadingTxt;
		//x.innerHTML = '<div><img src="/img/loading.gif" alt="" width="220" height="19" border="0" /></div>';
		//x.innerHTML = '<div><img src="/img/icon.indicator.gif" alt="" width="16" height="16" border="0" /></div>';
	}
}

function loadFrame(iframeObj,thisObj) {
	try{
		frameName = iframeObj.id;
		var x = new getObj(thisObj);
		x.innerHTML = '<div><img src="/img/loading.gif" alt="" width="220" height="19" border="0" /></div>';
		x.innerHTML = window.frames[frameName].document.body.innerHTML;
		
		RunScriptTag(x.innerHTML); //run the first script tag found in the response text
		
		// ajax_id_with_focus: contains the ID of the element that had focus before the AJAX called happed
		// use OnFocus="ajax_id_with_focus = this;" or OnFocus="ajax_id_with_focus = null;"
		// this will set the focus back to that element
		// Note for items outside the AJAX div (mainly drop down boxes), ajax_id_with_focus should be set to null
		// so the focus isn't changed after AJAX returns
		if(ajax_id_with_focus != null){
			getObj(ajax_id_with_focus).focus();
			ajax_id_with_focus = null;
		}
	} catch(e){
	 	alert('Error occurred while trying to load data from frame');
	 	return;
	}
}

/**
 * Looks in the passed in html string for the first javascript tag (<script...>...</script>) and evaluate it (only finds the first one)
 * @internal 7/27/2006: added the indexOf check
 * 
 * @param html:string the string to look for the script tags in
 */
function RunScriptTag(html){
	//If you don't find a start script tag, don't waste time with the RegExp
	if(html.indexOf("<script")>=0){
		try{
			//match start and end script tags with anything (including newlines) in the middle
			var re = new RegExp(/<script.*?>((?:.|\s)*?)<\/script>/i);
			var matches = re.exec(html);
			
			//Now run what you found
			if(matches && matches[1]!=""){
				//alert(matches[0]);alert(matches[1]);
				eval(matches[1]);
			}
			
		} catch(e){
			alert("RunScriptTag had an error: " + (e.toSource ? e.toSource() : e.description));
		}
	}
}

/**
 * used by hollerAtMe to get the parameters to pass
 *
 * @param fobj:form 		the form object to get the values from (i.e. document.user_form)
 * @param valFunc:function	function used to get the value of a field
 */
function getFormValues(fobj,valFunc) {

	var str 		= "";
	var valueArr 	= null;
	var val 		= "";
	var cmd 		= "";

	for(var i = 0;i < fobj.elements.length;i++) {
		switch(fobj.elements[i].type) {
			case "text":
			case "textarea":
				if(valFunc) {
					//use single quotes for argument so that the value of
                        //fobj.elements[i].value is treated as a string not a literal
                        cmd = valFunc + "(" + 'fobj.elements[i].value' + ")";
                        val = eval(cmd)
				}
                str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
			break;
			case "select-one":
				str += fobj.elements[i].name + "=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&";
			break;
          }
	}
	str = str.substr(0,(str.length - 1));
	return str;
}

/*big_list = "";
	for (property in obj) {
    	big_list +=property+"="+obj.property+"\n";
	  }
	alert(big_list);
	*/
	//callback = 'callback2';
	
function exportForm(id){
	var form = id;//document.getElementById(id);
	var outputStr = "";
	
	if(form==null){
		return null
	}
	if(typeof(form.elements)=='undefined'){ return null }
	var formData={};
	for(var iterator=0;iterator<form.elements.length;iterator++){
		var element=form.elements[iterator];
		if(element.disabled){continue}
		var elementType=element.tagName.toLowerCase();
		var elementName=null;
		var elementValue=null;
		if((typeof(element.name)!='undefined')&&(element.name.length>0)){
			elementName=element.name
		}else if((typeof(element.id)!='undefined')&&(element.id.length>0)){
			elementName=element.id
		}if(elementName!=null){
			if(elementType=='input'){
				if((element.type=='text')||(element.type=='password')||(element.type=='button')||(element.type=='submit')||(element.type=='hidden')){
					elementValue=element.value
				}else if(element.type=='checkbox'){
					if(element.checked){
						elementValue=element.value
					}else{
						try{
							var type=eval('typeof(formData.'+elementName+')');
							if(type!='undefined'){continue}
						} catch(e){continue}
					}
				}else if(element.type=='radio'){
					if(element.checked){
						elementValue=element.value
					}else{
						try{
							var type=eval('typeof(formData.'+elementName+')');
							if(type!='undefined'){continue}
						} catch(e){continue}
					}
				}
			}else if(elementType=='select'){
				if(element.options.length>0){
					if(element.multiple){
						elementName=elementName.replace(/\[\]$/ig,'');
						elementValue=[];
						for(var optionsIterator=0;optionsIterator<element.options.length;optionsIterator++){
							if(element.options[optionsIterator].selected){
								elementValue.push(element.options[optionsIterator].value)
							}
						}
					}else{
						if(element.selectedIndex>=0){
							elementValue=element.options[element.selectedIndex].value}
						}
					}
				}else if(elementType=='textarea'){
					elementValue=element.value
				}
				
				try{
					//eval('formData.'+elementName+' = elementValue;')
					outputStr += '&'+elementName+'='+elementValue;
				}catch(e){}
			}
		}
	
	/*
	big_list = "";
	for (property in formData) {
		if(property!="org_legal_name") continue;
    	
		big_list +=property+"="+formData.property+"\n";
		
		for (p in property) {
			alert(p);
		}
	  }
	alert(big_list);
	*/
	
	return outputStr;
}

function CheckAndSaveContent()
{
	var err = '';
	if(document.content_form.title.value == '') 		err = err+'\n- Please enter a page title';
	if (err == '')
	{
		document.content_form.submit();
	}
	else 
	{
		alert(err);
		return false;
	}
}

function CheckAndPublishContent()
{
	var err = '';
	if(document.content_form.title.value == '') 		err = err+'\n- Please enter a page title';
	if (err == '')
	{
		document.content_form.publish_now.value='1';
		document.content_form.submit();
	}
	else 
	{
		alert(err);
		return false;
	}
}

//Adds a link thats addes order_by and order_desc to the url
//Note: your SQL must look for order_by and order_desc in the url to make this work
//i.e. if url.order_by IS NOT "" then "ORDER BY " & url.order_by ...
//Last Changed 5/25/2006
function sortHeader(title,field){
	var out		= "";
	var desc	= false;
	var sorting	= false; //is this one currently sorting
	
	var query = window.location.search.substring(1);
	//alert(query);
	//Get rid of any spaces in the incomming vars
	title = title.replace(" ","");
	field = field.replace(" ","");
	
	//See whats in the query string now
	if(query.match("order_desc=on"))	desc = true;
	if(query.match("order_by="+field))	sorting = true;
	
	//remove order_by and order_desc from query
	query = query.replace(/&order_by=[A-Za-z_\-\.\,]*/g, "")
	query = query.replace(/&order_desc=[A-Za-z_\-\.]*/g, "")
	
	if(sorting){
		if(desc){
			out = "<a href=\"?"+query+"&order_by="+field+"\">"+title+"&nbsp;&uarr;</a>";
		} else {
			out = "<a href=\"?"+query+"&order_by="+field+"&order_desc=on\">"+title+"&nbsp;&darr;</a>";
		}
	} else {
		out = "<a href=\"?"+query+"&order_by="+field+"\">"+title+"</a>";
	}
	document.writeln(out);
}

function redirect(url){
	window.location.href = url;
}

//This function is ment for alternating row colors (that do not have a mouseover color)
//i.e. for delete
function RecolorTableRows(table_id,color1,color2){
	if(!color1)		color1="white";
	if(!color2)		color2="whitesmoke";
	
	var table = getObj(table_id);
	var rows = table.rows.length;
	var i=0;
	for(row=1; row<rows; row++){
		this_row = table.rows[row];
		if(this_row.style.display!='none' && this_row.innerHTML){
			if((++i)%2)	color=color1;
			else		color=color2;
			
			this_row.bgColor=color;
			//this_row.onmouseout = (this_row.onmouseout+"").replace(/this.bgColor\s*=\s*(.+);/,"this.bgColor = '"+color+"';");
		}
	}
}
