

//Funkce pro Mironet - volaji je z editovatelnyc stranek
function openConfigurator(pConfID) {
	// otevře stránku s konfiguracemi typu pConfID ... ne jednu konfiguraci
	window.location.href = "/Configuration.asp?cgt="+pConfID;
	//window.open("/Configuration.asp?cgt="+pConfID, "Konfigurator", "Height=500, Width=660, scrollbars=yes, resizable=yes");
}
function openConfigCFC() {
	var CFC = document.getElementById("KonfCFC").value;
	if (isNaN(CFC) || CFC<1) return;
	window.open("/Configuration.asp?CFC="+CFC, "Konfigurator", "Height=500, Width=660, scrollbars=yes, resizable=yes");
}
function openCFGonEnter() {
	if (event.keyCode == 13) {
		openConfigCFC();
		event.returnValue = false;
	}
}

//Konfigurator
function ResizeWindow() {
	var obj = getE('tblConfigurator');
	if (obj != null) {
		var nHeight = obj.offsetHeight + 48;
		if (nHeight>screen.availHeight) {nHeight = screen.availHeight};
		window.resizeTo(obj.offsetWidth+60, nHeight);
		window.moveTo(0,0); // kvůli Configuration.asp
	}
}

// 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;
	this.OP6	= this.AGENT.indexOf("Opera 6")>-1;
	this.OP7	= this.AGENT.indexOf("Opera 7")>-1;
	this.OP		= (this.OP5 || this.OP6 || this.OP7);

	this.IE4	= (document.all && !this.DOM && !this.OP);
	this.IE5	= (this.VER.indexOf("MSIE 5")>-1 && this.DOM && !this.OP);
	this.IE6	= (this.VER.indexOf("MSIE 6")>-1 && this.DOM && !this.OP);
	this.IE7	= (this.VER.indexOf("MSIE 7")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE		= (this.IE4 || this.IE5 || this.IE6 || this.IE7);

	this.NS4	= (document.layers && !this.DOM);
	this.NS7	= (this.DOM && parseInt(this.VER) >= 5 && this.AGENT.lastIndexOf('Netscape')<this.AGENT.lastIndexOf('7'));
	this.NS6	= (this.DOM && parseInt(this.VER) >= 5 && !this.NS7);
	this.NS		= (this.NS4 || this.NS6 || this.NS7);

	return this;
}

function getE(objectID) {
	if (document.getElementById)
		return document.getElementById(objectID);
	else
		return document.all[objectID];
/*
	if (Br.IE)
		return document.all[objectID];
	else
		return document.getElementById(objectID);
*/
}

function getF(formName) {
	return document.forms[formName];
}

function getFEx(formName, oDocument) {
	return oDocument.forms[formName];
}

function getEEx(objectID, oDocument) {
	if (oDocument.getElementById)
		return oDocument.getElementById(objectID);
	else
		return oDocument.all[objectID];
}

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 SetDSP(nDSP, sURL) {
	if (nDSP==1) {
		InsertCookieEx("WEB","DSP","1");
	} else {
		InsertCookieEx("WEB","DSP","0");
	}
//	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
	window.location.reload();
}

function SetAlsoNotStored(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookieEx("WEB",'COMANS')=='1') {
		InsertCookieEx("WEB","COMANS","0");
	} else {
		InsertCookieEx("WEB","COMANS","1");
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

function SetCloseout(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookieEx("WEB",'COMCLO')=='1')
		InsertCookieEx("WEB","COMCLO","0");
	else
		InsertCookieEx("WEB","COMCLO","1");
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

// ###   FCE PRO zaskrtnutí a odeslání pk zboží pro Compare.asp   ###
function CompareSelectedEx2(pk){
	alert('ddd')
}
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 = new Array(sapkTblCommodity.split('|'));
		apkTblCommodity = sapkTblCommodity.split('|');
		aLen = apkTblCommodity.length;
//		alert(apkTblCommodity.lenght);
//		alert(aLen);
		for (var i = 0; i<aLen; i++) {
			//alert(apkTblCommodity[i]);
			if (apkTblCommodity[i] == pk) {IsIn = 1;}
		}
		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('none') > -1){
		//alert('mazu');
		CompareRemoveOne(sapkTblCommodity, 'none', false);
		}
	sapkTblCommodity = ExtractCookieEx("WEB",'CMPSEL');
	var aPole = sapkTblCommodity.split('|');
