function open_help(about) {
    options = 'width=400,height=480,scrollbars=yes,toolbar=no,location=no';
    window.open('/help/load.php?subject='+about, 'FAQ',options); 
    return false;
}

/**
* Show img slides
*/
function loadSlides() {
	divs = document.getElementById("img_slides");
	
	AjaxRequest.get({
		'url':'ajax_slides/slides.php'
		,'onLoading':function(req) 	{ divs.innerHTML = 'Loading'; }
		,'onSuccess':function(req) 	{ divs.innerHTML = req.responseText; }
		,'onError':function(req) 		{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function loadP7Slides() {
	P7_setScroller('p7scroller1','p7s1content1',0,0);
	P7_runScroller('p7scroller1','Right','Slow',1,0,0,1);
}

function loadP7Reactions() {
    if (document.getElementById('p7scroller2')) {
    	P7_setScroller('p7scroller2','p7s2content1',0,0);
    	P7_runScroller('p7scroller2','Right','Slow',1,0,0,0);
    }
}

/**
* Display/hide div
*/

var Engine = {
	detect: function() {
		var UA = navigator.userAgent;
		this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);
		this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);
		this.isOpera = /Opera/.test(UA);
		this.isMSIE  = (/MSIE/.test(UA) && !this.isOpera);
		this.isMSIE7 = this.isMSIE && !(/MSIE 6\./.test(UA) && !this.isOpera);
	}
}
Engine.detect();

///////////////////////////////

function toggleInfo(id) {
	img = 'img_' + id;
	div = 'info_' + id;
	
	d = document.getElementById(img);
	if (d.src.indexOf('arr_up.gif')>0) {
		d['src'] = 'img/icon/arr_down.gif';
	} else {
		d['src'] = 'img/icon/arr_up.gif';		
	}
	toggleDiv(div);
}

function toggleDiv(id) {
	d = document.getElementById(id);
	//alert(d.style['display']);
	if (d.style['display'] == 'none') {
		d.style['display'] = 'block';
	} else {
	  d.style['display'] = 'none';
	}
}

/**
* Blur all links
*/
function blurAll() {
	for (i = 0; i < document.links.length; i++) {
		document.links[i].onfocus = function () {
			this.blur();
		}
	}
}

/**
* Count textarea chars
*/
function textCounter(field, cntfield, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	} else {
		cntfield.value = maxlimit - field.value.length;
	}
}


function trim(pstrText)
{
  var regWhitespace = " \t\n\r";

  if (pstrText == null || typeof(pstrText) != "string") return pstrText;

  pstrText = fTrimLeft(pstrText,regWhitespace);
  pstrText = fTrimRight(pstrText,regWhitespace);

  if (typeof(pstrText) == "string" && pstrText.length == 0) return "";

  return pstrText;
}

function fTrimLeft(pstrText, pstrStripCharacters)
{
  var nCounter;
  var strReturn = "";

  if (pstrText == null) return "";

  for (nCounter = 0; nCounter < pstrText.length ; nCounter++)
  {
    var strCharacter = pstrText.charAt(nCounter);
    if (pstrStripCharacters.indexOf(strCharacter) == -1) break;
  }

  if (nCounter == pstrText.length) return "";
  return pstrText.substr(nCounter);
}

function fTrimRight(pstrText, pstrStripCharacters)
{
  var nCounter;
  var strReturn = "";

  if (pstrText == null) return "";

  for (nCounter = pstrText.length; nCounter > 0 ; nCounter--)
  {
    var strCharacter = pstrText.charAt(nCounter-1);
    if (pstrStripCharacters.indexOf(strCharacter) == -1) break;
  }

  if (nCounter == 0) nCounter = pstrText.length;
  return pstrText.substr(0, nCounter);
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function

function getRadioSelectedValue(object) {
	var i = object.length;
	for (var j=0; j<i; j++) {
		if (object[j].checked) {
			return object[j].value;
		}
	}
	return "";
}

function switchClass(id, new_class) {
    el = document.getElementById(id);    
    
    el.className = new_class;
}
function switchToClass(object, new_class) {
    object.className = new_class;
}

function showRow(el_id) {
	ex = document.getElementById('ex_row');
	el = document.getElementById(el_id);
//alert(ex.style.display)
	el.style.display = ex.style.display;
}
function hideRow(el_id) {
	el = document.getElementById(el_id);

	el.style.display = 'none';
}

