// KOMPATIBILITA

var Br = new BrCheck()

function BrCheck()
{
	this.VER	= navigator.appVersion;
	this.AGENT	= navigator.userAgent;
	this.DOM	= document.getElementById ? true:false;

	this.OP5	= this.AGENT.indexOf("Opera 5")>-1							?true:false;
	this.OP6	= this.AGENT.indexOf("Opera 6")>-1							?true:false;
	this.OP7	= this.AGENT.indexOf("Opera 7")>-1							?true:false;
	this.OP		= (this.OP5 || this.OP6 || this.OP7);

	this.IE4	= (document.all && !this.DOM && !this.OP)					?true:false;
	this.IE5	= (this.VER.indexOf("MSIE 5")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE6 = (this.VER.indexOf("MSIE 6") > -1 && this.DOM && !this.OP) ? true : false;
	this.IE7 = (this.VER.indexOf("MSIE 7") > -1 && this.DOM && !this.OP) ? true : false;
	this.IE8 = (this.VER.indexOf("MSIE 8") > -1 && this.DOM && !this.OP) ? true : false;
	this.IE = (this.IE4 || this.IE5 || this.IE6 || this.IE7 || this.IE8);

	this.NS4	= (document.layers && !this.DOM)							?true:false;
	this.NS7	= (this.DOM && parseInt(this.VER) >= 5 && this.AGENT.lastIndexOf('Netscape')<this.AGENT.lastIndexOf('7'))?true:false;
	this.NS6	= (this.DOM && parseInt(this.VER) >= 5 && !this.NS7)		?true:false;
	this.NS		= (this.NS4 || this.NS6 || this.NS7);

	return this;
}

function getE(objectID) {
	return document.getElementById(objectID);
}

function getF(formName) {
	return document.forms[formName];
}

function getFEx(formName, oDocument) {
	return oDocument.forms[formName];
}

function getEEx(objectID, oDocument) {
	return oDocument.getElementById(objectID);
}

function SetDSP(nDSP, sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (nDSP==1) {
		document.cookie="DSP=1; expires="+vyprs.toGMTString()+";";
	} else {
		document.cookie="DSP=0; expires="+vyprs.toGMTString()+";";
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

function SetAlsoNotStored(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookies('COMANS')=='1') {
		document.cookie="COMANS=0; expires="+vyprs.toGMTString()+";";
	} else {
		document.cookie="COMANS=1; expires="+vyprs.toGMTString()+";";
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

function SetCloseout(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookies('COMCLO')=='1') {
		document.cookie="COMCLO=0; expires="+vyprs.toGMTString()+";";
	} else {
		document.cookie="COMCLO=1; expires="+vyprs.toGMTString()+";";
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

// ###   FCE PRO zaskrtnutí a odeslání pk zboží pro Compare.asp   ###

function CompareSelected() {
	var sapkTblCommodity, CompareAdd;
	sapkTblCommodity = "";
	//aby to fungovalo vsude mozzila ie atd....
	for (var x=0; x<document.forms.length;x++){
		if (document.forms[x].name.indexOf("BuyFormBody")){
			if (document.forms[x].CompareAdd){
				if(document.forms[x].CompareAdd.checked){
					if (sapkTblCommodity=="") {
						sapkTblCommodity = document.forms[x].CompareAdd.value;
					}else{
						sapkTblCommodity += "|" + document.forms[x].CompareAdd.value;
					}
				}
			}
		}
	}
	if (sapkTblCommodity.indexOf('|') == -1) {

		alert('Pro porovnání je nutno vybrat nejméně 2 výrobky ...');
	} else {
		window.open('/Compare.asp?CMP=' + sapkTblCommodity, "Compare","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=500,width=720,left=10,top=10,resizable=1,");
	}
}

function CompareRemoveOne(sapkTblCommodity, sComToRem) {
	var apkTblCommodity, aLen;
	if (sapkTblCommodity == '') {
		window.close();
		return;
	}
	apkTblCommodity = sapkTblCommodity.split('|');
	aLen = apkTblCommodity.length;
	if (aLen == 1) {
		window.close();
		return;
	}
	sapkTblCommodity = '';
	for (var i=0; i<aLen; i++) {
		if (apkTblCommodity[i]!=sComToRem) {
			if (sapkTblCommodity=='') {
				sapkTblCommodity = apkTblCommodity[i];
			} else {
				sapkTblCommodity += "|" + apkTblCommodity[i];
			}
		}
	}
	window.location.href = '/Compare.asp?CMP=' + sapkTblCommodity;
}

// ###   FCE PRO BOXIKY SE SUBKATEGORIEMI   ###

var IdTimeToHideCategoryBox;

function ShowCategoryBox(img_id, cat_id)
{
	if ((IdTimeToHideCategoryBox!=null) && (cat_id!=cat_id_last)) HideAllCategoryBox(cat_id_last);

	var objElem = img_id;
    var x = 0;
    var y = 0;
    x += parseFloat(objElem.offsetLeft) + parseFloat(objElem.offsetWidth);
    y += parseFloat(objElem.offsetTop);

	getE('categoryBoxtable_' + cat_id).style.left = x;
	getE('categoryBoxtable_' + cat_id).style.top = y - 10;
	getE('categoryBoxtable_' + cat_id).style.display = 'block';
}

function HideCategoryBox(cat_id)
{
	cat_id_last = cat_id;
	IdTimeToHideCategoryBox = window.setTimeout('HideAllCategoryBox(' + cat_id + ')', 300);
}

function HideAllCategoryBox(cat_id)
{
	window.clearTimeout(IdTimeToHideCategoryBox);
	IdTimeToHideCategoryBox = null;
	getE('categoryBoxtable_' + cat_id).style.display = 'none';
}

// ###   FCE PRO DIALOG ZADANI VOLITELNYCH PARAMETRU   ###
var gsFormSuffix, gsFormIndex;

function BuyOrSetVariableParams(sFormSuffix,sFormIndex) {
	var sSelects, nWindowHeight;
	gsFormIndex = sFormIndex;
	gsFormSuffix = sFormSuffix;

	sSelects = getE("DivForPars" + sFormSuffix + sFormIndex).innerHTML;
	// ve skeletu musí být ve fci GetFormattedParams "ParamItem" psáno CASE-SENSITIVE !!!
	if (sSelects == "") {
		getF("BuyForm" + sFormSuffix + sFormIndex).submit();
	} else {
		// 22 je výška selectu - definováno raději i podle stylu!
		// nWindowHeight = 86 + 22 * (sSelects.split("ParamItem").length);
		getE('DivForParams').innerHTML = getE("DivForPars" + sFormSuffix + sFormIndex).innerHTML;
		getE('ParamCaption').innerHTML = getE("BuyForm" + sFormSuffix + sFormIndex).NameItem.value;
		getE('ParamTbl').style.top =  window.event.srcElement.offsetTop + 20;
		getE('ParamTbl').style.left =  window.event.srcElement.offsetLeft - 60;
		getE('ParamTbl').style.display = 'inline';
	}
}

function BuyOrSetParams(sFormIndex) {
	var e = getE( "ItemParameters" + sFormIndex );
	e.style.display = "inline";
	e.style.position = "relative";
	e.style.top =  window.event.srcElement.offsetTop + 20;
	e.style.left =  window.event.srcElement.offsetLeft - 60;	
	e.style.border =  "1px solid black";	
}
function CopyParamsBack() {
	getE("DivForPars" + gsFormSuffix + gsFormIndex).innerHTML = getE('DivForParams').innerHTML;
	getF("BuyForm" + gsFormSuffix + gsFormIndex).submit();
}

// ###   FCE PRO ROZKLIKAVANI KATEGORII   ###

function InsertCookiesCat(intId,idTree){
	document.cookie="category"+idTree+"="+intId+";";
	document.cookie="category"+idTree+"="+intId+";";
}
function checkParent(src, dest) {
	while (src!=null) {
		if (src.tagName == dest) return src;
			src = src.parentElement;
	}
	return null;
}

function outlineCat() {
	var open = event.srcElement;
	var el = checkParent(open, "TD");
	if (null!=el) {
		var pos = 0;
		for (var pos=0; pos<el.children.length; pos++) {
			if ("TABLE"==el.children[pos].tagName) {
				if (el.children[0].src.indexOf("/img/catTree/plus.gif")>0) {
					el.children[0].src = "/img/catTree/minus.gif";
				}else{
					el.children[0].src = "/img/catTree/plus.gif";
				}
				break;
			}
		}
	    if (pos==el.children.length) return;
	} else return;
	el = el.children[pos];
	if ("TABLE"==el.tagName) {
		if (""==el.style.display) {
			el.style.display = "none";
		} else {
			el.style.display = "";
		}
	}
	event.cancelBubble = true;
}

// ###   FCE PRO PriceList ###

function SHModalDlgPricelist()
{
	var strReturn = showModalDialog("/Includes/EmailPricelist.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=320px;dialogHeight=124px;");

    if (strReturn == "") return;
	document.location.href = "/EmailPricelist.asp?EmailPricelist=" + strReturn;
}

// ##########

function onAction(imgName){
       getE(imgName).src = eval(imgName + "on.src")
}

function offAction(imgName){
	if (oldImgName.substring(0,4)!=imgName.substring(0,4)){
		getE(imgName).src = eval(imgName + "off.src")
	}
}

function OpenWnd(strURL){
	var objWnd = window.open(strURL,"_blank","scrollbars=no,height=500,width=400,left=10,top=10", true);
	objWnd.focus();
}
function showHMcalc(nprice){
	var objWnd = window.open("/HomeCredit.asp?nPrice=" + nprice,"_blank","scrollbars=no,height=450,width=600,left=10,top=10", true);
	objWnd.focus();
}
function showRecycleWin(code){
    //window.open("http://www.w3schools.com","_blank");
	var objWnd = window.open("/RecycleInfo.asp?CODE=" + code,"_blank","scrollbars=yes,height=450,width=700,left=10,top=10,resizable=1", true);
	objWnd.focus();
}

function AddBuy(strName, intPrice, intDph, strCode) {
	var strData,strReturn
	strData = strName+"&"+intPrice+"&"+intDph+"&"+strCode
	strReturn = showModalDialog("/AddUpdBuy.asp",strData,"status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=200pt");
	if (strReturn == "1")
		ActionCookies('BZbuy');
	else if (strReturn == "2")
		window.location.href = "/order.asp";
}
function AddBuyDetail(strName, intPrice, intDph, strCode) {
	var strData,strReturn
	strData = strName+"&"+intPrice+"&"+intDph+"&"+strCode
	strReturn = showModalDialog("/AddUpdBuy.asp",strData,"status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=200pt");
	if (strReturn == "1"){
		window.opener.ActionCookies('BZbuy')
	}else if (strReturn == "2"){
		window.opener.location.href="/order.asp";
		window.close();
	}
}
function ActionCookies(strName){
	var strString,strSum1,strSum2,intSuma;
	strSum2 = new Array();
	intSuma = 0;

	strString = ExtractCookies(strName);
	if (strString > ""){
		strSum1 = strString.split("#");
		for (var i=0; i< strSum1.length-1; i++){
			strSum2[i] = strSum1[i].split("&");
			intSuma += BarterComma(strSum2[i][1])*BarterComma(strSum2[i][4]);
		}
		getE('CompletPrice').value =  FormatNumber(intSuma);
	}
}
function DeleteCookies(strName){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie=strName+"=; expires="+vyprs.toGMTString()+";";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie=strName+"=; expires="+vyprs.toGMTString()+";";
	getE('CompletPrice').value = "0.00";
}
function InsTreeCook(intId,idTree){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie="category"+idTree+"="+intId+"; expires="+vyprs.toGMTString()+";";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie="category"+idTree+"="+intId+"; expires="+vyprs.toGMTString()+";";
}
function InsertCookies(strName,strData){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+";";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+";";
}

function ExtractCookies(strName){
	var cookieList=document.cookie.split("; ");
	var cookieArray = new Array();
	var name = "#"
	for (var i=0; i < cookieList.length; i++){
		if(cookieList[i].indexOf(strName)>-1){
			if( cookieList[i].indexOf("=")>-1){name = cookieList[i].split("=");}
		}
	}
	if (name != "#"){
		return name[1];
	}else{
		return "none";
	}
}
function ParseCookies(strName){
	var strCook = ExtractCookies(strName)
	if (strCook != "none"){
		var strList = strCook.split("a");
		for (var i=0; i < strList.length-1; i++){
			if(typeof(getE(strList[i]+'a')) == "object"){getE(strList[i]+'a').click();}
		}
	}
}
function FormatNumber(text){
	var mezi = BarterComma(text);
	mezi = ''+Math.round(parseFloat(mezi) * 100);
	var desetiny = mezi.substring(mezi.length-2, mezi.length);
	var cele = mezi.substring(0,mezi.length-2);
	if (parseFloat(mezi) < 1){
	        var mezi = "0."+desetiny;
	}else{
	        var mezi = cele+"."+desetiny;
	}
	return mezi;
}
function FormatFloat(nNumber,nDecimal){
	var sNumber = BarterComma(nNumber);
	sNumber = ''+Math.round(parseFloat(sNumber) * Math.pow(10,nDecimal));
	var sDedimal = sNumber.substring(sNumber.length-nDecimal, sNumber.length);
	var nInt = sNumber.substring(0,sNumber.length-nDecimal);
	if (parseFloat(sNumber) < 1){
	        var sNumber = "0."+sDedimal;
	}else{
	        var sNumber = nInt+"."+sDedimal;
	}
	return sNumber;
}
function FormatCurrency(nNumber,nDecimal){
	var sCurrency, iInsertSpace;
	sCurrency = FormatFloat(nNumber, nDecimal).replace('.',',');
	iInsertSpace = sCurrency.indexOf(',') - 3;
	while (iInsertSpace>0) {
		sCurrency = sCurrency.substring(0,iInsertSpace) + ' ' + sCurrency.substring(iInsertSpace,sCurrency.length);
		iInsertSpace -= 3;
	}
	if (nDecimal==0) sCurrency = sCurrency.substring(0,sCurrency.indexOf(","));
	return sCurrency;
}
function BarterComma(text){
	var mezi = ''+text;
	if (mezi.indexOf(',') != -1){
		mezi = mezi.split(",");
		mezi = mezi[0]+"."+mezi[1];
	}else{
		mezi = text;
	}
	return parseFloat(mezi);
}
function ControlNumber() {
     if (((event.keyCode <48) || (event.keyCode >57)) && (event.keyCode!=13)) event.returnValue = false;
}
function ControlPhone() {
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32)  && (event.keyCode!=40) && (event.keyCode!=41) && (event.keyCode!=43))
		event.returnValue = false;
}
function ControlPSC() {
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32))
		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 ShowSearchMenu(x){
    if (x == 1){
        getE('Searchtable').style.display='';
    }else{
        getE('Searchtable').style.display='none';
    }
}
function LocInfo(){
	getE('StateInfo2').innerHTML="  probíná připojování...";
	var e = event.srcElement;
	var y = 0;
	var x = 0;
	while (typeof e == 'object' && e.tagName != 'BODY'){
		y += e.offsetTop;
		e = e.offsetParent;
	};
	x = (window.screen.width/2)+375
	getE('StateInfo1').style.top=y-140;
	getE('StateInfo1').style.left=x;
}

function PositionInfo(strText){
	getE('StateInfo3').innerHTML=strText;
	getE('StateInfo2').innerHTML="  probíhá připojování...";
	var e = event.srcElement;
	var y = 0;
	var x = event.clientX;
	while (typeof e == 'object' && e.tagName != 'BODY'){
		y += e.offsetTop;
		e = e.offsetParent;
	};
	getE('StateInfo1').style.top=y-140;
	if (document.body.clientWidth < 933){
	  getE('StateInfo1').style.left=x-175;
	}else{
	  getE('StateInfo1').style.left=780;
	}
}
function LocState(strCode,intCount){
	window.parent.frames['WinStat'].location.href="/InfoState.asp?ID="+strCode+"&CN="+intCount
	PositionInfo("On-line stav");
}
function ChangeStorage(bState){
	if(bState){
		for(var i = 0; i < getE('S').length; i++){
			getE('S')[i].value="0"
		}
	}else{
		for(var i = 0; i < getE('S').length; i++){
			getE('S')[i].value="-1"
		}
	}
}
function ChangeCloseout(bState){
	if(bState){
		for(var i = 0; i < getE('C').length; i++){
			getE('C')[i].value="1"
		}
	}else{
		for(var i = 0; i < getE('C').length; i++){
			getE('C')[i].value="3"
		}
	}
}
function ValidateAccount(sAccount) {
	var u1,u2,t1,t2,i;
	var vahy = new Array("1","2","4","8","5","10","9","7","3","6")
	u1 = sAccount.substring(0,sAccount.length - 10);
	u2 = sAccount.substring(sAccount.length - 10,12);
	t1 = 0;t2 = 0;
	for(i=u1.length ;i>0;i--) {
		t1 += u1.charAt(i - 1)*vahy[10 - i];
	}	  
	for(i=u2.length ;i>0;i--) {
		t2 += u2.charAt(i - 1)*vahy[10 - i];
	}
	if (((t2%11) == 0)&&((t1%11 == 0))) {
		return true;
	} else {
		return false;
	}
}

function ControlSearch()
{

var sText =getF('SearchForm').EXPS.value;

while (sText.indexOf(' ')==0) {sText=sText.slice(1);}

while (sText.lastIndexOf(' ')==sText.length-1) {sText=sText.slice(0,sText.length-1);}

if (sText.length <3){alert('Minimální délka slova pro vyhledávání je 3!'); getF('SearchForm').EXPS.focus(); return false}
getF('SearchForm').EXPS.value = sText;
return true;
}


function CheckName(sText){
  var i,regEx  = new RegExp("[^a-zA-Z|ě|š|č|ř|ž|ý|á|í|é|ó|í|ú|ť|ď|ň|ů|Ě|Š|Č|Ř|Ž|Ý|Á|Í|É|Ó|Í|Ú|Ů|Ť|Ď|Ň \s]"); 

    regEx.ignoreCase = true;
	if (sText.length<2){return false}
    if (regEx.test(sText) == true ){return false}
	
return true;		
}
function CheckEmail(sText){
 if ( (sText.length<6) || (sText.indexOf('@') == '-1') || (sText.indexOf('@') >=  (sText.length) - 1 ) || (sText.indexOf('@') <= '0' ) || (sText.indexOf('.') == "-1") || (sText.indexOf('.') >= (sText.length) -2) ||  (sText.indexOf('.') <='0') || ( (sText.indexOf('@')+1) == (sText.indexOf('.')) )  ) {return false;}
	}
	
function CheckNums(sText,nLength,bEqual){
	if (bEqual == '1') { if ((sText.length >nLength)||(sText.length<nLength)||(isNaN(sText) == true ) ){return false} }
	else 
	{if ( (sText.length<nLength)||(isNaN(sText) == true) ){return false} }
 }
function CheckPhone(sText,nLength,bEqual){
		if (sText.substr(0,1)='+'){sText=sText.substr(1,length(sText))}
	if (bEqual == '1') { if ((sText.length >nLength)||(sText.length<nLength)||(isNaN(sText) == true ) ){return false} }
	else 
	{if ( (sText.length<nLength)||(isNaN(sText) == true) ){return false} }
}	
	

function ControlUserDataSubmit(){
	if(CheckName(getF('UserDataForm').FirstName.value) == false){alert("Jméno není správně vyplněno.");getF('UserDataForm').FirstName.focus();return false}
	if(CheckName(getF('UserDataForm').LastName.value) == false){alert("Příjmení není správně vyplněno.");getF('UserDataForm').LastName.focus();return false}
//	if((getF('UserDataForm').FirstName.value + getF('UserDataForm').LastName.value == "") && (getF('UserDataForm').Firm.value == "")){alert("Vyplňte název firmy, nebo jméno a příjmení.");return false}

	if(getF('UserDataForm').Street.value == ""){alert("Ulice není správně vyplněna.");getF('UserDataForm').Street.focus();return false}
	if(getF('UserDataForm').City.value == ""){alert("Město není správně vyplněno.");getF('UserDataForm').City.focus();return false}
	if(CheckNums(getF('UserDataForm').ZipCode.value,5,0)== false ) {alert("PSČ není správně vyplněno .");getF('UserDataForm').ZipCode.focus();return false}

//	if(CheckEmail(getF('UserDataForm').Email.value) == false){alert("Email není správně vyplněn.");getF('UserDataForm').Email.focus();return false}
	if(CheckNums(getF('UserDataForm').Phone.value,7,0) == false){alert("Telefonní číslo není správně vyplněno.");getF('UserDataForm').Phone.focus();return false}

	if(getF('UserDataForm').Phone.value + getF('UserDataForm').Mobil.value == ""){alert("Vyplňte telefon, nebo mobil.");getF('UserDataForm').Phone.focus();return false}
	if(!ValidateAccount(getF('UserDataForm').BankAccount.value)){alert("Číslo bankovního účtu není platné, zkuste jej zadat znovu, nebo pole nevyplňujte.");getF('UserDataForm').BankAccount.focus();return false};
	if(getF('UserDataForm').Login.value == ""){alert("Přihlašovací jméno není správně vyplněno.");getF('UserDataForm').Login.focus();return false}
	if(getF('UserDataForm').Login.value.length < 5){alert("Přihlašovací jméno musí mít nejméně 5 znaků.");getF('UserDataForm').Login.focus();return false}
	if(getF('UserDataForm').Password.value == ""){alert("Heslo není správně vyplněno.");getF('UserDataForm').Password.focus();return false}
	if(getF('UserDataForm').Password.value.length < 5){alert("Heslo musí mít minimálně 5 znaků.");getF('UserDataForm').Password.focus();return false}
	//if (getE('PaymentType').value == 34 ){ getF('UserDataForm').action =  "https://" +  getF('UserDataForm').sServVar.value + "/Order.asp"; return true}						
	
	return true;


}

function ControlUserDataSubmitNotReg(){
	if(CheckName(getF('OrderForm').DeliveryFirstName.value) == false){alert("Jméno není správně vyplněno.");getF('OrderForm').DeliveryFirstName.focus();return false}
	if(CheckName(getF('OrderForm').DeliveryLastName.value) == false){alert("Příjmení není správně vyplněno.");getF('OrderForm').DeliveryLastName.focus();return false}
	if(getF('OrderForm').DeliveryStreet.value == ""){alert("Ulice není správně vyplněna.");getF('OrderForm').DeliveryStreet.focus();return false}
	if(getF('OrderForm').DeliveryCity.value == ""){alert("Město není správně vyplněno.");getF('OrderForm').DeliveryCity.focus();return false}
	if(CheckNums(getF('OrderForm').DeliveryZipCode.value,5,1) == false)   {alert("PSČ není správně vyplněno.");getF('OrderForm').DeliveryZipCode.focus();return false}
	if(EmailControl(getF('OrderForm').sEmail.value) == false ) {getF('OrderForm').sEmail.focus();return false}
	if(CheckNums(getF('OrderForm').Phone.value,7,0) == false){alert("Vyplňte  správně telefon nebo mobil.");getF('OrderForm').Phone.focus();return false}	

//	if(getE('PaymentType').value == 34 ){ getF('OrderForm').action =  "https://" +  getF('OrderForm').sServVar.value + "/Order.asp"; alert(getF('OrderForm').action); return true}						

		return true;

	
}


function ControlDataOrder(){
	if(getE('OrderForm').DeliveryType.value == "-"){alert("Vyberte způsob dopravy."); getF('OrderForm').DeliveryType.focus(); return false}
	if(getE('OrderForm').PaymentType.value == "-"){alert("Vyberte způsob platby."); getF('OrderForm').PaymentType.focus(); return false}
	return true;
}
function ControlPassword(NameOne,NameTwo){
	if (getE(NameOne).value != getE(NameTwo).value){
		alert("Špatně zadané heslo.");
		getE(NameOne).value = "";
		getE(NameTwo).value = "";
		getE(NameOne).focus();
		return false;
	}else{
		return true;
	}
}

function EmailControl(f)
{
    
    return EmailControlRegExp(f, true);
    
	if ((f=='' || f=='Váš@email.cz') ||(f.indexOf('@') < 1 || f.indexOf('@') != f.lastIndexOf('@') || f.lastIndexOf('.') < f.lastIndexOf('@')+2  || f.lastIndexOf('.') > (f.length-3) || f.lastIndexOf('.') < (f.length-4))){
		alert('Nesprávný formát emailu');
		return false;
		}
    if (f.indexOf('"') != -1 || f.indexOf("'") !=  -1 || f.indexOf(';') !=  -1 || f.indexOf(',') !=  -1) 	
	{
	   alert('Email obsahuje nepovolený znak.');
	   return false; 
	}

	return true;
}

function EmailControlRegExp(sEmail, bShowMsg)
 {

   if (sEmail=='' || sEmail=='Váš@email.cz')
   {
        if (bShowMsg) alert('Nesprávný formát emailu');
		return false;
  }
  
  var regEx  = new RegExp("^[_a-zA-Z0-9\.\-]+@(([_a-zA-Z0-9\-]{0,}\.){1,})+\.[a-zA-Z]{2,}$"); 

  
  regEx.ignoreCase = true;
  
  if ((regEx.test(sEmail) == false)||(sEmail.indexOf('@')+1 == sEmail.indexOf('.')))

  {
        if (bShowMsg) alert('Nesprávný formát emailu');
		return false;
  }
  return true;
}  






// ##### PriceList BEEND #######################################################
function DelProducer(nProd) {
	if (nDeleted==nProducers-1) return;
	getE("bEnabled" + nProd).value='0';
	getE("Producer" + nProd).style.display="none";
	nDeleted += 1;
}

function PutCategoriesIdNameToSelect(saCatIdName, nIndex, bStart) {
	var arrData, arrSubData, saCatID, el;
	arrData = saCatIdName.split("*");
	saCatID = "";
	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];
		saCatID += arrSubData[0] + "$"
		if (bStart==true) {
			if (i==0) {
				el.text='-Všechny kategorie-';
				document.PL['Categ'+nIndex].options.add(el);
			}
		} else
		    document.PL['Categ'+nIndex].options.add(el);
	}
		
	document.PL['CatID' + nIndex].value = saCatID.substr(0,saCatID.length - 1);
	if (saCatIdName == "") {
		document.PL['Categ'+nIndex].style.display = "none";
		getE("ChooseCateg"+nIndex).style.display  = "inline";
	} else {
		document.PL['Categ'+nIndex].style.display = "inline";
		getE("ChooseCateg"+nIndex).style.display  = "none";
	}
}

