//zjisteni IE prohlizece a dany do globalni promenne
var IE= null;
var ua = navigator.appName.toLowerCase();
if(ua.indexOf('explorer')>-1 && document.getElementById && document.childNodes) {IE=true;}
var objItem;
//------------------------------------------------------
function Lsc(nId,nActId){
	if(document.getElementById('i'+nId) != null){
		if(document.getElementById('i'+nId).src.indexOf("/Img/Plus.gif") > -1){
			window.frames['WinStat'].location.replace('/WriteSubTree.asp?Id='+nId+'&Act='+nActId);
		}else{
			document.getElementById('i'+nId).src = "/Img/Plus.gif";
			document.getElementById('s'+nId).style.display = "none";
		}
	}
}
//----Cookies-------
function SaveCookies(Name, Value, Validity){
	var Cas = new Date();
	Validity = Validity*86400000;
	Cas.setTime(Cas.getTime()+Validity);
	document.cookie=Name+"="+escape(Value)+"; expires="+Cas.toGMTString();
}
function LoadCookies(Name)
{
	var Data = " "+document.cookie+";";
	var NameCookies = " "+Name+"=";
	var End, Result;
	var Begin = Data.indexOf(NameCookies);
	if (Begin!=-1){
		Begin+=NameCookies.length;
		End = Data.indexOf(";", Begin);
		Result = Data.substring(Begin, End);
		Result = unescape(Result);
	} else {
		Result = 0;
	}
	return Result;
}
//-----------------
//----ride text----
function SlideShow(strText){
	var intIndex;
	var arrText;
	var intLenght; 
	arrText = strText.split("$");
	intLength = arrText.length;
	intIndex = parseFloat(LoadCookies("RideText"));
	if (intIndex > intLength-2){intIndex = 0;}
 	if(IE){
		document.getElementById('Slide').innerHTML = arrText[intIndex];
	 	intIndex += 1;
	 	SaveCookies("RideText", intIndex, 1);
	 	document.getElementById('Slide').start();
	}else{
		document.getElementById('Slide').innerHTML = arrText[intIndex];
	 	intIndex += 1;
 		SaveCookies("RideText", intIndex, 1);
		setTimeout('SlideShow(strText)',10000);
	}	
 }
//--------------
function ShowDate(strItem) {
    objItem = strItem
    if(IE){
        var strReturn = showModalDialog("/SelectDate.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=250pt;dialogHeight=200pt");
        if (strReturn == undefined){return;}
        strItem.value = strReturn;
    }else{
       var objWnd = window.open("/SelectDateInc.htm","Date","scrollbars=no,height=230,width=330,left=10,top=10");
       objWnd.focus();
    }    
}
function AddChangeNameBasket(strName){
    if ( strName == "$new$"){
        var strReturn = showModalDialog("/QueryPage.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=200pt;dialogHeight=80pt");
        if (strReturn == ""){
                alert('Nebyl zadán ádný text.');
                return
        }else{
                document.FormNameBasket.NewNameBasket.value = strReturn
                document.FormNameBasket.submit()
        }
     }else{
        document.FormNameBasket.submit()
     }     
}       

