// ========= Boatshop nav
// ==========================================================
sfHover = function() {
	var sfEls = document.getElementById("language").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className = GetRegExp( this.className );
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

function GetRegExp( sVar )
{
	return (sVar.replace(new RegExp(" sfhover\\b"), ""))
}


// ========= Provjera browsera
// ==========================================================
   iens6 = document.all||document.getElementById

   if (iens6) {
     function obj(id){
       return document.getElementById? document.getElementById(id) : document.all.id }
   }
   else {
     browserNoGood = "Za pregled ovih stranica potreban je\n"
                   + "Microsoft Internet Explorer 5 ili Netscape 6."
     alert(browserNoGood);
     location.href = '/sorry.asp';
   }



//========== Provjera forme
//==========================================================
  function FormCheck(sortiraj, str)
  {
    var url = rootDir + 'katalog/repSkupni.asp?orderBy=' + sortiraj + '&str=' + str

     // if (document.frm1.CHKnovo.checked || document.frm1.CHKpolovno.checked) {
      
      document.frm1.action = url
      document.frm1.submit()
      //}
     // else {
      //  alert("Označite da li želite pretraživati nove ili polovne brodove ili oboje."); 
     // }
  }
	
	function FormCheck2(sortiraj, str)
  {
    var url = rootDir + 'katalog/repSkupni.asp?orderBy=' + sortiraj + '&str=' + str

     // if (document.frm1.CHKnovo.checked || document.frm1.CHKpolovno.checked) {
      
      document.frm2.action = url
      document.frm2.submit()
      //}
     // else {
      //  alert("Označite da li želite pretraživati nove ili polovne brodove ili oboje."); 
     // }
  }




// ========= Hover botuni
// ==========================================================
   function hover(obj, state) {
     if (state)
       obj.src = eval(obj.name + 'x.src')
     else
       obj.src = eval(obj.name + '.src')
   }



// ========= Prikaz/sakrivanje layera
// ==========================================================
   function sLayer(objName)  // show layer
   {
     obj(objName).style.visibility = "visible";
   }

   function hLayer(objName)  // hide layer
   {
     obj(objName).style.visibility = "hidden";
   }



// ========= Uključivanje / isključivanje layera s podmenijem
// ==========================================================
function mnuOn(kojiMnu){
   sLayer(kojiMnu+'_submenu'); return true;
}

function mnuOff(kojiMnu){
   hLayer(kojiMnu+'_submenu'); return true;
}

// ========= PopUp - ZOOM slika vijesti
// ==========================================================
   function zoomVijesti(id)
   {
     var winURL = rootDir + 'vijesti/PopUpVijesti.asp?id=' + id
     var winIme = 'popUpVijesti'
     var winAtributi =
       'width=486'       +
       ',height=400'     +
       ',toolbar=no'     +
       ',location=no'    +
       ',directories=no' +
       ',status=no'      +
       ',menubar=no'     +
       ',scrollbars=yes'  +
       ',resizable=yes'   ;

     eval("window.open(winURL, winIme, winAtributi)");
   }

// ========= PopUp - ZOOM karta
// ==========================================================
   function zoomKarta()
   {
     var winURL = rootDir + 'jamnica/PopUpKarta.asp'
     var winIme = 'popUpKarta'
     var winAtributi =
       'width=780'       +
       ',height=475'     +
       ',toolbar=no'     +
       ',location=no'    +
       ',directories=no' +
       ',status=no'      +
       ',menubar=no'     +
       ',scrollbars=yes'  +
       ',resizable=yes'   ;

     eval("window.open(winURL, winIme, winAtributi)");
   }

// ========= PopUp - ZOOM slika
// ==========================================================
   function zoomFotka(id)
   {
     var winURL = rootDir + 'katalog/PopUpSlika.asp?id=' + id
     var winIme = 'popUpSlika'
     var winAtributi =
       'width=486'       +
       ',height=400'     +
       ',toolbar=no'     +
       ',location=no'    +
       ',directories=no' +
       ',status=no'      +
       ',menubar=no'     +
       ',scrollbars=yes'  +
       ',resizable=yes'   ;

     eval("window.open(winURL, winIme, winAtributi)");
   }
// ========= PopUp - Interaktivni katalog naplataka
// ==========================================================
   function interStart(rootDir)
   {
     var winURL = rootDir + 'interactive/index.asp'
     var winIme = 'interactive'
     var winAtributi =
       'width=600'       +
       ',height=450'     +
       ',toolbar=no'     +
       ',location=no'    +
       ',directories=no' +
       ',status=no'      +
       ',menubar=no'     +
       ',scrollbars=no'  +
       ',resizable=no'   ;

     eval("window.open(winURL, winIme, winAtributi)");
   }

// ========= PopUp - Copyright Arcode & Dobbin
// ==========================================================
   function copyAD(id)
   {
     var winURL = 'http://www.dobbin.hr/copy-ad/ad-' + id + '.asp'
     var winIme = 'copyAD'
     var winAtributi =
       'width=490'       +
       ',height=390'     +
       ',toolbar=no'     +
       ',location=no'    +
       ',directories=no' +
       ',status=no'      +
       ',menubar=no'     +
       ',scrollbars=no'  +
       ',resizable=no'   ;

     eval("window.open(winURL, winIme, winAtributi)");
   }



    function chkFrm(lang) {
      
      if (lang=='hr'){
        var strNadimak = "Nadimak"
        var strKomentar= "Komentar"
        var nisteUp = 'Niste upisali sve potrebne podatke!\nNedostaje:'
      }
      else {
        var strNadimak = "NickName"
        var strKomentar= "Comment"
        var nisteUp = 'You have not entered all the necessary details!\nMissing:'
      }
      
      
        fali = ""
        if (document.frm2.nadimak.value == "") fali = fali + "\n  -" + strNadimak
        if (document.frm2.komentar.value == "") fali = fali + "\n  -" + strKomentar
    
    if (fali != "") {
        alert (nisteUp + "\n" + fali)
      }
      else {
        document.frm2.submit()
      }
    
    }
    
    
  function provjeriFormu(lang) {
      
      if (lang=='hr'){
        var strIme = "Ime"
        var strEmail = "Prijateljev email"
        var nisteUp = 'Niste upisali sve potrebne podatke!\nNedostaje:'
        var vrongMail = "Upisana email adresa je neispravna."
      }
      else {
        var strIme = "Name"
        var strEmail = "Friends email"
        var nisteUp = 'You have not entered all the necessary details!\nMissing:'
        var vrongMail = "Incorrect e-mail address entered."
      }
      
      
        fali = ""
        if (document.frm3.ime.value == "") fali = fali + "\n  -" + strIme
        if (document.frm3.email.value == "") fali = fali + "\n  -" + strEmail
    
    if (fali != "") {
        alert (nisteUp + "\n" + fali)
      }
      else {
      if (provjeraMaila(document.frm3.email.value)==true){
            alert(vrongMail)
          }
          else {
            document.frm3.submit()
          }
      }
    
    }
    
    // ========= pop-up prozor
  function winPopUp(url,w,h,scroll,mnu,resize)
  {
    var winURL = rootDir + url
    var winIme = 'PopUp'
    var winAtributi =
      'width=' + w
    + ',height=' + h
    + ',toolbar=no'
    + ',location=no'
    + ',directories=no'
    + ',status=no'
    + ',menubar=' + mnu
    + ',scrollbars=' + scroll
    + ',resizable=' + resize;

    eval("window.open(winURL, winIme, winAtributi)");
  }
  
  function provjeraMaila(mail) {
    
    var str = mail
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
	
  	if ((str==null)||(str=="")){
      return true;
  	}

		if (str.indexOf(at)==-1){
       return true;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       return true;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return true;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
        return true;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return true;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
        return true;
		 }
		
		 if (str.indexOf(" ")!=-1){
        return true;
		 }
	}