function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = '';
        else if(visStr == 'hide') visStr = 'none';
      }
      obj.display = visStr;
    }
  }
}

function zmazat_objednavku(){
if (confirm("Chcete vymazat všetok neobjednany tovar?")){
	document.location.href="zmaz_obj.asp"}
}

function je_cislo (text){
if (text.search(/[^0-9]/g)!=-1) return false;
return true;
}

function uloz_do_kosa(obj,kod,co) {
	obj=obj.parentElement;
	obj=obj.children.tags("input")[0];
if ((obj.value==0) || (!je_cislo(obj.value))) 
		alert ("Musite vyplnit množstvo výrobku! Množstvo musí byt zadané ako celé císlo!");
	else
		{window.open("uloz.asp?kod="+kod+"&mnozstvo="+obj.value+"&co="+co);}
	}

function uloz_do_kosa_z_old(kod,mnozstvo,co) {
	window.open("uloz.asp?kod="+kod+"&mnozstvo="+mnozstvo+"&co="+co);
	}
	
function windowOpener(file) {
	newWindow=window.open(file,"","toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,height=450,width=450");
	return;
}

function PreLoad(){
	imagesArray = new Array (PreLoad.arguments.length);
	for (var i=0; i < PreLoad.arguments.length; i++) {
		imagesArray[i] = new Image();
		imagesArray[i].src = PreLoad.arguments[i];
	}
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'MAPA', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var popUpWin_scrol=0;
function popUpWindow_scrol(URLStr, left, top, width, height)
{
  if(popUpWin_scrol)
  {
    if(!popUpWin_scrol.closed) popUpWin_scrol.close();
  }
  popUpWin_scrol = open(URLStr, '', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function reg_overenie(){
var obj
var zasli=true
var text="priezvisko,meno,tel,email,id,heslo,heslo2,ico,ic_dph,Obchn"
pole=text.split(",")
	for (obj in pole) {
		//alert (pole[obj]);
		document.getElementById(pole[obj]).style.background="";
	}

	for (obj in pole) {
		//alert (pole[obj]);
		if (document.getElementById(pole[obj]).value==""){
		zasli=false;
		document.getElementById(pole[obj]).style.background="red";
		}
	}
	
	if (document.frm_registracia.heslo.value !=document.frm_registracia.heslo2.value) { 
		zasli=false;
		document.frm_registracia.heslo.style.background="red";
		document.frm_registracia.heslo2.style.background="red";
	}

	var mailformat = /@{1}/g
	if (!mailformat.test(document.frm_registracia.email.value))	{
		zasli=false;
		document.frm_registracia.email.style.background="red";
	}
	
	if (!document.frm_registracia.suhlas.checked){
	zasli=false;
	alert("Pre registráciu musíte súhlasiť s obchodnými podmienkami.");
	document.frm_registracia.suhlas.style.background="red";
	}

if (zasli) {
	return true;}
else {
	document.all["hlaska"].style.display="";
	return false;}
}


function displayInfo(id, obj) {
	img=obj.children.tags("img")[0];
	if (document.getElementById(id).style.display == "none")
		{document.getElementById(id).style.display = "";
		img.src="images/ine/rozbal.gif";}
	else
		{document.getElementById(id).style.display = "none";
		img.src="images/ine/zbal.gif";}
}

function napiste_nam_overenie(){
var obj
var zasli=true
var text="meno,email"
pole=text.split(",")
	for (obj in pole) {
		//alert (pole[obj]);
		document.getElementById(pole[obj]).style.background="";
	}

	for (obj in pole) {
		//alert (pole[obj]);
		if (document.getElementById(pole[obj]).value==""){
		zasli=false;
		document.getElementById(pole[obj]).style.background="red";
		}
	}
	
	var mailformat = /@{1}/g
	if (!mailformat.test(document.frm_napiste_nam.email.value))	{
		zasli=false;
		document.frm_napiste_nam.email.style.background="red";
	}

if (zasli) {
	return true;}
else {
	document.all["hlaska"].style.display="";
	return false;}
}

function search_overenie(){
var zasli=true
var text="searchFor"
	if (document.getElementById(text).value==""){
		zasli=false;
		alert ("Musite vyplnit hľadaný výraz!");
	}
	else {
	document.forms['frm_search'].submit();
	}
}

// funkcie Fireworksu pre sortiment
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