function GetCategoriesIdNameForSelect(nTree,bAlsoDisabled,nIndex,nUserType) {
	var saCatID,nProID,sProNM;
	var r;
	
	nProID = document.PL['ProdID'+nIndex].value;
	
	sProNM = document.PL['ProdID'+nIndex].options[document.PL['ProdID'+nIndex].selectedIndex].innerHTML
	saCatID = document.PL['CatID' + nIndex].value;
	if(Br.IE){
		var strReturn = showModalDialog("/Includes/PriceListSelectCatsOfProd.asp?TREE="+nTree+"&ProID="+nProID+"&DIS="+bAlsoDisabled+"&CatIDs="+saCatID+"&ADM="+nUserType+"&ProNM="+sProNM,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=450px;dialogHeight=400px");
		if (typeof(strReturn) == 'undefined') return;
		with(getE("Categ"+nIndex)){
			r = options.length;
	       		for (var i=0; i<r; i++) {
	               		options.remove(options.length-1);
	       		}
		}
		PutCategoriesIdNameToSelect(strReturn, nIndex, false);
	}else{
		window.open("/Includes/PriceListSelectCatsOfProd.asp?TREE="+nTree+"&ProID="+nProID+"&DIS="+bAlsoDisabled+"&CatIDs="+saCatID+"&ADM="+nUserType+"&ProNM="+sProNM+"&nIndex="+nIndex,"okno","toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=450,height=400,left=0,top=0");
	}
	
}
function ClearCategories(nIndex) {

	while(document.PL['Categ'+nIndex].length>0) {
		document.PL['Categ'+nIndex].options[0] = null;	
		}
	
	document.PL['CatID' + nIndex].value = "";
	document.PL['Categ'+nIndex].style.display = "none";
	getE("ChooseCateg"+nIndex).style.display  = "inline";
}

// ##### PriceList END #####

var iTshLast;
iTshLast = 0;
var arrTsh = new Array();

function showTsh(iTsh, nTshCount, oTshOn) {

	if (iTsh == iTshLast) return;

	var sHidePar, sHideHod, sHideSes, sHideSpec;
	sHidePar = "none";
	sHideHod = "none";
	sHideSes = "none";
	sHideSpec = "none";
	if ("DetSpecifikace" == oTshOn) { sHideSpec = "inline"; }
	else if ("DetParametry" == oTshOn) { sHidePar = "inline"; }
	else if ("DetHodnoceni" == oTshOn) { sHideHod = "inline"; }
	else { sHideSes = "inline"; }

	if (getE('DetSpecifikace')!=null) getE('DetSpecifikace').style.display = sHideSpec;
	if (getE('DetParametry')!=null) getE('DetParametry').style.display = sHidePar;
	if (getE('DetHodnoceni')!=null) getE('DetHodnoceni').style.display = sHideHod;
	if (getE('DetSestava')!=null) getE('DetSestava').style.display = sHideSes;

	getE('tshImg' + (iTshLast * 2 + 1)).style.backgroundImage = 'url(/img/' + gsPlusPath + 'tshMidOff.gif)';
	getE('tshImg' + (iTsh * 2 + 1)).style.backgroundImage = 'url(/img/' + gsPlusPath + 'tshMidOn.gif)';
	getE('tshImg' + (iTshLast * 2 + 1)).className = 'DetTshOff';
	getE('tshImg' + (iTsh * 2 + 1)).className = 'DetTshOn';
	if (iTshLast == 0)
		getE('tshImg0').src = arrTsh[00].src;
	else {
		if (iTshLast!=iTsh+1)
			getE('tshImg' + (iTshLast*2)).src = arrTsh[20].src;
	}
	if (iTshLast == nTshCount - 1) {
		getE('tshImg' + (iTshLast*2+2)).src = arrTsh[30].src;
	} else {
		if (iTshLast!=iTsh-1)
			getE('tshImg' + (iTshLast*2+2)).src = arrTsh[20].src;
	}
	
	if (iTsh == 0)
		getE('tshImg0').src = arrTsh[01].src;
	else
		getE('tshImg' + (iTsh*2)).src = arrTsh[21].src;
	if (iTsh == nTshCount - 1)
		getE('tshImg' + (iTsh*2+2)).src = arrTsh[31].src;
	else
		getE('tshImg' + (iTsh*2+2)).src = arrTsh[22].src;

	iTshLast = iTsh;
}
// ##### Zalozky na detailu END #########################################################

function DisTshParamAndCompare(sImgDisCompareBegin, sImgDisCompareMid, sImgDisCompareEnd, sImgDisParamSearchEndOn) {
	var iTsh;
	iTsh = 0;
	while (getE('tshCompareMid'+iTsh)!=null) {
		if (aDisableTshAndCmp[iTsh]) {
			getE('tshCompareMid'+iTsh).innerHTML = 'Porovnej ceny';
			if (getE('tshParamSearchLR'+iTsh) != null) {
				getE('tshParamSearchLR'+iTsh).src = sImgDisParamSearchEndOn;
				getE('tshParamSearchMid'+iTsh).style.display = "none";
				getE('tshParamSearchEnd'+iTsh).style.display = "none";
			}
		}
		iTsh += 1;
	}
}

function ShowImage(sImgPath) {
		window.open('/ShowImage.asp?IMG=' + sImgPath, "Foto","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=100,width=100,resizable=1,left=0,top=0");
}


//       STIFFOVY FCE
// ********************************* 

function ShowHide(element) {
	var e = getE(element);
	if (e.style.display=="none") { e.style.display = "" } else { e.style.display = "none" };
//	if (!Br.IE) this.blur(); //aby nam nezustaval v mozile oznacen klikaci text
}

function styleChange(elementId,classNameStr) {
	var e = getE(elementId);
	e.className = classNameStr;
}


// ShopConfirmBox - Count Dialog
function showCountDialog( formname, code, minCount, onlyMultiplied ) {
	var e = getE( "shopconfirmbox" );
	e.style.display = "";
	e.style.position = "absolute";
	e.style.top = (document.body.scrollTop + document.body.clientHeight/2 +150)+'px';
	e.style.left = (document.body.clientWidth/2 - 100)+'px';
	document.forms.shopconfirmform.elements.original_form.value = formname;
	document.forms.shopconfirmform.elements.code.value = code;
	document.forms.shopconfirmform.elements.minCountForOrder.value = minCount;
	document.forms.shopconfirmform.elements.onlyMultipliedCount.value = onlyMultiplied;
	document.forms.shopconfirmform.elements.count.value = minCount;
	document.forms.shopconfirmform.elements.count.focus();
}
function hideCountDialog() {
	var e = getE( "shopconfirmbox" );
	e.style.display = "none";
}
function submitCountDialog() {
	var orig_form;    orig_form    = document.forms["BuyForm"+document.forms.shopconfirmform.elements.original_form.value].elements;
	var shopbox_form; shopbox_form = document.forms.shopconfirmform.elements;

	if ( !((shopbox_form.count.value > 0) && (shopbox_form.count.value < 1000000000)) ) {
		hideCountDialog();
		return false;
	}
	
	if (!checkCount( shopbox_form.count.value, shopbox_form.minCountForOrder.value, shopbox_form.onlyMultipliedCount.value )) return false;
	
	orig_form.Count.value = shopbox_form.count.value;
	orig_form.submit();
}

function checkCount( myCount, minCount, onlyMultiplied ) {
	if ( myCount == 0 ) return true;
	if ( myCount < minCount ) {
		alert('Toto zboží lze objednat v minimálním počtu '+minCount+' ks.'); return false;
	}
	if ( (onlyMultiplied==1) && ( (myCount % minCount) != 0) ) {
		alert('Toto zboží lze zakoupit pouze v násobcích '+minCount+' ks.'); return false;
	}
	return true;
}

	


// AvaibilityBox - Avaibility Dialog
function showAvaibilityDialog( code, posX, posY ) {
	var e = getE( "avaibilitybox" );
	e.style.display = "";
	e.style.position = "absolute";
//	e.style.top = (posY + 50)+'px';
//	e.style.left = (posX + 50)+'px';
	e.style.top = (document.body.scrollTop + document.body.clientHeight/4 )+'px';
	e.style.left = (document.body.clientWidth/3 )+'px';

  document.forms.avaibilityform.elements.code.value = code;
//	getE("avaibilityFrame").src = "Avaibility.asp?sCode=" + code;
	
		//document.frames.avaibilityFrame.document.location = "Avaibility.asp?sCode=" + code;
//	document.forms.avaibilityform.elements.count.value = "Zjišťuje se...   ";
//	document.forms.avaibilityform.elements.sSklad.value = "Zjišťuje se...   ";

}
function hideAvaibilityDialog() {
	var e = getE( "avaibilitybox" );
	e.style.display = "none";
//	var e = getE( "avaibilitybox" );
//	e.style.display = "none";
}


function UnleashHideSpecial(objcheck, objHiddenTd, objsubcheck, objSubHiddenTd)
{

if(getE(objcheck).checked == true && getE(objHiddenTd).style.display == "none")
	{
		if(getE(objsubcheck).checked == true && getE(objcheck).checked == true)
			{
			getE(objSubHiddenTd).style.display = "block";
			}
		getE(objHiddenTd).style.display = "block";
	} 
else if(getE(objcheck).checked == false && getE(objHiddenTd).style.display == "block")
	{
		getE(objSubHiddenTd).style.display = "none";
		getE(objHiddenTd).style.display = "none";
	}
else
	{
		getE(objSubHiddenTd).style.display = "none";
		getE(objHiddenTd).style.display = "none";
	}
	/*
	if (getE(objcheck).checked == false ) 
	{
	
	    getE(objHiddenTd).style.display = "none";
//	   getE(objSubHiddenTd).style.display == "none"; 
	 } 
	 else
	 {
	
	    getE("TransportHidden2").style.display = "block";
     } 
     */
}
	   
    // checkboxy - kosik - order_inc.asp
	function GetSumValue(sId)   
	{
	    var sHTML='';
	    
	    sHTML=getE(sId).innerHTML;
	    sHTML=sHTML.replace(/ /g,'');
        sHTML=sHTML.replace(/\&nbsp;/g,'');
        sHTML=sHTML.replace(/,/g,'.');
	    sHTML=sHTML.replace('<b>','');
	    sHTML=sHTML.replace('</b>','');
	    sHTML=sHTML.replace(String.fromCharCode(160),'');

	    return parseFloat(sHTML);
	}
	function SetComputedValue(sId, nValueSum, nValue, nPrecision, bDPH)
	{
	    var fResult = 0;
	    if (bDPH == false) nValue = nValue / 1.19;
	    
	    fResult = FormatCurrency( (nValueSum+nValue) , nPrecision);
	    getE(sId).innerHTML  = fResult;
	}
   
   function CopyPricesToForm()
   {
       getF('OrderForm').PriceSum.value                  = FormatCurrency(GetSumValue('sumWithoutDPH'),2);
       getF('OrderForm').Pricex.value                         = FormatCurrency(GetSumValue('sumWithDPH'),2);
       getF('OrderForm').PriceSumWithDph.value  = FormatCurrency(GetSumValue('sumWithDPH'),2);
   } 
  
   
    function setManipulation()
    {
        var nSumWidthDph   =0;
        var nSumWithoutDph=0; 
        var fResult                    =0; 

	    nSumWidthDph    = GetSumValue('sumWithDPH');
		nSumWithoutDph = GetSumValue('sumWithoutDPH');
	
       if(getE('bManipulationWithOrder').checked==true)
       {
            getE('cellManBezDPH').innerHTML  = '50,42';
            getE('cellManDPH').innerHTML         = '[19%] 9,58';
            getE('cellManSUM').innerHTML         = '60,00';
            getE('rowManipulation').style.display = ''; 

            SetComputedValue('sumWithDPH', nSumWidthDph, 60, 2, true);
            SetComputedValue('sumWithoutDPH', nSumWithoutDph, 60, 2, false);
            
            SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), 60, 2, false);
            SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), 9.58, 2, true);
            SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), 60, 2, true);
            
            getF('OrderForm').bManipulace.value = "1";
            getF('OrderForm').nManipulacePrice.value = FormatCurrency(60,2);
            
       }
       else
       {
            getE('rowManipulation').style.display = 'none'; 
            
            SetComputedValue('sumWithDPH', nSumWidthDph, -60, 2, true);
            SetComputedValue('sumWithoutDPH', nSumWithoutDph, -60, 2, false);

            SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), -60, 2, false);
            SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), -9.58, 2, true);
            SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), -60, 2, true);
            
            setFloor('0');
            getE('bElevator').checked=false;
            getE('nFloor').value=0;
            
            getF('OrderForm').bManipulace.value = "0";
            getF('OrderForm').nManipulacePrice.value = "0";
            getF('OrderForm').nFloor.value = "0";
       }
       CopyPricesToForm();
    
    }
	
    function setFloor(sCount)
    {
        var nSumWidthDph   =0;
        var nSumWithoutDph=0;  
        var nPay                       =0;
        var nFloorValue          = getE('nFloor').value; 
 
        if (sCount=='' || isNaN(sCount))             sCount='0';
        if (parseInt(sCount<0))                            sCount='0';
        if (getE('bElevator').checked == false)   {sCount='0'; getE('nFloor').value='0';nFloorValue = 0; }
	    if (isNaN(nFloorValue))                            nFloorValue=0;

	    nSumWidthDph    = GetSumValue('sumWithDPH');
		nSumWithoutDph = GetSumValue('sumWithoutDPH');
	
// update radku manipulace	
	    getE('cellManBezDPH').innerHTML = FormatCurrency(nFloorValue * 25.21 + 50.42,2);
		getE('cellManDPH').innerHTML        = '[19%] ' + FormatCurrency( (60 + nFloorValue*30) - (nFloorValue * 25.21 + 50.42) ,2);
		getE('cellManSUM').innerHTML        = FormatCurrency(nFloorValue * 30 + 60,2);

        nPay=(nSumWidthDph - (nFloorMem*30) );       //odectu predchozi hodnotu
        SetComputedValue('sumWithDPH', nPay, (sCount*30) , 2, true);
       
        nPay=(nSumWithoutDph - (nFloorMem*25.21) );       //odectu predchozi hodnotu
        SetComputedValue('sumWithoutDPH', nPay, (sCount*30) , 2, false); 
       
        nPay=(GetSumValue('nsumAllWithoutDPH') - (nFloorMem*25.21) );       //odectu predchozi hodnotu
        SetComputedValue('nsumAllWithoutDPH', nPay, (sCount*30), 2, false);

        nPay=(GetSumValue('nsumAllWithDPH') - (nFloorMem*25.21) );       //odectu predchozi hodnotu
        SetComputedValue('nsumAllWithDPH', nPay, (sCount*30), 2, true);
              
        nPay=GetSumValue('nsumAllWithDPH') - GetSumValue('nsumAllWithoutDPH');
        SetComputedValue('nsumAllOnlyDPH', nPay, 0, 2, true);

        nFloorMem=parseInt(sCount);
       
        getF('OrderForm').nManipulacePrice.value = getE('cellManSUM').innerHTML;
        getF('OrderForm').nFloor .value = nFloorMem; 
            
        CopyPricesToForm(); 
    }
   
   
    function SetDeliveryRblRow()
    {
        var nSumWidthDph   = 0;
        var nSumWithoutDph = 0;  
    
        
    
   	    nSumWidthDph    = GetSumValue('sumWithDPH');
		nSumWithoutDph  = GetSumValue('sumWithoutDPH');
		
		if ( getE('DeliveryType') == null ) return false;
		
		var nIdDelivery = getE('DeliveryType').options[getE('DeliveryType').selectedIndex].value;
		//alert (nIdDelivery);
		
		if ( getE('DelPrice_' + nIdDelivery) == null ) return false;
		
		var nPriceDelivery = getE('DelPrice_' + nIdDelivery).value.replace(',','.');               //    cena vcetne dph
		nPriceDelivery = nPriceDelivery * 1;
		
		var nDelWDPH = nPriceDelivery / 1.19;
		var nDelDPH =  nPriceDelivery - nDelWDPH;
		
		
		var nDelPricePrevious = GetSumValue('cellDeliverySUM');                                  //    cena vcetne dph
		nDelPricePrevious     = nDelPricePrevious * (-1);
		
		var nDelWDPHPrevious  =  nDelPricePrevious / 1.19;
		var nDelDPHPrevious   =  nDelPricePrevious - nDelWDPHPrevious;
		
		
		
// ---------------------- ============ ODECET PUVODNI HODNOTY ========== -----------------------
		SetComputedValue('sumWithDPH', nSumWidthDph, nDelPricePrevious, 2, true);
        SetComputedValue('sumWithoutDPH', nSumWithoutDph, nDelWDPHPrevious, 2, true); 
        SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), nDelWDPHPrevious, 2, true); 
        SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), nDelDPHPrevious, 2, true); 
        SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), nDelPricePrevious, 2, true);   
        
        
