/*public*/

function schedule_refresh(content,target,pref) {
	if(content=="cams"){
		rContext.target = target;
		rContext.pref = pref;
		rContext.content = content;
		window.clearTimeout(rContext.timeoutID);
		rContext.timeoutID = setTimeout(get_refresh,30000);
	}
}

function postpone_refresh() {
	window.clearTimeout(rContext.timeoutID);
	rContext.timeoutID = setTimeout(get_refresh,30000);
}

function set_refresh(content,target,pref) {
	if(content=="cams"){
		rContext.target = target;
		rContext.pref = pref;
		rContext.content = content;
		window.clearTimeout(rContext.timeoutID);
		rContext.timeoutID = setTimeout(get_refresh,30000);
	}
	GetContent(content,target,pref);
}

/*private*/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(detect_schedule_prefs);

function detect_schedule_prefs() {
	var tabs = document.getElementsByTagName("span");
	for(var i=0;i<tabs.length;i++){
		if(tabs[i].className.toString().indexOf("selected")>=0)
			if(tabs[i].onclick.toString().indexOf("cams")>=0)
				rContext.timeoutID = setTimeout(tabs[i].onclick,30000);
	}
}

var rContext = new Object();

function get_refresh() {
	GetContent(rContext.content,rContext.target,rContext.pref);
	rContext.timeoutID = setTimeout(get_refresh,30000);
}
