// globalni promenna------------------
//zjisteni IE prohlizece a dany do globalni promenne
var IE= null;
var ua = navigator.appName.toLowerCase();
if(ua.indexOf('explorer')>-1 ) {IE=true;}
var strContentElBarto = "";
//----------------------------x = nazev prvku
function objGet(x) {
	if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);
	else if (Boolean(document.ids)) return eval('document.ids.'+x);
	else return null;
}
//------------------------------------
function WinActionLocation(strURL) {
      window.frames['WinAction'].location.href = strURL;
      }
function ShowHelp(intId){
   var msg = window.open('/Admin/HelpAdmin.asp?help='+intId,'helpAdmin','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=500,height=400,left=20,top=20');
   msg.focus();
}
function NewWin(strUrl){
   var msg = window.open(strUrl,'NewWindow','toobar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,resizable=yes,width=900,height=700,left=20,top=20');
   msg.focus();
}
function SystemAction(strURL) {
      window.frames['WinAction'].location.href = strURL;
      }
function CacheWindow(){
   var msg = window.open('/Admin/Cache.asp','cache','toobar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=300,height=180,left=20,top=20');
   msg.focus();
}
function AddSubCategory(intTree){
  var arrData,arrSubData;
  var strReturn = showModalDialog("SelectCategory.asp?TREE="+intTree,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=300pt");
          if (strReturn == undefined){alert('Nebylo nic vybráno.');return}
          var el,r;
          with(document.all['strCategory']){
                 r = options.length;
                 for (var i=0; i<r; i++) {
                         options.remove(options.length-1);
                 }
          }
          arrData = strReturn.split("*");
          for (var i=0; i<arrData.length-1; i++) {
              arrSubData = arrData[i].split("/")
              el = document.createElement("OPTION")
              el.value = arrSubData[0];
              el.text = arrSubData[1];
              document.all['strCategory'].options.add(el);
          }
}
function ShowDate(strItem) {
     var strReturn = showModalDialog("/SelectDate.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=250pt;dialogHeight=200pt");
     if (strReturn == undefined){return;}
     strItem.value = strReturn;
}
function ChangeStateOrder(intState){
   var Childstate;
   var lengthItem
       if (intState == 0){
         Childstate = 0
       }else if(intState == 3){
         Childstate = 2
       }else if(intState == 4){
         Childstate = 4
       }else{
         Childstate = 1
       }

    if(typeof (document.EditOrder.IdItem[1]) == "object"){
          lengthItem = document.EditOrder.IdItem.length
          for(var i = 0; i < lengthItem; i++){
            document.EditOrder.StateItem[i].value = Childstate;
          }
     }else{
           document.EditOrder.StateItem.value = Childstate;
     }

}

function ShowOffers(intId) {
        if (document.all[intId].style.display == "none"){
                document.all[intId].style.display = ""
        }else{
                document.all[intId].style.display = "none"
        }

      }


function FrameLocation(strURL) {
      window.frames['ActionFrame'].location.href = strURL;
      }

function WriteNameAction(strName) {
      if(strName != ""){
          window.parent.document.all.NameAction.innerHTML = strName;
        }else{
         window.parent.document.all.NameAction.innerHTML = "Administrace katalogu"
        }
      }

function ChangeCategory(strString){
        var arrData;
        arrData = strString.split("##");
        document.EditCategory.NameCategory.value = arrData[1];
        document.EditCategory.IDCategory.value = arrData[0];
        document.EditCategory.ParentSelect.value = arrData[2];
        document.EditCategory.ImageCat.value = arrData[3];
        document.all.ImgCat1.src = '/Foto/ImgCategory/'+arrData[3];
        document.all.ImgCat2.src = '/Foto/ImgCategory/Over/'+arrData[3];
        window.frames.FrameDescription.location.href='BlankWhite.htm';
        if(arrData[4].toString() == "True"){
              document.EditCategory.bDisabled.checked = "True";
        }else{
              document.EditCategory.bDisabled.checked = "" ;
        }
      }

function ControlParent(idCat){
        if(idCat == document.EditCategory.IDCategory.value){
                alert("Kategorie nemůže být nadřazená sama sobě.");
                document.EditCategory.ParentSelect.value = 0;
                }
        }
function EmptyCategory(){

        document.EditCategory.NameCategory.value = "";
        document.EditCategory.IDCategory.value = 0;
        document.EditCategory.ParentSelect.value = 0;

      }

function AddNameParameter(){

  var strReturn = showModalDialog("QueryPage.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=200pt;dialogHeight=100pt");

          if (strReturn == ""){alert('Nebyl zadán žádný text.');return}
          var strValue = strReturn;
          var strText = strReturn;
          var el;
        if(typeof(document.all.VALUEPARAM.length) == "number"){
                for (var i=0; i<document.all.PARAMETERNAME.length; i++) {
                        el = document.createElement("OPTION")
                        el.text = strText;
                        el.value = strValue;
                          document.all.PARAMETERNAME[i].options.add(el);
                  }
        }else{
                el = document.createElement("OPTION")
                el.text = strText;
                el.value = strValue;
                document.all.PARAMETERNAME.options.add(el);
        }

}
function InsertImage(Action){
      var strReturn = showModalDialog("ListImage.asp?STAT="+Action,"","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
      if (strReturn == undefined){return;}
      document.all.ImageItem.value = strReturn;
      ChangeImage();

}
function InsertAddImage(intNoInput){

         var strReturn = showModalDialog("ListAddImage.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

         if (strReturn == undefined){return;}
         if(typeof(document.all.ImageAddItem.length) == "number"){
                document.all.ImageAddItem[intNoInput].value = strReturn;
         }else{
                document.all.ImageAddItem.value = strReturn;
         }
}
function InsertImageAdvertising(objForm){

         var strReturn = showModalDialog("/ElBarto/ListImg.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

         if (strReturn == undefined){return;}
         if(strReturn.substring(strReturn.length-3) == "swf"){
             objForm.Body.value = "<embed width='468' height='60' src='/ImgGalery/"+strReturn+"' >";
         }else{
             var strUrl = prompt("Zadejte URL na kterou má obrázek odkazovat.","http://");
             objForm.Body.value = "<a href='"+strUrl+"' target='blank'><img src='/ImgGalery/"+strReturn+"' border=0></a>";
         }
}
function InsertAddFile(intNoInput){

         var strReturn = showModalDialog("ListAddFiles.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

         if (strReturn == undefined){return;}
             if(typeof(document.all.FileAddName.length) == "number"){
                   document.all.FileAddPath[intNoInput].value = strReturn;
             }else{
                   document.all.FileAddPath.value = strReturn;
             }
}

function InsertImageCat(Action){
      var strReturn = showModalDialog("ListImageCat.asp?STAT="+Action,"","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
      if (strReturn == undefined){return;}
      document.all.ImageCat.value = strReturn;
      document.all.ImgCat1.src = '/Foto/ImgCategory/'+strReturn;
      document.all.ImgCat2.src = '/Foto/ImgCategory/Over/'+strReturn;
}

function PrintOrder(strPkOrder){
   var msg = window.open('OrderPrintAdmin.asp?ID='+strPkOrder,'okno','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=700,height=500,left=20,top=20');
   msg.focus();
}

function DeleteOrder(strPkOrder){
    if (confirm("Opravdu chcete objednávku č.: "+strPkOrder+" smazat?")){
           return true
    }else{
           return false
    }

}

function InsertTemplate(){
  var arrReturn
  var strReturn = showModalDialog("ListTemplate.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
    if(strReturn != undefined){
       arrReturn = strReturn.split("&");
       if(arrReturn[0] == "Param"){window.location.href=window.location.pathname+"?IdItem="+document.all.IdItem.value+"&PRM="+arrReturn[1]}
       if(arrReturn[0] == "All"){window.location.href="EditCommodityItem.asp?TMP="+arrReturn[1]}
    }
}

function ControlNumber(){
     if ((event.keyCode <48) || (event.keyCode >57)) event.returnValue = false;
}
function AddCategory(intTree){
  var arrData,arrSubData;
  var strReturn = showModalDialog("SelectCategory.asp?TREE="+intTree+"&CAT="+document.all.IdItem.value,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=300pt");
          if (strReturn == undefined){alert('Nebylo nic vybráno.');return}
          var el,r;
          with(document.all['strCategory'+intTree]){
                 r = options.length;
                 for (var i=0; i<r; i++) {
                         options.remove(options.length-1);
                 }
          }
          arrData = strReturn.split("*");
          for (var i=0; i<arrData.length-1; i++) {
              arrSubData = arrData[i].split("/")
              el = document.createElement("OPTION")
              el.value = arrSubData[0];
              el.text = arrSubData[1];
              document.all['strCategory'+intTree].options.add(el);
          }
}
function SendBulkMail(bNews,bCustomer,intID){
   if(bNews){
         bNews = 1
   }else{
         bNews = 0
   }
   if(bCustomer){
         bCustomer = 1
   }else{
         bCustomer = 0
   }
   var msg = window.open('SendBulkMail.asp?TypeMail=Client&NWS='+bNews+'&CST='+bCustomer+'&GRP='+intID,'okno','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=700,height=500,left=20,top=20');
   msg.focus();
}
function SendMail(strAddress){
   var msg = window.open(strAddress,'win','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=700,height=500,left=20,top=20');
   msg.focus();
}
function InsertElBarto(strContent){
   strContentElBarto = strContent;
   var msg = window.open('ShowOneElBarto.asp','EditWindow','toobar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=700,height=550,left=20,top=20');
   msg.focus();
}
function ControlPassword(NameOne,NameTwo){
  if (document.all[NameOne].value != document.all[NameTwo].value){
  alert("Špatně zadané heslo.");
  document.all[NameOne].value = "";
  document.all[NameTwo].value = "";
  document.all[NameOne].focus();
  return false;
  }else{
  return true;
  }
}

