/* Switches the img (up.png/down.png) and toggles the div (display:none:[block|inline]) */
function toggle_icon(img, div, mode) {
	if(!mode) mode = 'block';
	if (div.clientHeight > 0) {
	  img.src = img.src.replace('/up.png','/down.png');
	  div.style.display='none';
	  /*Effect.SlideUp(div);*/
	} else {
	  img.src = img.src.replace('/down.png','/up.png');
	  div.style.display = mode;
	  /*Effect.SlideDown(div)*/
	}
}

function toggle_arrow(sender_id, img1, img2){
	img = document.getElementById(sender_id);
	img_src = img.src;
	if (img_src.search(img2) != -1) img.src=img_src.replace(img2, img1);
	if (img_src.search(img1) != -1) img.src=img_src.replace(img1, img2);
}

function toggleDiv(id){
	node = document.getElementById(id);
	if (node.style.display == 'none') node.style.display='block';
	else                              node.style.display='none';
}

function toggleCheck(sender) {
	state=sender.checked;
	allboxes=document.getElementsByTagName("input");
	for (var i=0; i<allboxes.length; i++){
	b = allboxes.item(i);
	 if ( b.alt!='') {
			contr=explode(',',b.alt);
			if (contr.inArray(sender.name)){
				b.checked=state;			
			}
	  	 
	  }
	}
}

function explode(delimiter,item) {
  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);

  while (tempString.indexOf(delimiter)>0) {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
    Count=Count+1
  }

  tempArray[Count]=tempString;
  return tempArray;
}

Array.prototype.inArray = function (value)
{
	var i;
	for (i=0; i < this.length; i++) {
		// Matches identical (===), not just similar (==).
		if (this[i] == value) {
			return true;
		}
	}
	return false;
}