//pro kosik;
var sdsimbol = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");

function action(sAction)
{
	document.fmCart.action.value = sAction;
	document.fmCart.submit();
}

function validateForm(form) {
var i,field,theCheck,name,errors='';

for (i=0; i<(form.elements.length-1); i+=1) {
  field = form.elements[i];
  if (field.title) {
    theCheck=field.title.substr(field.title.length-1,1);
    if (theCheck=='*') {
      if (!(field.value) || (field.value=="@")) { //IF EMPTY FIELD
        name=field.title.substr(0,field.title.length-1);
        errors += name+' chybí\n';
      }
    }
  }
}

if (errors)
  alert('Objevily se následující chyby:\n'+errors);
  return (errors == '');
}

function isQty(text) {
  if (!(text.value == "")) {
		strCheck=text.value;
		if (!check(strCheck,sdsimbol)) {
			alert("Počet kusů musí mít hodnotu od 1 do 999.");
			text.value = 1;
			text.focus();
		}
   else {
		if (text.value < 1 || text.value > 999) {
			alert("Počet kusů musí mít hodnotu od 1 do 999.");
			text.value = 1;
			text.focus();
		}
    }
  }
}

function check(input,simbol) {
  var ok = true;
  for (var i = 0; i < input.length; i++) {
    var chr = input.charAt(i);
    var found = false;
    for (var j = 0; j < simbol.length; j++) {
      if (chr == simbol[j]){
        found = true;
        break;
       }
    }
    if (!found) ok = false;
  }
  return ok;
}