// ---------------------- ============ PRICTENI NOVE HODNOTY ========== -----------------------
		SetComputedValue('sumWithDPH', GetSumValue('sumWithDPH'), nPriceDelivery, 2, true);
        SetComputedValue('sumWithoutDPH', GetSumValue('sumWithoutDPH'), nDelWDPH, 2, true); 
        SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), nDelWDPH, 2, true); 
        SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), nDelDPH, 2, true); 
        SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), nPriceDelivery, 2, true);   
            

        nDelDPH  = FormatCurrency(nDelDPH,2);
        nDelWDPH = FormatCurrency(nDelWDPH,2);
        nPriceDelivery = FormatCurrency(nPriceDelivery,2);
		getE('cellDeliveryBezDPH').innerHTML  = nDelWDPH;
        getE('cellDeliveryDPH')   .innerHTML  = nDelDPH.replace('.',',');
        getE('cellDeliverySUM')   .innerHTML  = nPriceDelivery.replace('.',','); ;
        getE('rowDelivery').style.display = ''; 
        
    }   
    
  
     function setDisposal()
     {
        var nSumWidthDph   =0;
        var nSumWithoutDph=0;  
    
   	    nSumWidthDph    = GetSumValue('sumWithDPH');
		nSumWithoutDph = GetSumValue('sumWithoutDPH');

        if (getE('bOrderGarbageDisposal').checked==true)
        {

            getE('cellOdvozBezDPH').innerHTML  = '327,73';			// '327,73';
            getE('cellOdvozDPH').innerHTML         = '[19%] 62,27'; //'[19%] 62,27';
            getE('cellOdvozSUM').innerHTML         = '390,00';		//'390,00';
            getE('rowOdvoz').style.display = ''; 
            
             SetComputedValue('sumWithDPH', nSumWidthDph, 390, 2, true); //390, 2, true);
             SetComputedValue('sumWithoutDPH', nSumWithoutDph, 390, 2, false); //390, 2, false);
            
            SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), 390, 2, false);   //, 390, 2, false);
            SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), 46.31, 2, true); 		//, 62.27, 2, true);
            SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), 390, 2, true);       //, 390, 2, true);
            
             getF('OrderForm').bOdvoz.value = "1";
             getF('OrderForm').nOdvozPrice.value = "390"; //"390";
         }
         else
         {
                getE('rowOdvoz').style.display = 'none'; 
               
               SetComputedValue('sumWithDPH', nSumWidthDph, -390, 2, true); //-390, 2, true);
               SetComputedValue('sumWithoutDPH', nSumWithoutDph, -390, 2, false); //-390, 2, false); 
               
               SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), -390, 2, false); //-390, 2, false);
               SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), -62.27, 2, true); //-62.27, 2, true);
               SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), -390, 2, true); //-390, 2, true);
               
               getF('OrderForm').bOdvoz.value = "0";
               getF('OrderForm').nOdvozPrice.value = "0";
         }
         CopyPricesToForm();             
      }
    
     function setNightDistribute()
     {
           var nSumWidthDph   =0;
           var nSumWithoutDph=0;  
    
           nSumWidthDph    = GetSumValue('sumWithDPH');
		   nSumWithoutDph = GetSumValue('sumWithoutDPH'); 
		   
           if (getE('bOrderNightDistribute').checked==true)
           {
		        getE('cellRozvNBezDPH').innerHTML  = '159,66';
                getE('cellRozvNDPH').innerHTML         = '[19%] 30,34';
                getE('cellRozvNSUM').innerHTML         = '190,00';
                getE('rowRozvozNight').style.display    = ''; 
            
                SetComputedValue('sumWithDPH', nSumWidthDph, 190, 2, true);
                SetComputedValue('sumWithoutDPH', nSumWithoutDph, 190, 2, false);
               
               SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), 190, 2, false);
               SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), 30.34, 2, true);
               SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), 190, 2, true); 
               
               getF('OrderForm').bRozvozVecer.value = "1";
               getF('OrderForm').nRozvozVecerPrice.value = "190";
          }
         else
         {
                getE('rowRozvozNight').style.display = 'none'; 
               
               SetComputedValue('sumWithDPH', nSumWidthDph, -190, 2, true);
               SetComputedValue('sumWithoutDPH', nSumWithoutDph, -190, 2, false); 
               
               SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), -190, 2, false);
               SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), -30.34, 2, true);
               SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), -190, 2, true); 
               
               getF('OrderForm').bRozvozVecer.value = "0";
               getF('OrderForm').nRozvozVecerPrice.value = "0";
         }
        CopyPricesToForm();  
     }   
     
     function setWeekDistribute()
     {
           var nSumWidthDph   =0;
           var nSumWithoutDph=0;  
    
            nSumWidthDph    = GetSumValue('sumWithDPH');
  		    nSumWithoutDph = GetSumValue('sumWithoutDPH'); 
  		
           if (getE('bOrderWeekDistribute').checked==true)
           {
                getE('cellRozvWBezDPH').innerHTML  = '411,76';
                getE('cellRozvWDPH').innerHTML         = '[19%] 78,24';
                getE('cellRozvWSUM').innerHTML         = '490,00';
                getE('rowRozvozWeekend').style.display    = ''; 
            
                SetComputedValue('sumWithDPH', nSumWidthDph, 490, 2, true);
                SetComputedValue('sumWithoutDPH', nSumWithoutDph, 490, 2, false);
               
               SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), 490, 2, false);
               SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), 78.24, 2, true);
               SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), 490, 2, true);  
               
               getF('OrderForm').bRozvozSvatek.value = "1";
               getF('OrderForm').nRozvozSvatekPrice.value = "490";
          }
         else
         {
                getE('rowRozvozWeekend').style.display = 'none'; 
               
               SetComputedValue('sumWithDPH', nSumWidthDph, -490, 2, true);
               SetComputedValue('sumWithoutDPH', nSumWithoutDph, -490, 2, false); 
               
               SetComputedValue('nsumAllWithoutDPH', GetSumValue('nsumAllWithoutDPH'), -490, 2, false);
               SetComputedValue('nsumAllOnlyDPH', GetSumValue('nsumAllOnlyDPH'), -78.24, 2, true);
               SetComputedValue('nsumAllWithDPH', GetSumValue('nsumAllWithDPH'), -490, 2, true);  
               
               getF('OrderForm').bRozvozSvatek.value = "0";
               getF('OrderForm').nRozvozSvatekPrice.value = "0";
          }
         CopyPricesToForm();  
     }   
      
