/* JS functions file */

function searchfunc(elmtId, pg)
{
	var val = document.getElementById(elmtId).value;
	//alert(val);
	if (val!="" && val!="Separate search words using commas")
	{
		var path = pg;
		path += "?val="+val;
		location.replace(path);
		return false;
	}
	else
	{
		document.getElementById(elmtId).value = "Separate search words using commas";
	}
}	// function searchfunc

function searchWithId(elmtId, pg)
{
	var val = document.getElementById(elmtId).value;
	//alert(val);
	if (val!="" && val!="Separate search words using commas")
	{
		var path = pg;
		path += "&val="+val;
		location.replace(path);
		return false;
	}
	else
	{
		document.getElementById(elmtId).value = "Separate search words using commas";
	}
}	// function searchfunc

function clearbox(elmtId)
{ 
	var val = document.getElementById(elmtId).value;
	if (val=="Separate search words using commas")
	{
		document.getElementById(elmtId).value = "";
	}
}	// function clearbox

function updChks(elmtId,lim,page,tab,fld)
{
	var elmt = "";
	var str1 = "";
	var str0 = "";
	
	for(j=0; j<lim; j++)
	{
		elmt = elmtId+j;
		//alert(elmt);
		if (document.getElementById(elmt).checked==true){
			str1 += document.getElementById(elmt).value+",";
		}
		else{
			str0 += document.getElementById(elmt).value+",";
		}
	}	// for(i=0; i<lim; i++)
	if (tab=="member_mylist" || tab=="labels"){
		var url = "process_upd_checks_user.php";
	}
	else{
		var url = "process_upd_checks.php";
	}
	url += "?page="+page+"&table="+tab+"&field="+fld+"&str1="+str1+"&str0="+str0;
	url += "&sid="+Math.random();
	if(page=="member_view.php" && tab=="members" && fld=="memberid")
		url += "&flag="+"is_blocked";
	//alert(url);
	location.replace(url);
}	// function getChks()

/*
RNS Modified
function updChks(elmtId,lim,page,tab,fld)
{
	var elmt = "";
	var str1 = "";
	var str0 = "";
	
	var comma1 = "";
	var comma0 = "";
	
	for(j=0; j<lim; j++)
	{
		elmt = elmtId+j;
		//alert(elmt);
		if (document.getElementById(elmt).checked==true){
			str1 += comma1+""+document.getElementById(elmt).value;
			comma1=",";
		}
		else{
			str0 += comma0+""+document.getElementById(elmt).value;
			comma0=",";
		}
	}	// for(i=0; i<lim; i++)
	if (tab=="member_mylist" || tab=="labels"){
		var url = "process_upd_checks_user.php";
	}
	else{
		var url = "process_upd_checks.php";
	}
	url += "?page="+page+"&table="+tab+"&field="+fld+"&str1="+str1+"&str0="+str0;
	url += "&sid="+Math.random();
	if(page=="member_view.php" && tab=="members" && fld=="memberid")
		url += "&flag="+"is_blocked";
	//alert(url);
	location.replace(url);
}	// function getChks()

*/

function pgChange(url)
{	
	//alert(url);
	if (url!="" && url!="#")
		location.replace(url);
}	// function pgChange(url)


function updTxt(elmtId,lim,page,tab,fld)
{
	var elmt = "";
	var str1 = "";
	var str0 = "";
	
	for(j=0; j<lim; j++)
	{
		elmt = elmtId+j;
		//alert(elmt);
		if (document.getElementById(elmt).checked==true){
			str1 += document.getElementById(elmt).value+",";
		}
		else{
			str0 += document.getElementById(elmt).value+",";
		}
	}	// for(i=0; i<lim; i++)
	if (tab=="member_mylist" || tab=="labels"){
		var url = "process_upd_checks_user.php";
	}
	else{
		var url = "process_upd_checks.php";
	}
	url += "?page="+page+"&table="+tab+"&field="+fld+"&str1="+str1+"&str0="+str0;
	url += "&sid="+Math.random();
	//alert(url);
	location.replace(url);
}	// function getChks()

function clearboxAny(elmtId)
{
	document.getElementById(elmtId).value = "";
}	// function clearbox

function toggleLayer( whichLayer )
{
  var elem, elem2, vis, vis2;
  if( document.getElementById ){ // this is the way the standards work
    elem = document.getElementById( whichLayer );
	elem2 = document.getElementById( whichLayer+"m" );
  }
  else if( document.all ){ // this is the way old msie versions work
      elem = document.all[whichLayer];
      elem2 = document.all[whichLayer+"m"];
  }
  else if( document.layers ){ // this is the way nn4 works
    elem = document.layers[whichLayer];
    elem2 = document.layers[whichLayer+"m"];
  }
  vis = elem.style;
  vis2 = elem2.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined){
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
    vis2.display = (elem2.offsetWidth!=0&&elem2.offsetHeight!=0)?'block':'none';
  }
  
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  vis2.display = (vis2.display==''||vis2.display=='block')?'none':'block';
}

/*

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
*/
