var systemlogtime=now();
var systemlog=new Array();
var gHOMEBASE="../../../program/livepro/admin/";
var gUnknownDuration=9595959;
var gLANGUAGE="";

function logga(atxt){
try{
systemlog[systemlog.length]=(now()-systemlogtime)+unescape("%09")+atxt;
}catch(errObj){
systemlog[systemlog.length]="Fel i loggtext";
}//end catch
}//end function
function logg(){
return replace(systemlog.join("<br>"),unescape("%09"),"ms&nbsp;&nbsp;");
}//end function

function WIN(){
return (window.navigator.userAgent.indexOf("Win")>-1);
}//end function

function MAC(){
return (window.navigator.userAgent.indexOf("Mac")>-1);
}//end function

//general
function IE(){
return (window.navigator.userAgent.indexOf("MSIE") > -1);
}//end if

function NS(){
return (window.navigator.userAgent.indexOf("Netscape") > -1);
}//end if

function SF(){
return (window.navigator.userAgent.indexOf("Safari") > -1);
}//end if

function FX(){
return (window.navigator.userAgent.indexOf("Firefox") > -1);
}//end if

function FX3(){
return (window.navigator.userAgent.indexOf("Firefox/3") > -1);
}//end if

function iif(cond,a,b){
return cond?a:b;
}//end function

//general
function setWindowToContent(q_wid,q_hei){
if(IE()){
	logga("setting window to "+q_wid+"x"+q_hei);
	window.resizeTo(q_wid,q_hei);
	//window.resizeTo(q_wid+q_wid-document.body.offsetWidth+4,q_hei+q_hei-document.body.offsetHeight+3);
}else if(FX()){
	window.resizeTo(q_wid+window.outerWidth-window.innerWidth,q_hei+window.outerHeight-window.innerHeight);
}else{
	window.resizeTo(q_wid,q_hei);
}//end if
}//end function

//general
function eventTrigger(e){
    if (!e) e = event;
    return e.target || e.srcElement;
}//end function

//general
function isRightclick(evnt){
try{
if(IE()){
	return (evnt.button==2);
}else if(FX()){
  return (evnt.which == 3); 
}else if(NS()){
  return (evnt.which == 3); 
}else{
	return (evnt.button==2);
}//end if
}catch(errObj){
}//end catch
}//end function

function rightClickIE2(){
return true;
return false;
}//end function

if(NS()){
	window.captureEvents(Event.MOUSEDOWN);
	window.captureEvents(Event.MOUSEUP);
	window.onmousedown = isRightclick;
	window.onmouseup = isRightclick;
}else if(FX()){
   document.oncontextmenu=rightClickIE2;
}else{
	document.oncontextmenu=rightClickIE2;
}//end if

//general
function initKey(){
 if(IE()){
	 document.onkeyup=onKeyIE;
 }else if(FX()){
	 //document.onkeyup=onKeyNS;
	 document.addEventListener("keydown", onKeyFX, false);
 }else{
//    document.onkeyup = onKeyNS;
 //   document.captureEvents(Event.KEYUP);
    document.onkeydown = onKeyNS;
    document.captureEvents(Event.KEYDOWN);
 }//end if
}//end function
function onKeyIE(){//IE keyhandler
window.altKey=false;
onKey(window.event.keyCode);
}//end function
function onKeyFX(e){//FX keyhandler
//alert("Key"+e.keyCode );
window.event=e;
onKey(e.keyCode,e);
return false;
}//end function
function onKeyNS(e){//NS keyhandler
if(e.which==18){window.altKey=true};
window.event=e;
onKey(e.which);
e.cancelBubble=true;
}//end function

function ignoreKey(e){
if(window.event){
	e=window.event;
}//end if
e.cancelBubble=true;
if(event.keyCode){
e.keyCode=null;
}//end if
if(e.which){
//e.which=null;
}//end if
return false;
}//end function

//--STRING functions-------------------------------
//general
function two(q_num){
if(q_num<10){
   return "0"+q_num;
}else{
   return q_num;
   }//end if
}//end function

function isalfanumeric(q_str){
var validRegExp = /^[a-zA-Z0-9_]{0,}$/;
//alert("alfanumeric:"+!vnos.search(validRegExp));
return !q_str.search(validRegExp);
}//end function

function keepAlfanum(q_str){
var str="";
var ix=0;
while(ix<q_str.length){
	var c=q_str.substring(ix,ix+1);
	if(isalfanumeric(c)){
		str=str+c;
	}//end if
	ix=ix+1;
}//end while
return str;
}//end function

function lTrim(q_str){
var q_whitespace=new String(" \t\n\r");
var q_s=new String(q_str);
if(q_whitespace.indexOf(q_s.charAt(0))>-1){
	var q_j=0;
	var q_i=q_s.length;
	while(q_j< q_i && q_whitespace.indexOf(q_s.charAt(q_j))>-1){
		q_j++;
	}//end while
	q_s = q_s.substring(q_j, q_i);
}//end if
return q_s;
}//end function

function rTrim(q_str){
var q_whitespace=new String(" \t\n\r");
var q_s=new String(q_str);
if(q_whitespace.indexOf(q_s.charAt(q_s.length-1))>-1){
	var q_i=q_s.length-1;
	while(q_i>=0 && q_whitespace.indexOf(q_s.charAt(q_i))>-1){
		q_i--;
	}//end while
	q_s=q_s.substring(0, q_i+1);
}//end if
return q_s;
}//end function

function trim(q_str){
  return rTrim(lTrim(q_str));
}//end function

function endspace(q_str){
return rTrim(q_str)+" ";
}//end function

//general
function nreplace(str,a,b){
return replace(str,a,""+b);
}//end function

function replace(q_entry,q_a,q_b){
if(q_a==q_b||q_a==""){
	return q_entry;
}else if(q_b.indexOf(q_a)>-1){
	q_temp=replace(q_entry,q_a,"$$zz");
	q_temp=replace(q_temp,"$$zz",q_b);
	return q_temp;
}else{
	q_temp = "" + q_entry;
	while (q_temp.indexOf(q_a)>-1){
	   q_pos= q_temp.indexOf(q_a);
	   if(q_a=="\n"){
	      q_temp = "" + (q_temp.substring(0, q_pos-1) + q_b + q_temp.substring((q_pos + q_a.length), q_temp.length));
	   }else{
	      q_temp = "" + (q_temp.substring(0, q_pos) + q_b + q_temp.substring((q_pos + q_a.length), q_temp.length));
	   }//end if
	}//loop
	return q_temp;
	}//end if
}//end function

//general
function WildFind(q_pos,q_searchstr,q_findstr){
var q_wildstr="";
if(q_findstr.indexOf("*") == -1 || q_searchstr==""){
	     q_wildstr="";
}else{
   var q_iz=q_findstr.indexOf("*");
   var q_ix=q_searchstr.indexOf(q_findstr.substr(0,q_iz),q_pos);
   if(q_ix==-1){
      q_wildstr="";
   }else{
		var q_iy=q_searchstr.indexOf( q_findstr.toString().substr(q_iz+1,q_findstr.length-q_iz),q_ix+q_iz);      
      if(q_iy==-1){
	     q_wildstr="";
      }else{
         q_wildstr=q_searchstr.substr(q_ix+q_iz,q_iy-q_ix-q_iz);      
      }//end if
   }//end if
}//end if
return q_wildstr;
}//end function

//general
function WildReplace(q_searchstr,q_findstr,q_newstr){
q_foundstr=WildFind(0,q_searchstr,q_findstr);
if((q_foundstr!="")||(q_searchstr.indexOf(q_findstr.replace("*",""))>-1)){
	q_prevstr=replace(q_findstr,"*",q_foundstr);
	q_newstr=replace(q_findstr,"*",q_newstr);
	return replace(q_searchstr,q_prevstr,q_newstr);
}else{
	return q_searchstr;
}//end if
}//end function

function startswith(q_ag,q_b){
try{
	if(q_ag==""||q_b==""){
		return false;
	}//end if
	if(q_ag.substr(0,q_b.length)==q_b){
		return true;
	}else{
		return false;
	}//end if
}catch(errObj){
	return false;
}//end catch
}//end function

function endswith(q_ag,q_b){
return (right(q_ag,q_b.length)==q_b);
}//end function

function contains(q_ag,q_b){
if(q_ag){
	if(q_ag>""){
		return (q_ag.indexOf(q_b)>-1);
	}//end if
}//end if
return false;
}//end function

function lstartswith(q_a,q_b){
return ((q_b!="") && (q_a.substr(0,q_b.length).toLowerCase()==q_b.toLowerCase()));
}//end function

function inList(str,list){
return inListSep(str,list,",");
}//end function

function inListSep(str,list,sep){
return ((sep+list+sep).indexOf(sep+str+sep)>-1);
}//end function

function right(q_str,q_ix){
if(q_ix>q_str.length){
	return q_str;
}else{
	return q_str.substr(q_str.length-q_ix,q_ix);
}//end if
}//end function


function left(q_str,q_ix){
	return q_str.substr(0,q_ix);
}//end function

function mid(q_str,q_ix,q_len){
	return q_str.substr(q_ix,q_len);
}//end function

function Len(q_str){
return q_str.length;
}//end function

function Right(q_str,q_ix){
return right(q_str,q_ix);
}//end function

function Left(q_str,q_ix){
	return left(q_str,q_ix);
}//end function

function Mid(q_str,q_ix,q_len){
	return mid(q_str,q_ix,q_len);
}//end function

function InStr(q_ix,q_str,q_f){
	return q_str.indexOf(q_f,q_ix);
}//end function

function stringCropright(row, mark){
var ix=row.lastIndexOf(mark);
if(ix>-1){
   return row.substring(0,ix);
}else{
   return row;
}//end if
}//end function

//--TRANSFORMS---------------------------------
//general
function HTMLEncode(q_t){
return q_t.replace(/&/g, '&amp;').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}//end function

function html2text(str){
var q_str=replace(str,"<BR>"," ");
var q_tag=WildFind(0,q_str,"<*>");
while(q_tag!=""){
	q_str=replace(q_str,"<"+q_tag+">","");
	q_tag=WildFind(0,q_str,"<*>");
}//while
return q_str;
}//end function

//private notused
function q_hugo(q_str){
if(q_str){
q_ix=0;
q_p=0;
while (q_ix<q_str.length){
	q_p=(q_p+(q_str.charCodeAt(q_ix) % 175)*Math.pow(175,(q_ix % 4))) % (937890625);
	q_ix=q_ix+1;
}//loop
return q_p;
}else{
return 0;
}//end if
}//end function