function checkPaymentType(nPymentType, nId)
{

	if (nPymentType == nId)
		getE('tr_paymentcards').style.visibility = "visible";
	else
		getE('tr_paymentcards').style.visibility = "hidden";
}
function VazbySelect(s1,s2,pkDel){

//$$$$41||Dobírkou##43||Hotove##46||Predem (eBanka)##$$$$43||Hotove##46||Predem (eBanka)##$$$$
//0$$$$142$$$$143$$$$
	var s1pole,s2pole,s1pom,s1p,pkP,NazevP,iHtml;
//	alert(s1+'\n'+s2 +'\n ' +pkDel);
//	return true;//**************************************************************************************************
	iHtml = '<select tabindex="213" id="PaymentType" size="1" name="PaymentType" class="input_text2" style="'+getE('stPaymentType')+'" onchange="checkPaymentType(this.value);">';
	oPaymentType.length = 0;
	s1pole = s1.split('$$$$');
	s2pole = s2.split('$$$$');
	for (i=0;i<s2pole.length-1; i++){
		if (s2pole[i] == pkDel){
			s1pom = s1pole[i].split('##');
			for(j=0;j<s1pom.length-1;j++){
				s1p = s1pom[j].split('||');
				pkP = s1p[0];
				NazevP = s1p[1];
				iHtml += '<option value="' + pkP + '">' + NazevP + '</option>';
				oPaymentType.options[j] = new Option(NazevP,pkP);
				  
			}
		}
	}
	iHtml +='</select>';
//	getE('DivForVazby').innerHTML = iHtml;
	getE('tr_paymentcards').style.visibility = "hidden";
	
	SetDeliveryRblRow();
}
//******************************************************************************