//	alert(sapkTblCommodity);
//	if ((sapkTblCommodity.indexOf('|') == -1)||(sapkTblCommodity.indexOf('none') > -1)||(aPole.length == 1)) {
	if ((sapkTblCommodity.indexOf('|') == -1)||(aPole.length == 1)) {
		alert('Pro porovnani je nutno vybrat nejmene 2 vyrobky ...');
	} else {
		window.open('/Compare.asp?CMPID=' + sapkTblCommodity, "Compare","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=500,width=900,left=10,top=10,resizable=1,");
	}
}
function CompareAddRemItem(oChk,sName) {
	var apkTblCommodity,aLen;
//	alert(oChk+' : ('+ExtractCookieEx("WEB",'CMPSEL')+')');
	var sapkTblCommodity = ExtractCookieEx("WEB",'CMPSEL');
	CompareRemoveOne(sapkTblCommodity, 'none', false);
/*
	if ((sapkTblCommodity=='none')||(sapkTblCommodity=='')||(sapkTblCommodity==oChk.value)) {
		InsertCookieEx("WEB", "CMPSEL", (oChk.checked) ? oChk.value : "");
		//return;
	}
*/
	apkTblCommodity = sapkTblCommodity.split('|');
	if (oChk.checked) {
		aLen = apkTblCommodity.length;
		for (var i = 0; i<aLen; i++) {
			if (apkTblCommodity[i] == oChk.value) return;
		}
//		alert(sName);
		InsertCookieEx("WEB", "CMPSEL", sapkTblCommodity + "|" + oChk.value);
		getE('CompStorage').style.display='';
		getE('cmpTable').style.display='';
		MoveImg(oChk,oChk.value,sName);
		
	} else {
		//CompareRemoveOne(sapkTblCommodity, oChk.value, false);
		CompareRemOne(oChk.value);
//			alert('|'+sapkTblCommodity+'|');
		if (getE('cdiv'+oChk.value)) {
			getE('cdiv'+oChk.value).style.display='none';
			}
	}
}
function CompareRemOne(pk){
	var sapkTblCommodity = ExtractCookieEx("WEB",'CMPSEL');
//	alert('|'+sapkTblCommodity+'|');
	CompareRemoveOne(sapkTblCommodity, pk, false);
	getE('cdiv'+pk).style.display='none';
	getE('CompareAdd'+pk).checked=false;
	var sapkTblCommodity = ExtractCookieEx("WEB",'CMPSEL');
	if ((sapkTblCommodity=='none')||(sapkTblCommodity=='')||(sapkTblCommodity==' ')){
		var t = getE('CompStorage');
		t.innerHTML = '';
		t.style.display='none';
		getE('cmpTable').style.display='none';
	}
}
function CompareRemoveAll() {
	InsertCookieEx("WEB","CMPSEL","");
}