function jssyntax(q_t){
//replace characters that would corrupt javascript syntax
//Scripts are passed and executed from string arguments, therefore we cannot use the javascript denotation -  they would just unfold
var q_tmp=q_t;
q_tmp=q_tmp.replace(/'/g, '&#39;').replace(/\n/g, '<br>').replace(/\r/g, '');
q_tmp=q_tmp.replace(/"/g, '&#34;').replace(/\\/g, '&#92;');
//q_tmp=replace(q_tmp,"\n","<br>");
return q_tmp;
}//end function

function antijssyntax(q_t){
var q_tmp=q_t;
q_tmp=q_tmp.replace(/&#39;/g, "'");
q_tmp=q_tmp.replace(/&#34;/g, '"');
return q_tmp;
}//end function

//private notused
function q_urlclean(q_astr){
//Rid nasty characters
var q_bstr=q_astr;
q_bstr=replace(q_bstr,"\\","/");
q_bstr=replace(q_bstr,"\"","`");
q_bstr=replace(q_bstr,"'","`");
q_bstr=replace(q_bstr,"\n"," ");
q_bstr=replace(q_bstr,"&","%26");
return q_bstr;
}//end function

//general
function scandChar(q_t){
var q_tmp=q_t;
//Disabled for Unicode
return q_tmp;
}//end function

function cleanstring(q_astr){
var q_bstr="";
q_bstr=replace(q_astr,"\"","`");
q_bstr=replace(q_bstr,"'","`");
q_bstr=replace(q_bstr,"\n"," ");
q_bstr=replace(q_bstr,"&","");
return q_bstr;
}//end function

function cleanquotes(q_astr){
var q_bstr=q_astr;
q_bstr=replace(q_bstr,"\x22","`");
q_bstr=replace(q_bstr,"\x27","`");
q_bstr=replace(q_bstr,"\u2018","`");
q_bstr=replace(q_bstr,"\u2019","`");
q_bstr=replace(q_bstr,"\u201C","`");
q_bstr=replace(q_bstr,"\u201D","`");
return q_bstr;
}//end function

function cleanfilename(bstr){
var astr=right(bstr,240);
astr=replace(astr,"'","");
astr=replace(astr,"\"","");
astr=replace(astr,"\\","");
astr=replace(astr,"/","");
astr=replace(astr,":","");
astr=replace(astr,"*","");
astr=replace(astr,"?","");
astr=replace(astr,"<","");
astr=replace(astr,">","");
astr=replace(astr,"|","");
return astr;
}//end function

function array2tab(q_G){
var q_sep="";
var q_h=new Array();
for (var q_row=0;q_row<q_G.length;q_row++){
for (var q_col=0;q_col<q_G[q_row].length;q_col++){
	q_h[q_h.length]=q_sep+q_G[q_row][q_col];
	q_sep=unescape("%09");
}//next
q_sep="\n";
}//next
return q_h.join("");
}//end function

function tab2array(q_strIn){
if(q_strIn==""){
	return new Array();
}//end if
var CRLF=unescape("%0D%0A");
var LF=unescape("%0A");
q_str=replace(q_strIn,CRLF,LF);
//CRLF=unescape("\n");
var q_G=q_str.split(LF);
var q_h=new Array();
for (var q_row=0;q_row<q_G.length;q_row++){
	if(q_G[q_row]!=""){
		q_h[q_h.length]=q_G[q_row].split(unescape("%09"));
	}//end if
}//next
return q_h;
}//end function

function splitAction(q_a){
return js2array(q_a);
}//end function

function js2array(q_a){
if(q_a){
	var q_str=js2tab(q_a);
	if(q_str){
		return q_str.split(unescape("%09"));
	}else{
		return null;
	}//end if
}else{
	return null;
}//end if
}//end function

function js2tab(q_a){
//Parse a js command or a typical js new Array() row
var q_action=q_a;
var q_ix=q_action.indexOf("(");
var q_iy=q_action.lastIndexOf(")");
if(q_ix>0&&q_iy>q_ix){
	var q_word=q_action.substr(0,q_ix);
	q_action=q_action.substr(q_ix+1,q_iy-q_ix-1);
	var q_str=q_word;
	var q_sep=unescape("%09");
	var maxcn=20;
	while(q_action>"" && maxcn>0){
		maxcn--;
		if(q_action.substr(0,1)==","){
			q_action=q_action.substr(1);
		}//end if
		if(q_action.length==0){
			break;
		}else if(q_action.substr(0,2)=="''"){
			q_word="";
			q_action=q_action.substr(2);
		}else if(q_action.substr(0,1)=="'"){
			q_word=WildFind(0,q_action,"'*'");
			q_action=q_action.substr(2+q_word.length);
		}else if(q_action.indexOf(",")>=0){
			q_word=WildFind(0,q_action,"*,");
			q_action=q_action.substr(1+q_word.length);
		}else{
			q_word=q_action;
			q_action="";
		}//end if
		q_str=q_str+q_sep+q_word;
	}//end while
	return q_str;
}else{
	return null;
}//end if
}//end function

function arrayDelete(q_arr,q_iy){
if ((q_iy>=0) && (q_iy<q_arr.length)){
   var q_ix=q_iy;
   while (q_ix<q_arr.length-1){
      q_arr[q_ix]=q_arr[q_ix+1];
      q_ix=q_ix+1;
   }//loop
   q_arr.length=q_arr.length-1;
	return q_arr;
}else{
	return q_arr;
}//end if
}//end function

//--VALIDATION-----------------------------
function checkEmail(q_str){
if((q_str.length < 6) || (q_str.indexOf("@") ==-1)|| (q_str.indexOf(".") == -1)){
	alert("Please correct the email address.("+q_str+")");
}//end if
}//end function

function checkNumeric(q_str){
if(!(/^\d+$/.test(q_str))){
	alert("Please correct bitrate. Bitrate must be numeric.");
}//end if
}//end function

function isNumeric(str){
if(str>""){
	var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; // Note: this WILL allow a number that ends in a decimal: -452. 
	return RegExp.test(str);
}else{
	return false;
}//end if
}//end function

function isNumberPair(str){
var RegExp = /^(-)?(\d*)(\,)(\d*)$/; // Note: this WILL allow a number that ends in a decimal: -452. 
return RegExp.test(str);
}//end function

function myLng(a){
if(!isNaN(parseInt(a))){
	return parseInt(a);
}else{
	return 0;
}//end if
}//end function

//--------TRANSLATE---------------------------------------------------
function translate(intext){
if(gLANGUAGE==""){
	gLANGUAGE="en";
}//end if
return translateTo(gLANGUAGE,intext);
}//end function

function translateTo(lang,intext){
var str;
if(lang=="se"){
	str=translate_RemoveLang(intext,"en");
}else{
	str=translate_RemoveLang(intext,"se");
}//end if
return translate_KeepLang(str,lang);
}//end function

function translate_RemoveLang(intext,lang){
var str;
str=intext;
if(contains(str,"["+lang+"]")){
	str=WildReplaceMatch(str,"["+lang+"]*[/"+lang+"]","");
}//loop
return str;
}//end function

function translate_KeepLang(str,lang){
return replace(replace(str,"[/"+lang+"]",""),"["+lang+"]","");
}//end function

//WildReplace will find the first match of findstr and replace the entire match with a new string
function WildReplaceMatch(q_searchstr,q_findstr,q_newstr){
var q_foundstr,q_prevstr,q_newstr2;
q_foundstr=WildFindExtract(0,q_searchstr,q_findstr);
if(q_foundstr>"" || InStr(0,q_searchstr,replace(q_findstr,"*",""))>0){
	return replace(q_searchstr,q_foundstr,q_newstr);
}else{
	return q_searchstr;
}//end if
}//end function

//WildFindExtract will find the first match of aLine and extract the complete match including * content
function WildFindExtract(ix,aLine,sString){
var found,sstart,sstopp;
found=WildFind(ix,aLine,sString);
if(found==""){
	return "";
}else{
   sstart = Left(sString,InStr(0,sString,"*")-0);
   sstopp = Mid(sString,InStr(0,sString,"*",1)+1,Len(sString));
   return sstart+found+sstopp;
}//end if
}//end function

//--DATETIME--------------------------------
function now(){
return (new Date()).getTime();
}//end function

function checkDateTime(q_str){
if(q_str==""){
}else{
	var q_date=cvDate(q_str);
	if(q_date==""){
		alert(q_str+" is incorrect. \nPlease correct the date/time format. \nExample: 2003-03-01 15:00");
		return false;
	}//end if
}//end if
return true;
}//end function

function checkDuration(q_str){
if(q_str==""){
}else{
	//var aDate=cvTime(ds);
	if(!isDuration(q_str)){
		alert(q_str+" is incorrect. \nPlease enter a numeric duration time. \nExample: 20");
		return false;
	}//end if
}//end if
return true;
}//end function

function isDate(q_str){
return (!(cvDate(q_str)==""));
}//end function

function cvDate(q_str){
if(/(20\d{2})-([0|1]?\d)-([0-3]?\d)\s([0-2]?\d):([0-5]?\d):([0-5]?\d)[\s]*$/.test(q_str)){
return new Date(RegExp.$1,RegExp.$2-1,RegExp.$3,RegExp.$4,RegExp.$5,RegExp.$6);
}else if(/(20\d{2})-([0|1]?\d)-([0-3]?\d)\s([0-2]?\d):([0-5]?\d)[\s]*$/.test(q_str)){
return new Date(RegExp.$1,RegExp.$2-1,RegExp.$3,RegExp.$4,RegExp.$5);
}else if(/(20\d{2})-([0|1]?\d)-([0-3]?\d)\s([0-2]?\d)[\s]*$/.test(q_str)){
return new Date(RegExp.$1,RegExp.$2-1,RegExp.$3,RegExp.$4);
}else if(/(20\d{2})-([0|1]?\d)-([0-3]?\d)[\s]*$/.test(q_str)){
return new Date(RegExp.$1,RegExp.$2-1,RegExp.$3);
}else{
return "";
}//end if
}//end function

function cvTime(q_str){
if(/([0-2]?\d):([0-5]?\d):([0-5]?\d)[\s]*$/.test(q_str)){
return 1000*(3600*parseInt(RegExp.$1,10)+60*parseInt(RegExp.$2,10)+parseInt(RegExp.$3,10));
}else if(/([0-2]?\d):([0-5]?\d)[\s]*$/.test(q_str)){
return 1000*(60*parseInt(RegExp.$1,10)+parseInt(RegExp.$2,10));
}else if(/([0-2]?\d)[\s]*$/.test(q_str)){
return 1000*(parseInt(RegExp.$1,10));
}else{
return "";
}//end if
}//end function

function cvTime2(q_str){
if(/([0-2][0-9]):([0-5][0-9]):([0-5][0-9])$/.test(q_str)){
//return "is time 00:00:00";
return 1000*(3600*parseInt(RegExp.$1,10)+60*parseInt(RegExp.$2,10)+parseInt(RegExp.$3,10));
}else if(/([0-5][0-9]):([0-5][0-9])$/.test(q_str)){
return 1000*(60*parseInt(RegExp.$1,10)+parseInt(RegExp.$2,10));
}else if(/([0-2]?\d)[\s]*$/.test(q_str)){
return 1000*(parseInt(RegExp.$1,10));
}else{
return "";
}//end if
}//end function

function cvWeek(q_str){
if(/v[0-5][0-9]/.test(q_str)){
return "2008"+q_str;
}else{
return "";
}//end if
}//end function

//general
function isWeek(q_str){
return (!(cvWeek(q_str)==""));
}//end function

//general
function isTime(q_str){
return (!(cvTime(q_str)==""));
}//end function

//general
function isDuration(q_str){
if(/^\d+$/.test(q_str)){
return true;
}else{
return false;
}//end if
}//end function

function datestring(q_tpos){
if(q_tpos>=0){
    return q_tpos.getFullYear() + "-" + two(q_tpos.getMonth()+1) + "-"  + two(q_tpos.getDate());
}else{
	return "unknown date";
}//end if
}//end function

function mydateformat(q_tpos){
if(q_tpos>=0){
    return q_tpos.getFullYear() + "-" + two(q_tpos.getMonth()+1) + "-"  + two(q_tpos.getDate()) + " " + two(q_tpos.getHours()) + ":"  + two(q_tpos.getMinutes()) + ":" + two(q_tpos.getSeconds());
}else{
	return "unknown date";
}//end if
}//end function

function mytimeformat(q_tpos){
if(q_tpos>=0){
    return two(q_tpos.getHours()) + ":"  + two(q_tpos.getMinutes()) + ":" + two(q_tpos.getSeconds());
}else{
	return "unknown date";
}//end if
}//end function

function timestamp2date(x){
return (new Date(parseInt(x)-2209165199500));
}//end function

function timestamp(x){
return (now()+2209165199500);
}//end function

function timestamp2timestring(x){
return mytimeformat(timestamp2date(x));
}//end function

function myminuteseconds(q_tpos){
if(q_tpos>=3600000){
    return (q_tpos.getHours()-1)+":"+two(q_tpos.getMinutes()) + ":" + two(q_tpos.getSeconds());
}else if(q_tpos>=0){
    return two(q_tpos.getMinutes()) + ":" + two(q_tpos.getSeconds());
}else{
	return "--:--";
}//end if
}//end function

function mydatefilename(q_tpos,suffix){
if(q_tpos>=0){
    return ""+q_tpos.getFullYear() + two(q_tpos.getMonth()+1) + two(q_tpos.getDate()) + "_" + two(q_tpos.getHours()) + two(q_tpos.getMinutes()) + "_" + keepAlfanum(suffix);
}else{
	return "";
}//end if
}//end function

function mydatename(q_prefix,q_tpos){
if(q_tpos>=0){
    return q_prefix + "_" + q_tpos.getFullYear() + two(q_tpos.getMonth()+1) + two(q_tpos.getDate()) + "_" + two(q_tpos.getHours()) + two(q_tpos.getMinutes());
}else{
	return "unknown date";
}//end if
}//end function

function timestring(q_tposin){
if(q_tposin==gUnknownDuration){
    return "--:--:--";
}else if(q_tposin>=0){
	var q_tpos=q_tposin%86400;
    return Math.floor(q_tpos/3600) + ":" + two(0+(Math.floor(q_tpos/60)%60)) + ":"  + two((Math.floor(q_tpos)%60));// + "."  + Math.floor((q_tpos-Math.floor(q_tpos))*1000);
}else if(q_tposin<0){
	var q_tpos=(-q_tposin)%86400;
    return "-"+Math.floor(q_tpos/3600) + ":" + two((Math.floor(q_tpos/60)%60)) + ":"  + two((Math.floor(q_tpos)%60));// + "."  + Math.floor((q_tpos-Math.floor(q_tpos))*1000);
}else{
	return "--:--:--";
}//end if
}//end function

function durstring(q_tpos){
if((q_tpos>=0)&&(q_tpos<3600)){
    return two(Math.floor(q_tpos/60)%60) + ":"  + two(Math.floor(q_tpos)%60);// + "."  + Math.floor((q_tpos-Math.floor(q_tpos))*1000);
}else if((q_tpos>=3600)&&(q_tpos<3600*24)){
    return two(Math.floor(q_tpos/3600)%24) + ":" + two(Math.floor((q_tpos%3600)/60)%60) + ":"  + two(Math.floor(q_tpos)%60);
}else{
	return "--:--";
}//end if
}//end function

function timeframestring(q_tpos){
if(q_tpos>=0){
    return Math.floor(q_tpos/3600) + ":" + two((Math.floor(q_tpos/60)%60)) + ":"  + two((Math.floor(q_tpos)%60)) + "."  + Math.floor((q_tpos-Math.floor(q_tpos))*1000);
}else if(q_tpos<0){
    return "-"+Math.floor(-q_tpos/3600) + ":" + two((Math.floor(-q_tpos/60)%60)) + ":"  + two((Math.floor(-q_tpos)%60)) + "."  + Math.floor((-q_tpos-Math.floor(-q_tpos))*1000);
}else{
	return "--:--:--.--";
}//end if
}//end function

function isvalidtimestring(q_str){
if(/([0-2]?\d):([0-5]?\d):([0-5]?\d)[\s]*$/.test(q_str)){
return true;
}else if(/([0-5]?\d):([0-5]?\d)[\s]*$/.test(q_str)){
return true;
}else if(/([0-5]?\d)[\s]*$/.test(q_str)){
return true;
}else{
return false;
}//end if
}//end function

function getoffsetX(q_evt){
if(IE()){
	return window.event.offsetX;
}else if(q_evt.target){
  var q_coords = {x: 0, y: 0 };
  var q_el = q_evt.target;
  do {
    q_coords.x += q_el.offsetLeft;
  }while ((q_el = q_el.offsetParent));
  return q_evt.clientX - q_coords.x;
}//end if
}//end function

function getoffsetY(q_evt){
if(IE()){
	return window.event.offsetY;
}else if(q_evt.target){
  var q_coords = {x: 0, y: 0 };
  var q_el = q_evt.target;
  do {
    q_coords.y += q_el.offsetTop;
  }while ((q_el = q_el.offsetParent));
  return q_evt.clientY - q_coords.y;
}//end if
}//end function

function absoluteTop(obj){
if(obj.offsetParent){
	return obj.offsetTop+absoluteTop(obj.offsetParent);
}else if(obj.y){
	return obj.y;
}else{
	return obj.offsetTop;
}//end if
}//end function
			
function absoluteLeft(obj){
if(obj.offsetParent){
	return obj.offsetLeft+absoluteLeft(obj.offsetParent);
}else if(obj.x){
	return obj.x;
}else{
	return obj.offsetLeft;
}//end if
}//end function

function hideDiv(obj){
obj.style.visibility="hidden";
}//end function

function getsrcElement(q_evt){
if(IE()){
	return window.event.srcElement;
}else{
	return q_evt.target;
}//end if
}//end function

function getEvent(q_evt){
if(window.event){
	return window.event;
}else{
	return q_evt;
}//end if
}//end function

function setTablecell(q_table,q_row,q_col,q_value){
if((q_row>=0)&&(q_col>=0)&&(q_row<q_table.rows.length)){
	q_table.rows.item(q_row).getElementsByTagName("td").item(q_col).innerHTML=q_value;
}//end if
}//end function

function getTablecell(q_table,q_row,q_col){
if((q_row>=0)&&(q_col>=0)&&(q_row<q_table.rows.length)){
	return q_table.rows.item(q_row).getElementsByTagName("td").item(q_col).innerHTML;
}//end if
}//end function

function getTablecellobj(q_table,q_row,q_col){
if((q_row>=0)&&(q_col>=0)&&(q_row<q_table.rows.length)){
	return q_table.rows.item(q_row).getElementsByTagName("td").item(q_col);
}//end if
}//end function

function getTablecols(q_table,q_row){
if((q_row>=0)&&(q_row<q_table.rows.length)){
	return q_table.rows.item(q_row).getElementsByTagName("td");
}//end if
}//end function

function getTablecolcount(q_table,q_row){
	//return q_table.cols.length;
if((q_row>=0)&&(q_row<q_table.rows.length)){
	return q_table.rows.item(q_row).getElementsByTagName("td").length;
}//end if
}//end function

//general
function setTablecellbg(q_table,q_row,q_col,q_value){
if((q_row>=0)&&(q_col>=0)&&(q_row<q_table.rows.length)){
	q_table.rows.item(q_row).getElementsByTagName("td").item(q_col).style.backgroundImage="url("+q_value+")";
}//end if
}//end function

//general
function setTablecellcolor(q_table,q_row,q_col,q_value){
if((q_row>=0)&&(q_col>=0)){
	try{
	q_table.rows.item(q_row).getElementsByTagName("td").item(q_col).style.backgroundColor=q_value;
	}catch (errObj){
//		alert("Could not select row "+q_row);
	}//end catch
}//end if
}//end function

//general
function setTabletextcolor(q_table,q_row,q_col,q_value){
if((q_row>=0)&&(q_col>=0)){
	q_table.rows.item(q_row).getElementsByTagName("td").item(q_col).style.color=q_value;
}//end if
}//end function

//general
function setTablerowcolor(q_table,q_row,q_value){
if((q_row>=0)){
	q_table.rows.item(q_row).style.backgroundColor=q_value;
}//end if
}//end function

function setTablerowclass(q_table,q_row,q_value){
if((q_row>=0)){
	q_table.rows.item(q_row).className=q_value;
	//special for chapter object
	q_table.rows.item(q_row).getElementsByTagName("td").item(1).className=q_value;
}//end if
}//end function

function getRadioValue(q_radiogroup){
var q_value = null;
if(q_radiogroup.length){//group 
  	for (var q_b = 0; q_b < q_radiogroup.length; q_b++){
		if(q_radiogroup[q_b].checked){
			q_value = q_radiogroup[q_b].value;
		}//end if
	}//next
}else if(q_radiogroup.checked){
	q_value = q_radiogroup.value;
}//end if
return q_value;
}//end function

//-------------------
function checkStickyNote(q_stickynote,q_prodid){
if((q_stickynote=="0")&&(q_prodid=="etetv")){
	if(document.getElementById("StickyNote")){
		document.getElementById("StickyNote").style.visibility="visible";
	}//end if
}//end if
}//end function

function disableSelection(element) {
element.onselectstart = function(){return false;}
}//end function

function disableselect() {
return false;
}//end function

//general
function setSelectionRange(q_input, q_selstart, q_selend){
  if(q_input.setSelectionRange){
    q_input.focus();
    q_input.setSelectionRange(q_selstart, q_selend);
  }else if(q_input.createTextRange){
    var q_range = q_input.createTextRange();
    q_range.collapse(true);
    q_range.moveEnd('character', q_selend);
    q_range.moveStart('character', q_selstart);
    q_range.select();
  }//end if
}//end function

//general
function setCaretToEnd(q_input){
  setSelectionRange(q_input, q_input.value.length, q_input.value.length);
}//end function

//general
function stringtime(q_str){
if(q_str!=""){
	var q_val=q_str.split(":");
	var q_t=0;
	for(var q_i=0;q_i<q_val.length;q_i++){
		q_t=q_t*60+parseInt(q_val[q_i],10);
	}//next
	if(isNaN(q_t)){
		return "";
	}else{
   		return q_t;
	}//end if
}//end if
return "";
}//end function

//--URL parsing-----------------------------------------------------------------
function forwardslash(str){
	return replace(str,"\\","/");
}//end function

function URL2servername(q_url){
if(startswith(q_url,"//")){
	return WildFind(0,q_url,"//*/");
}else if(q_url.indexOf("://")>-1){
	return WildFind(0,q_url,"://*/");
}else{
	return "";
}//end if
}//end function

function URL2name(q_url){
	var ix=q_url.lastIndexOf("/")+1;
	var iy=q_url.indexOf(".",ix)-ix;
	if(iy>-1){
		return q_url.substr(ix,iy);
	}else{
		return q_url.substr(ix,q_url.length);
	}//end if
}//end function

function URL2filename(q_url){
	var ix=q_url.lastIndexOf("/")+1;
	var iy=q_url.indexOf("?",ix)-ix;
	if(iy>-1){
		return q_url.substr(ix,iy);
	}else{
		return q_url.substr(ix,q_url.length);
	}//end if
}//end function

function URL2extension(q_url){
	var filename=URL2filename(q_url);
	var ix=filename.indexOf(".");
	return filename.substr(ix,filename.length);
}//end function

function URL2folder(q_url){
if(startswith(q_url,"//")){
	var ix=q_url.indexOf("/",3)+1;
	var iy=q_url.lastIndexOf("/")-ix+1;
	return q_url.substr(ix,iy);
}else if(q_url.indexOf("://")>-1){
	var servername=URL2servername(q_url);
	var ix=q_url.indexOf("://")+4+servername.length;
	var iy=q_url.lastIndexOf("/")-ix+1;
	return q_url.substr(ix,iy);
}else{
	var ix=0;
	var iy=q_url.lastIndexOf("/");
	return q_url.substr(ix,iy);
}//end if
}//end function

function URL2protocol(q_url){
if(startswith(q_url,"//")){
	return "file://";
}else if(q_url.indexOf("://")>-1){
	return left(q_url,q_url.indexOf("://")) + "://";
}else{
	return "http://";
}//end if
}//end function

//general
function getPresentationname(q_str){
	if((q_str.indexOf("/")>-1)){
		return q_str.split("/")[q_str.split("/").length-2];
	}else{
		return "";
	}//end if
}//end function

//general
function getSlidenumber(q_file){
var q_str;
var q_ix,q_iy;
	q_str=q_file.toLowerCase();
	q_ix=q_str.lastIndexOf("/");
	if(q_ix>-1){
		q_str=q_str.substr(q_ix+1,q_str.length-q_ix);
	}else{
		q_str=q_str;
	}//end if
	if((q_str.indexOf("slide")>-1)&&(q_str.indexOf(".")>-1)){
		q_str=(q_str.split(".")[0]).replace("slide","");
		return q_str;
	}else{
		return q_str;
	}//end if
}//end function

function request_querystring(q_name){
return request_queryvalue(document.location.search.substring(1),q_name);
}//end function

function request_queryvalue(qs,q_name){
if(qs.indexOf("&")>-1){
	var q_list=qs.split("&");
	if(q_list.length>=1){
		for (var q_i=0;q_i<q_list.length;q_i=q_i+1){
			var q_clist=q_list[q_i].split("=");
			if(q_clist[0].toLowerCase()==q_name.toLowerCase()){
			return unescape(q_clist[1]);
			}//end if
		}//next
		return "";
	}else{
		return "";
	}//end if
}else{
	var q_clist=qs.split("=");
	if(q_clist[0].toLowerCase()==q_name.toLowerCase()){
		return unescape(q_clist[1]);
	}else{
		return "";
	}//end if
}//end if
}//end function



//general
function extractFileNamePart(q_file){
return url_getFilename(q_file);
}//end function

//general
function url_getFilename(q_file){
var q_str="/" + replace(q_file,"\\","/");
var q_ix=q_str.lastIndexOf("/");
try{
return q_str.substr(q_ix+1,q_str.length-q_ix);
}catch(errObj){
return "";
}//end catch
}//end function

//general
function url_getPlayerformat(url){
var playerformatsWM,playerformatsRM,playerformatsQT,playerformatsFL,ext;
	var playerformatsWM= ".asf.asx.wm.wmx.wmp.wma.wax.wmv.wvx.vob.cda.avi.wav.mpeg.mpg.mpe.m1v.mp2.mpv2.mp2v.mpa.mp3.m3u.mid.midiivf.aif.aifc.aiff.au.snd";
	var playerformatsRM= ".mes.asf.au.lqt.mjf.m3u.pls.xpl.mp3.mpeg.mpa.mp2.mpv.mx3.pls.m3u.avi.aiff.ram.rmm.ra.rm.rmx.rmj.rms.mnd.rp.rt";
	var playerformatsQT= ".mov";	
	var playerformatsFL= ".flv.mp4";	
ext=fileextension(url);
if(startswith(url,"rtmp://")){
	return "FL"; 
}else if(contains(playerformatsWM,ext)){
	return "WM"; 
}else if(contains(playerformatsRM,ext)){
	return "RM";
}else if(contains(playerformatsQT,ext)){
	return "QT"; 
}else if(contains(playerformatsFL,ext)){
	return "FL";
}else{ 
	return "";
}//end if
}//end function

//general
function fileextension(q_str){
var q_file=q_str;
if(q_file.indexOf("#")>4){
	q_file=q_file.split("#")[0];
}//end if
var q_ix=q_file.lastIndexOf(".");
   if(q_file.lastIndexOf(".asp?")>=0){
      return "asp";
   }else if(q_ix>=0){
      return q_file.substr(q_ix+1,q_file.length-q_ix);
   }else{
      return "";
   }//end if
}//end function

function filepath(q_file){
try{
	return q_file.substr(0,q_file.lastIndexOf("/")+1);
}catch(errObj){
//alert("error in filepath");
return "";
}//end catch
}//end function

function cssurlpath(q_file){
	return q_file.substr(4,q_file.lastIndexOf("/")-3);
}//end function

function getLocationPath(){
//Read the current location base
return filepath(document.location.protocol+"/"+"/"+document.location.host+document.location.pathname.replace(/\\/g, "/"));
}//end function

function getBaseHref(){
var baseTag = document.getElementsByTagName("base");
for(var i=0; i<baseTag.length; i++){
	var baseId = baseTag[i].id;
	var baseHref = baseTag[i].href;
	return baseHref;
}//next
return getLocationPath();
}//end function

function resolveUrl(q_base,q_x){
var q_url;
if(q_base==""){
	q_url=q_x;
}else if(right(q_base,1)=="/"){
	q_url=q_base+q_x;
}else{
	q_url=q_base+"/"+q_x;
}//end if
var t=q_getSubref(q_url);
while(t>""){
	q_url=replace(q_url,t,"");
	t=q_getSubref(q_url);
}//end while
return q_url;
}//end function

//private
function q_getSubref(q_url){
//match xxx/../
var p=q_url.indexOf("/../")-1;
if(p>0){
	q=q_url.lastIndexOf("/",p);
	if(q>=0){
		return(q_url.substr(q+1,p-q+4));
	}//end if
}//end if
return "";
}//end function

function isASX(q_src){
if(q_src>""){
	return (("asx,wvx,wax").indexOf(fileextension(q_src))>-1);
}else{
	return false;
}//end if
}//end function

//private
function q_validprotocol(q_url){
var q_str=q_url;
q_str=replace(q_str,"\n","");
q_str=replace(q_str,"\\","/");
var q_slashslash="/"+"/";
if(left(q_url,7)=="<object"||left(q_url,6)=="video/"){
	return q_url;
}else if(q_str.substr(1,2)==":/"||q_str.substr(0,2)==q_slashslash){
	q_str="file:"+q_slashslash+q_str;
}//end if
if((q_str.substr(0,3)=="../") || (q_str.substr(0,7)==("http:"+q_slashslash)) || (q_str.substr(0,7)==("rtsp:"+q_slashslash)) || (q_str.substr(0,7)==("rtmp:"+q_slashslash)) || (q_str.substr(0,6)==("mms:"+q_slashslash))|| (q_str.substr(0,7)==("file:"+q_slashslash))){
	return q_str;
}else if(q_url==""){
	yellowmessage("Please add a video/audio source to this track.","Missing Media Source");
 	return q_str;
}else{
	yellowmessage("URL ("+q_str+") must start with a valid streaming protocol (http,rtsp,rtmp,mms,file)","Incorrect Media Source");
 	return q_str;
}//end if
}//end function

//--

function inp(q_name){
return document.getElementById(q_name).value;
}//end function

function logNotes(q_str){
var q_obj=document.getElementById("Notes");
if(q_obj){
q_obj.innerHTML=q_obj.innerHTML+"<br>"+q_str;
}//end if
}//end function

var q_NOTESTIMER=null;
var q_TARGETTOP=0;

function resetYellowmessage(){
var q_obj=document.getElementById("Notes");
if(q_obj){
	q_obj.style.visibility="hidden";
	q_obj.style.left=windowWidth()-q_obj.offsetWidth-10;
	q_obj.style.top=windowHeight()-q_obj.offsetHeight;
	q_TARGETTOP=windowHeight()-96;
}//end if
}//end if

function yellowmessage(q_msg,q_title){
var q_obj=document.getElementById("Notes");
if(q_obj){
	if(q_msg==""){
		if(q_NOTESTIMER){window.clearTimeout(q_NOTESTIMER)};
		q_obj.style.visibility="hidden";
		q_obj.style.height=10;
		q_obj.style.top=windowHeight()-parseInt(q_obj.style.height);
	}else if(q_obj.style.visibility=="hidden"){
//title 34,8,245,15
//message 11,28,280,45
		q_TARGETTOP=windowHeight()-96;
		q_obj.style.left=windowWidth()-parseInt(q_obj.style.width)-10;
		q_obj.style.height=10;
		q_obj.style.top=windowHeight()-parseInt(q_obj.style.height);
		if(q_title){
		}else{
			q_title="";
		}//end if
		q_msg="<div style='left:34px; top:8px; width:245px; height:15px; position:absolute; font-weight:bold;'>"+q_title+"</div><div style='left:11px; top:28px; width:280px; height:45px; position:absolute;'>"+q_msg+"</div>";
		q_obj.innerHTML=q_msg;
		q_obj.style.visibility="visible";
		q_NOTESTIMER=setTimeout("yellowmessage('glideup')",50);
	}else if (parseInt(q_obj.style.top)>q_TARGETTOP){
//		q_obj.style.top=parseInt(q_obj.style.top)-10;
		q_obj.style.top=parseInt(q_obj.style.top)-10;
		q_obj.style.height=windowHeight()-parseInt(q_obj.style.top)-4;
		q_NOTESTIMER=setTimeout("yellowmessage('glideup')",50);
	}else{
		q_NOTESTIMER=setTimeout("yellowmessage('')",15000);
	}//end if
}//end if
}//end function

function windowHeight(){
if (window.innerHeight){
	return window.innerHeight;
}else if (document.body.clientHeight){
	return document.body.clientHeight;
}else if (document.body.offsetHeight){
	return document.body.offsetHeight;
}else{
	return 700;
}//end if
}//end function

function windowWidth(){
if (window.innerWidth){
	return window.innerWidth;
}else if (document.body.clientWidth){
	return document.body.clientWidth;
}else if (document.body.offsetWidth){
	return document.body.offsetWidth;
}else{
	return 1014;
}//end if
}//end function

function select_AddItem(q_item){
 this.options[this.options.length] = new Option(q_item,q_item);
}//end function

function select_AddItemlist(q_obj,q_list){
q_obj.addItem=select_AddItem;
if(q_list!=""){
	var q_pptlist=q_list.split("#");
	for (q_i=0;q_i<q_pptlist.length;q_i++){
		q_obj.addItem(q_pptlist[q_i]);
	}//next
}//end if
}//end function

//general
function maketable_html(q_G,q_obj){
var q_objectname=q_obj.id;
var q_html=new Array();
var q_tableid=q_obj.id + "_Table";
var q_width=parseInt(q_obj.style.width);
q_html[q_html.length]="<table id='";
q_html[q_html.length]=q_tableid;
q_html[q_html.length]="' style='font-family:Verdana; font-size:10px; width:";
q_html[q_html.length]=(q_width);
q_html[q_html.length]="px; border-collapse:collapse; border-style:none;'>\n";

for (var q_row=0;q_row<q_G.length;q_row++){
	if(q_row==0){
		q_html[q_html.length]="<tr style='background-color:#F8E85F; font-weight:bold;'>"; 
	}else if(q_row%2==0){
		q_html[q_html.length]="<tr style='background-color:#B5B8CE;'>"; 
	}else{
		q_html[q_html.length]="<tr style='background-color:#B9C7EE;'>"; 
	}//end if
	for(var i=0;i<q_G[q_row].length;i++){
		q_html[q_html.length]="<td>"+q_G[q_row][i]+"</td>";
	}//next
	q_html[q_html.length]="</tr>\n"; 
}//next
q_html[q_html.length]="</table>";
return q_html.join("");
}//end function

function getFrameByName(aname){
for(var i=0;i<window.frames.length;i++){
if (window.frames[i].name==aname){
	return window.frames[i];
}//end if
}//next
return null;
}//end function

//general
function makelist_html(q_G,q_obj){
var q_objectname=q_obj.id;
var q_html=new Array();
var q_tableid=q_obj.id + "_list";
var q_width=parseInt(q_obj.style.width);
q_html[q_html.length]="<div id='";
q_html[q_html.length]=q_tableid;
q_html[q_html.length]="' style='font-family:Verdana; font-size:10px; width:100%";
//q_html[q_html.length]=(q_width-10);
q_html[q_html.length]="; border-collapse:collapse; border-style:none;'>\n";

for (var q_row=0;q_row<q_G.length;q_row++){
	if(q_row%2==0){
		q_html[q_html.length]="<div style='background-color:#B5B8CE;'>"+q_G[q_row]+"</div>"; 
	}else{
		q_html[q_html.length]="<div style='background-color:#B9C7EE;'>"+q_G[q_row]+"</div>"; 
	}//end if
}//next
q_html[q_html.length]="</div>";
return q_html.join("");
}//end function

function option_html(v){
return replace("<option value='z_VALUE'>z_VALUE</option>","z_VALUE",v);
}//end function

function optionList_html(t){
var options="";
for(var i=0;i<t.length;i++){
options=options+option_html(t[i]);
}//next
return options;
}//end function

function optionvalue_html(v,txt){
return replace(replace("<option value='z_VALUE'>z_TXT</option>","z_VALUE",v),"z_TXT",txt);
}//end function

function optionvalueSelected_html(v,txt){
return replace(replace("<option value='z_VALUE' selected>z_TXT</option>","z_VALUE",v),"z_TXT",txt);
}//end function

function optionValueList_html(t,q_selected){
var options="";
for(var i=0;i<t.length;i++){
if(i==q_selected){
	options=options+optionvalueSelected_html(t[i][0],t[i][1]);
}else{
	options=options+optionvalue_html(t[i][0],t[i][1]);
}//end if
}//next
return options;
}//end function

//general
function scrollBottomto(q_obj,q_top){
q_obj.scrollTop=q_top-parseInt(q_obj.offsetHeight);
}//end function

//general
function scrollTopto(q_obj,q_top){
q_obj.scrollTop=q_top;
}//end function

function changeScrollbarColor(C){
if (document.all){
	document.body.style.scrollbarBaseColor=C;
}//end if
}//end function

//general
function lockDocumentScroll(){
if(IE()){
	document.body.onscroll=dontscroll; 
	//document.body.onmousemove=dontscroll; 
}else if(FX()){
	//document.body.onkeydown=disableArrowKeys; 
	window.onkeydown=disableArrowKeys; 
}//end function
return;
}//end function

//general
function dontscroll(){
if(document.body.scrollTop){
	document.body.scrollTop=0;
	document.body.scrollLeft=0;
}//end if
}//end function

function disableArrowKeys(e){
var ev = e||event;
var key = ev.which||ev.keyCode;
var esc = (key==37||key==38||key==39||key==40);
if(esc==true && ev.preventDefault){
	ev.preventDefault();
	return false;
}else{
	return true;
}//end if
}//end function

//general
function getRowtop(q_table,q_row){
var q_top=0;
for(var q_i=0;q_i<=q_row;q_i++){
if(q_i>=q_table.rows.length){
	return q_top;
}else{
	q_top=q_top+q_table.rows[q_i].offsetHeight;
}//end if
}//next
return q_top;
}//end function

function keyhandlerF5(){
if(window.event && window.event.keyCode == 116){ 
	// Capture and remap F5
	window.event.keyCode = 505;
}//end if
if(window.event && window.event.keyCode == 505){ 
	// New action for F5
	return false;// Must return false or the browser will refresh anyway
}//end if
}//end function
function disablekeyF5(){
document.onkeydown = keyhandlerF5;
}//end function

function touchbut(q_theimage){
q_ix=(q_theimage.src).toString().lastIndexOf('_over');
if(q_ix>0){
   q_theimage.src=(q_theimage.src).toString().slice(0,q_ix)+'.gif';
}else{
	q_ix=(q_theimage.src).toString().lastIndexOf('_down');
	if(q_ix>0){
	   q_theimage.src=(q_theimage.src).toString().slice(0,q_ix)+'.gif';
	}else{
	   q_ix=(q_theimage.src).toString().lastIndexOf('.gif');
	   q_theimage.src=(q_theimage.src).toString().slice(0,q_ix)+'_over.gif';
	}//end if
}//end if

}//end function

function downbut(q_theimage){
q_ix=(q_theimage.src).toString().lastIndexOf('_down.gif');
if(q_ix>0){
   q_theimage.src=(q_theimage.src).toString().slice(0,q_ix)+'_over.gif';
}else{
	q_ix=(q_theimage.src).toString().lastIndexOf('_over.gif');
	if(q_ix>0){
	   q_theimage.src=(q_theimage.src).toString().slice(0,q_ix)+'_down.gif';
	}//end if
}//end if

}//end function

function isOKENV(q_str){
//testing if environment combination is supported
var q_t=false;
q_t=q_t || (/(WIN\/MZ\/WM\/ONDEMAND)$/.test(q_str));
q_t=q_t || (/(WIN\/OP\/WM\/ONDEMAND)$/.test(q_str));
q_t=q_t || (/(MAC\/OP\/WM\/DIRECT)$/.test(q_str));
q_t=q_t || (/(MAC\/[A-Z]*\/WM\/ONDEMAND)$/.test(q_str));
q_t=q_t || (/(LINUX\/[A-Z]*\/WM\/[A-Z]*)$/.test(q_str));
q_t=q_t || (/(LINUX\/[A-Z]*\/QT\/[A-Z]*)$/.test(q_str));
q_t=q_t || (/([A-Z]*\/[A-Z]*\/WM\/SMIL)$/.test(q_str));
q_t=q_t || (/([A-Z]*\/[A-Z]*\/RM\/INSTREAM)$/.test(q_str));
q_t=q_t || (/([A-Z]*\/[A-Z]*\/QT\/INSTREAM)$/.test(q_str));
q_t=q_t || (/(MAC\/[A-Z]*\/[A-Z]*\/INSTREAM)$/.test(q_str));
q_t=q_t || (/(LINUX\/[A-Z]*\/[A-Z]*\/INSTREAM )$/.test(q_str));
q_t=q_t || (/(MAC\/[A-Z]*\/[A-Z]*\/ONDEMAND)$/.test(q_str));
q_t=q_t || (/(LINUX\/[A-Z]*\/[A-Z]*\/ONDEMAND)$/.test(q_str));
return !q_t;
}//end function

//--DOM------
function div(q_name){
return document.getElementById(q_name);
}//end function

function divArray(q_name){
var q_ix=0;
var q_arr=new Array();
while(q_ix>-1){
	q_obj=document.getElementById(q_name+q_ix);
	if(q_obj){
		q_arr[q_arr.length]=q_obj;
		q_ix=q_ix+1;
	}else if(q_ix>1){
		return q_arr;
	}else{
		q_ix=q_ix+1;
	}//end if
}//end while
return null;
}//end function

function hidelayer(q_layer){
var q_obj=document.getElementById(q_layer);
if(q_obj){
	q_obj.style.visibility="hidden";
}//endif
}//end function

function showlayer(q_layer){
var q_obj=document.getElementById(q_layer);
if(q_obj){
	q_obj.style.visibility="visible";
}//endif
}//end function

function setOpacityName(objectname,value){
setOpacity(div(objectname),value);
}//end function

function getOpacityName(objectname){
return getOpacity(div(objectname));
}//end function

function setOpacity(object,value){
//object.style.width="100%";
//object.style.height="100%";
var v=(IE())?"alpha(opacity="+value+")":value/100;
var property=(IE())?"filter":"MozOpacity";
object.style[property]=v;
}//end function

function getOpacity(object){
try{
	if(IE()){
		if(object.style["filter"]==""){
			return 100;
		}else{
			return parseInt(WildFind(0,""+object.style["filter"],"alpha(opacity=*)"));
		}//end if
	}else{
		if(!isNumeric(object.style["MozOpacity"])){
			object.style["MozOpacity"]=1.0;
		}//end if
		return parseFloat(object.style["MozOpacity"])*100;
	}//end if
}catch(errObj){
	return 100;
}//end catch
}//end function

function fadeOut(objectname){
if(getOpacityName(objectname)>0){
	setFade(objectname,1400,20,"fadeout");
}//end if
}//end function

function fadeIn(objectname){
if(getOpacityName(objectname)<100){
setFade(objectname,700,10,"fadein");
}//end if
}//end function

function getFade(objectname){
}//end function

var gAnimationFinalTimeout=0;
function setFade(objectname,time,steps,fadetype){
var step,t,v,cmd,level,startOffset;
if(gAnimationFinalTimeout>now()){
	startOffset=gAnimationFinalTimeout-now();
}else{
	startOffset=0;
}//end if

for(var step=0;step<=steps;step=step+1){
t=time*step/steps;
if(step==steps){
	level=100;
}else{
	level=Math.floor(100*step/steps+0.5);
}//end if
if(fadetype=="fadeout"){
	v=100-level;
}else{
	v=level;
}//end if
cmd="setOpacityName('"+objectname+"',"+v+")";
setTimeout(cmd,startOffset+t);
}//next
gAnimationFinalTimeout=now()+startOffset+t;
}//end function

function deselectAll(){
if(document.selection){
	document.selection.empty();
}else if (window.getSelection){
	window.getSelection().removeAllRanges();
}//end if
}//end function

function selectElement(id){
if(document.selection){
	var range = document.body.createTextRange();
	range.moveToElementText(document.all[id]);
	range.select();
}else if (window.getSelection()){
	var range = document.createRange();
	range.selectNodeContents(document.getElementById(id));
	var selection = window.getSelection();
	selection.removeAllRanges();
	selection.addRange(range);
}//end if
}//end function

function doGetCaretPosition(ctrl){
var CaretPos = 0;	// IE Support
if (document.selection){
ctrl.focus ();
	var Sel = document.selection.createRange();
	Sel.moveStart ('character', -ctrl.value.length);
	CaretPos = Sel.text.length;
}else if (ctrl.selectionStart || ctrl.selectionStart == '0'){
	CaretPos = ctrl.selectionStart;
}//end if
return (CaretPos);
}//end function

function setCaretPosition(ctrl, pos){
if(ctrl.setSelectionRange){
	ctrl.focus();
	ctrl.setSelectionRange(pos,pos);
}else if (ctrl.createTextRange){
	var range = ctrl.createTextRange();
	range.collapse(true);
	range.moveEnd('character', pos);
	range.moveStart('character', pos);
	range.select();
}//end if
}//end function

function limitMaxlength(obj){
if(obj.getAttribute){
	var maxLength=parseInt(obj.getAttribute("maxlength"));
	if(obj.value.length>maxLength){
		obj.value=obj.value.substring(0,maxLength);
	}//end if
}//end if
}//end function

function setDivContent(q_Label,q_t1){
	if(document.getElementById){
        q_myTarget = document.getElementById(q_Label);
		if (q_myTarget){
        q_myTarget.innerHTML = q_t1;
		}//end if
	}else if(document.all){
		document.all[q_Label].innerHTML=q_t1;
	}//end if
}//end function

function dynframe(PRODUCER_ID, SESSIONID){
//Some antivirus programs confuse the a valid i-frame to be malicious content.
return "<IF"+"RAME id='iframesender'  name='iframesender' frameborder=0 width=360 height=270 src='a_refreshsession.asp?PRODUCER_ID=" +PRODUCER_ID +"&SESSIONID="+ SESSIONID +"' scrolling='no' style=''> </ifr"+"ame>";
}//end function

function relateMe(){
	this.relatedElement.value = this.value;
}//end function

function getPropertyValueFromCss(className, propertyName){
var cssStyle=getCssStyle(className);
if(cssStyle){
	return cssStyle[propertyName];
}else{
	return null;
}//end if
}//end function

function getCssStyle(className){
var toReturn = null;
for (var i = 0; i < document.styleSheets.length; i++){
    var cssRules = getCssRules(document.styleSheets[i]);
    if (cssRules){
        for (var j = 0; j < cssRules.length; j++){
            if (isSelectedCssRule(cssRules[j].selectorText,className)){
                toReturn = cssRules[j].style;
				return toReturn;
            }//end if
        }//next
    }//end if
}//next
return toReturn;
}//end function

function getCssRules(styleSheet){
try{
	if (styleSheet.rules){// IE
	    return styleSheet.rules;
	}else if (styleSheet.cssRules){// Mozilla and others
		return styleSheet.cssRules;
	}else{
		return null;
	}//end if
}catch(errObj){
	logga("getCssRules:"+errObj.description);
	return null;
}//end catch
}//end function

function listCssStyle(className){
var toReturn = null;
var n=new Array();
n[n.length]="listCssStyle";
for (var i = 0; i < document.styleSheets.length; i++){
    var cssRules = getCssRules(document.styleSheets[i]);
    if (cssRules){
        for (var j = 0; j < cssRules.length; j++){
            n[n.length]=cssRules[j].selectorText;
        }//next
    }else{
	return n;
    }//end if
}//next
return n;
}//end function

function isSelectedCssRule(ruleSelectorText,className){
return equal(ruleSelectorText,className)||equal(ruleSelectorText,"."+className)||equal(ruleSelectorText,"#"+className);
}//end function

function getOpacityFromCSS(className){
try{
	if(IE()){
		cssvalue=getPropertyValueFromCss("div.imagezoomtitlebg", "filter");
		return parseFloat(WildFind(0,cssvalue,"opacity=*)"));
	}else{
		cssvalue=getPropertyValueFromCss("div.imagezoomtitlebg", "opacity");
		if(cssvalue){
			return 100*parseFloat(cssvalue);
		}else{
			cssvalue=getPropertyValueFromCss("div.imagezoomtitlebg", "MozOpacity");
			return 100*parseFloat(cssvalue);
		}//end if
	}//end if
}catch(errObj){
	return 100;
}//end catch
}//end function

function appendHTML(destinationnode,htmlstring){
var e=document.createElement("div");
e.innerHTML=htmlstring;
var x=e.childNodes;
for(var i=0;i<x.length;i++){
	destinationnode.appendChild(e);
}//next
e=null;
}//end function

// This function inserts newNode after referenceNode
function insertAfter(referenceNode,newNode){
    referenceNode.parentNode.insertBefore(newNode,referenceNode.nextSibling);
}//end function

function getVideoBackgroundColor(){
str=getPropertyValueFromCss("video", "backgroundColor");
if(str==null){
	return "000000";
}else if(startswith(str,"rgb(")){
	return eval(str);
}else if(startswith(str,"#")){
	return mid(str,1,str.length);
}else{
	return str;
}//end if
}//end function

function rgb(r,g,b){
value=r+256*g+65536*b;
var hex_string = "";
for (var hexpair = 0; hexpair < 3; hexpair++) {
	var myByte = value & 0xFF;            // get low byte
	value >>= 8;                        // drop low byte
	var nybble2 = myByte & 0x0F;          // get low nybble (4 bits)
	var nybble1 = (myByte >> 4) & 0x0F;   // get high nybble
	hex_string += nybble1.toString(16); // convert nybble to hex
	hex_string += nybble2.toString(16); // convert nybble to hex
}//next
return hex_string.toUpperCase();
}//end function

//--MATH------------------------
function rnd(){
return Math.random();
}//end function

function rndint(range){
return Math.floor(Math.random()*range);
}//end function

function equal(a,b){
return a.toLowerCase()==b.toLowerCase();
}//end function

//EVENTLIST common code-----------------------------
Array.prototype.insert = function(q_index,q_item) {
   this.splice(q_index,0,q_item);
   return this;
}//end function

Array.prototype.insertArray = function(q_index,q_array) {
if(q_array.length>0){
	for(var ix=q_array.length-1;ix>=0;ix=ix-1){
	   this.insert(q_index,q_array[ix]);
	}//next
}//end if
return this;
}//end function

Array.prototype.copy = function(){
var newCopy=new Array();
for(var ix=0;ix<this.length;ix=ix+1){
   newCopy.append(this[ix]);
}//next
return newCopy;
}//end function

Array.prototype.append = function(q_item) {
   this[this.length]=q_item;
   return this;
}//end function

Array.prototype.remove = function(q_index) {
   this.splice(q_index,1);
   return this;
}//end function

//public
Array.prototype.removeItem = function(q_col0){
for (var q_r=0;q_r<this.length;q_r++){
	if(this[q_r][0]==q_col0){
		this.remove(q_r);
		return this;
	}//end if
}//next
return this;
}//end function

//public
Array.prototype.removeItems = function(itemList){
var iname=itemList.split(",");
for (var q_r=0;q_r<iname.length;q_r++){
	this.removeItem(iname[q_r]);
}//next
return this;
}//end function

Array.prototype.escape = function() {
   return escape(this.join("\t"));
}//end function

function unescapeArray(str){
   return unescape(str).split("\t");
}//end function

Array.prototype.xorsum = function() {
var s=this.join("");
var sum=0;
for(var ix=0;ix<s.length;ix=ix+1){
   sum=(sum ^ s.charCodeAt(ix));
}//next
return sum;
}//end function

Array.prototype.seek = function(findstr) {
for(var ix=this.length-1;ix>=0;ix=ix-1){
	if(this[ix]==findstr){
		return ix;
	}//end if
}//next
return -1;
}//end function

Array.prototype.seekCol = function(col,findstr){
for(var ix=this.length-1;ix>=0;ix=ix-1){
	if(this[ix][col]==findstr){
		return ix;
	}//end if
}//next
return -1;
}//end function

function split(a,b){
return a.split(b);
}//end function

function Ubound(arr){
return arr.length-1;
}//end function

function LCase(a){
return a.toLowerCase();
}//end function

function UCase(a){
return a.toUpperCase();
}//end function

function myCdbl(t){
var x=parseFloat(t);
if(!isNaN(x)){
	return x;
}else{
	return 0;
}//end if
}//end function

function getTarget(astr){
if(astr.indexOf("setslide(")>-1){
	return 1;
}else if(astr.indexOf("interaction('animate'")>-1){
	return 1;
}else if(astr.indexOf("setvideo('")>-1){
	return 4;
}else if(astr.indexOf("interaction('advertisement'")>-1){
	return 3;
}else if(astr.indexOf("interaction('addcomment'")>-1){
	return 3;
}else if(astr.indexOf("interaction(")>-1){
	return 2;
}else{
	ix=astr.lastIndexOf(",");//find last parameter
	if(ix>-1){
		//return parseInt(WildFind(0,astr.substr(ix,5),",*)"));
		return parseInt(replace(WildFind(0,astr.substr(ix,5),",*)"),"'",""));
	}else{
		return 0;
	}//end if
}//end if
}//end function

function eventlist_getCliparray(eventlist,q_pos){
var q_cmd=eventlist_getTimecmd(eventlist,q_pos,4);
if(q_cmd==""){
	return null;
}else{
	return js2array(q_cmd);
}//end if
}//end function

function eventlist_getTimecmd(eventlist,q_tpos,q_target){
var q_evix=eventlist_getTimecmdindex(eventlist,q_tpos,q_target);
if (q_evix>-1){
	return eventlist[q_evix][1];
}else{
	return "";
}//end if
}//end function

function eventlist_getTimecmdindex(eventlist,q_tpos,q_target){
var q_evix=eventlist.length-1;
while (q_evix>=0){
 if (q_tpos>=getEventtime(eventlist,q_evix)){
 	if (q_target==getTarget(eventlist[q_evix][1])){
		return q_evix;
   }//end if
}//end if
q_evix=q_evix-1;
}//loop
return -1;
}//end function

function eventlist_getCmdAt(eventlist,q_time,q_target){
var q_evix=eventlist.length-1;
while (q_evix>0){
 	if (q_time>getEventtime(eventlist,q_evix)){
		return "";
	}else if(q_time==getEventtime(eventlist,q_evix)){
	 	if (q_target==getTarget(eventlist[q_evix][1])){
			return eventlist[q_evix][1];
		}else{
			return "";
		}//end if
   }//end if
q_evix=q_evix-1;
}//loop
return "";
}//end function

function eventlist_getEventduration(eventlist,q_evix){
var q_target=getTarget(eventlist[q_evix][1]);
var q_ix=q_evix+1;
while (q_ix<eventlist.length){
 	if (q_target==getTarget(eventlist[q_ix][1])){
		return eventlist[q_ix][0]-eventlist[q_evix][0];
   }//end if
q_ix=q_ix+1;
}//loop
return getEndtime(eventlist)-eventlist[q_evix][0];
}//end function

function eventlist_getTrack(eventlist,q_target){
var track=new Array();
for (var q_i=1;q_i<eventlist.length;q_i++){
	if (q_target==getTarget(eventlist[q_i][1])){
		track[track.length]=eventlist[q_i];
	}//end if
}//next
return track;
}//end function

function endOfVideo(eventlist){
//Find the end of the video
var track=eventlist_getTrack(eventlist,4);
if(track.length>0){
	var lasttrack=track[track.length-1];
	var q_parsed=js2array(lasttrack[1]);
	if(getDur(q_parsed)==gUnknownDuration){
		return gUnknownDuration;
	}else{
		return parseFloat(lasttrack[0])+getDur(q_parsed);
	}//end if
}else{
	return 0;
}//end if
}//end function

function getDur(q_parsed){
return calcDuration(parseFloat(q_parsed[3],10),parseFloat(q_parsed[2],10));
}//end function
//public

function calcDuration(a,b){
if(a==gUnknownDuration||b==gUnknownDuration){
	return gUnknownDuration;
}else{
	return parseFloat(a)-parseFloat(b);
}//end if
}//end function

function getEventtime(eventlist,q_ix){
return parseFloat(eventlist[q_ix][0]);
}//end function

function getStarttime(eventlist){
return parseFloat(eventlist[0][0]);
}//end function

function getEndtime(eventlist){
	if(eventlist.length){
		return parseFloat(eventlist[eventlist.length-1][0]);
	}else{
		return -1;
	}//end if
}//end function

//--DEBUG---------------------
//invoke error handler at an appropriate place
//window.onerror = window_onerror;
function window_onerror(msg, url, line){
doReportError(msg, url, line);
return true;
}//end function
function window_silentreport(msg, url, line){
doReportError(msg, url, line);return 0;
//Just log the runtime error
var qs="?msg="+escape(msg)+"&line="+line+"&url="+escape(url);
window.open(gHOMEBASE+"a_silenterror.asp"+qs,"SilentError","dependent,top=1228,left=283,width=450,height=420");
return true;
}//end function
function window_error_defaulthandler(msg, url, line){
return false;
}//end function

function report_error(msg, url, line){
//ugly error report...
   var q_p="";
   q_p=q_p+"<FORM action='mailto:richard.zembron@abiliteam.se' METHOD='post' ENCTYPE='text/plain'>";
   q_p=q_p+"";
   q_p=q_p+"<b>Report Error:</b><br>";
   q_p=q_p+"You can help us to correct an error by reporting it here:<br><br> ";
   q_p=q_p+"<div align=right>";
   q_p=q_p+"Your Email: <INPUT type=text size=50 NAME='email' VALUE=''><br>";
   q_p=q_p+"<textarea rows=4 cols=52 NAME=action>Action that caused the error:</textarea><br>";
   q_p=q_p+'Error:<INPUT type=text SIZE=50 NAME=message VALUE="'+ msg + '"><br>';
   q_p=q_p+"URL:<INPUT type=text SIZE=50 NAME='url' VALUE='" + url + "'><br>";
   q_p=q_p+"<INPUT type=hidden NAME='line' VALUE='"+ line + "'>";
   q_p=q_p+"Browser:<INPUT SIZE=50 NAME='version' VALUE='" + navigator.userAgent + "'><br>";
   q_p=q_p+"<INPUT TYPE='button' VALUE='Debug' onclick='doDebug();'>";
   q_p=q_p+"<INPUT TYPE='submit' VALUE='Report Error'><br>";
   q_p=q_p+"</div>";
   q_p=q_p+"</FORM>";
   return q_p;  
}//end function

function debugeval(q_str){
return eval(q_str);
}//end function
function inf(what){
var sep="";
var output="";
for (var i in what){
	output += i+sep;
	sep=", ";
}//next
if(output==""){
	try{
		output=what;
	}catch(errObj){
	}//end catch
}//end if
return(output);
}//end function

function inf2(what){
var output="";
for (var i in what){
	output = output+i+"\t"+what[i]+"\n";
}//next
if(output==""){
	try{
		output=what;
	}catch(errObj){
	}//end catch
}//end if
return(output);
}//end function

function debugobject(objectname){
var what=eval(objectname);
var output = '';
for (var i in what){
output += "<span title='"+debugshortvalue(objectname+"."+i)+"'>"+i+ "</span>, ";
}//next
return(output);
}//end function
function debugshortvalue(q_a1){
var q_title=debugvalue(q_a1)+" ";
//return " "+q_title;
if(q_title.length<600){
	return q_title;
}else{
	return q_title.substr(0,600)+"...";
}//end if
}//end function
function debugvalue(q_a2){
try{
	return eval(q_a2);
}catch(errObj){
	return q_a2;
}//end catch
}//end function

function showIframesender(){
div("l_keepalive").style.visibility="visible";
div("l_keepalive").style.left=div("WinContentLibrary").offsetLeft;
div("l_keepalive").style.top=div("WinContentLibrary").offsetTop;
div("l_keepalive").style.width=div("WinContentLibrary").offsetWidth;
div("l_keepalive").style.height=div("WinContentLibrary").offsetHeight;
}//end if

 // Get a list of all elements in the document
function findHighest(){
	var h=0;
	var t=0;
	var ht=0;
	var maxht=0;
    var list = document.getElementsByTagName("*");
    for (var i=0; i<list.length; i++) {
        // Get element
        var element = list[i];
		if (element){
			h=element.offsetHeight;
			t=element.offsetTop;
			if(h){
				if(t){
					ht=h+t;
					if(maxht<ht){
						maxht=ht;
						maxname=element.id;
					}
				}
			}
		}
    }//next
	return maxname +":"+maxht;
}//end function

function divi(aname){
return HTMLEncode(div(aname).innerHTML);
}//end function

function grid(q_arr){
var c="";
var q_sep="";
for(var q_row=0;q_row<q_arr.length;q_row++){
	if(typeof(q_arr[q_row])=="string"){
		if(q_arr[q_row]){
			c=c+q_sep+q_arr[q_row];
		}else{
			c=c+q_sep+"[undefined]";
		}//end if
	}else{
		for(var q_col=0;q_col<q_arr[q_row].length;q_col++){
			if(q_arr[q_row][q_col]>=""){
				if(q_arr[q_row][q_col]=="0"){
					c=c+q_sep+"0";
				}else	if(q_arr[q_row][q_col]==""){
					c=c+q_sep+"&quot;&quot;";
				}else	if(q_arr[q_row][q_col]==" "){
					c=c+q_sep+"[SPACE]";
				}else{
					c=c+q_sep+q_arr[q_row][q_col];
				}//end if
			}else{
				c=c+q_sep+"[undefined]";
			}//end if
			q_sep="</td><td>";
		}//next
	}//end if
	q_sep="</td></tr><tr><td>&nbsp;";
}//next
return "<table style='width:200px;border-collapse:collapse; font-size:11px;' border=1 cellpadding=2><tr><td>"+c+"</td></tr></table>";
}//end function

function almostEqual(a,b){
return (Math.abs(a-b)<1);
}//end function

//--ACTION COMMANDS-----------------------------------------------
function smartendspace(q_str,q_inter){
var q_list=",chapter,infotext,comment,notes,advertisement,pollyesno,pollmultiple,resulttext,resultgraph,resultpercent,";
if(q_list.indexOf(","+q_inter+",")>-1){
	return endspace(q_str);
}else{
	return q_str;
}//end if
}//end function

function isVideocmd(q_str){
return (startswith(q_str,"setvideo("));
}//end if

function videoCmdstr(q_URL,q_markin,q_markout){
if(parseFloat(q_markout)>parseFloat(q_markin)){
	return "setvideo('"+q_validprotocol(q_URL)+"',"+parseFloat(q_markin)+","+parseFloat(q_markout)+",4)";
}else{
	return "setvideo('"+q_validprotocol(q_URL)+"',"+parseFloat(q_markin)+","+gUnknownDuration+",4)";
}//end if
}//end function

//--ABILITY SPECIAL------------------
function getSessionId(){
try{
	return SESSIONID;
}catch(errObj){
	return "";
}//end catch
}//end function

function setStickyNote(q_str){
if(q_obj=document.getElementById("StickyNote")){
	q_obj.innerHTML=q_str;
	q_obj.style.visibility="visible";
}//end if
}//end function

function removeUnusedRadioitems(q_radio){
if(!include(45)){
		q_radio.removeItem("Animate Slide");
}//end if
if(!include(41)){
		q_radio.removeItem("Database");
}//end if
if(!include(26)){
		q_radio.removeItems("Web Page,Open URL,InfoURL,InfoHtml");
}//end if
if(!include(35)){
		q_radio.removeItem("Chapter");
}//end if
if(!include(43)){
	q_radio.removeItems("Poll Yes/No,Poll Multiple,ResultText,ResultGraph,PercentGraph");
}//end if
if(!include(34)){
	q_radio.removeItems("Flash,Excel,Word,PDF,Image,InfoPicture,Advertisement");
}//end if
if(!include(51)){
	q_radio.removeItems("Email,Chat,Comment");
}//end if
if(!include(61)){
	q_radio.removeItems("Flip,Goto,Fullscreen");
}//end if
if(!include(62)){
	q_radio.removeItems("Script");
}//end if
}//end function

function include(ix){
try{
	return (gExc.indexOf(","+ix+",")>-1);
}catch (errObj){
	alert("Include "+ix+" not activated"+errObj.message);
	return true;
}//end catch
}//end function

function FET(q_a){
return (q_a<=30);
}//end function

function isUndefined(a){
return typeof(a)=="undefined";
}//end function

var gExtrawindow;
function doNav(q_opennew,q_page,q_producerid,q_foldername){
if(typeof(gExc)!="undefined"){ 
	if(include(80)&&q_page=="a_projectpage"){
	q_page="bthbooking";
	}//end if
}//end if
var q_URL;
if(q_page=="a_new"){
	q_URL=gHOMEBASE+"a_main.asp?SELECTEDTAB=0&PRODUCER_ID="+q_producerid+"&FOLDERNAME="+q_foldername+"&SESSIONID="+getSessionId();
}else if(q_page=="speed"){
	q_URL="../../../show/"+q_producerid+"/"+q_foldername+"/speed.asp?PRODUCER_ID="+q_producerid+"&FOLDERNAME="+q_foldername+"&SESSIONID="+getSessionId()+"&MENU="+(q_opennew==1?0:1);
	if(q_opennew==1){
		gExtrawindow=window.open(q_URL,'Mainshow', 'resizable,dependent,top=0,left=0,width=996,height=592');
		return;
	}//end if
}else{
	q_URL=gHOMEBASE+q_page+".asp?PRODUCER_ID="+q_producerid+"&FOLDERNAME="+q_foldername+"&SESSIONID="+getSessionId();
}//end if
if(q_opennew==1){
	if(q_page=="encodermanager"){
		gExtrawindow=window.open(q_URL,'Extra','resizable,dependent,top=0,left=0,width=1014,height=536');
	}else	if(q_page=="splitshow"){
		gExtrawindow=window.open(q_URL,'Splitshow','resizable,dependent,scrollbars,top=0,left=0,width=1014,height=711');
	}else{
		gExtrawindow=window.open(q_URL,'Extra','resizable,dependent,top=0,left=0,width=1014,height=711');
	}//end if
	gExtrawindow.focus();
}else{
	if(q_page=="livecontrol"){
		if(window.opener){
			if((window.name=="Extra")){
				if(window.opener.closed){
					//window.name="Main";//doesnt change external name reference...
				}else{
					window.opener.focus();
					return 0;
				}//end if
			}//end if
		}//end if
	}//end if
	document.location.href=q_URL;
}//end if
}//end function


function buttonlogoff_Click(me){
var agree=confirm("Are you sure you want to log off?");
if (agree){
   if (agree!==""){
      document.form1.action.value="logoff";
      document.form1.submit();
   }//end if
}//end if
}//end function

function doExit(){
window.close();
}//end function

function doHelp(){
if(FET(30)){
window.open(gHOMEBASE+"ability_usermanual_rev01.pdf","AbilityHelp","resizable,dependent,top=0,left=380,width=624,height=680");
}else{
window.open(gHOMEBASE+"a_streamblasterhelp.pdf","StreamblasterHelp","resizable,dependent,top=0,left=380,width=624,height=680");
}//end if
}//end function

function doMasterOverview(p,f){
q_URL=gHOMEBASE+"a_overview.asp?FOLDERNAME="+f+"&SHOWFOLDER="+p+"/"+f+"&PRODUCER_ID="+p+"&SESSIONID="+getSessionId();
if(FET(30)){
	window.open(q_URL,'MasterOverview','resizable,dependent,top=128,left=283,width=700,height=300').focus();
}else{
	document.location.href=q_URL;
}//end if
}//end function

function doViewerHelp(p,f){
q_URL=gHOMEBASE+"a_viewerhelp.asp?FOLDERNAME="+f+"&SHOWFOLDER="+p+"/"+f+"&PRODUCER_ID="+p+"&SESSIONID="+getSessionId();
if(FET(30)){
	window.open(q_URL,'AbilityAbout','resizable,dependent,top=128,left=283,width=450,height=420').focus();
}else{
	document.location.href=q_URL;
}//end if
}//end function

function doAbout(q_PRODUCER_ID){
q_URL=gHOMEBASE+"abilityabout.asp?PRODUCER_ID="+q_PRODUCER_ID+"&SESSIONID="+getSessionId();
if(FET(30)){
	window.open(q_URL,'AbilityAbout','resizable,dependent,top=128,left=283,width=450,height=420').focus();
}else{
	document.location.href=q_URL;
}//end if
}//end function

function doAboutPlus(q_PRODUCER_ID){
q_URL=gHOMEBASE+"aboutplus.asp?PRODUCER_ID="+q_PRODUCER_ID+"&SESSIONID="+getSessionId();
if(FET(30)){
	window.open(q_URL,'AbilityAbout','resizable,dependent,top=128,left=283,width=450,height=420').focus();
}else{
	document.location.href=q_URL;
}//end if
}//end function

function doReportError(q_msg,q_url,q_line,p,f){
var q_URL;
if(q_msg>""){
	q_URL=gHOMEBASE+"a_reporterror.asp"+"?msg="+escape(q_msg)+"&line="+q_line+"&url="+escape(q_url);
}else{
	q_URL=gHOMEBASE+"a_reporterror.asp?FOLDERNAME="+f+"&PRODUCER_ID="+p+"&SESSIONID="+getSessionId();
}//end if
if(FET(30)){
	window.open(q_URL,'ReportError','resizable,dependent,top=128,left=283,width=450,height=420').focus();
}else{
	document.location.href=q_URL;
}//end if
}//end function

function doPreview(q_producerid,q_foldername){
alert("TODO:preview and mainshow");
//window.open('abilityabout.asp','AbilityAbout','resizable,dependent,top=128,left=283,width=460,height=345');
}//end function

function openHttpUpload(PRODUCER_ID,INPUTTEMPLATE,MEDIAFORMAT,SERVER,SESSIONID){
var q_URL;
if(SESSIONID>""){
	q_URL="http://z_SERVER/ability/program/livepro/admin/httpupload.asp?PRODUCER_ID=z_PRODUCER_ID&SESSIONID=z_SESSIONID&ABILITYSERVER=z_ABILITYSERVER&INPUTTEMPLATE=z_INPUTTEMPLATE&MEDIAFORMAT=z_MEDIAFORMAT";
	q_URL=replace(q_URL,"z_SESSIONID",SESSIONID);
}else{
	q_URL="http://z_ABILITYSERVER/ability/program/livepro/admin/httpuploadlogin.asp?PRODUCER_ID=z_PRODUCER_ID&TARGETURL=http%3A%2F%2Fz_SERVER%2Fability%2Fprogram%2Flivepro%2Fadmin%2Fhttpupload.asp%3FPRODUCER_ID%3Dz_PRODUCER_ID%26SESSIONID%3Dz_SESSIONID%26ABILITYSERVER%3Dz_ABILITYSERVER%26INPUTTEMPLATE%3Dz_INPUTTEMPLATE%26MEDIAFORMAT%3Dz_MEDIAFORMAT";
}//end if
	q_URL=replace(q_URL,"z_SERVER",SERVER);
	q_URL=replace(q_URL,"z_PRODUCER_ID",PRODUCER_ID);
	q_URL=replace(q_URL,"z_ABILITYSERVER",document.location.host);
	q_URL=replace(q_URL,"z_INPUTTEMPLATE",INPUTTEMPLATE);
	q_URL=replace(q_URL,"z_MEDIAFORMAT",MEDIAFORMAT);
	window.open(q_URL,'httpUpload'+parseInt(rnd()*100),'dependent,top=128,left=283,width=500,height=400').focus();
}//end function

function openConferenceBooking(PRODUCER_ID,INPUTTEMPLATE,MEDIAFORMAT,SERVER,SESSIONID){
var q_URL;
if(SESSIONID>""){
	q_URL="http://z_SERVER/ability/program/livepro/admin/conferencebooking.asp?PRODUCER_ID=z_PRODUCER_ID&SESSIONID=z_SESSIONID&ABILITYSERVER=z_ABILITYSERVER&INPUTTEMPLATE=z_INPUTTEMPLATE&MEDIAFORMAT=z_MEDIAFORMAT";
	q_URL=replace(q_URL,"z_SESSIONID",SESSIONID);
	document.location.href=q_URL;
}else{
	q_URL="http://z_ABILITYSERVER/ability/program/livepro/admin/conferencebookinglogin.asp?PRODUCER_ID=z_PRODUCER_ID&TARGETURL=http%3A%2F%2Fz_SERVER%2Fability%2Fprogram%2Flivepro%2Fadmin%2Fhttpupload.asp%3FPRODUCER_ID%3Dz_PRODUCER_ID%26SESSIONID%3Dz_SESSIONID%26ABILITYSERVER%3Dz_ABILITYSERVER%26INPUTTEMPLATE%3Dz_INPUTTEMPLATE%26MEDIAFORMAT%3Dz_MEDIAFORMAT";
}//end if
	q_URL=replace(q_URL,"z_SERVER",SERVER);
	q_URL=replace(q_URL,"z_PRODUCER_ID",PRODUCER_ID);
	q_URL=replace(q_URL,"z_ABILITYSERVER",document.location.host);
	q_URL=replace(q_URL,"z_INPUTTEMPLATE",INPUTTEMPLATE);
	q_URL=replace(q_URL,"z_MEDIAFORMAT",MEDIAFORMAT);
	window.open(q_URL,'confLogin'+parseInt(rnd()*100),'dependent,top=128,left=283,width=500,height=400').focus();
}//end function

function hidenote(){
q_Obj=document.getElementById("StickyNote");
try{
	q_Obj.filters[0].Apply();
	q_Obj.style.visibility="hidden";
	q_Obj.filters[0].Play();
}catch(errObj){
	q_Obj.style.visibility="hidden";
}//catch
}//end function

function getEncoderHTML(q_STREAMID,typename){
if(q_STREAMID==0){
	//localencoder
if(typename=="push"){
//	return '<OBJECT ID="enctrl'+q_STREAMID+'" width=360 height=270 CLASSID="CLSID:D4CC9059-0AAB-4888-87DA-3ED4EF1CFEE2" CODEBASE="localencoder.CAB#version=2,0,0,61"></OBJECT>';
	return '<OBJECT ID="enctrl'+q_STREAMID+'" width=360 height=270 CLASSID="CLSID:1E622D9A-00A7-454E-AF36-AD08C9617530" CODEBASE="localencoderpush.CAB#version=2,0,0,63"></OBJECT>';
}else{
	return '<OBJECT ID="enctrl'+q_STREAMID+'" width=360 height=270 CLASSID="CLSID:C06BD467-D513-4ED5-998B-DACB30A4BC6E" CODEBASE="localencoder.CAB#version=2,0,0,49"></OBJECT>';
}//end if

}else{
	//encodermanager unit
	return '<OBJECT ID="enctrl'+q_STREAMID+'" width=202 height=395 CLASSID="CLSID:37F11BCA-233E-4245-B6CF-8634822635FF" CODEBASE="EncoderManagerCtrl.CAB#version=2,0,0,17"></OBJECT>';
}//end if
}//end function

function initFileUploads(){
var W3CDOM = (document.createElement && document.getElementsByTagName);
if (W3CDOM){
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='pix/button_select.gif';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++){
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		x[i].onchange = x[i].onmouseout = function (){this.relatedElement.value = this.value;}
	}//next
}//end if
}//end function

function addMenuWindowHelp(q_menulist){
if(!include(96)){
	var windowMenu="Window,Pro_ject Page,<hr>,_Design,_Live Control,_Timeline Editor,<hr>,Coverp_age,_Preview Show,<hr>,_Report Manager,Encoder Monitor";
}else{//Movieweb simplifications
	var windowMenu="Window,Pro_ject Page,<hr>,_Preview Show,<hr>,_Report Manager";
}//end if
if(!include(49)){
		windowMenu=replace(windowMenu,",_Live Control","");
}//end if
if(!include(72)){
		windowMenu=replace(windowMenu,",_Timeline Editor","");
}//end if
if(!include(41)){
		windowMenu=replace(windowMenu,",_Report Manager","");
}//end if
if(!include(56)){
		windowMenu=replace(windowMenu,",Encoder Monitor","");
}//end if

q_menulist[q_menulist.length]=windowMenu.split(",");
q_menulist[q_menulist.length]=new Array("Help","Ability Help","Report Error","<hr>","About Ability","<hr>","About PlusModules");
return;
}//end function

function setMenuLivemode(gMenustrip,q_pagename,CHANNEL){
gMenustrip.disableMenuitem(q_pagename,"YouAreHere");
if(CHANNEL=="2" || CHANNEL=="7" || !include(72)){ 
		gMenustrip.disableMenuitem("Timeline Editor","RequiresOndemandShow");
}//end if
if(CHANNEL=="4" || !include(49)){ 
		gMenustrip.disableMenuitem("Encoder Monitor","RequiresLiveShow");
		gMenustrip.disableMenuitem("Live Control","RequiresLiveShow");
}//end if

}//end function

function doOpenshow(q_URL,q_STREAMID,q_width,q_height,q_RESIZABLE){
q_resizable=(q_RESIZABLE=="1")?"resizable,":"";
q_URL=q_URL.replace("z_STREAMID",q_STREAMID);
if(FET(30)){
	window.open(q_URL,"Mainshow",q_resizable+"top=0,left=0,width="+q_width+",height="+q_height).focus();
}else{
	document.location.href=q_URL;
}//end if
}//end function

function caseWindowHelp(q_openNew,q_itemname,q_PRODUCER_ID,q_FOLDERNAME){
switch (q_itemname){
case "Close":doNav(q_openNew,"a_main",q_PRODUCER_ID,q_FOLDERNAME);break;
case "Preferences":doNav(q_openNew,"a_preferences",q_PRODUCER_ID,q_FOLDERNAME);break;
case "Log Off":doNav(q_openNew,"a_login",q_PRODUCER_ID,q_FOLDERNAME);break;
case "Quit":doExit();break;
case "Project Manager":doNav(q_openNew,"a_main",q_PRODUCER_ID,q_FOLDERNAME);break;
case "Project Page":doNav(q_openNew,"a_projectpage",q_PRODUCER_ID,q_FOLDERNAME);break;
case "Design":if(q_FOLDERNAME){doNav(q_openNew,"design",q_PRODUCER_ID,q_FOLDERNAME)};break;
case "Live Control":if(q_FOLDERNAME){doNav(q_openNew,"a_livecontrol",q_PRODUCER_ID,q_FOLDERNAME)};break;
case "Timeline Editor":if(q_FOLDERNAME){doNav(q_openNew,"a_eventeditor",q_PRODUCER_ID,q_FOLDERNAME)};break;
case "Coverpage":if(q_FOLDERNAME){doNav(q_openNew,"speed",q_PRODUCER_ID,q_FOLDERNAME)};break;
case "Preview Show":if(q_FOLDERNAME){doRunshow("1")};break;
case "Report Manager":if(q_FOLDERNAME){doNav(q_openNew,"a_report",q_PRODUCER_ID,q_FOLDERNAME)};break;
case "Encoder Monitor":if(q_FOLDERNAME){doNav(1,"a_encodermanager",q_PRODUCER_ID,q_FOLDERNAME)};break;
case "About PlusModules":doAboutPlus(q_PRODUCER_ID);break;
case "Ability Help":doHelp();break;
case "Report Error":doReportError("","","",q_PRODUCER_ID,q_FOLDERNAME);break;
case "About Ability":doAbout(q_PRODUCER_ID);break;
case "StreamBlaster Help":doHelp();break;
case "About StreamBlaster":doAbout(q_PRODUCER_ID);break;
}//end switch
}//end function

function setStatus(astr){
if(document.getElementById("status")){
document.getElementById("status").innerHTML=astr;
}else{
}//end if
}//end function

function stateConstWM(q_stateNum){
switch (q_stateNum){
case 0:return "idle";
case 1:return "stop";
case 2:return "pause";
case 3:return "play";
case 4:return "play";
case 5:return "play";
case 6:return "buffer";
case 7:return "connect";
case 8:return "idle";
case 9:return "connect";
case 10:return "idle";
case 11:return "connect";
default:return "idle";
}//end switch
return "null";
}//end function

function stateConstWM64(q_stateNum){
switch (q_stateNum){
case 0:return "stop";
case 1:return "pause";
case 2:return "play";
case 3:return "connect";
case 4:return "play";
case 5:return "play";
case 6:return "buffer";
case 7:return "buffer";
case 8:return "idle";
}//end switch
}//end function

function stateConstRM(q_stateNum){
switch (q_stateNum){
case 0: return "stop"; 
case 1: return "connect";
case 2: return "buffer";
case 3: return "play";
case 4: return "pause";
default:return "idle";
}//end switch
}//end function

function stateConstQT(q_stateNum){
return stateConstWM(q_stateNum);
}//end function

function formatName(q_str){
switch (q_str){
case "WM":return "Windows Media";
case "RM":return "Real Media";
case "QT":return "Quicktime";
case "FL":return "Flash Video";
case "MP":return "Media Player";
default:return "";
}//end switch
}//end function

function Player_Factory(q_format){
switch(q_format){
case "WM":return new PlayerWM(Player_onChange,Player_onCommand);
case "FL":return new PlayerFL(Player_onChange,Player_onCommand);
case "QT":return new PlayerQT(Player_onChange,Player_onCommand);
default: return null;
}//end switch
}//end function

function validMediaExtensions(){
return "asf,asx,wm,wmx,wmp,wma,wax,wmv,wvx,vob,cda,avi,wav,mpeg,mpg,mpe,m1v,mp2,mpv2,mp2v,mpa,mp3,m3u,mid,midi,rmi,ivf,aif,aifc,aiff,au,snd,mp2,rm,mov,flv,mp4,m4v,mpeg,3gp,rmvb,mkv,ogm,mjpeg";
}//end function

function isBetween(a,b,c){
return (a>b && a<c);
}//end if

function getHighest(){
var h;
var highest="";
var htop=0;
var tagName=Array("A","SPAN","DIV","IMG","INPUT");
for(var tx=0;tx<tagName.length;tx++){
var divs = document.getElementsByTagName(tagName[tx]);
for(var q_ix=0;q_ix<divs.length;q_ix++){
	h=divs[q_ix].offsetTop+divs[q_ix].offsetHeight;
	if(htop<h){
		highest=tagName[tx]+"."+divs[q_ix].id;
		htop=h;
	}//end if
}//next
}//next
return highest + "=" + htop;
}//end function

//Cookie handling
function setCookie(q_cookieName,q_cookieValue,q_nDays) {
 var q_today = new Date();
 var q_expire = new Date();
 if (q_nDays==null || q_nDays==0) q_nDays=1;
 q_expire.setTime(q_today.getTime() + 3600000*24*q_nDays);
 document.cookie = q_cookieName+"="+escape(q_cookieValue)+ ";expires="+q_expire.toGMTString();
}//end function

function getCookie(q_name) {
var q_arg = q_name + "=";
var q_alen = q_arg.length;
var q_clen = document.cookie.length;
var q_i = 0;
var q_j = 0;
while (q_i < q_clen) {
   q_j = q_i + q_alen;
   if (document.cookie.substring(q_i, q_j) == q_arg){
      return getCookieval(q_j);
   }//end if
   q_i = document.cookie.indexOf(" ", q_i) + 1;
   if (q_i == 0){
      break; 
   }//end if
}//loop
return "";
}//end function
function getCookieval(q_offset){
var q_endstr = document.cookie.indexOf (";", q_offset); 
if (q_endstr==-1){
	q_endstr=document.cookie.length; 
}//end if
return unescape(document.cookie.substring(q_offset, q_endstr)); 
}//end function

//class Mediatrackitem
//public
function Mediatrackitem(src,markin,markout,clipstart){
this.mySrc=src;this.myMarkin=parseInt(markin);this.myMarkout=parseInt(markout);this.myClipstart=parseInt(clipstart);this.myDuration=calcDuration(this.myMarkout,this.myMarkin);
}//end function

//public
Mediatrackitem.prototype.isIdentical=function Mediatrackitem_isIdentical(b){
return (this.myClipstart==b.myClipstart);//same item in eventlist
}//end function
//end class

//class Dictionary
function Dictionary(){
}//end function

Dictionary.prototype.toName=function Dictionary_toName(a) {
    return replace("_"+a," ","_");
}//end function

Dictionary.prototype.item=function Dictionary_item(a) {
    return this[this.toName(a)];
}//end function

Dictionary.prototype.add=function Dictionary_add(a,b) {
return this[this.toName(a)]=b;
}//end function

Dictionary.prototype.set=function Dictionary_set(a,b) {
return this[this.toName(a)]=b;
}//end function

Dictionary.prototype.changeKey=function Dictionary_changeKey(a,b){
this[this.toName(b)]=this[this.toName(a)];
this.remove(this.toName(a));
}//end function

Dictionary.prototype.remove=function Dictionary_remove(a){
delete this[this.toName(a)];
}//end function

Dictionary.prototype.exists=function Dictionary_exists(a) {
return (typeof(this.toName(a))!="undefined");
}//end function

Dictionary.prototype.count=function Dictionary_count() {
var s=0;
for(var i in this){
  s=s+1;
}//next
return s-7;
}//end function

//end class