/*  --        trideni v katalogu */
function SortIn(sURLParams, sDirection)
{
    var sSelValue = getE('PN').value;
 
      if (sDirection  != '')
      { 
        if  (sURLParams.substring(sURLParams.length - 1) == '&' )           
              sURLParams = sURLParams + 'SORT=' +  sDirection;      
        else  
              sURLParams = sURLParams + '&SORT=' +  sDirection;      
             
        if (sURLParams.indexOf('PN=') == -1)   {    sURLParams = sURLParams + '&PN=sName';}
      }  
      else
       {
            if  (sURLParams.substring(sURLParams.length - 1) == '&' ) 
                sURLParams = sURLParams+ 'PN=' +  sSelValue;
            else 
                sURLParams = sURLParams+ '&PN=' +  sSelValue;
               
             var nIndex =   sURLParams.indexOf('PgID=');
             if (nIndex  != -1)   
            {
                var nIndex2 = sURLParams.indexOf('&', nIndex); 
                if (nIndex2 == -1)                 sURLParams = sURLParams.substring(0,nIndex)
                else                                       sURLParams = sURLParams.substring(0,nIndex) + sURLParams.substring(nIndex2+1,sURLParams.length);
            }
        }                
    window.location.href = sURLParams;
}

function SortInSeo(sURLParams, sDirection)
{
    var sSelValue = getE('PN').value;
 
      if (sDirection  != '')
      { 
        if  (sURLParams.substring(sURLParams.length - 1) == '&' )           
              sURLParams = sURLParams + 'SORT=' +  sDirection;      
        else  
              sURLParams = sURLParams + '?SORT=' +  sDirection;      
             
        if (sURLParams.indexOf('PN=') == -1)   {    sURLParams = sURLParams + '&PN=sName';}
      }  
      else
       {
            if  (sURLParams.substring(sURLParams.length - 1) == '&' ) 
                sURLParams = sURLParams+ 'PN=' +  sSelValue;
            else 
                sURLParams = sURLParams+ '?PN=' +  sSelValue;
               
             var nIndex =   sURLParams.indexOf('PgID=');
             if (nIndex  != -1)   
            {
                var nIndex2 = sURLParams.indexOf('&', nIndex); 
                if (nIndex2 == -1) sURLParams = sURLParams.substring(0,nIndex)
                else sURLParams = sURLParams.substring(0,nIndex) + sURLParams.substring(nIndex2+1,sURLParams.length);
            }
        }                
    window.location.href = sURLParams;
}

