var currentURL = window.location;
var bal_path=currentURL.pathname.split('/');
bal_path=bal_path.length>2?'../../':'./';

function jsTip(co) {
	Tip('<B>'+co+'</B>', BALLOON, true, ABOVE, true);
}

function hladat(f) {
	var doc=document.getElementById('vyhladat');
	if (f==true) {
	  doc.value='';
	} else  {
	  doc.value=(doc.value=='vyhľadávanie' || doc.value=='')?'vyhľadávanie':doc.value;
	}
	doc.style.color=doc.value=='vyhľadávanie'?'silver':'black';
}

function hladaj(e,addr) {
    var charCode;
    if(e && e.which){ charCode = e.which; }
    else if(window.event){
        e = window.event;
        charCode = e.keyCode;
    }
    if(charCode == 13) {
        document.location.href=addr+'/search/'+document.getElementById('vyhladat').value;
    }
}

function show_calc() {
  px=450;
  py=400;
  var l=Math.round((screen.width/2)-(px/2));
  var t=Math.round((screen.height/2)-(py/2));
  window.open("/kalkulacka",'_blank',"height="+py+",width="+px+",status=no,toolbar=no,menubar=no,location=no,left="+l+",top="+t);
}

function show_bonita() {
  px=550;
  py=380;
  var l=Math.round((screen.width/2)-(px/2));
  var t=Math.round((screen.height/2)-(py/2));
  window.open("/bonita",'_blank',"height="+py+",width="+px+",status=no,toolbar=no,menubar=no,location=no,left="+l+",top="+t);

}

function vub_suhlas() {
  px=550;
  py=380;
  var l=Math.round((screen.width/2)-(px/2));
  var t=Math.round((screen.height/2)-(py/2));
  window.open("/suhlas",'_blank',"height="+py+",width="+px+",status=no,toolbar=no,menubar=no,location=no,left="+l+",top="+t);

}

function show_email() {
  px=440;
  py=310;
  var l=Math.round((screen.width/2)-(px/2));
  var t=Math.round((screen.height/2)-(py/2));
  window.open("/email",'_blank',"height="+py+",width="+px+",status=no,toolbar=no,menubar=no,location=no,left="+l+",top="+t);
}

function show_order(pom,id) {
  var iew=window.open("/ziskaj-viac/"+id,'_self');
}

function show_por(adr) {
  var ch=0;
  var por=document.getElementsByName('porovnaj[]');
  var j=0;
  var ret=' ';
  for (i=0;i<por.length;i++) {
  	if (por[i].checked) {
  		ch+=1;
  		j++;
  		var p=por[i].id;
  		ret+=p.substr(1)+'-';
  	}
  }
  if (ch<2) alert('Pre porovnanie je potrebné zvoliť min. 2 produkty');
  else  document.location.href='/'+adr+'/porovnat/'+ret.substr(1,ret.length);
}

function max_por(max) {
  var ch=0;
  var por=document.getElementsByName('porovnaj[]');
  for (i=0;i<por.length;i++) {
  	if (por[i].checked) ch+=1;
      if (ch>max) {
      	alert('Porovnať je možné max. '+max+' produkty');
      	por[i].checked=false;
      	ch=0;
      }
  }
}

function kontrola_email() {
  var t=' ';
  if (document.getElementById('meno').value=='')            { t=t+'Nie je vyplnené meno\n'; }
  if (isValidEmail(document.getElementById('email').value)) { t=t+'Nesprávne vyplnený email\n'; }
  if (document.getElementById('text').value=='')            { t=t+'Nie je napísaný text\n'; }
  if (t!=' ')
  return (t==' '?true:false);
}


function i419() {
	var pom=document.getElementById('inp_419').value;
	var pom2=document.getElementById('inp_389');
	if (pom=='4643') {
		pom2.value=(pom2.value[0]!='-'?'-'+pom2.value:pom2.value);
	}
	if (pom=='4641') {
      pom2.value=(pom2.value[0]=='-'?pom2.value.substr(1):pom2.value);
	}
	if (pom=='4642') {
      pom2.value='0';
	}

}

function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  return (strEmail.search(validRegExp) == -1)?true:false;
}

function show_faq_o(f,t) {
  var pom=document.getElementsByName('faq_o');
  for (i=0;i<pom.length;i++) {
  	if (pom[i].id!='ot_'+f+'_'+t) {
  	  pom[i].style.display='none';
  	}
  }
  var ot=document.getElementById('ot_'+f+'_'+t);
  ot.style.display=(ot.style.display=='block'?'none':'block');
}

function warn() {
  document.getElementById('d_warning').style.display='none';
}

function close_error() {
  document.getElementById('d_error').style.display='none';
}

function close_info() {
  document.getElementById('d_info').style.display='none';
}


function kalkulacka_kontrola() {
	ret=true;
	for (i=1;i<=4;i++) {
	  if (parseInt(document.getElementById('calc_'+i))!=document.getElementById('calc_'+i)) { ret=false; }
	}
	if (ret==false) { alert('nesprávne vyplnené hodnoty'); }
	return ret;
}