function printOrder(order)
{
	url = "popup.php?order=" + order + "&amp;action=orderprint";
	sTop = (screen.availHeight-560) / 2;
	sLeft = (screen.availWidth-680) / 2;
	var winZoom = window.open(url, "w123", "width=680,height=520,top=0,screenY=" + sTop + ",left=0,screenX=" + sLeft + ",toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	winZoom.focus();
}

function PrintDocument()
{
    window.document.execCommand('print');
}

function TestMail(form)
{
for (i=0; i<(form.elements.length-1); i+=1)
 {
  field = form.elements[i];
  if (field.title=='Email')
    {
    if ((field.value.indexOf('@')==-1) || (field.value.indexOf('.')==-1))
       {
       alert('Emailová adresa je zadána chybně!');
       return false;
       break;
       }
    }
 }
return true; 
}

function SendEmail(strUrl)
{
    var strEmail
    strEmail = window.prompt("Zadejte e-mail příjemce.","");
    if (strEmail > "")
	{
        window.location.href = strUrl + strEmail;
    }
}

function viewImg(path)
{
   url = "popup.php?image=" + path;
	sTop = (screen.availHeight-560) / 2;
	sLeft = (screen.availWidth-680) / 2;
	var winZoom = window.open(url, "w123", "width=0,height=0,top=0,screenY=" + sTop + ",left=0,screenX=" + sLeft + ",toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	winZoom.focus();
}

/*regformular*/
function checkpassword (field)
{
	if ( (field.value!=document.all.passX.value) && (field.value.length>0) )
	{
		//alert (field.value + ' - ' + document.all.passX.value);
		field.focus;field.select();
		alert ("Potvrzení hesla není stejné jako heslo");
		//  return false;
	}
	else
	{
		return '';
	}
}

function checkTextBox(field,minValue,numeric)
{
	var text='';
	var name=field.title.substr(0,field.title.length);
	if ((minValue) && (!minLength (name,field.value.length, minValue)))
	{
		text='Min. počet znaků pro '+name+' je '+minValue;
	}
	else if ((numeric) && (!isInt(field.value)))
	{
		text=name+' musí být číslo';
	}

	if(text!='')
	{
		field.focus;field.select();
	}
	return text;
}

function minLength (name, len, minValue)
{
	if ((len<minValue) && (len>0))
	{
		return false;
	}
	return true;
}

function isInt (text)
{
	for (i=0;i<text.length;i++)
   		if (isNaN(text.substring(i,i+1))){ return false; }
 	return true;
}

function isChar (text)
{
	for (i=0;i<text.length;i++)
	if (!isNaN(text.substring(i,i+1))) { return false; }
	return true;
}
/*end reg form*/

function setWindow()
{
	imgx = document.img.width+130;
	imgy = document.img.height+130;
	if(screen.height <= imgy)
		imgy = screen.height-60;
	if(screen.width <= imgx)
		imgx = screen.width;

	window.resizeTo(imgx, imgy)
}

function fnShowPopUp(ord,path,type)
{
	var  sTop, sLeft;
	url = "popup.php?ord=" + ord + "&amp;path=" + path + "&amp;type=" + type;
	sTop = 0;
	sLeft = 0;
	var winZoom = window.open(url, "w123", "width=450,height=400,top=" + sTop + ",screenY=" + sTop + ",left=" + sLeft + ",screenX=" + sLeft + ",toolbar=no,menubar=no,resizable=no,scrollbars=yes");
	winZoom.focus();
}
/*
function regToPay(f)
{
   var w = document.getElementById("wait_to_pay");
   if(!w)
      w = document.all.wait_to_pay;

   if(f.checked)
   {
      w.className = "noitem";
   }
   else if(!f.checked)
   {
      w.className = "noscreen";
   }
}
*/
/*
function isInt (text) {
 for (i=0;i<text.length;i++)
   if (isNaN(text.substring(i,i+1))) { return false; }
 return true;
}

function resize() {
  try {
    img=document.all.imgFile;
    height=img.height;
	width=img.width;

    if (height>150 && width>200) {
   	   if (height>width) {  img.height=150;  }
	   else {img.width=200;}
	}
	else if (height>150) {
   	   img.height=150;
	}
	else if (width>200) {
   	   img.width=200;
	}
  }
  catch(e) {
  }
}

function OutOrder(){
   if (confirm("Opravdu chcete vymazat vše, co jste si dosud objednali?")){
	  window.location.href='cart.php?action=deleteAll';
      }else{
          return
      }
}

function manufacturerSearch(level,special){ //,special
	  window.location.href='products.php?path=' + level + special;
}


function StornoOrder(ordNum){
   if (confirm("Opravdu chcete vymazat objednavku?")){
	  window.location.href='partners.php?pord='+ordNum+'&action=storno';
      }else{
          return
      }
}



function ChangeChecked() {
	var element;

	for (var i = 0; i < document.forms.length; i++) {
		if (document.forms[i].name == 'fmBasket') {
			for (var j = 0; j < document.forms[i].elements.length; j++) {
				element = document.forms[i].elements[j];
				if (element.type == 'checkbox' && element.name != 'btnCheck' ){
					document.forms[i].elements[j].checked = document.fmBasket.btnCheck.checked;
				}
			}
		}
	}
}

function fnShowInfo(id,db) {
	var  sTop, sLeft;
	url = "info.php?id=" + id + "&amp;db=" + db;
	sTop = 0;
	sLeft = 0;

	var winZoom = window.open(url, "w123", "width=450,height=400,top=" + sTop + ",screenY=" + sTop + ",left=" + sLeft + ",screenX=" + sLeft + ",toolbar=no,menubar=no,resizable=no,scrollbars=yes");
	winZoom.focus();
}

function fnShowServis(id) {
	var  sTop, sLeft;

	url = "servis.php?ord=" + id;
	sTop = 30;
	sLeft = 30;

	var winZoom = window.open(url, "w123", "width=330,height=210,top=" + sTop + ",screenY=" + sTop + ",left=" + sLeft + ",screenX=" + sLeft + ",toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	winZoom.focus();
}

function fnShowZoom(idp,maintype) {
	var url, sTop, sLeft;

	url = "zoom.php?idp=" + idp+"&maintype=" + maintype;
	sTop = (screen.availHeight-560) / 2;
	sLeft = (screen.availWidth-680) / 2;

	var winZoom = window.open(url, "w123", "width=680,height=520,top=" + sTop + ",screenY=" + sTop + ",left=" + sLeft + ",screenX=" + sLeft + ",toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	winZoom.focus();
}

function fnShowDetail(strURL){
         var objWnd = window.open(strURL, "InfoDetail", "scrollbars=yes,height=500,width=500,resizable=yes,top=0,left=0");
         objWnd.focus();
         try {
           window.clearTimeout(mytimer);
         }
         catch(e) {}
}

function fnShowForm(strURL){
         var objWnd = window.open(strURL, "InfoDetail", "scrollbars=yes,height=550,width=500,resizable=yes,top=0,left=0");
         objWnd.focus();
         try {
           window.clearTimeout(mytimer);
         }
         catch(e) {}
}

function fnShowHidden(strURL){
         var objWnd = window.open(strURL, "", "toolbar=no,status=no,scrollbars=no,height=1,width=1,resizable=no,menubar=no");
}

function AddBuy(maintype,item,price,count,retPage,sequence,detail) {
        var strData,strReturn;
        strReturn = showModalDialog("addbuy.php","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=60pt");
        if (strReturn == "1"){
          try {
            if (detail) {
              window.opener.priceImp.value=(window.opener.priceImp.value*1.0)+price*count;
            }
            else {
              priceImp.value=(priceImp.value*1.0)+price*count;
            }
          }
          catch(e){}
          fnShowHidden('cart.php?action=addItemF&maintype='+maintype+'&cartItem='+item+'&count='+count+'&returnPage='+retPage);
        }
        else if (strReturn == "2"){
          if (detail) {
            window.opener.location.href='cart.php?action=addItem&maintype='+maintype+'&cartItem='+item+'&sequence='+sequence+'&count='+count+'&returnPage='+escape(window.opener.location.href);
          }
          else {
            window.location.href='cart.php?action=addItem&maintype='+maintype+'&cartItem='+item+'&sequence='+sequence+'&count='+count+'&returnPage='+escape(window.location.href);
          }
        }
}


function hrefAndClose(strURL){
   window.opener.location.href=strURL;
   window.close();
}

function fnFromDetail(strURL){
   window.opener.location.href=strURL+'&count='+fmItem.count.value+'&returnPage='+escape(window.opener.location);
   window.close();
}

function fnFromNormal(strURL){
   window.location.href=strURL+'&count='+fmItem.count.value+'&returnPage='+escape(window.location);
}


function jump(aHref,targetFrame) {
  if (aHref != "")  {
   if (targetFrame == "_blank") {
     window.open(aHref);
     } else {
     targetFrame.location = aHref;
     }
   }
}

function banner(msg, ctrlwidth) {
        newmsg=msg;
        while (newmsg.length < ctrlwidth) {
                newmsg += msg;
        }
        document.write ('<table cellspacing="0" cellpadding="0"><tr><FORM NAME="Banner"><td>');
        document.write ('<INPUT style="FONT-SIZE: 11px; BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 0px solid; BORDER-LEFT: #000000 0px solid; BORDER-RIGHT: #000000 0px solid; BORDER-TOP: #000000 0px solid; COLOR: #000000; HEIGHT: 14px; TEXT-ALIGN: right" NAME="banner" VALUE= "'+newmsg+'" SIZE= '+ctrlwidth+' readonly>');
        document.write ('</td></FORM></tr></table>');
        var bannerid = null;
        rollmsg();
}

function rollmsg() {
        NowMsg=document.Banner.banner.value;
        NowMsg = NowMsg.substring(1, NowMsg.length) + NowMsg.substring(0, 1);
        document.Banner.banner.value = NowMsg;
        bannerid=setTimeout("rollmsg()", 100);
}


//#####################################################
function checkpassword (field) {
 if ( (field.value!=document.all.pass.value) && (field.value.length>0) ) {
//  alert (this.name+' není stejné jako heslo');
  field.focus;field.select();
  return 'Potvrzení hesla není stejné jako heslo';
//  return false;
 }
 else {return '';}
}
function checkTextBox(field,minValue,numeric){
 var text='';
 var name=field.title.substr(0,field.title.length);
 if ((minValue) && (!minLength (name,field.value.length, minValue))){text='Min. počet znaků pro '+name+' je '+minValue;}
 else if ((numeric) && (!isInt(field.value))){text=name+' musí být číslo'}

 if(text!=''){field.focus;field.select();}
 return text;
}
function minLength (name, len, minValue) {
  if ((len<minValue) && (len>0)) {
	 return false;
  }
  return true;
}

function isInt (text) {
 for (i=0;i<text.length;i++)
   if (isNaN(text.substring(i,i+1))) { return false; }
 return true;
}

function isChar (text) {
 for (i=0;i<text.length;i++)
   if (!isNaN(text.substring(i,i+1))) { return false; }
 return true;
}

// ###### R O Z  B A L O V A C I   R E K L A M A  #######
var flo_updown=1;
var flo_pheight=200;
var flo_ptop=-65;
var roolBack=180;
// ###### R O Z  B A L O V A C I   R E K L A M A  #######
Cookies = {

	save : function(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else expires = ""
		document.cookie = name+"="+value+expires+"; path=/";
	},
	read : function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i<ca.length;i++) {
		var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	},
	erase : function(name) {
		Cookies.save(name,"",-1);
	}

}

var flo_updown=1;
var flo_pheight=200;
var flo_ptop=-65;
var roolBack=180;

function flo_downrun(){
try {
	if (((flo_pheight<200)&&(flo_updown==0)) || ((flo_pheight>3)&&(flo_updown==1))) {
		if(flo_pheight==200){flo_a.style.display="";}
		(flo_updown==0)?flo_pheight+=3:flo_pheight-=3;
		(flo_updown==0)?flo_ptop-=3:flo_ptop+=3;
		flo_a.style.clip="rect(" + flo_pheight + ",320,200,0)";
		flo_a.style.top=flo_ptop;
                if (!((flo_pheight>roolBack)&&(flo_updown==0))) {
   		   setTimeout("flo_downrun();",20);
                }
                else {
                  //stop
                  Cookies.save("float_banner","1",1/48);
                }

	}
 else {
		if (flo_updown==1){
			flo_a.style.clip="rect(0,320,200,0)";
			flo_a.style.top=flo_ptop+2;
			flo_updown=0;
			setTimeout("flo_downrun();",5000);
		}
	}
 }
  catch(e) {}
}

function AddPartnerImpulse()
{
  Cookies.save("aff_impulse","1",60*60*24*31);
  document.all.imgPartnerImpulse.src='addimpuls.php'
}

function flo_down() {
  var c = Cookies.read("float_banner");
  var d = Cookies.read("aff_impulse");
  if (!d) {
    setTimeout("AddPartnerImpulse();",60000);
  }
  if (!c) {
    flo_downrun();
  }
}

*/

