﻿
// ========= Return element id =============================
function getEl(sId) {
  return (document.all? document.all(sId): (document.getElementById? document.getElementById(sId): null));
}


// ========= Navigae URL =============================
function NavigateUrl(sValue)
{
    if ( sValue != '0' ) { location.href = sValue; }
    //alert( sValue );
}


// ========= Main Search =============================
function mainSearch()
{
    var theForm = document.forms['aspnetForm'];
    theForm.action = '/hr/ah/search.aspx';
    theForm.submit();
}


// ========= Provjera forme za ispis guma ===================
// ==========================================================
function FormCheck() {
  // Najmanje jedan proizvođač treba biti selektiran - polje pro[i]
  checked=0
  checkWhat = document.obrazac.elements

  for (var i = 0; i < checkWhat.length; i++) {
    if ((checkWhat[i].type == 'checkbox') &&
        (checkWhat[i].name.substr(0,3) == 'pro') &&
        (checkWhat[i].checked)) {
      checked += 1
    }
  }

  if (checked == 0)
     alert('Odaberite najmanje jednog proizvođača za prikaz!');
  else
   document.obrazac.submit();
}



function checkCatalog( sNamjena )
{
  /*if ( (document.aspnetForm._ctl0:CPH3:chkPro:0.checked == false)&&(document.aspnetForm._ctl0:CPH3:chkPro:1.checked == false)&&(document.aspnetForm._ctl0:CPH3:chkPro:2.checked == false)&&(document.aspnetForm._ctl0:CPH3:chkPro:3.checked == false)&&(document.aspnetForm._ctl0:CPH3:chkPro:4.checked == false)&&(document.aspnetForm._ctl0:CPH3:chkPro:5.checked == false) )
  {
        alert('Odaberite najmanje jednog proizvođača za prikaz!');
  }
  else {*/
      if ( sNamjena == '*' )
      {
         alert('Odaberite vrstu vozila!');
      }
      else {   
        document.aspnetForm.action = '?search=true';
        document.aspnetForm.submit();
      }
  //}  
}


// ========= Zoom div za fotke ===========================
// =======================================================
var activeDiv = 'TR0';

function zoom(IDguma) {
  currentDiv = 'TR'+ IDguma;
  if ( getEl( currentDiv ).className == 'hide' )
  {
    try {
        getEl( activeDiv ).className = 'hide';
    }
    catch(e){}
    getEl( currentDiv ).className = 'show box';
    activeDiv = currentDiv;
  }
  else {
    getEl( currentDiv ).className = 'hide';
  }
}

function zoomOut() {

  try {
      getEl( activeDiv ).className = 'hide';
  }
  catch(e){}
}

function zoomPic(idFolder, idPic)
{
 var winURL = '/naplatciPic.aspx?idF='+ idFolder +'&idP='+ idPic
 var winIme = 'ImgZoom'
 var winAtributi =
   'width=290'       +
   ',height=290'     +
   ',toolbar=no'     +
   ',location=no'    +
   ',directories=no' +
   ',status=no'      +
   ',menubar=no'     +
   ',scrollbars=no'  +
   ',resizable=no'   ;

 var win = eval("window.open(winURL, winIme, winAtributi)");
 win.focus();
}

function newsPic(picPath)
{
 var winURL = '/newsPic.aspx?id='+ picPath
 var winIme = 'ImgZoom'
 var winAtributi =
   'width=660'       +
   ',height=500'     +
   ',toolbar=no'     +
   ',location=no'    +
   ',directories=no' +
   ',status=no'      +
   ',menubar=no'     +
   ',scrollbars=no'  +
   ',resizable=no'   ;

 var win = eval("window.open(winURL, winIme, winAtributi)");
 win.focus();
}

function galleryPic(sTitle, picPath)
{
 var winURL = '/galleryPic.aspx?id='+ picPath +'&title=' + sTitle;
 var winIme = 'ImgZoom'
 var winAtributi =
   'width=660'       +
   ',height=500'     +
   ',toolbar=no'     +
   ',location=no'    +
   ',directories=no' +
   ',status=no'      +
   ',menubar=no'     +
   ',scrollbars=no'  +
   ',resizable=no'   ;

 var win = eval("window.open(winURL, winIme, winAtributi)");
 win.focus();
}




// ========= Show / hide Level5 Ford  ====================
// =======================================================
ActiveLevel = '1';

function showLevel( nIDLevel )
{
    sListID = 'list' + nIDLevel;
    sLevelBoxID = 'levelBox' + nIDLevel;
    
    hideLevel();
    getEl( sListID ).className = 'active';
    getEl( sLevelBoxID ).className = 'show';
    ActiveLevel = nIDLevel;
}

function hideLevel()
{
    sActiveListID = 'list' + ActiveLevel;
    sActiveLevelBoxID = 'levelBox' + ActiveLevel;
    
    getEl( sActiveListID ).className = 'default';
    getEl( sActiveLevelBoxID ).className = 'hide';
}


// ========= Show / hide  ===========================
// =======================================================

function ShowHideWeather(currentXml)
{
  if ( getEl( currentXml ).className == 'hide' )
  {
    try
    {
        getEl( activeXml ).className = 'hide';
    } catch(e) {}
    getEl( currentXml ).className = 'showOnly';
    activeXml = currentXml;
  }
  else {
    getEl( currentXml ).className = 'hide';
  }
}


function ShowHideCentri(currentCentar)
{
  if ( getEl( currentCentar ).className == 'hide' )
  {
    try
    {
        getEl( activeCentar ).className = 'hide';
    } catch(e) {}
    getEl( currentCentar ).className = 'showOnly';
    activeCentar = currentCentar;
  }
  else {
    getEl( currentCentar ).className = 'hide';
  }
}

function ShowHidePayment(_id)
{
  if ( _id == 1 )
  {
    getEl( 'divPayment1' ).className = 'showOnly';
    getEl( 'divPayment2' ).className = 'hide';  
  }
  else {
    getEl( 'divPayment1' ).className = 'hide';
    getEl( 'divPayment2' ).className = 'showOnly';  
  }
}


// =============== Default functions ========================
// ==========================================================

function top() {
  window.scrollTo(0, 0);
}


function back() {
  history.back();
} 