function CompareUncheck(sComToRem) {
	// uncheck na window.parent
	if (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;
						if (window.opener.getE('cdiv'+sComToRem)) {
							window.opener.getE('cdiv'+sComToRem).style.display='none';
						}
						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 ((sapkTblCommodity=='none')||(sapkTblCommodity=='')||(sapkTblCommodity==' ')){
		var t = getE('CompStorage');
		t.innerHTML == '';
		t.style.display='none';
		if (window.opener.getE('cmpTable')){
			getE('cmpTable').style.display='none';
		}
		getE('cmpTable').style.display='none';
	}
	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 ParamDescShow(pkTblParamName, sParamName) {
	window.open('/ParamNameDesc.asp?' + ((pkTblParamName!=0)? "CPNPK=" + pkTblParamName : "CPNS=" + sParamName), "PARAMDESCR","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=350,width=350,left=10,top=10,resizable=1");
}
// ###   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 CopyParamsBack() {
	getE("DivForPars" + gsFormSuffix + gsFormIndex).innerHTML = getE('DivForParams').innerHTML;
	getF("BuyForm" + gsFormSuffix + gsFormIndex).submit();
}

// ###   FCE PRO ROZKLIKAVANI KATEGORII   ###

function InsertCookiesCat(intId,idTree){
	InsertCookieEx("WEB","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,"InfoDetail","scrollbars=yes,height=600,width=460,left=10,top=10");
	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")
		UpdateBasket();
	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.UpdateBasket()
	}else if (strReturn == "2"){
		window.opener.location.href="/order.asp";
		window.close();
	}
}
function UpdateBasket(){
	var strString,strSum1,strSum2,intSuma;
	strSum2 = new Array();
	intSuma = 0;

	strString = ExtractCookieEx("CLI",'BZbuy');
	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){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	InsertCookieEx("WEB","category"+idTree,intId);
}
function ParseCookies(strName, strKey){
	var strCook = ExtractCookieEx(strName, strKey)
	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.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íhá 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(){
	var o = getF('UserDataForm');
	if(((o.FirstName.value == "") || (o.LastName.value == "")) & (o.Firm.value == "")){alert("Vyplňte název firmy nebo jméno a příjmení.");return false}
	if(o.Street.value == ""){alert("Vyplňte ulici.");return false}
	if(o.City.value == ""){alert("Vyplňte město.");return false}
	if(o.ZipCode.value == ""){alert("Vyplňte PSČ.");return false}
	if(o.Phone.value == ""){alert("Vyplňte telefon.");return false}
	if(o.Email.value == ""){alert("Vyplňte email.");return false}
	if(IsEmail('idEmail','Email','Nesprávný formát e-mailu !',false))
	if(!ValidateAccount(o.BankAccount.value)){alert("Bankovní účet není platný, zkuste jej zadat znovu, nebo pole nevyplňujte.");return false};
//	if(o.Login.value == ""){alert("Vyplňte přihlašovací jméno.");return false}
//	if(o.Login.value.length < 5){alert("Přihlašovací jméno musí mít minimálně 5 znaků.");return false}
	if(o.Password.value == ""){alert("Vyplňte heslo.");return false}
	if(o.Password.value.length < 5){alert("Heslo musí mít minimálně 5 znaků.");return false}
	

	return true
}
function ControlDataOrder(){
  if (document.getElementById('idnCommMarket')) 
  {
	var o = getF('OrderForm');
	var oMarket = o.nCommMarket;
	if((o.DeliveryType.value == "-")||(o.DeliveryType.value == "0")){alert("Vyberte způsob dopravy.");SH_order('zpusob_doruceni');return false}
	if(getE("idnCommMarket")) {
		if((o.DeliveryType.value == "152")&&(o.nCommMarket.value == "0")){alert("Vyberte pobočku.");SH_order('zpusob_doruceni');return false}
		}
	if((o.PaymentType.value == "-")||(o.PaymentType.value == "0")){alert("Vyberte způsob platby.");SH_order('zpusob_doruceni');return false}
//	if((document.getElementById('DodatDoID').value == "")&&(o.DeliveryType.value == "152")){alert("Vyberte, kdy chcete zboží odebrat.");SH_order('zpusob_doruceni');return false}
//	if((document.getElementById('DodatDoID').value == "")&&(o.DeliveryType.value != "152")){alert("Vyberte, kdy chcete zboží doručit.");SH_order('zpusob_doruceni');return false}
//	if(oMarket!=null)
//		if ((DeliveryTextShowsMarket(o.DeliveryType.options[o.DeliveryType.selectedIndex].text))&&(oMarket.value == "0")) { alert("Vyberte pobočku.");return false}
	return true;
	}
	else
	{ alert('Pro dokončení objednávky se prosím zaregistrujte,\nnebo přihlaste pod vaším účtem.'); return false; }
}
function ControlPasswordPartners(NameOne,NameTwo){
//	alert('*'+getE("strFirm").value+'*');
	if(getE("strFirm").value==""){alert("Vyplňte prosím firmu");return false}
	if(getE("strPhone").value==""){alert("Vyplňte prosím telefon");return false}
	if(getE("strFirstName").value==""){alert("Vyplňte prosím jméno");return false}
	if(getE("strFax").value==""){alert("Vyplňte prosím fax");return false}
	if(getE("strLastName").value==""){alert("Vyplňte prosím příjmení");return false}
	if(getE("strEmailInfo").value==""){alert("Vyplňte prosím email info");return false}
	if(getE("strStreet").value==""){alert("Vyplňte prosím ulici");return false}
	if(getE("strEmailShop").value==""){alert("Vyplňte prosím email shop");return false}
	if(getE("strCity").value==""){alert("Vyplňte prosím město");return false}
	if(getE("strEmailReclamation").value==""){alert("Vyplňte prosím email reklamace");return false}
	if(getE("intZipCode").value==""){alert("Vyplňte prosím PSČ");return false}
	if(getE("intIco").value==""){alert("Vyplňte prosím IČO");return false}
	if(getE("strCountry").value==""){alert("Vyplňte prosím Stát");return false}
	if(getE("strDic").value==""){alert("Vyplňte prosím DIČ");return false}
	if(getE("strBank").value==""){alert("Vyplňte prosím banku");return false}
	if(getE("strLogin").value==""){alert("Vyplňte prosím login");return false}
	if(getE("strBankAccount").value==""){alert("Vyplňte prosím číslo účtu");return false}
	if(getE("strUrl").value==""){alert("Vyplňte prosím URL firmy");return false}
	if(getE("strServerAddress").value==""){alert("Vyplňte prosím URL shopu");return false}
	if(getE(NameOne).value==""){alert("Vyplňte prosím heslo");return false}
	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(sEmail){
	var re = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	if (!(sEmail.match(re)) || (sEmail.toLowerCase() == 'váš@email.cz')) {
		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=480px;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=480,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();
var arrTshInfo = new Array();
// nTshCount - v ASP na DetailPage

function showTsh(sTshOn) {

	iTsh = 0;
	// zapnutí správné záložky + získání indexu zapnuté
	for (var i=0; i<arrTshInfo.length; i++) {
		oTsh = getE(arrTshInfo[i]);
		if (oTsh!=null) {
			if (arrTshInfo[i]==sTshOn) iTsh = i;
			oTsh.style.display = (arrTshInfo[i]==sTshOn) ? "inline" : "none";
		}
	}

	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;

	//document.all.DetZalozkyObr.src = arrOfDetZalozky[idArrShow].src;
}
// ##### Zalozky na detailu END #########################################################

function DisTshParamAndCompare(sImgDisCompareBegin, sImgDisCompareMid, sImgDisCompareEnd, sImgDisParamSearchEndOn) {
	var iTsh;
	iTsh = 0;
	while (getE('tshCompareMid'+iTsh)!=null) {
		if (aDisableTshAndCmp[iTsh]) {
			//getE('tshCompareBegin'+iTsh).src = sImgDisCompareBegin;
			//getE('tshCompareBegin'+iTsh).sty.src = sImgDisCompareBegin;
			//getE('tshCompareEnd'+iTsh).src = sImgDisCompareEnd;
			getE('tshCompareMid'+iTsh).innerHTML = 'Porovnej ceny';
			if (getE('tshParamSearchLR'+iTsh) != null) {
				getE('tshParamSearchLR'+iTsh).src = sImgDisParamSearchEndOn;
				getE('tshParamSearchMid'+iTsh).style.display = "none"; // .backgroundImage = 'url(' + sImgDisParamSearchMid + ')';
				getE('tshParamSearchEnd'+iTsh).style.display = "none"; // .src = sImgDisParamSearchEnd;
			}
		}
		iTsh += 1;
	}
}
function DisableNonSelectedParams(formobj){
	var oS, oI, oSL, oIL; // konkrétní objekt SELECT / INPUT + L jako length
	var str = "";
	//jednoduchy select bez vetsiho mensiho rovnase
	if(formobj.SimpleSelect){
		if(formobj.SimpleSelect.tagName!='SELECT'){
			oSL = formobj.SimpleSelect.length;
			for(var i = 0;i < oSL; i++){
				oS = formobj.SimpleSelect[i];
				if(oS.value == ""){
					oS.disabled = "true";
				} else {
					str += '&'+escape(oS.name)+'='+escape(oS.value);
				}
			}
		}else{
			oS = formobj.SimpleSelect;
			if(oS.value == ""){
				oS.disabled = "true";
			}else{
				str += '&'+escape(oS.name)+'='+escape(oS.value);
			}		
		}
	}

	if (formobj.StateTxt) {
		if (formobj.StateTxt.length){
			oIL = formobj.StateTxt.length;
			for(var x = 0;x < oIL; x++){
				oI = formobj.StateTxt[x];
				if(oI.value==""){
					 oI.disabled = "true";
				}else{
					str += '&'+escape(oI.name)+'='+escape(oI.value);
				}
			}
		}else{
			oI = formobj.StateTxt;
			if(oI.value == ""){
				oI.disabled = "true";
			}else{
				str += '&'+ escape(oI.name) + '=' + escape(oI.value);
			}
		}
	}

	str += '/AdvancedSearch.asp?SearchButt=1&CatId=' + formobj.CatId.value;
	if(str.length > 1850 ){
		// než to tady někdo změní, tak mi plz řekněte !!! Lemma
		alert('Prosím, zadejte k vyhledávání méně parametrů, nebo kratší text. Vyhledáváný výraz je příliš dlouhý.')
		return false;
	}
	return true;
}

function DisableNonSelectedParamsM(formobj){

var i = 0;

for (x = 0; x < formobj.length; x++)
{
  if (formobj.elements[x].type == 'hidden')
  {
    if ((formobj.elements[x].value == '') && (!formobj.elements[x].disabled))
    { formobj.elements[x].disabled = 'disabled'; }
    else if (formobj.elements[x].value != '')
    { i = i + 1; }
  }
  if (formobj.elements[x].type == 'text')
  {
    if ((formobj.elements[x].value == '') && (!formobj.elements[x].disabled))
    { formobj.elements[x].disabled = 'disabled'; }
    else if (formobj.elements[x].value != '')
    { i = i + 1; }
  }
  if (formobj.elements[x].type == 'checkbox')
  {
    if ((!formobj.elements[x].checked) && (!formobj.elements[x].disabled))
    { formobj.elements[x].disabled = 'disabled'; }
    else if (formobj.elements[x].checked)
    { i = i + 1; }
  }
  if (formobj.elements[x].type == 'radio')
  {
    if ((!formobj.elements[x].selected) && (!formobj.elements[x].disabled))
    { formobj.elements[x].disabled = 'disabled'; }
    else if (formobj.elements[x].selected)
    { i = i + 1; }
  }
  if (formobj.elements[x].type == 'select')
  {
    if ((formobj.elements[x].selectedIndex == '') && (!formobj.elements[x].disabled))
    { formobj.elements[x].disabled = 'disabled'; }
    else if (formobj.elements[x].selectedIndex != '')
    { i = i + 1; }
  }
}

if ((formobj.name == 'frmSrchAdvF') && (i == 3) && (!formobj.SearchButtF.disabled)) formobj.action = '/default.asp?CatId=' + formobj.CatId.value;
//  alert(formobj['Price|From'].value);
//  if (formobj['Price|From']) if (formobj['Price|From'].value == "") formobj['Price|From'].disabled = 'disabled';
//  if (formobj['Price|To']) if (formobj['Price|To'].value == "") formobj['Price|To'].disabled = 'disabled';
  
//  alert(i);
  
//  if (formobj.length == 3) formobj.action = '/default.asp?CatId=' + formobj.CatId.value;

	return true;
}

function CfglShowDescription(pkCFGL) {
	window.open('/ConfigListDesc.asp?pkCFGL=' + pkCFGL, "CFGLdesc","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=350,width=350,left=10,top=10,resizable=1");
}
function RefreshBasket(nPrice) {
	// parametr = gnPriceWithDPH
	// aktualizace ceny nákupu + refresh, pokud je opener order.asp
	var oBasket;
	if (window.opener==null) return;
	if (typeof(window.opener.document)=="unknown") return;
	oBasket = getEEx('BasketPrice',window.opener.document);
	if (oBasket==null) return;
	oBasket.innerHTML = FormatCurrency(nPrice,0) + ' Kč';
	if (window.opener.location.href.toLowerCase().indexOf('order.asp')>-1)
		// nemůžu použít reload (protože bych třeba i nakupoval / hlasoval apod.)
		// navíc se MUSÍ dodržet zásada: Read-Request - R.QueryString; Write-Request - R.Form
		window.opener.location.href = window.opener.location.href;
}
function CheckMfSearch(value,exps){
	
	if(value == 'Articles'){
		getF('dagFormSearch').action = '/Default.aspx?CatId=306&txbSearch='+ exps
		getF('dagFormSearch').method = 'post'
	}else if (value=='Consult') {
		getF('dagFormSearch').action = '/Default.aspx?Consult=true&CatId=306&txbSearch='+ exps
		getF('dagFormSearch').method = 'post'
	}else{
//		getF('dagFormSearch').action = 'http://www.mironet.cz/Search.asp'
		getF('dagFormSearch').action = '/Search.asp'
		getF('dagFormSearch').method = 'get'
	}

	if(document.forms.dagFormSearch.EXPS.value=='' || document.forms.dagFormSearch.EXPS.value=='Hledej'){
		document.forms.dagFormSearch.EXPS.focus(); 
		alert('Zadejte hledaný výraz');
		return false;
	}
}

/* COOKIES */

function InsertCookie(strName, strValue){
	document.cookie=strName+"="+strValue+";";
}
/*
function InsertCookies(strName,strData){
        var vyprs=new Date();
        vyprs.setDate(vyprs.getDate() - 365);
        document.cookie=strName+"="+strData+";expires="+vyprs.toGMTString()+";domain=mironet.cz;path=/";
        vyprs.setDate(365 + 365 + vyprs.getDate());
        document.cookie=strName+"="+strData+";expires="+vyprs.toGMTString()+";domain=mironet.cz;path=/";
}
*/
function InsertCookieEx(strName, strKey, strValue){
//	alert(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 + ";domain=yshop.cz;path=/;";
	} else if (("&"+strKeysValues.toLowerCase()).indexOf("&"+strKey.toLowerCase()+"=")==-1) {
		document.cookie = strName + "=" + strKeysValues + "&" + strKey + "=" + strValue + ";domain=yshop.cz;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 + ";domain=yshop.cz;path=/;";
	}
}
function InsertCookieDSP(strName, strKey, strValue){
//	alert(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 + ";domain=yshop.cz;";
	} else if (("&"+strKeysValues.toLowerCase()).indexOf("&"+strKey.toLowerCase()+"=")==-1) {
		document.cookie = strName + "=" + strKeysValues + "&" + strKey + "=" + strValue + ";domain=yshop.cz;";
	} 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 + ";domain=yshop.cz;";
	}
}

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 unescape(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 unescape(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()+";";
			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 + ";";
	}
}

function CommSearchAdvFill() {
	var asQS, asQSKeyValue, oF, oFE, oFElen, sQS;
	sQS = getE("SrchAdvQS").innerHTML;
	if (sQS.length==0) return;
	asQS = sQS.split("&amp;");
	oF = getF("frmSrchAdv");
	for (var i=0;i<asQS.length;i++) {
		asQSKeyValue = asQS[i].split("=");
		asQSKeyValue[0] = asQSKeyValue[0];
		asQSKeyValue[1] = asQSKeyValue[1];
		oFE = oF[asQSKeyValue[0]];
		if (oFE!=null) {
			if (oFE.tagName=="INPUT")
				oFE.value = asQSKeyValue[1];
			else if (oFE.tagName=="SELECT") {
				oFElen = oFE.length;
				for (var ii=0; ii<oFElen; ii++) {
//					alert(asQSKeyValue[1]+' : '+oFE.options[ii].value+' = '+asQSKeyValue[1].indexOf(oFE.options[ii].value));
					//if ((oFE.options[ii].value == asQSKeyValue[1])||(asQSKeyValue[1].indexOf(oFE.options[ii].value)!=-1)) {
//					if ((oFE.options[ii].value == asQSKeyValue[1])) {
					if ((asQSKeyValue[1].match(oFE.options[ii].value)!=null)) {
//						oFE.selectedIndex = ii;
						if (oFE.options[ii].value!=""){	oFE.options[ii].selected = true;}
						//break;
					}
				}
			}
		}
	}
}

// forumCommodity  + forumOrder

function IsEmpty(oFormItem, sErrObjName) {
	if ((oFormItem.value=="") && (sErrObjName!="")) alert("Vyplňte prosím pole " + sErrObjName );
	oFormItem.focus();
	return (oFormItem.value=="");
}

function ForumAdd(fkTblCommodity, fkTblForum, sSubject) {
	getE("idForumHdr").innerHTML = (fkTblForum==0) ? "<div style=\"font-size: 10px; padding: 5px; color: #404040; font-weight: bold;\">Nový příspěvek</div>" : "<div style=\"font-size: 10px; padding: 5px; color: #404040; font-weight: bold;\">Odpovědět na příspěvek ( " + fkTblForum + " )</div>";
	getE("idForumReply").style.display = "block";
	window.scrollTo(0,8000);

	f = getF("FormAdd");
	f.Subject.value = (fkTblForum==0) ? sSubject : "RE: " + sSubject;
	f.PID.value = fkTblForum;
	f.Author.focus();
}

function ForumEdit(fkTblCommodity, fkTblForum, sSubject, sText) {
  getE("idForumHdr").innerHTML = "<div style=\"font-size: 10px; padding: 5px; color: #404040; font-weight: bold;\">Editace příspěvku</div>";
	getE("idForumReply").style.display = "block";
	getE("idForumEdit").value = "1";
	window.scrollTo(0,8000);

	f = getF("FormAdd");
	f.Subject.value = sSubject;
	f.PID.value = fkTblForum;
	f.Text.value = sText;
	f.Author.focus();
}


function ForumAddStorno() {
	getE("idForumReply").style.display = "none";
}

function ForumValidate(oForm) {
	if(IsEmpty(oForm.Author, 'Jméno')) return false;
	if(IsEmpty(oForm.Subject, 'Předmět')) return false;
	if(IsEmpty(oForm.Text, 'Text')) return false;
	if( oForm.GetAnswers.checked && (!EmailControl(oForm.Email.value)) ) return false;
	return true;
}

function ForumDel(pkTblForum) {
	if (confirm("Opravdu chcete příspěvek smazat?")) {
		f = getF("idForumDel");
		f.PID.value = pkTblForum;
		f.submit();
	}
}
function ForumIgnore(pkTblForum) {
	if (confirm("Opravdu chcete příspěvek ignorovat?")) {
		f = getF("idForumDel");
		f.PID.value = -pkTblForum;
		f.submit();
	}
}

function ForumOrderAdd(fkTblCommodity, fkTblForumOrder, sSubject) {
	getE("idForumOrderHdr").innerHTML = (fkTblForumOrder==0) ? "Nový příspěvek" : "Odpovědět na příspěvek ( " + fkTblForumOrder + " )";
	getE("idForumOrderReply").style.display = "block";
	window.scrollTo(0,8000);

	f = getF("FormAdd");
	f.Subject.value = (fkTblForumOrder==0) ? sSubject : "RE: " + sSubject;
	f.FOID.value = fkTblForumOrder;
	f.Author.focus();
}


function ForumOrderAddStorno() {
	getE("idForumOrderReply").style.display = "none";
}

function ForumOrderValidate(oForm) {
	if(IsEmpty(oForm.Author, 'Jméno')) return false;
	if(IsEmpty(oForm.Subject, 'Předmět')) return false;
	if(IsEmpty(oForm.Text, 'Text')) return false;
	//if( oForm.GetAnswers.checked && (!EmailControl(oForm.Email.value)) ) return false;
	return true;
}

function ForumOrderDel(pkTblForumOrder) {
	if (confirm("Opravdu chcete příspěvek smazat?")) {
		f = getF("idForumOrderDel");
		f.FOID.value = pkTblForumOrder;
		f.submit();
	}
}
function SetCloseoutOnly(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookieEx("WEB",'COMCLOONLY')=='1')
		InsertCookieEx("WEB","COMCLOONLY","0");
	else
		InsertCookieEx("WEB","COMCLOONLY","1");
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

function zobraz(e) {
	getE(e).style.display='block';
}

function zavri(e) {
	getE(e).style.display='none';
}
function spust(id,kat)
{

if (document.getElementById(id).style.display != "none")
  {
    document.getElementById(id).style.display = "none";
    document.getElementById('o'+id).src = "http://www.yshop.cz/Foto/vo/close.gif";
    document.getElementById('o'+id).alt = "Otevřít "+kat;
  }
  else
  {
    document.getElementById(id).style.display = "";
    document.getElementById('o'+id).src = "http://www.yshop.cz/Foto/vo/open.gif";
    document.getElementById('o'+id).alt = "Zavřít "+kat;
  }

}
function ShowImage(sImgPath,pk) {
		window.open('/ShowImg.asp?IMG=' + sImgPath +'&PK=' + pk, "Foto","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=800,width=800,resizable=1");
}
function ShowImageExt(sImgPath,pk,sText,bRes) {
		window.open('/ShowImg.asp?IMG=' + sImgPath +'&PK=' + pk + '&Text=' + sText + '&Res=' + bRes, "Foto","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=100,width=100,resizable=1");
}
function ShowDate(strItem) {
     var strReturn = showModalDialog("/Administration/SelectDate.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=250pt;dialogHeight=200pt");
     if (strReturn == undefined){return;}
     strItem.value = strReturn;
}
function SelectDateDialog(intNoInput){
	var saCodes = getE('saCodesID').value;
	var saCounts = getE('saCountsID').value;
	var sGetDate = getE('DodatDoID').value;
	var sKodPob = getE('nCommMarket').value;
	var sDeliveryType = aDeliveryTypeI6[oDeliveryType.selectedIndex-1];//getE('DeliveryType').value;
//	var strReturn = showModalDialog("SelectDate.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
	window.open("SelectDate.asp?saCodes="+saCodes+"&saCounts="+saCounts+"&sDelivery="+sDeliveryType+"&sGetDate="+sGetDate+"&sKodPob="+sKodPob,"","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=350,width=300,resizable=1");
//	if (strReturn == undefined){return;};
//	getE('DodatDoID').value = strReturn;
}
function ShowMDInput(){
	getE('DodatDoID').value='';
	if(getE('idPaymentType').value == '-'){
		getE('MDTR').style.display = "none";
		return;
	}
//	alert(getE('DeliveryType').value+" : "+getE('idPaymentType').value);
	if (getE('DeliveryType').value != '-'){
		if(getE('idPaymentType').value != '-'){
			getE('MDTR').style.display = "";
		} 
	} else {
		getE('MDTR').style.display = "none";
	}
	if(getE('Pobocka').style.display == ''){
		if(getE('nCommMarket').value != '0'){
			getE('MDTR').style.display = "";
		} else {
			getE('MDTR').style.display = "none";
		}
	}
}
function ShowMDInputEx(){
	getE('DodatDoID').value='';
	if(getE('idPaymentType').value == '-'){
		getE('MDTR').style.display = "none";
		return;
	}	
	if (getE('nCommMarket').value == '0'){
		getE('MDTR').style.display = "none";
	} else {
		if(getE('idPaymentType').value != '-'){
			getE('MDTR').style.display = "";
		}
	}
}
function AddMRKS(nProd){
	var o=document.getElementsByName("MRKs");
	if (o !=null ){
		for(var i=0;i<o.length;i++){
			if (o[i].value==nProd){
				o[i].checked=true;
			}
		}
		document.ProdForm.submit();
	}
	
}
function IsEmail(obj, name, err, AllowEmpty)
{	
	var msg =err;	
	var str = getE(obj).value;
	// are regular expressions supported?
	var supported = 0;
	if(AllowEmpty&&obj.value=='')
		return true;
	
	if(window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if(tempReg.test(tempStr)) supported = 1;
	}
	if(!supported)
	{
		if((str.indexOf("@") > 0))
		{
			alert(msg);
			getE(obj).focus();
			return false;
		}	
	}
	else
	{	
		  var regEx  = new RegExp("^[_a-zA-Z0-9\.\-]+@(([_a-zA-Z0-9\-]{1,}\.){1,})+\.[a-zA-Z]{2,}$");                                      
		  regEx.ignoreCase = true;  
		  if (regEx.test(str) == false)
		  {
		        alert(msg);
				getE(obj).focus();
		        return false;
		  }
	}
	return true;
}
function OpenErrWnd(sName,sCode) {
	if (Br.IE){
//		var strReturn = showModalDialog("/ErrWnd.asp?Name=" + sName,"","status:no; center:yes; help:no; minimize:no;dialogWidth=600px;dialogHeight=400px;");
		window.open("/ErrWnd.asp?Name=" + sName + "&Code=" + sCode,null, "Height=400px, Width=600px, scrollbars=yes, resizable=yes");		
	} else {
		window.open("/ErrWnd.asp?Name=" + sName + "&Code=" + sCode,null, "Height=400px, Width=600px, scrollbars=yes, resizable=yes");		
	}
}

function ShowHCcalc(idProduct)
{
    var msg = window.open('/HomeCreditCalc.asp?ID='+idProduct,'calc','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=600,height=550,left=20,top=20');		
}
function ShowCetelcalc(nPrice)
{
    var msg = window.open('http://reklama.mironet.cz/splatky/webcalc.php?o_price='+nPrice,'calc','toobar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=440px,height=360px,left=120pt,top=120pt');		
}


function show_hide_filter(e)
{
  if (document.getElementById('div_'+e).style.display != 'none')
  {
    document.getElementById('img_'+e).src = '/img/ico_close.gif';
    document.getElementById('div_'+e).style.display = 'none';
//    if (e == 'cena') document.getElementById('top_'+e).style = 'white-space: nowrap; background-color: #D1EFFF; padding: 3px; background-image: url(\'/img/bg_filtermid.gif\'); border-bottom: solid 1px #c6c7c6;';
  }
  else
  {
    document.getElementById('img_'+e).src = '/img/ico_open.gif';
    document.getElementById('div_'+e).style.display = '';
//    if (e == 'cena') document.getElementById('top_'+e).style = 'white-space: nowrap; background-color: #D1EFFF; padding: 3px; background-image: url(\'/img/bg_filtermid.gif\');';
  }
}

function SH_order(e)
{
//	if (document.getElementById('dodatdo')) { document.getElementById('dodatdo').style.display = 'none'; }

  if (e == 'obsah_kosiku')
  {
    if (document.getElementById('zpusob_doruceni')) document.getElementById('zpusob_doruceni').style.display = 'none';
    if (document.getElementById('kontaktni_udaje')) document.getElementById('kontaktni_udaje').style.display = 'none';
    if (document.getElementById('odeslani_objednavky')) document.getElementById('odeslani_objednavky').style.display = 'none';
    if (document.getElementById('obsah_kosiku')) document.getElementById('obsah_kosiku').style.display = '';
    document.getElementById('SH_img_1').src = '/img/tshBeginOn.gif';
    document.getElementById('SH_img_2').src = '/img/tshLROnOff.gif';
    document.getElementById('SH_img_3').src = '/img/tshLROffOff.gif';
    document.getElementById('SH_img_4').src = '/img/tshLROffOff.gif';
    document.getElementById('SH_img_5').src = '/img/tshEndOff.gif';
    document.getElementById('SH_tbl_1').style.backgroundImage = 'url(/img/tshMidOn.gif)';
    document.getElementById('SH_tbl_2').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_3').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_4').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('spanT1').style.fontWeight = 'bold';
    document.getElementById('spanT2').style.fontWeight = 'normal';
    document.getElementById('spanT3').style.fontWeight = 'normal';
    document.getElementById('spanT4').style.fontWeight = 'normal';
    document.getElementById('strOrderFoot').innerHTML = '<a href="http://www.yshop.cz/default.asp?DO=ok"><img src="/img/btn_order_free.gif" border="0"></a>&nbsp;&nbsp;<img src="/img/btn_order_next.gif" onclick="SH_order(\'zpusob_doruceni\')" style="cursor: pointer;">&nbsp;&nbsp;<img src="/img/btn_order_sub.gif" onclick="if (ControlDataOrder(document.getElementById(\'idOrderForm\'))) document.getElementById(\'idOrderForm\').submit();" style="cursor: pointer;">';
  }

  if (e == 'zpusob_doruceni')
  {
    if (document.getElementById('obsah_kosiku')) document.getElementById('obsah_kosiku').style.display = 'none';
    if (document.getElementById('kontaktni_udaje')) document.getElementById('kontaktni_udaje').style.display = 'none';
    if (document.getElementById('odeslani_objednavky')) document.getElementById('odeslani_objednavky').style.display = 'none';
    if (document.getElementById('zpusob_doruceni')) document.getElementById('zpusob_doruceni').style.display = '';
//    if (document.getElementById('dodatdo'))
//    {
//      dodatdo();
//    }
    document.getElementById('SH_img_1').src = '/img/tshBeginOff.gif';
    document.getElementById('SH_img_2').src = '/img/tshLROffOn.gif';
    document.getElementById('SH_img_3').src = '/img/tshLROnOff.gif';
    document.getElementById('SH_img_4').src = '/img/tshLROffOff.gif';
    document.getElementById('SH_img_5').src = '/img/tshEndOff.gif';
    document.getElementById('SH_tbl_1').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_2').style.backgroundImage = 'url(/img/tshMidOn.gif)';
    document.getElementById('SH_tbl_3').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_4').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('spanT1').style.fontWeight = 'normal';
    document.getElementById('spanT2').style.fontWeight = 'bold';
    document.getElementById('spanT3').style.fontWeight = 'normal';
    document.getElementById('spanT4').style.fontWeight = 'normal';
    document.getElementById('strOrderFoot').innerHTML = '<a href="http://www.yshop.cz/default.asp?DO=ok"><img src="/img/btn_order_free.gif" border="0"></a>&nbsp;&nbsp;<img src="/img/btn_order_prev.gif" onclick="SH_order(\'obsah_kosiku\')" style="cursor: pointer;">&nbsp;&nbsp;<img src="/img/btn_order_next.gif" onclick="SH_order(\'kontaktni_udaje\')" style="cursor: pointer;">&nbsp;&nbsp;<img src="/img/btn_order_sub.gif" onclick="if (ControlDataOrder(document.getElementById(\'idOrderForm\'))) document.getElementById(\'idOrderForm\').submit();" style="cursor: pointer;">';
  }

  if (e == 'kontaktni_udaje')
  {
    if (document.getElementById('obsah_kosiku')) document.getElementById('obsah_kosiku').style.display = 'none';
    if (document.getElementById('zpusob_doruceni')) document.getElementById('zpusob_doruceni').style.display = 'none';
    if (document.getElementById('odeslani_objednavky')) document.getElementById('odeslani_objednavky').style.display = 'none';
    if (document.getElementById('kontaktni_udaje')) document.getElementById('kontaktni_udaje').style.display = '';
    document.getElementById('SH_img_1').src = '/img/tshBeginOff.gif';
    document.getElementById('SH_img_2').src = '/img/tshLROffOff.gif';
    document.getElementById('SH_img_3').src = '/img/tshLROffOn.gif';
    document.getElementById('SH_img_4').src = '/img/tshLROnOff.gif';
    document.getElementById('SH_img_5').src = '/img/tshEndOff.gif';
    document.getElementById('SH_tbl_1').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_2').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_3').style.backgroundImage = 'url(/img/tshMidOn.gif)';
    document.getElementById('SH_tbl_4').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('spanT1').style.fontWeight = 'normal';
    document.getElementById('spanT2').style.fontWeight = 'normal';
    document.getElementById('spanT3').style.fontWeight = 'bold';
    document.getElementById('spanT4').style.fontWeight = 'normal';
    document.getElementById('strOrderFoot').innerHTML = '<a href="http://www.yshop.cz/default.asp?DO=ok"><img src="/img/btn_order_free.gif" border="0"></a>&nbsp;&nbsp;<img src="/img/btn_order_prev.gif" onclick="SH_order(\'zpusob_doruceni\')" style="cursor: pointer;">&nbsp;&nbsp;<img src="/img/btn_order_next.gif" onclick="if (ControlDataOrder(document.getElementById(\'idOrderForm\'))) document.getElementById(\'idOrderForm\').submit();" style="cursor: pointer;">&nbsp;&nbsp;<img src="/img/btn_order_sub.gif" onclick="if (ControlDataOrder(document.getElementById(\'idOrderForm\'))) document.getElementById(\'idOrderForm\').submit();" style="cursor: pointer;">';
  }

  if (e == 'odeslani_objednavky')
  {
    if (document.getElementById('obsah_kosiku')) document.getElementById('obsah_kosiku').style.display = 'none';
    if (document.getElementById('zpusob_doruceni')) document.getElementById('zpusob_doruceni').style.display = 'none';
    if (document.getElementById('kontaktni_udaje')) document.getElementById('kontaktni_udaje').style.display = 'none';
    if (document.getElementById('odeslani_objednavky')) document.getElementById('odeslani_objednavky').style.display = '';
    document.getElementById('SH_img_1').src = '/img/tshBeginOff.gif';
    document.getElementById('SH_img_2').src = '/img/tshLROffOff.gif';
    document.getElementById('SH_img_3').src = '/img/tshLROffOff.gif';
    document.getElementById('SH_img_4').src = '/img/tshLROffOn.gif';
    document.getElementById('SH_img_5').src = '/img/tshEndOn.gif';
    document.getElementById('SH_tbl_1').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_2').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_3').style.backgroundImage = 'url(/img/tshMidOff.gif)';
    document.getElementById('SH_tbl_4').style.backgroundImage = 'url(/img/tshMidOn.gif)';
    document.getElementById('spanT1').style.fontWeight = 'normal';
    document.getElementById('spanT2').style.fontWeight = 'normal';
    document.getElementById('spanT3').style.fontWeight = 'normal';
    document.getElementById('spanT4').style.fontWeight = 'bold';
    document.getElementById('strOrderFoot').innerHTML = '';
  }

}
