var d=document;
// -------------- Buttons -------------- //
var imgsPath="images\/";
var HBtns=new Array("btn1","btn2","btn3","btn4","btn5","btn6");
var HRImgs=new Array("btn11.jpg","btn12.jpg","btn21.jpg","btn22.jpg","btn31.jpg","btn32.jpg","btn41.jpg","btn42.jpg","btn51.jpg","btn52.jpg","btn61.jpg","btn62.jpg");
function HPreloadImgs(langid){
 var j=0; 
 if (!d.HBImgs){d.HBImgs=new Array(13);} 
 for (var i=0;i<=12;i++){
  d.HBImgs[i]=new Image();
  if(langid=='ro'){d.HBImgs[i].src=imgsPath+HRImgs[j];}
  j++;
 }
}
function HBtnHover(id, stat){ 
 if (d.HBImgs){d.images[HBtns[id]].src=d.HBImgs[stat].src;}
}

function body_onclick(){
	if(document.all("faq").style.display == ""){
		document.all("faq").style.display = "none";
	}
 if(document.all("faq1").style.display == ""){
		document.all("faq1").style.display = "none";
	}
}

function callpopup(){
	if(document.all("faq").style.display == "none"){
		document.all("faq").style.display = "";
	}
	if(document.all("faq1").style.display == "none"){
		document.all("faq1").style.display = "";
	}
}
function svover(x) {

            nR = eval("document.getElementById('" + x + "')");

                 if (nR.className=="svout") {
                    nR.className="svover";
                    nR = ""
                  }

                  else {
                    nR.className="svout";
                    nR = ""
                  }


} 

// ------ Miscellaneous functions ------ // 
function trim(s){
  if(typeof s!="string"){return s;}
  var retS=s; var ch=retS.substring(0,1);
  while (ch==" "){ retS=retS.substring(1,retS.length); ch=retS.substring(0,1); }
  ch=retS.substring(retS.length-1,retS.length);
  while (ch==" "){ retS=retS.substring(0,retS.length-1); ch=retS.substring(retS.length-1,retS.length); }
  while (retS.indexOf("  ")!=-1){ retS=retS.substring(0,retS.indexOf("  "))+retS.substring(retS.indexOf("  ")+1,retS.length); }
  return retS;
}
function checkEmail(s){
  var ok="1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
  var re1=/(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
  var re2=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  for (var i=0; i<s.length; i++){ if(ok.indexOf(s.charAt(i))<0) return false; }
  if (!s.match(re1)&&s.match(re2)) return (-1);
}
function checkPhone(theForm)
{
	var checkOK = "0123456789";
 var checkStr = theForm.telefon.value;
 var allValid = true;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
	 ch = checkStr.charAt(i);
	  for (j = 0;  j < checkOK.length;  j++)
	   if (ch == checkOK.charAt(j))
	   break;
	   if (j == checkOK.length)
	{
	allValid = false;
	break;
	}
	if (ch != ",")
	allNum += ch;
	}
	if (!allValid)
	{
	return (-1);
	}
}
function checkSNumber(theForm)
{
	var checkOK = "0123456789";
 var checkStr = theForm.supportnr.value;
 var allValid = true;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
	 ch = checkStr.charAt(i);
	  for (j = 0;  j < checkOK.length;  j++)
	   if (ch == checkOK.charAt(j))
	   break;
	   if (j == checkOK.length)
	{
	allValid = false;
	break;
	}
	if (ch != ",")
	allNum += ch;
	}
	if (!allValid)
	{
	return (-1);
	}
}


function ShowFoto (filename, sirina, visina, naziv)
{ // putanja do foldera sa slikama koje treba da se pojavljuju u pop-up prozoru
 image_path = 'images/podgorica_slike/velike/';	// putanja je relativna u odnosu na folder u kojem se nalazi ovaj fajl
 
 // centriranje pop-up
 screen_sirina = screen.availWidth;
 screen_visina = screen.availHeight;
 position_left = (screen_sirina - sirina) / 8;
 position_top = (screen_visina - visina) / 2; 
 
 // otvaranje pop-up prozora i ucitavanje slike
 w = window.open("","newWindow","width="+sirina+",height="+visina+",scrollbars=no,left="+position_left+",top="+position_top);
 w.document.open();
 w.document.write('<html><title>'+naziv+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
 w.document.write('<img src=\"' + image_path + filename + '\" width='+sirina+' height='+visina+' alt=\"'+naziv+'\">');
 w.document.write('</body></html>');
 w.document.close();
 w.focus();
}

function cgShowFoto (filename, sirina, visina, naziv)
{ // putanja do foldera sa slikama koje treba da se pojavljuju u pop-up prozoru
 image_path = '../images/podgorica_slike/velike/';	// putanja je relativna u odnosu na folder u kojem se nalazi ovaj fajl
 
 // centriranje pop-up
 screen_sirina = screen.availWidth;
 screen_visina = screen.availHeight;
 position_left = (screen_sirina - sirina) / 8;
 position_top = (screen_visina - visina) / 2; 
 
 // otvaranje pop-up prozora i ucitavanje slike
 w = window.open("","newWindow","width="+sirina+",height="+visina+",scrollbars=no,left="+position_left+",top="+position_top);
 w.document.open();
 w.document.write('<html><title>'+naziv+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
 w.document.write('<img src=\"' + image_path + filename + '\" width='+sirina+' height='+visina+' alt=\"'+naziv+'\">');
 w.document.write('</body></html>');
 w.document.close();
 w.focus();
}
function cgShowPictures (filename, sirina, visina, naziv)
{ // putanja do foldera sa slikama koje treba da se pojavljuju u pop-up prozoru
 image_path = '../pictures/';	// putanja je relativna u odnosu na folder u kojem se nalazi ovaj fajl
 
 // centriranje pop-up
 screen_sirina = screen.availWidth;
 screen_visina = screen.availHeight;
 position_left = (screen_sirina - sirina) / 8;
 position_top = (screen_visina - visina) / 2; 
 
 // otvaranje pop-up prozora i ucitavanje slike
 w = window.open("","newWindow","width="+sirina+",height="+visina+",scrollbars=no,left="+position_left+",top="+position_top);
 w.document.open();
 w.document.write('<html><title>'+naziv+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
 w.document.write('<img src=\"' + image_path + filename + '\" width='+sirina+' height='+visina+' alt=\"'+naziv+'\">');
 w.document.write('</body></html>');
 w.document.close();
 w.focus();
}