function m(msg){window.alert(msg)};

function AlertUserOfAPIError(strText) {return  null}

function FindAPI(win) {return win.API}

function APIOK() {return  null}

function SCOInitialize() {return  null}

function SCOFinish() {return  null}

function SCOGetValue(nam){return  null}
function SCOCommit(parm){return  null}
function SCOGetLastError(parm){return  null}
function SCOGetErrorString(n)	{return  null}
function SCOGetDiagnostic(p)	{return  null}

function SCOSetValue(nam,val){return  null}

function SCOReportSessionTime() {return  null}

function SCOSetStatusCompleted(){return  null}

function MillisecondsToCMIDuration(n) {
//Convert duration from milliseconds to 0000:00:00.00 format
	var hms = "";
	var dtm = new Date();	dtm.setTime(n);
	var h = "000" + Math.floor(n / 3600000);
	var m = "0" + dtm.getMinutes();
	var s = "0" + dtm.getSeconds();
	var cs = "0" + Math.round(dtm.getMilliseconds() / 10);
	hms = h.substr(h.length-4)+":"+m.substr(m.length-2)+":";
	hms += s.substr(s.length-2)+"."+cs.substr(cs.length-2);
	return hms
}

function qReportIt(){return  null};
function qReportWrongAnsw() {if (xqDebug) window.alert('Ответ неверный')}
function SCOSetStatusFailed(){if (xqDebug) window.alert("Тест не пройден!")}

function qGetAttempt() {return 0 }

function qCheckState()
{}

function qReadSuspend()
{var s;
  s=''; //getCookie('currTestS'+xBookID,'');
  return s
}

function qWriteSuspend(s)
{ //setCookie('currTestS'+xBookID, s)
}

 function chkurl(axBookID, achid)
    {//m('chkurl entered '+axBookID+':'+achid);
    xBookID=axBookID;
    chid=achid;
    var ct = qReadSuspend();
    //m('chkurl context: '+ct);
    if (ct!="") {
        ct = ct.split('//');
        if ((typeof(ct)!='undefined') && (ct.length>3) && (typeof(ct[1])!='undefined'))
        {
          ct = ct[1];
          //m('chkurl testing!!!');
          var s1 ="/"+ct; 
          var s2=document.location.href;       
          //m('chkurl '+ s1+'<--------->'+s2);
          if (s2.lastIndexOf(s1)<=0)
            {     window.alert('Внимание! Производится перенаправление на незавершенное тестовое задание!'+".."+s1);  
                  document.location.replace(".."+s1) }
         }         
      }       
   

  {//m('chkurl struc enter'); 
   var oldS=top.location.href.toLowerCase() ;
   var newS, par;
   var i;
   //m('chkurl chid check: '+typeof(chid));
  //m('try AsIs:'+oldS+'-'+chid); 
  i=oldS.lastIndexOf('/');
  if (i>=0) {i=oldS.lastIndexOf('/',i-1)};
 
  if (i>=0)
  { if (oldS.substring(i,i+17)!='/index/index.html') 
      {
          if (typeof(chid) != 'undefined') 
         {par=oldS.substring(i+1)} 
else{par=oldS.substring(i+1)}
       par="go="+par.replace('/',"*");
       //m('chkurl '+oldS.substring(0,i)+'::'+par);
       newS=oldS.substring(0,i)+'/index/index.html?'+par;
       //m('chkurl replace to: '+newS);
      top.location.replace(newS);
      }}
  }
 } 


