/**
*Copyright (c) 2009 Gomilsek-informatika.
*All rights reserved. This program and the accompanying materials
*are made available under the terms of the GNU Public License v2.0
*which accompanies this distribution, and is available at
*http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*Contributors:
*	Gomilsek-informatika  (initial API and implementation)
*Contact:
*	customers@toolsjx.com
 */

function SimpleAJAXCallback(in_text, obj) {
	document.getElementById(obj).innerHTML = in_text;
	setStatus ("",obj+"-showimg");
}

/*
function checkAll(checkname, exby) {
var bgcolor = '$global[row_colora1]';
  for (i = 0; i < checkname.length; i++) {
  checkname[i].checked = exby.checked? true:false
  var cell = document.getElementById('row' + i);
	if (bgcolor == '$global[row_color2]') {
		var bgcolor = '$global[row_color1]';
	} else {
		var bgcolor = '$global[row_color2]';
	}
	if (checkname[i].checked) {
		cell.style.background = '#$global[row_color_selected]';
	} else {
		cell.style.background = '#' + bgcolor;
	}
  }
}
*/

function checktoggle(box,theId,color) {
if(document.getElementById) {
  var cell = document.getElementById(theId);
  var box = document.getElementById(box);
  //alert(box);
  if(box && box.checked) {
  	cell.style.background = '#abcdef';
    //cell.style.background = '#$global[row_color_selected]';
  } else {
  cell.style.background = '#' + color;
  }
}
}

function checktoggle_over(box,theId,color) {
if(document.getElementById) {
  var cell = document.getElementById(theId);
  var box = document.getElementById(box);
  
  cell.style.background = '#' + color;
}
}

//Function to set a loading status.
function setStatus (theStatus, theObj){
	obj = document.getElementById(theObj);
	var img_url = document.getElementById('img_url').value;

	if (obj) {

	if (theStatus == 1){
		obj.innerHTML = "<img src=\""+img_url+"/loading.gif\" alt=\"Loading....\" vspace=4 hspace=4 style=\"border:none;margin:0px;\">";
	} else {
		obj.innerHTML = "";
	}

	}
}


function doneloading(theframe,thefile){
	var theloc = ""
	theframe.processajax ("showimg",theloc);
}

var qsParm = new Array();

function qs(serverPage) {

	var query = serverPage;
	var parms = query.split('&');

	for (var i=0; i<parms.length; i++) {

		var pos = parms[i].indexOf('=');

		if (pos > 0) {

			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;

		}
	}
}

function searchjx(grid_url, id){
	var sf; 
	var ds; 
	var rpp; 
	var url=grid_url;
	
	if(document.getElementById('sf'+id)!=null){
		sf = document.getElementById('sf'+id).value;
		sf = encodeURIComponent(sf);
		url+="&s_f="+sf;
	}
	if(document.getElementById('ds'+id)!=null){
		ds = document.getElementById('ds'+id).value;
		ds = encodeURIComponent(ds);
		url += "&data_search="+ds;
	}
	if(document.getElementById('rpp'+id)!=null){
		rpp = document.getElementById('rpp'+id).value;
		url += "&rpp="+rpp;
	}
	url+="&ajax=1";
	
	//alert(sf+' '+ds+' '+grid_url+' '+id);
	
	SimpleAJAXCall(url,SimpleAJAXCallback, '', 'data_listings'+id);
}


