var lastbutton = 'NULL';

function printFrame(whichFrame){
	parent[whichFrame].focus();
	parent[whichFrame].print();
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}

function getObj(e) {
  var targ;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  return targ;
}

function openWindow(url) {

  var windowprops = "location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes";
	var popup = window.open(url,'Window',windowprops);
}

function buttonClick(e,url) {

  var targ_elem = getObj(e);

  if (lastbutton != 'NULL') {
    buttonUnClick(lastbutton);
  }
  // fix for some browsers interpret click on text
  if (targ_elem.nodeType == 3) {
    targ_elem = targ_elem.parentNode;
  }
  lastbutton = targ_elem;
  targ_elem.style.border = "1px inset";
  targ_elem.style.backgroundColor = "#3C567A";
  targ_elem.style.fontSize = 'smaller';

  lasturl = url;
  document.location.href = url;
}

function buttonUnClick(elem) {
  elem.style.border = "1px outset";
  elem.style.backgroundColor = "#E0E0E0"
}

function setLocation(eid) {

  if (eid == '' || eid=='undefined') {
    return;
  }
  var elem = null;
  elem = document.getElementById(eid);

  if (elem == '' || elem=='undefined') {
	return;
  }

  if (elem == null)
  {
	return;	
  }
  elem.setAttribute('class','selected');
  elem.setAttribute('onClick','javascript:history.back(-1)');
}

function gotoChannel(channelid) {
  document.location.href = 'channel.php?loc='+channelid+'-00-00';
}
function gotoCategory(categoryid,channelid) {
  document.location.href = 'category.php?loc='+channelid+'-'+categoryid+'-00';
}
function gotoPage(pageid,channelid,categoryid) {
  alert = ('page.php?loc='+channelid+'-'+categoryid+'-'+pageid);
  document.location.href = 'page.php?loc='+channelid+'-'+categoryid+'-'+pageid;
}
