// JavaScript Document
//alert('dvdsv');
// Example: obj = findObj("image1");
function count( mixed_var, mode ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: _argos
    // *     example 1: count([[0,0],[0,-4]], 'COUNT_RECURSIVE');
    // *     returns 1: 6
    // *     example 2: count({'one' : [1,2,3,4,5]}, 'COUNT_RECURSIVE');
    // *     returns 2: 6
 
    var key, cnt = 0;
 
    if( mode == 'COUNT_RECURSIVE' ) mode = 1;
    if( mode != 1 ) mode = 0;
 
    for (key in mixed_var){
        cnt++;
        if( mode==1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
            cnt += count(mixed_var[key], 1);
        }
    }
 
    return cnt;
}
function findObj(theObj, theDoc)

{
  var p, i, foundObj;

  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  return foundObj;
}

var arrType = new Array();
var arrCat = new Array();

function explode( delimiter, string ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: kenneth
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
 
    var emptyArray = { 0: '' };
 
    if ( arguments.length != 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
 
    return string.toString().split ( delimiter.toString() );
}

function AllChecked(checkboxses, prefix, action){
	//alert('1111');
var Check = findObj(checkboxses);
var Checkbox = new Object;

var length = explode('*', Check.value)
for (i=1; i< count(length); i++)
{
Checkbox = findObj(prefix + length[i]);
//alert(prefix + length[i]);
Checkbox.checked = action;
}
Checkbox = findObj(prefix + '226');
Checkbox.checked = action;

}



//function AllChecked2(checkboxses, prefix, action){

//var Check = findObj(checkboxses);
//var Checkbox = new Object;
//alert(Check.value);

//var length = explode('*', Check.value);
//for (j=1; j< count(length); j++)
//{
//	var length2 = explode('+', length[j]);
//	for (i=1; i< count(length2); i++)
//		Checkbox = findObj(prefix + length[j]+ length2[i]);
//		alert(prefix + length[j]+ length2[i]);
//		Checkbox.checked = action;
//}
//Checkbox = findObj(prefix + '226');
//Checkbox.checked = action;

//}

function AllChecked2(checkboxses, prefix,parent, action){
	
var Check = findObj(checkboxses);
var Checkbox = new Object;
//alert(Check.value);
var length = explode('*', Check.value)
for (i=1; i< count(length); i++)
{
Checkbox = findObj(prefix + length[i] + '-' + parent);
//alert(prefix + length[i]+'-'+parent);
//alert(Checkbox);
if ( Checkbox != null){
Checkbox.checked = action;
};
}
Checkbox = findObj(prefix + '226');
Checkbox.checked = action;

}


function AllChecked3(checkboxses, prefix, action){
	//alert('333');
var Check = findObj(checkboxses);
var Checkbox = new Object;

var length = explode('*', Check.value)
for (j=1; j< count(length); j++)
{
	Checkbox = findObj(prefix + length[j] + '-' + '0');
	//alert(prefix + length[i]);
	if ( Checkbox != null){
	Checkbox.checked = action;
	};
	for (i=1; i< count(length); i++)
	{
		Checkbox = findObj(prefix + length[j] + '-' + length[i]);
		//alert(prefix + length[i]);
		if ( Checkbox != null)
			{
			Checkbox.checked = action;
			};
	};
	
	
}
Checkbox = findObj(prefix + '226');
Checkbox.checked = action;

}

