function DPg(Lng) 
{
  with (document.QV)
  {
    i=getCookie("FormView")
    QT[0].checked= (i == 1)?0:1
    QT[1].checked= (i == 1)?1:0
  }
  //Toolbar
  if (ToolbarFrame())
  {
    AllToNull();
    SetLang(Lng,"/default"+(1-Lng)+".stm")
    if (parent.frames[0].ToolChg) parent.frames[0].ToolChg();
  }
}

//QUExxy
function ToQ(PgId) 
{
  var Cx;
  if(getCookie("Q"+PgId) != null) {document.forms[0].Q.value=getCookie("Q"+PgId);}
  Cx=getCookie("I"+PgId) 
  if (Cx == "on") document.forms[0].I.checked=true
 
  setCookie ("FormView","1",14);
  setCookie ("Pg"+PgId.substring(0,2),"QUE"+PgId+".stm",0);
  
  //Toolbar
  if (ToolbarFrame())
  {
    AllToNull();
    Lng=parseInt(PgId.substring(2,3));if (isNaN(Lng)) Lng= 1
    SetLang(Lng,"/Que"+PgId.substring(0,2)+(1-Lng)+".stm")
    if (parent.frames[0].ToolChg) parent.frames[0].ToolChg();
  }
}

//SQUxxy
function ToV(PgId) 
{
  var Cx,Nx;
  with (document.forms[0])
  {
    for (var i=1; i < elements.length-2;i++)
    {    
      Nx=elements[i].name;
      if (Nx != null)
      {
        Cx=getCookie(Nx+PgId);
        if (Cx != null) 
        {
          if (Nx != "I")
          {
            elements[i].value=Cx;
          }
          else if (Cx == "on")
          {
            elements[i].checked= true
          }
        }
      }
    }
  }
  setCookie ("FormView","0",14);
  setCookie ("Pg"+PgId.substring(0,2),"SQU"+PgId+".stm",0);

  //Toolbar
  if (ToolbarFrame())
  {
    AllToNull();
    Lng=parseInt(PgId.substring(2,3));if (isNaN(Lng)) Lng= 1
    SetLang(Lng,"/Squ"+PgId.substring(0,2)+(1-Lng)+".stm")
    if (parent.frames[0].ToolChg) parent.frames[0].ToolChg();
  }
}

//Gy_xx
function DSPg(Lng,dLngP)
{
  if (ToolbarFrame())
  {
    AllToNull();
    SetLang(Lng,dLngP)
    if (parent.frames[0].ToolChg) parent.frames[0].ToolChg();
  }
}

function ToolbarFrame() 
{
  test= 0;
  if (parent.frames.length == 2) {if (parent.frames[0].name == "toolbar") test= 1}
  return test; 
}


//Gy_xx
function GuidePg(Lng,pg)
{
  //Toolbar
  if (ToolbarFrame())
  {
    AllToNull();
    if (pg == 1) 
       {SetLang(Lng,"/g/G"+(1-Lng)+"_"+d2(pg)+".htm")}
    else
       {SetLang(Lng,"/g/G"+(1-Lng)+"_"+d2(pg)+".stm")}
    
    ChgIt(2,"/g/G"+Lng+"_01.htm","","R")
    if (pg < parent.GuidePages) {ChgIt(3,"/g/G"+Lng+"_"+d2(pg+1)+".stm","","D")}
    if (pg > 2) {ChgIt(4,"/g/G"+Lng+"_"+d2(pg-1)+".stm","","L")}
        else if (pg > 1) {ChgIt(4,"/g/G"+Lng+"_"+d2(pg-1)+".htm","","L")}
    if (parent.frames[0].ToolChg) parent.frames[0].ToolChg();
  }
}

function UpdGPg() {if (parent.Frm0.FGPg) {parent.Frm0.FGPg(document.location.href)}}

function AllToNull() {for (i=0;i<6;i++) ChgIt(i,'javascript:void(0)','','N')}


function d2(n){return (n < 10)?"0"+n:n;} 

function ChgIt(i,href_,alt_,img_)
{
  if (parent.tlinks)
  {
    parent.tlinks[i].href_= href_ 
    parent.tlinks[i].alt_=  alt_
    parent.tlinks[i].img_=  "/f/"+img_+".gif" 
  }
}

function SetLang(Lng,nm)
{
 if (Lng)
 { 
   ChgIt(0,'/default1.stm','','house')
   ChgIt(5,nm,'Slovenski jezik','SI')
 }
 else
 { 
   ChgIt(0,'/default0.stm','Vstopna stran','house')
   ChgIt(5,nm,'English Language','GB')
 }
}

// 