function CheckWriteFormOrderForm()
{var  Od=getF('WriteFormOrderForm').d_D1.value.split('.'),
      Do=getF('WriteFormOrderForm').d_D2.value.split('.'),
	  i;
	  
for (i=0;i<getF('WriteFormOrderForm').d_D1.value.split('.').length;i++)
{if(isNaN(Od[i])){alert(getF('WriteFormOrderForm').d_D1.value + ' není ve správném formátu!');getF('WriteFormOrderForm').d_D1.value.focus; return false;}}

for (i=0;i<getF('WriteFormOrderForm').d_D2.value.split('.').length;i++)
{if(isNaN(Do[i])){alert(getF('WriteFormOrderForm').d_D1.value + ' není ve správném formátu!');getF('WriteFormOrderForm').d_D1.value.focus; return false;}}

return true;
}

function actualizeAvail(code) {

    if (getE('availBlock') == null) return false;
    getE('availBlock').className = "oran";getE('availBlock').innerHTML='Čekejte prosím ...';
    var t = new Date();
    getE('iAvail').src = '/avail.asp?code=' + code + '&t' + t;
}

function competitionSubmit(nCountItems, nTypeComp) {

  if (nTypeComp == 0) {
    if (EmailControl(getF('frmCompetition').s_EMAIL.value)==false) {getF('frmCompetition').s_EMAIL.focus();return false;}
  	if(getF('frmCompetition').s_EMAIL.value == ""){alert("Vyplňte email.");getF('frmCompetition').s_EMAIL.focus();return false}
   getE('frmCompetition').submit();
 
  } else {
    getE('frmCompetition').submit();    
  }

}