function OpenWnd(strURL){
         var objWnd = window.open(strURL,"InfoDetail","scrollbars=no,height=500,width=400,left=10,top=10");
         objWnd.focus();
}
function ControlNumber(){
     if ((event.keyCode <48) || (event.keyCode >57)) event.returnValue = false;
}
//----------info okno-------------------------------------------------------
function InfoWindow(strAddress) {
       showModalDialog(strAddress,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=450pt;dialogHeight=320pt");
}
function WriteDate(){
    var strDay=new Date();
    var d=strDay.getDay();
    if (d==1) {document.writeln('pondělí') }
    else { if (d==2) {document.writeln('úterý') }
    else { if (d==3) {document.writeln('středa') }
    else { if (d==4) {document.writeln('čtvrtek') }
    else { if (d==5) {document.writeln('pátek') }
    else { if (d==6) {document.writeln('sobota') }
    else { if (d==0) {document.writeln('neděle') }}}}}}};
    document.writeln(strDay.getDate(),'.',strDay.getMonth()+1,'.',strDay.getFullYear());
    }
function RunEmailControl(adresa){
	 re = /^[+_a-zA-Z0-9-]+(\.[+_a-zA-Z0-9-]+)*@[\.a-zA-Z0-9-]+\.[a-zA-Z0-9-]{2,4}$/;
    return adresa.search(re) == 0;
}
function EmailControl(address){
	if(RunEmailControl(address)){
		return true;
	}else{
		alert('patně vyplněný e-mail.')
		return false
	}
}         

function ShowSearchMenu(x){
    if (x == 1){
        document.all.SearchTable.style.display='';
    }else{
        document.all.SearchTable.style.display='none';
    }
}
function PositionInfo(strText,oX,oY){
        document.getElementById('StateInfo3').innerHTML=strText;
        document.getElementById('StateInfo2').innerHTML="  probíhá připojování...";
        var x = oX;
        if (IE){
                var e = event.srcElement;
                var y = 0;
                while (typeof e == 'object' && e.tagName != 'BODY'){
                        y += e.offsetTop;
                        e = e.offsetParent;
                };
        }else{
                var y = oY + document.body.scrollTop;    
        }   
        document.getElementById('StateInfo1').style.top=y-140;
        if (document.body.clientWidth < 933){
                document.getElementById('StateInfo1').style.left=x-175;
        }else{
                document.getElementById('StateInfo1').style.left=780;
        }
}

function LocState(strCode,intCount,oX,oY){
    window.parent.frames['WinStat'].location.href="/InfoState.asp?ID="+strCode+"&CN="+intCount
    PositionInfo("On-line stav",oX,oY);
}
function ChangeStorage(bState){
    if(bState){
        for(var i = 0; i < document.all['S'].length; i++){
            document.all['S'][i].value="0"
        }
    }else{
        for(var i = 0; i < document.all['S'].length; i++){
            document.all['S'][i].value="-1"
        }

    }
}
function ChangeCloseout(bState){
    if(bState){
        for(var i = 0; i < document.all['C'].length; i++){
            document.all['C'][i].value="1"
        }
    }else{
        for(var i = 0; i < document.all['C'].length; i++){
            document.all['C'][i].value="3"
        }

    }
}
function ControlUserDataSubmit(){
	if(document.UserDataForm.Firm.value == ""){alert("Vyplňte název firmy (jméno a příjmení).\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Street.value == ""){alert("Vyplňte ulici.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.City.value == ""){alert("Vyplňte město.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.ZipCode.value == ""){alert("Vyplňte PSČ.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Phone.value == ""){alert("Vyplňte telefon.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Email.value == ""){alert("Vyplňte prosím email.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Login.value == ""){alert("Vyplňte přihlaovací jméno.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Login.value.length < 5){alert("Přihlaovací jméno musí mít minimálně 5 znaků.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Password.value == ""){alert("Vyplňte heslo.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Password.value.length < 5){alert("Heslo musí mít minimálně 5 znaků.\n\nV případě problémů kontaktujte registrace@alzasoft.cz");return false}
	if(document.UserDataForm.Password.value != document.UserDataForm.PasswordControl.value){alert("patně zadané heslo.Zadejte prosím znovu.");return false}
	// if(document.UserDataForm.DeliveryType.value == ""){alert("Vyberte způsob dopravy.");return false}
	return EmailControl(document.UserDataForm.Email.value);
	return true
}
function ControlDataOrder(){
	if(document.OrderForm.DeliveryFirm.value == "" && document.OrderForm.DeliveryName.value == ""){alert("Zadejte název firmy nebo jméno a příjmení v dodací adrese.");return false}
	if(document.OrderForm.DeliveryType.value == "-"){alert("Vyberte způsob dopravy.");return false}
	if(document.OrderForm.DeliveryType.value == "109" || document.OrderForm.DeliveryType.value == "101" || document.OrderForm.DeliveryType.value == "106" || document.OrderForm.DeliveryType.value == "97"){return true}
	if(document.OrderForm.DeliveryCity.value == ""){alert("Zadejte město v dodací adrese.");return false}
	if(document.OrderForm.DeliveryZipCode.value == ""){alert("Zadejte PSČ v dodací adrese.");return false}
  return true
}
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;
  }
}
//zahlasovani ankety funguje pod netscapem(4.7+) mozilou(1.3) ie....
function VoteInquiry(plngAns){
	document.forms.frmInq.InqAns.value = plngAns;
	document.forms.frmInq.submit();
}