// 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 checkAll(nameOfForm,nameofElmnt)
	{
	var obj=getF(nameOfForm)
	  for (var i=0;i<obj.elements.length;i++)
	  {
		var e = obj.elements[i];
		if (e.name == nameofElmnt)
		  e.checked = true //!e.checked;
	  }
	  
	}
	
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) {

	if (nDSP==1) {
		InsertCookieEx("NOEXP","DSP","1");
	} else {
		InsertCookieEx("NOEXP","DSP","0");
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

function SetAlsoNotStored(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookieEx('NOEXP','COMANS')=='1') {
		InsertCookieEx("NOEXP","COMANS","0");
	} else {
		InsertCookieEx("NOEXP","COMANS","1");
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

function SetCloseout(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookieEx('NOEXP','COMCLO')=='1') {
		InsertCookieEx("NOEXP","COMCLO","0");
	} else {
		InsertCookieEx("NOEXP","COMCLO","1");
	}
	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){
	InsertCookieEx("NOEXP","category"+idTree, intId);
}
// ###  END  FCE PRO ROZKLIKAVANI KATEGORII	###

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,"InfoDetail","scrollbars=no,height=500,width=400,left=10,top=10");
	objWnd.focus();
}
function ActionCookies(strName){
	var strString,strSum1,strSum2,intSuma;
	strSum2 = new Array();
	intSuma = 0;

	strString = ExtractCookieEx('NOEXP',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 InsTreeCook(intId,idTree){
	InsertCookieEx("NOEXP","category"+idTree,intId);
}
/* COOKIES advanced (Lemma) */

function InsertCookie(strName, strValue){
	document.cookie=strName+"="+strValue+"; path=\/;";
}

function InsertCookieEx(strName, strKey, strValue){
	var strKeysValues = ExtractCookie(strName, strKey);
	var sTmp = '';
	var sDelimiter = '';
	aKeyValue = new Array();
	aOneKeyValue = new Array();
	if ((strKeysValues=="none")||(strKeysValues=="")) {
		document.cookie = strName + "=" + strKey + "=" + strValue + "; path=\/;";
	} else if (("&"+strKeysValues.toLowerCase()).indexOf("&"+strKey.toLowerCase()+"=")==-1) {
		document.cookie = strName + "=" + strKeysValues + "&" + strKey + "=" + strValue + "; path=\/;";
	} else {
		aKeyValue = strKeysValues.split("&");
		for (var i = 0; i<aKeyValue.length; i++) {
			aOneKeyValue = aKeyValue[i].split("=");
			if (aOneKeyValue[0].toLowerCase()==strKey.toLowerCase()) aOneKeyValue[1] = strValue;
			sTmp += sDelimiter + aOneKeyValue[0] + "=" + aOneKeyValue[1];
			sDelimiter = "&";
		}
		document.cookie = strName + "=" + sTmp + "; path=\/;";
	}
}

function ExtractCookie(strName){
	var iIndex;
	var cookieList=document.cookie.split("; ");
	for (var i=0; i < cookieList.length; i++){
		iIndex = cookieList[i].toLowerCase().indexOf(strName.toLowerCase()+'=');
		if (iIndex==0)
			return cookieList[i].substring(strName.length+1,cookieList[i].length);
	}
	return "none";
}

function ExtractCookieEx(strName, strKey){
	var strKeysValues = ExtractCookie(strName, strKey);
	if ((strKeysValues=="none")||(strKeysValues=="")) return "none";
	aKeyValue = new Array();
	aOneKeyValue = new Array();
	aKeyValue = strKeysValues.split("&");
	for (var i = 0; i<aKeyValue.length; i++) {
		aOneKeyValue = aKeyValue[i].split("=");
		if (aOneKeyValue[0].toLowerCase()==strKey.toLowerCase()) return aOneKeyValue[1];
	}
	return "none";
}

function DeleteCookie(strName){
	var vyprs=new Date();
	var cookieList=document.cookie.split("; ");
	for (var i=0; i < cookieList.length; i++){
		iIndex = cookieList[i].toLowerCase().indexOf(strName.toLowerCase()+'=');
		if (iIndex==0) {
			vyprs.setDate(vyprs.getDate() - 365);
			document.cookie = cookieList[i]+"=; expires="+vyprs.toGMTString()+"; path=\/;";
			return;
		}
	}
}

function DeleteCookieEx(strName, strKey) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	var strKeysValues = ExtractCookie(strName, strKey);
	var sTmp = '';
	var sDelimiter = '';
	aKeyValue = new Array();
	aOneKeyValue = new Array();
	if ((strKeysValues=="none")||(strKeysValues=="")) {
		document.cookie = strName+"=; expires="+vyprs.toGMTString()+";";
	} else if (("&"+strKeysValues.toLowerCase()).indexOf("&"+strKey.toLowerCase()+"=")!=-1) {
		aKeyValue = strKeysValues.split("&");
		for (var i = 0; i<aKeyValue.length; i++) {
			aOneKeyValue = aKeyValue[i].split("=");
			if (aOneKeyValue[0].toLowerCase()!=strKey.toLowerCase()) {
				sTmp += sDelimiter + aOneKeyValue[0] + "=" + aOneKeyValue[1];
				sDelimiter = "&";
			}
		}
		document.cookie = strName + "=" + sTmp + "; path=\/;";
	}
}
/* COOKIES - END */

function ParseCookies(strName){
	var strCook = ExtractCookie(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 ControlUserDataSubmit(){

	if(getF('UserDataForm').FirstName.value == ""){alert("Vyplňte jméno.");getF('UserDataForm').FirstName.focus();return false};
	if(getF('UserDataForm').LastName.value == ""){alert("Vyplňte příjmení.");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').Firm.value == ""){alert("Vyplňte firmu.");getF('UserDataForm').Firm.focus();return false};
//	if(getF('UserDataForm').ICO.value == ""){alert("Vyplňte IČO.");getF('UserDataForm').ICO.focus();return false};
//	if(getF('UserDataForm').DIC.value == ""){alert("Vyplňte DIČ.");getF('UserDataForm').DIC.focus();return false};
	
	if(getF('UserDataForm').Street.value == ""){alert("Vyplňte ulici.");getF('UserDataForm').Street.focus();return false};
	if(getF('UserDataForm').City.value == ""){alert("Vyplňte město.");getF('UserDataForm').City.focus();return false};
	if(getF('UserDataForm').ZipCode.value == ""){alert("Vyplňte PSČ.");getF('UserDataForm').ZipCode.focus();return false};
	// specialita electrogarden
	if(getF('UserDataForm').Email.value == ""){alert("Vyplňte email.");getF('UserDataForm').Email.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("Bankovní účet není platné, zkuste jej zadat znovu, nebo pole nevyplňujte.");getF('UserDataForm').BankAccount.focus();return false};
	if(getF('UserDataForm').Login.value == ""){alert("Vyplňte přihlašovací jmé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("Vyplňte heslo.");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(getF('UserDataForm').PasswordControl.value == ""){alert("Vyplňte kontrolu hesla.");getF('UserDataForm').PasswordControl.focus();return false};
	if(getF('UserDataForm').PasswordControl.value.length < 5){alert("Kontrola hesla musí mít minimálně 5 znaků.");getF('UserDataForm').PasswordControl.focus();return false};
	if(getF('UserDataForm').Password.value != getF('UserDataForm').PasswordControl.value){alert("Zadaná hesla se neshodují.");getF('UserDataForm').PasswordControl.focus();return false};
	
	if (((getF('UserDataForm').DeliveryCountry == "SR" && getF('UserDataForm').Country == "ČR") || (getF('UserDataForm').DeliveryCountry == "ČR" && getF('UserDataForm').Country == "SR")) && ((getF('UserDataForm').DeliveryStreet == "") || (getF('UserDataForm').DeliveryCity == "") || (getF('UserDataForm').DeliveryZipCode == "")))
	 {
	alert("Dodací adresa je v jiném státě než fakturační. Dopňte prosím dodací adresu.");getF('UserDataForm').sDeliveryCountry.focus();return false
	}
  
  return true;
}
function ControlDataOrder(){
	var f = getF('OrderForm');
	if (ExtractCookieEx("NOEXP","Logged") != "true") {
		if (f.DeliveryFirstName.value == "") { alert("Vyplňte jméno"); f.DeliveryFirstName.focus(); return false}
		if (f.DeliveryLastName.value == "") { alert("Vyplňte příjmení"); f.DeliveryLastName.focus(); return false}
		if (f.Telefon.value=="") { alert("Vyplňte telefon"); f.Telefon.focus(); return false }
		//specialita electrogarden
		//if (f.Email.value=="") { alert("Vyplňte email"); f.Email.focus(); return false }
		if(f.Email.value == ""){alert("Vyplňte email.");f.Email.focus();return false};
    if (f.DeliveryStreet.value=="") { alert("Vyplňte ulici"); f.DeliveryStreet.focus(); return false }
		if (f.DeliveryCity.value=="") { alert("Vyplňte město"); f.DeliveryCity.focus(); return false }
		if (f.DeliveryZipCode.value=="") { alert("Vyplňte PSČ"); f.DeliveryZipCode.focus(); return false }
	}
	
	if (f.DeliveryType.value == "-"){alert("Vyberte způsob dopravy."); f.DeliveryType.focus(); return false}
	if (f.PaymentType.value == "-"){alert("Vyberte způsob platby."); f.PaymentType.focus(); return false}
	
	/*alert(getE('idMarket').style.display);
	alert(f.ChosenMarket.value);
	if ((getE('idMarket').style.display == "block") && (f.ChosenMarket.value==0)){alert("Vyberte pobočku, nebo jiný způsob dopravného."); f.DeliveryType.focus(); return false}
	if ((f.ChosenMarket.value!=0) && (f.bHomeCreditOk.value==0) && (f.PaymentType.options[f.PaymentType.selectedIndex].text.indexOf("Home Credit") != -1)) { alert("Vybraná pobočka zatím bohužel nepodporuje\nmožnost platby přes Home Credit.\nVyberte prosím jinou pobočku, nebo způsob platby."); return false}
	*/
	
	//if ((getE('idMarket').style.display == "block") && (f.ChosenMarket.value==0)){alert("Vyberte pobočku, nebo jiný způsob dopravného."); f.DeliveryType.focus(); return false}
	if ((f.ChosenMarket.value!=0) && (f.bHomeCreditOk.value==0) && (f.PaymentType.options[f.PaymentType.selectedIndex].text.indexOf("Home Credit") != -1)) { alert("Vybraná pobočka zatím bohužel nepodporuje\nmožnost platby přes Home Credit.\nVyberte prosím jinou pobočku, nebo způsob platby."); 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 EmailControlR(f,defaultVal){
	if (f=='')
	{
		alert('Nesprávný formát emailu');
		return false;
	}
	return EmailControlRegExp(f, true);	
}
function EmailControl(f){
	return EmailControlRegExp(f, true);	
}

function EmailControlRegExp(sEmail, bShowMsg)
 {
	if (sEmail=='' || sEmail=='Váš@email.cz')
	{
		if (bShowMsg) alert('Nesprávný formát emailu');
		return false;
  }
 											// ("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,}$"); 
  var regEx  = new RegExp("^[_a-zA-Z0-9\.\-]+@(([_a-zA-Z0-9\-]{1,}\.){1,})+\.[a-zA-Z]{2,}$"); 	 
  										//  "^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$"  from asp
  regEx.ignoreCase = true;
  
  if (regEx.test(sEmail) == false)
  {
		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=0,status=0,toolbar=0,location=0,directories=0,height=100,width=100,resizable=1");
}


//		STIFFOVY FCE
// ********************************* 

function ShowHide(elementId) {
	var e = getE( elementId );
	if(e !=null){	
		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
}
var gnMn;
function ShowHideMn(elementId,style) {
	if (gnMn) window.clearTimeout(gnMn);
	gnMn = window.setTimeout("ShowHideEx('" + elementId + "','" + style + "');", 200);
}
function ShowHideEx(elementId,style) {
	var e = getE( elementId );
	if(e !=null){	
		e.style.display = style;
	}
	//	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 != parseFloat(myCount) ) {
		alert('Zadejte korektně počet ks.'); return false;
	}
	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;
}
//************


function blendInObject ( objID, speed, opacity ) { // fce necha plynule zobrazit libovolny objekt na strance dle jeho ID; speed je 1-100; opacity je
//nepovinna vychozi hodnota
	clearTimeout;
	var obj = getE(objID);
	if (!(opacity>0)) opacity = 0;
	opacity+=10;
	if (Br.IE) {
		obj.style.filter = 'alpha(Opacity='+opacity+')';
		if (opacity<100) {setTimeout("blendInObject('"+objID+"',"+speed+","+opacity+");", speed); }
		else { obj.style.filter=''; }
	} else if (Br.NS) {
		obj.style.MozOpacity = opacity/100;
		if (opacity<100) {
			setTimeout("blendInObject('"+objID+"',"+speed+","+opacity+");", speed); }
		else { obj.style.MozOpacity=1; }
	}
	if (obj.style.display=='none') obj.style.display='block';
}


function blendOutObject ( objID, speed, opacity ) { // fce necha plynule zmiznout libovolny objekt na strance dle jeho ID; speed je 1-100; opacity je
//nepovinna vychozi hodnota
	clearTimeout;
	var obj = getE(objID);
	if (!(opacity>0)) opacity = 100;
	opacity-=10;
	if (Br.IE) {
		obj.style.filter = 'alpha(Opacity='+opacity+')';
		if (opacity>0) {
setTimeout("blendOutObject('"+objID+"',"+speed+","+opacity+");", speed) }
else { obj.style.display='none'; obj.style.filter=''; }
	} else if (Br.NS) {
		obj.style.MozOpacity = opacity/100;
		if (opacity>0) {
setTimeout("blendOutObject('"+objID+"',"+speed+","+opacity+");", speed) }
else { obj.style.display='none'; obj.style.MozOpacity=1; }
	}
}

//***************
// AvaibilityBox - Avaibility Dialog

function showAvaibilityDialog( code,posY ,posX,isDetail) {
	var e = getE( "avaibilitybox" );
	
	//e.style.display = "";
	blendInObject( "avaibilitybox", 1,0 )	
	e.style.position = "absolute";	
	
	
	if (isDetail == 1){	
		e.style.top = topScroll()+(posY - 200)+'px';
		e.style.left = (500)+'px';
	}else{
		e.style.top = topScroll()+(posY - 250)+'px';
		e.style.left = (600)+'px';
	}
	
	getE("codeAVA").innerHTML = code;
	window.frames.avaibilityFrame.window.location = "Avaibility.asp?sCode=" + code;
	getF("avaibilityform").elements.count.value = "Zjišťuje se...";
}

function hideAvaibilityDialog() {
	blendOutObject (  "avaibilitybox", 10, 0 )
	//	var e = getE( "avaibilitybox" );
	//e.style.display = "none";
}


function WriteBasketContent(nOrderItems, sScriptAddress,sPolozek,nPriceWithDPH) {
	getE('idBasketPart').innerHTML = 
		(nOrderItems==0) ? "<ul><li>&nbsp;</li><li>&nbsp;</li></ul><div class='BA_Ex'>V nákupním košíku nemáte žádné položky</div>" :
		"<ul><li class='orderBasket'><a href='/Order.asp'><strong>Zobrazit</strong> obsah košíku</a></li>"+
		"<li><form action='' name='delOrder' method='post'><input type='hidden' name='DO' value='ok'/></form><a href='javascript:document.forms[\"delOrder\"].submit();'><strong>Vyprázdnit</strong> košík</a></li>" +
		"</ul><div class='BA_Ex'><a href='/Order.asp'><img src='/img/btbasket.gif' alt='Nákupní košík' /></a>V košíku máte máte<strong class='baEx1'> " + nOrderItems + "</strong>" + sPolozek + " celkem za <strong class='baEx2'>" + nPriceWithDPH + ",- Kč</strong></div>";
}


function topScroll() {
	if (window.innerHeight) {
		  return ( window.pageYOffset )
	} else if (document.documentElement && document.documentElement.scrollTop) {
		return ( document.documentElement.scrollTop )
	} else if (document.body) {
		  return ( document.body.scrollTop )
	}
}
function showBox(idOfElement, posY, posX) {

	var e = getE( idOfElement );
	e.style.display = "";
	e.style.position = "absolute";

	e.style.top  =topScroll()+(posY-5)+'px'
	e.style.left =(posX-320)+'px'

	//	getE("pcsCode").innerHTML=code
	//	getE("pcsOnStore").innerHTML=pcs;
}
function ZavriKosik()
{
	getE("StateInfo1").style.display="none";
}
// ShopInfoBox

function showShopInfoDialog( code, name, count, price ) {
	var e = getE( "shopinfobox" );
	e.style.display = "";
	e.style.position = "absolute";
	e.style.top = (document.body.scrollTop + document.body.clientHeight/2 -100)+'px';
	e.style.left = (document.body.clientWidth/2 - 100)+'px';
	document.forms.shopinfoform.elements.code.value = code;
	document.forms.shopinfoform.elements.name.value = name;
	document.forms.shopinfoform.elements.count.value = count + ' ks';
	setTimeout("hideShopInfoboxDialog();", 10000);
}
function hideShopInfoboxDialog() {
	var e = getE( "shopinfobox" );
	e.style.display = "none";
}

/* pretahnuti polozek z jednoho slectu do druheho */
function move(odkud,kam,cislo){
	if (document.all[odkud].selectedIndex < 0){alert('Nebylo nic vybráno!');return}
	var strValue = document.all[odkud].value;
	var strText = document.all[odkud].options[document.all[odkud].selectedIndex].text;
	var intIndex = parseFloat(document.all[odkud].selectedIndex)
	if (strValue != ""){
		var el = document.createElement("OPTION")
		el.text = strText;
		el.value = strValue;
		document.all[kam].options.add(el);
	}
	var x = "";
	x = "but"+odkud;
	document.all[odkud].options.remove(intIndex);
	if (parseFloat(document.all[odkud].options.length)== 0){
		document.all[x].disabled = true;
	}
	x = "but"+kam;
	if (parseFloat(document.all[kam].options.length)> 0){
		document.all[x].disabled = false;
	}
	document.all["total"+cislo].value = ""; 
	for(var i = 0; i < document.all["SelectMenu"+cislo].length; i++){
	document.all["total"+cislo].value += "&nbsp;"+(i+1)+"."+document.all["SelectMenu"+cislo].options[i].value+" &nbsp;";
  }
} 
		  
function GaleryPicture(FormName, ImageSrc, InputUrl, InputWidth, InputHeight, IgnoreImage, StartingPath, GaleryTitle)
{	
	window.open('/Administration/ImageGalery/ImageGalery.asp?fF='+FormName+'&fSRC='+ImageSrc+'&fURL='+InputUrl+'&fW='+InputWidth+'&fH='+InputHeight+'&II='+IgnoreImage+'&Path='+StartingPath+'&Title='+GaleryTitle, 'GaleryPicture', 'toolbar=yes,location=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes');	
}

function ControlBookofWishSubmit(){

  if(document.wishform.Jmeno.value == ""){alert("Vyplňte jméno.");return false}
  if(document.wishform.Email.value == ""){alert("Vyplňte e-mail.");return false}
  if(document.wishform.Nadpis.value == ""){alert("Vyplňte předmět.");return false}
  if(document.wishform.text.value == ""){alert("Vyplňte zprávu.");return false}
  
  return true
}


function fnCheckParamCommodityUse(objForm) {
	if (objForm.bParamUsed.value=='0') 
		return true;
	else 
		return confirm('Tento parametr je použit u zboží, opravdu jej chcete smazat?');
}
function VazbySelect(saPay,saDel,pkDel){
	//25^Dobírkou¤33^Zálohovou fakturou¤|25^Dobírkou¤33^Zálohovou fakturou¤   -   | oddělovač deliveryType
	//148¤1¤111|149¤0¤111|   -   pkDelivery ¤ bShowMarket ¤ Cena za dopravne
	var aDelItem;
	var oPay = getE('idPayment');
	oPay.options.length = 1;
	oPay.options[0] = new Option('-- Zvolte platbu --', '-');
	
	var aDelInfo = saDel.split('|');
	var aPayInfo = saPay.split('|');
	for (var i=0;i<aDelInfo.length-1; i++){
		aDelItem = aDelInfo[i].split('¤');
		if (aDelItem[0] == pkDel){
		  getE('endOrderPrice').innerHTML = FormatNumber(parseInt(nOrderPrice) + parseInt(aDelItem[2]) + nOrderPriceHandling);
		  nOrderPriceWDelivery = parseInt(nOrderPrice) + parseInt(aDelItem[2]);
		  aPayGroup = aPayInfo[i].split('¤');
			for(var j=0;j<aPayGroup.length-1;j++){
				aPayItem = aPayGroup[j].split('^');
				oPay.options[oPay.options.length] = new Option(aPayItem[1], aPayItem[0]);
			}
			if ((aDelItem[1]==1) && (ExtractCookieEx("NOEXP","B2B")=="0"))
			{
				getE('idMarket').style.display = "block";
			} else {
				getE('idMarket').style.display = "none";
				SetMarket(0);
			}
			return;
		}
	}
}

function setHandlingPrice (pkHd,nPrice) {

var pkHdl = getE(pkHd);

  if (pkHdl.checked==true)
   {
     nOrderPriceHandling = parseInt(nOrderPriceHandling) + parseInt(nPrice);  
   } else 
   {
     nOrderPriceHandling = parseInt(nOrderPriceHandling) - parseInt(nPrice);
   }

    getE('endOrderPrice').innerHTML = FormatNumber(parseInt(nOrderPriceWDelivery) + parseInt(nOrderPriceHandling));

}


function VazbyInitialize(saDel) {
	var oDel = getE('idDelivery');
	var l = oDel.options.length;
	// smazání dodacích adres, které nemají vazbu
// 	for (var i=l-1; i>-1; i--) {
// 		if (('|' + saDel).indexOf('|' + oDel.options[i].value + '¤') == -1)
// 			oDel.options.remove(i);
// 	}
	if (l > 0)
		VazbySelect(gvsPayment, gvsDelivery, oDel.options[oDel.selectedIndex].value);
}
function HighlightCat(nCatID) {
	if (nCatID!=0) {
		var o = getE('c' + nCatID);
		if (o) {
			o.style.color = '#932E04';
			o.style.borderRight = 'solid 4px #1888D8';
			o.className = 'catSEL';
		}
	}
}

/* Markets */
var arrOfImages = new Array();
function FillMarketImgs() {
	//nacacheovani obrazku do pameti
	arrOfImages[0] = new Image();
	arrOfImages[0].src = '/img/mapa/mapa_default.gif';
	arrOfImages[1] = new Image();
	arrOfImages[1].src = '/img/mapa/mapa_01.gif';
	arrOfImages[2] = new Image();
	arrOfImages[2].src = '/img/mapa/mapa_02.gif';
	arrOfImages[3] = new Image();
	arrOfImages[3].src = '/img/mapa/mapa_03.gif';
	arrOfImages[4] = new Image();
	arrOfImages[4].src = '/img/mapa/mapa_04.gif';
	arrOfImages[5] = new Image();
	arrOfImages[5].src = '/img/mapa/mapa_05.gif';
	arrOfImages[6] = new Image();
	arrOfImages[6].src = '/img/mapa/mapa_06.gif';
	arrOfImages[7] = new Image();
	arrOfImages[7].src = '/img/mapa/mapa_07.gif';
	arrOfImages[8] = new Image();
	arrOfImages[8].src = '/img/mapa/mapa_08.gif';
	arrOfImages[9] = new Image();
	arrOfImages[9].src = '/img/mapa/mapa_09.gif';
	arrOfImages[10] = new Image();
	arrOfImages[10].src = '/img/mapa/mapa_10.gif';
	arrOfImages[11] = new Image();
	arrOfImages[11].src = '/img/mapa/mapa_11.gif';
	arrOfImages[12] = new Image();
	arrOfImages[12].src = '/img/mapa/mapa_12.gif';
	arrOfImages[13] = new Image();
	arrOfImages[13].src = '/img/mapa/mapa_13.gif';
	arrOfImages[14] = new Image();
	arrOfImages[14].src = '/img/mapa/mapa_14.gif';
}
function HiglightKraj(id_kraj)
{
	getE('mapa_kraju').src = arrOfImages[id_kraj].src;
	//getE('MarketKrajSel').innerHTML = nazev_kraje;
}
function SelectKraj(nazev_kraje) {
	getE('MarketKrajSel').innerHTML = nazev_kraje;
}
function HiddeKraj(id_kraj)
{
	getE('mapa_kraju').src = arrOfImages[0].src;
	//getE('MarketKrajSel').innerHTML = 'Vyberte kraj';
}

function SetMarket(pkMarket, sEmail, bHomeCreditOk) {
	parent.getE('ChosenMarket').value = pkMarket;
	if (pkMarket==0) {
		parent.getE('idMarketSel').value = "";
		parent.getE('EmailMarket').value = "";
		parent.getE('bHomeCreditOk').value = "";
	} else {
		parent.getE('idMarketSel').value = getE('idMarketFirm' + pkMarket).innerHTML;
		parent.getE('EmailMarket').value = sEmail;
		parent.getE('bHomeCreditOk').value = bHomeCreditOk;
	}
}

/*
function SetMarket(pkMarket, sEmail, bHomeCreditOk) {
alert(pkMarket);
alert(window.parent.document.getElementById('ChosenMarket').value);

	window.parent.document.getElementById('ChosenMarket').value = pkMarket;
	if (pkMarket==0) {
		window.parent.document.getElementById('idMarketSel').value = "";
		window.parent.document.getElementById('EmailMarket').value = "";
		window.parent.document.getElementById('bHomeCreditOk').value = "";
	} else {
		window.parent.document.getElementById('idMarketSel').value = getE('idMarketFirm' + pkMarket).innerHTML;
		window.parent.document.getElementById('EmailMarket').value = sEmail;
		window.parent.document.getElementById('bHomeCreditOk').value = bHomeCreditOk;
	}
}*/
var gsIdTshDet;
function TshDetShow(pkCom,oBtn1) {
	var oBtn0 = getE(gsIdTshDet)
	var oDiv1 = getE(oBtn1.id + "Body");
	if (oBtn0) {
		oBtn0.src = oBtn0.src.replace("1", "0");
		getE(gsIdTshDet + "Body").style.display = "none";
	}
	oBtn1.src = oBtn1.src.replace("0", "1");
	oDiv1.style.display = "block";
	gsIdTshDet = oBtn1.id;
	InsertCookieEx("NOEXP", "TSHDET", pkCom + "|" + oBtn1.id);
}
function TshDetInit(pkCom, sShow) {
	var s = ExtractCookieEx("NOEXP","TSHDET");
	// pokud stále existuje záložka a je stále vybráno stejné zboží, pak ji zobrazím
	if (s!="none") {
		var as = s.split("|");
		if (pkCom == as[0]) {
			o = getE(as[1]);
			if (o) TshDetShow(as[0], o);
			return;
		}
	}
	
	if (sShow!="none") {
      TshDetShow(pkCom, getE(sShow));
  } else {
  
  // pokud neexistuje, zobrazím první existujíci
	var aTsh = new Array ('detLeg','detPar','detAlt', 'detRel');
	for (var i=0; i<aTsh.length; i++) {
		o = getE(aTsh[i]);
		if (o) {
			TshDetShow(pkCom, o);
			return;
		}
	}
	}
}
function SetPrevNextMod(nModul,oA){
	//if(window.location.pathname.toLowerCase().indexOf("detailpage.asp") == -1){
	InsertCookieEx("NOEXP", "PrevNextMod", nModul);
	window.setTimeout("window.location='" + oA.href + "'", 500);
	return false;
	//}
}
function Buy() {
	var strHtml = '';
	strHtml += "<table class='dynKosik'>";
	strHtml += "	<tr><td class='header' colspan='2'><img src='/img/BGbuyInfo.gif' class='img1' alt='zavřít' onclick='ShowHide(\"commodityBought\")'/><img src='/img/button_no.gif' class='img2' alt='zavřít' onclick='ShowHide(\"commodityBought\")'/><\/td><\/tr>";
	strHtml += "	<tr><td class='paranazev1' colspan='2' >&nbsp;Zboží se vkládá do košíku ...<\/td><\/tr>";
    strHtml += "	<tr><td class='para4I' colspan='2' align='center' style='height:32px;'><a href='javascript:ShowHide(\"commodityBought\")' style='cursor:pointer;' >Zavřít okno<\/a>&nbsp;&nbsp;&nbsp;<a href='/order.asp' >Zobrazit košík<\/a>";
	strHtml += "<\/table>";
	var o = window.getE('commodityBought');
	o.innerHTML = strHtml;
	o.style.display = 'inline';
	return true;
}
function SelectSearchType() {
	oST = getE("idSearchType");
	for (var i=0; i<oST.options.length; i++) {
		if (window.location.href.indexOf("SearchType=" + oST.options[i].value) > 0) {
			oST.options[i].selected = true;
			break;
		}
	}
}
function CheckComFilters(index) {
	getE("idNEW"+index).checked = (window.location.href.indexOf("NEW=1") != -1);
	o = getE("idACT"+index);
	if (o) o.checked = (window.location.href.indexOf("ACT=1") != -1);
}
function CheckProducersList() {
	var srch = "&" + window.location.search.substr(1) + "&";
	var frm = document.forms["frmMrkFilter"];
	for (var i = 0; i<frm.elements.length; i++) {
		if ((frm.elements[i].name=="MRK") && (srch.indexOf("&MRK=" + frm.elements[i].value + "&")!=-1))
			frm.elements[i].checked = true;
	}
}
function SavePrevNext(oA, nModId) {
	window.location.href = oA.href + (oA.href.indexOf("?")==-1 ? "?mod=" : "&amp;mod=") + nModId;
	return false;
}
// ###   FCE PRO zaskrtnutí a odeslání pk zboží pro Compare.asp   ###
function CompareSelectedEx(pk){

	var apkTblCommodity,aLen,IsIn;
	IsIn = 0;
	var sapkTblCommodity = ExtractCookieEx("WEB",'CMPSEL');

	if ((sapkTblCommodity=='none')||(sapkTblCommodity=='')||(sapkTblCommodity==pk)) {
		InsertCookieEx("WEB", "CMPSEL", pk);
	} else
	{
		apkTblCommodity = sapkTblCommodity.split('-');
		aLen = apkTblCommodity.length;
		for (var i = 0; i<aLen; i++) {
			//alert(apkTblCommodity[i]);
			if (apkTblCommodity[i] == pk) {IsIn = 1; break; }
		}
		if (IsIn == 0) {InsertCookieEx("WEB", "CMPSEL", sapkTblCommodity + "-" + pk)}
	}	
	CompareSelected();
	//	CompareRemoveOne(sapkTblCommodity, pk, false);
}
function CompareSelected() {
	var sapkTblCommodity, CompareAdd;
	sapkTblCommodity = ExtractCookieEx("WEB",'CMPSEL');

	if (sapkTblCommodity.indexOf('-') == -1) {
		alert('Pro porovnání je nutno vybrat nejméně 2 výrobky ...');
	} else {
		window.open('/Compare.asp?CMPID=' + sapkTblCommodity, "Compare","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=500,width=950,left=10,top=10,resizable=1,");
	}
}
function CompareAddRemItem(oChk) {
	var apkTblCommodity,aLen;
	var sapkTblCommodity = ExtractCookieEx("WEB",'CMPSEL');
	if ((sapkTblCommodity=='none')||(sapkTblCommodity=='')||(sapkTblCommodity==oChk.value)) {
		InsertCookieEx("WEB", "CMPSEL", (oChk.checked) ? oChk.value : "");
		return;
	}
	apkTblCommodity = sapkTblCommodity.split('-');
	if (oChk.checked) {
		aLen = apkTblCommodity.lenght;
		for (var i = 0; i<aLen; i++) {
			if (apkTblCommodity[i] == oChk.value) return;
		}
		InsertCookieEx("WEB", "CMPSEL", sapkTblCommodity + "-" + oChk.value);
	} else {
		CompareRemoveOne(sapkTblCommodity, oChk.value, false);
	}
}

function CompareRemoveAll() {
	InsertCookieEx("WEB","CMPSEL","");
}

function CompareUncheck(sComToRem) {
	// uncheck na window.parent
	if (window.opener && (window.opener!=window))
		for (var x=0; x<window.opener.document.forms.length;x++)
			if (window.opener.document.forms[x].name.indexOf("BuyForm")!=-1)
				if (window.opener.document.forms[x].CompareAdd)
					if (window.opener.document.forms[x].CompareAdd.value==sComToRem) {
						window.opener.document.forms[x].CompareAdd.checked = false;
						return;
					}
}

function CompareRemoveOne(sapkTblCommodity, sComToRem, bRedir) {
	var apkTblCommodity, aLen;

	if (sapkTblCommodity == '') {
		if (bRedir) window.close();
		return;
	}
	apkTblCommodity = sapkTblCommodity.split('-');
	aLen = apkTblCommodity.length;
	if (aLen == 1) {
		CompareRemoveAll();
		if (bRedir) {
			window.close();
		}
		return;
	}
	sapkTblCommodity = '';
	for (var i=0; i<aLen; i++) {
		if (apkTblCommodity[i]!=sComToRem) {
			if (sapkTblCommodity=='') {
				sapkTblCommodity = apkTblCommodity[i];
			} else {
				sapkTblCommodity += "-" + apkTblCommodity[i];
			}
		}
	}
	InsertCookieEx("WEB","CMPSEL",sapkTblCommodity);
	if (bRedir) {
		iPos = window.location.href.toLowerCase().indexOf("catid=");
		if (iPos==-1)
			window.location.href = '/Compare.asp?CMPID=' + sapkTblCommodity;
		else
			window.location.href = '/Compare.asp?CMPID=' + sapkTblCommodity + "&CatID=" + QueryString("CatID");
	}
}

function CompareRemoveOneAndRedir(sapkTblCommodity, sComToRem) {
	CompareUncheck(sComToRem);
	CompareRemoveOne(sapkTblCommodity, sComToRem, true);
}

function CompareCheckItemOnPage() {
	var sCommodities = ExtractCookieEx("WEB","CMPSEL");
	if ((sCommodities == "none")||(sCommodities == "")) return;
	for (var x=0; x<document.forms.length;x++) {
		if (document.forms[x].CompareAdd) {
			if (("-"+sCommodities+"-").indexOf("-"+document.forms[x].CompareAdd.value+"-")!=-1) {
				document.forms[x].CompareAdd.checked = true;
			}
		}
	}
}

function ShowHideSameParams(bCompareSame) {
	var tblCmp = getE('tblCmp');
	var tblRowLen = tblCmp.rows.length;
	var sDisplayStyle;
	var oTR;
	InsertCookieEx("WEB", "CMPSAME",bCompareSame);
	if (bCompareSame==1) {
		for (var iTR=0; iTR < tblRowLen; iTR++) {
			oTR = tblCmp.rows(iTR);
			if (oTR.id.indexOf('idRowFixedPar') == 0)
				oTR.style.display = "block";
		}
	} else {
		for (var iTR=0; iTR < tblRowLen; iTR++) {
			oTR = tblCmp.rows(iTR);
			if (oTR.id.indexOf('idRowFixedPar') == 0) {
				// pokud jsou hodnoty parametrů ve všech TD stejné, pak řádek schovám
				tblTdLen = oTR.cells.length;
				sFirstTdHTML = oTR.cells(1).innerHTML;
				bFixedParamSame = true;
				for (var iTD=2; iTD < tblTdLen; iTD ++) {
					if (sFirstTdHTML!=oTR.cells(iTD).innerHTML) {
						bFixedParamSame = false;
						break;
					}
				}
				if (bFixedParamSame) oTR.style.display = "none";
				
			}
		}
	}
}
function QueryString(sKey) {
	iPos = window.location.href.indexOf("?");
	if ((iPos==-1)||(sKey=="")) return "";
	aQS = window.location.href.substr(iPos+1).split("&");
	sKey = sKey.toLowerCase();
	for (var iKey=0; iKey<aQS.length; iKey++)
		if (aQS[iKey].toLowerCase().substr(0,sKey.length)==sKey) return aQS[iKey].split("=")[1];
	return "";
}
function ShowOkresy(sOkresy) {
	var e = window.parent.getE("idOkresy");
	e.innerHTML = sOkresy;
}
function DisableUnusedInputs(oForm) {
	var choice;
	for (var i=0; i<oForm.elements.length; i++) {
		if (oForm.elements[i].value=="") {
			oForm.elements[i].disabled = true;
			choice = oForm[oForm.elements[i] + "State"];
			if (choice) choice.disabled = true;
		}
	}
}

//statistiky netdirect
function ExtractSessionId() 
{
    var cookieList=document.cookie.split("; ");
    for (var i=0; i < cookieList.length; i++) 
    {
         asCookieNameValue = cookieList[i].split("=");

         if ((asCookieNameValue.length==2)&&(asCookieNameValue[0].toLowerCase().indexOf('session')!=-1))

         return unescape(asCookieNameValue[1]);
   }
    return "none";
}


function OpenWndClc(strURL){
	var objWnd = window.open(strURL,"InfoDetail","scrollbars=no,height=500,width=600,left=10,top=10");
	objWnd.focus();
}

function addBookmark(sTitleX, sUrlX) 
{

    var sTitle, sUrl;
  
    sTitle = sTitleX;
    sUrl  = document.location.href; 

    
    if (window.sidebar) 
    { 
            window.sidebar.addPanel(sTitle, sUrl,""); 
    } 
    else if ( document.all ) 
    {
            window.external.AddFavorite( sUrl, sTitle);
    } 
    else if ( window.opera && window.print ) 
    {
            return true;
    }
}

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;
} 