function clearPayments(obj) {

  for (var x=0; x<getF('doprava_form').PaymentType.length;x++){
        getF('doprava_form').PaymentType[x].checked = false;
  }  
    
    
  for (var x=0; x<getE(obj).children.length;x++){
     if(getE(obj).children[x].tagName == 'INPUT') {getE(obj).children[x].checked = true; getE(obj).children[x].click(); break;}  
  }  
   
  
}


function controlReclaimForm() {
    if (getF('reclaimForm').dateorder.value == "") { alert("Vyplňte datum prodeje."); getF('reclaimForm').dateorder.focus(); return false; }
    if (getF('reclaimForm').faktura.value == "") { alert("Vyplňte číslo faktury."); getF('reclaimForm').faktura.focus(); return false; }
    if (getF('reclaimForm').subname.value == "") { alert("Vyplňte příjmení."); getF('reclaimForm').subname.focus(); return false; }
    if (getF('reclaimForm').name.value == "") { alert("Vyplňte jméno."); getF('reclaimForm').name.focus(); return false; }
    if (getF('reclaimForm').street.value == "") { alert("Vyplňte ulici."); getF('reclaimForm').street.focus(); return false; }        
    if (getF('reclaimForm').cpopis.value == "") { alert("Vyplňte číslo popisné."); getF('reclaimForm').cpopis.focus(); return false; }
    if (getF('reclaimForm').city.value == "") { alert("Vyplňte město."); getF('reclaimForm').city.focus(); return false; }
    if (getF('reclaimForm').zipcode.value == "") { alert("Vyplňte PSČ."); getF('reclaimForm').zipcode.focus(); return false; }
    if (getF('reclaimForm').phone.value == "") { alert("Vyplňte telefon."); getF('reclaimForm').h.focus(); return false; }
    if (getF('reclaimForm').email.value == "") { alert("Vyplňte email."); getF('reclaimForm').email.focus(); return false; }
    if (getF('reclaimForm').producer.value == "") { alert("Vyplňte výrobce."); getF('reclaimForm').producer.focus(); return false; }
    if (getF('reclaimForm').prodtype.value == "") { alert("Vyplňte typové označení."); getF('reclaimForm').prodtype.focus(); return false; }
    if (getF('reclaimForm').prodcode.value == "") { alert("Vyplňte výrobní číslo."); getF('reclaimForm').prodcode.focus(); return false; }
    if (getF('reclaimForm').reclamdescript.value == "") { alert("Vyplňte popis."); getF('reclaimForm').reclamdescript.focus(); return false; }    

    getF('reclaimForm').submit();
    return true;
    
}

function  backReklamForm() {

  
  getF('Reklamace').enctype = '';
  getF('Reklamace').action = '/Reklamace.asp';
  getF('Reklamace').step.value = '';
  getF('Reklamace').submit();

}


function bezdiak(txt)
{
  var  sdiak = "áäčďéěíĺľňóô öŕšťúů üýřžÁÄČĎÉĚÍĹĽŇÓÔ ÖŔŠŤÚŮ ÜÝŘŽ";
  var bdiak = "aacdeeillnoo orstuu uyrzAACDEEILLNOO ORSTUU UYRZ";

  tx = "";
  for(p = 0; p < txt.length; p++)
  {
    if (sdiak.indexOf(txt.charAt(p)) != -1)
    {
      tx += bdiak.charAt(sdiak.indexOf(txt.charAt(p)));
    }
    else tx += txt.charAt(p);
  }  
  

 return tx;
}

function setLogin(obj) {
  if (getE('login_from_reg') != null) {
    getE('login_from_reg').innerHTML = obj.value;     
  
  }  
  
}