function getCookie(Name) 
{          
  var search = Name + "=";          
  if (document.cookie.length > 0) 
  {                   
    offs1 = document.cookie.indexOf(search)                     
    if (offs1 != -1) 
    {
      offs1 += search.length                        
      offs2 = document.cookie.indexOf(";", offs1) 
      if (offs2 == -1) offs2= document.cookie.length                              
      return unescape(document.cookie.substring(offs1, offs2))                    
    }           
  }
  return null;
}


function setCookie(name, value, expires) 
{    
  if (expires > 0)
  {
    var expdate=new Date();
    expdate.setTime(expdate.getTime()+(24*60*60*1000*expires)); 
    document.cookie = name + "=" + escape (value) + "; expires=" + expdate.toGMTString(); 
  }
  else
  {
    document.cookie = name + "=" + escape (value); 
  }
}

function setC(Form,PgId) 
{
  setCookie (Form.name+PgId, Form.value,null);
  if(getCookie(Form.name+PgId == null)) setCookie (Form.name+PgId, Form.value,null);
}

function setCx(Form,PgId) 
{

  if (Form.checked == true) {vv="on"} else {vv="off"}
  setCookie (Form.name+PgId,vv,null);
  if(getCookie(Form.name+PgId == null)) setCookie (Form.name+PgId,vv,null);

} 


function SDPg() 
{
  if (document.QV.QT[1].checked)
  {
    setCookie ("FormView","1",14)
  }
  else
  {
    setCookie ("FormView","0",14)
  }
}

function DynamicL(rep) //Obsolete
{
  lang= rep.substring(2,3);
  qty=(document.QV.QT[1].checked)?"Que":"Squ";  
    
  document.links[2].href=qty+"00"+lang+".stm"
  document.links[3].href=qty+"03"+lang+".stm"
  document.links[4].href=qty+"01"+lang+".stm"
  document.links[5].href=qty+"02"+lang+".stm"
  alert('Sprememba 3')

}


function resetC(PgId) 
{
  var Nx;
  for (var i=1; i < document.forms[0].elements.length-2;i++)
  {    
    Nx=document.forms[0].elements[i].name;	
    if (Nx != null) setCookie (Nx+PgId,"",null);
  }
}
function TstI(Frm) 
{  
  var S;
  for (var i=1; i < Frm.elements.length-2;i++)
  {
    if (Frm.elements[i].name != "I")
    {
      S=Frm.elements[i].value;
      for (var j=S.length-1; j >= 0;j--) if (S.charAt(j) > " ") return true;
    }
  }  
  return false; 
}

function OpnURL(url) 
{

 txt='width='+(2*screen.width/3+48)+',height='+2*screen.height/3+',top='+screen.height/6+',left='+(screen.width/6-24)+',toolbar=yes,resizable=yes,scrollbars=yes,menubar=no,status=yes'
 u=url
 if (u.toLowerCase().indexOf('/g/g1_') != - 1)
 {
   nw=window.open('/g/g1_cls.htm?'+url,'RefWin',txt)
 }
 else
 {
   nw=window.open('/g/g0_cls.htm?'+url,'RefWin',txt)
 }
}


function opnPdfWnd(urltxt)
{

  nw=window.open(urltxt,'_blank','width='+(screen.width/2-2)+',height='+(screen.height-80)+',top=2,left='+(screen.width/2)+',toolbar=yes,resizable=yes,scrollbars=yes,menubar=yes,statusbar=yes');

 if (!nw)
  {
   alert('NO!');
  }

  if (window.focus) nw.focus();
}

function opn2Bib(urltxt)
{
  nw=window.open(urltxt,'Wnd2Bib','width='+screen.width/2+',height='+(screen.height-80)+',top=2,left='+(screen.width/2-20)+',toolbar=yes,resizable=yes,scrollbars=yes,statusbar=yes');
  if (nw.focus) nw.focus();
}

function OpenMadrid(irn,num) 
{
  with (document.forms[0])
  {
    elements[0].value='IRN/'+irn+' OR (ORI/SI AND (OBA/Z-'+num+' OR OBR/'+num+'))';
    nw=window.open('','X1','width='+screen.width/2+',height='+(screen.height/2)+',top='+screen.height/4+',left='+screen.width/4+',toolbar=no,resizable=yes,scrollbars=yes,statusbar=yes');
    target="X1";	
    submit();
    if (nw.focus) nw.focus();

  }
}

function OpenCTM(regNum)
{ 
  var Url;
  Url= 'http://oami.europa.eu/CTMOnline/RequestManager/en_Result?transition=ResultsDetailed&ntmark=&application=CTMOnline&bAdvanced=0'+
        '&language=en&deno=&source=search_basic.jsp&idappli='+regNum

  nw=window.open(Url,'Y1','width='+screen.width/2+',height='+(screen.height/2)+',top='+screen.height/4+',left='+screen.width/4+',toolbar=no,resizable=yes,scrollbars=yes,statusbar=yes');
  if (nw && window.focus) nw.focus();
}

