// KOMPATIBILITA

var cAnim = null

var Br = new BrCheck()

function BrCheck()
{
	this.VER	= navigator.appVersion;
	this.AGENT	= navigator.userAgent.replace(/[\/]/g,' ');
	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.OP8	= this.AGENT.indexOf("Opera 8")>-1;
	this.OP		= (this.OP5 || this.OP6 || this.OP7 || this.OP8);

	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);
	this.IE8 = (this.VER.indexOf("MSIE 8") > -1 && this.DOM && !this.OP);
	this.IE = (this.IE4 || this.IE5 || this.IE6 || this.IE7 || this.IE8);

	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)     {   return document.getElementById(objectID); }
function getF(formName)     {	return document.forms[formName];}

function ChckF(name,text)
{
    var el = getE(name); if (el == null) return false;
    if (el.value=='') { alert(text); el.focus(); return false;}
    return true;
}
function SetDSP(nDSP, sURL) {
	var vyprs=new Date(); vyprs.setDate(vyprs.getDate() + 14);

	if (nDSP==1) {document.cookie="DSP=1; expires="+vyprs.toGMTString()+";path=\/";	} 
	else 	     {document.cookie="DSP=0; expires="+vyprs.toGMTString()+";path=\/";	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

var gsFormSuffix, gsFormIndex;
function extractNumberEX(obj, decimalPlaces, allowNegative)
{
	var temp = obj.value;
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0)      {reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';} 
	else if (decimalPlaces < 0) {reg0Str += '\\.?[0-9]*';}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str); if (reg0.test(temp)) return true;

	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) {
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key; var isCtrl = false; var keychar; var reg;
	if(window.event) { key = e.keyCode;	isCtrl = window.event.ctrlKey; }
	else if(e.which) { key = e.which; isCtrl = e.ctrlKey;              }
	if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);
	if (key == 8 || isCtrl) {return true;}
	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	return isFirstN || isFirstD || reg.test(keychar);
}

function CheckMaxLenght(obj, e, nMax) {return (obj.value.length < nMax);}
function CheckMaxLenghtBlur(obj, nMax) 
{ 
    if ( obj.value.length > nMax) 
    {
        alert('Překročen maximální počet povolených znaků ('+ nMax + ')');
        obj.innerHTML = obj.value.substring(0,nMax);
        obj.focus();
    }
    return true;
}

function SelectExcept(o) { return !( (o.id == "AMenu1")||(o.id == "TabMenu1")||(o.id == "TabMenu5")||(o.id == "TabMenu6")||(o.id == "CellMenu1")||(o.id == "CellMenu2")||(o.id == "ImgMenu1")); }

function SelectHide(sStyle)
{
 SelectHideEx(sStyle,document);
 var iframes = document.getElementsByTagName("iframe");
 for (var i = 0; i < iframes.length; i++)  { if (iframes[i].id != 'EShopsBar')  { SelectHideEx(sStyle,window.frames[i].document); } }
}

function SelectHideEx(sStyle,odocument)
{	
	var o=odocument.getElementsByTagName("select");
	if (o !=null ){
		if (o.tagName == 'SELECT') {if (SelectExcept(o)) o.style.visibility=sStyle;	} 
		else                       { for(var i=0;i<o.length;i++) {if (SelectExcept(o[i])) o[i].style.visibility=sStyle;} }
	}
}

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 InsertCookies(strName,strData){
	var vyprs=new Date();vyprs.setDate(vyprs.getDate() - 365);
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+"; path=\/;";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+"; path=\/;";
}
function ExtractCookies(strName)
{
	var cookieList=document.cookie.split("; ");
	var cookieArray = new Array();
	var name = "#";
	for (var i=0; i < cookieList.length; i++)
	{
		if(cookieList[i].indexOf(strName)>-1)
		{
			if( cookieList[i].indexOf("=")>-1)  {   name = cookieList[i].split("=");}
		}
	}
	if (name != "#")	{	return name[1];	}
	else        	    {	return "none";	}
}
	
function ExtractCookies_simple(strName){
	var cookieList=document.cookie.split("; ");
	var cookieArray = new Array();
	var name = "#"
	for (var i=0; i < cookieList.length; i++){
		if(cookieList[i].indexOf(strName+'=')==0){
			return cookieList[i].substr(cookieList[i].search('=')+1);
		}
	}
	return "";
}

//***************************************************************************/

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));
	
	while (sNumber.length<nDecimal) {sNumber='0'+sNumber;}
	var sDecimal = sNumber.substring(sNumber.length-nDecimal, sNumber.length);
	var nInt = sNumber.substring(0,sNumber.length-nDecimal);
	return ( parseFloat(nNumber) < 1 ? "0" : nInt) + "."+sDecimal;
}

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 controlMaxNumber(value,nMax, obj){
	  if(value > nMax && value >= 1)   {alert("Číslo stránky musí být v rozmezí od 1 - " + nMax); return false;}
	  else{
			if (obj.action.indexOf('pg-0') != -1) obj.action = obj.action.replace(/pg-0/,'pg-'+value)
			else if (obj.action.indexOf('PgID=0') != -1) obj.action = obj.action.replace(/PgID=0/,'PgID='+value)
      return true;
    }
}

function ControlFloat(){
	if (!Br.IE) return;
	if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode !=46) && (event.keyCode !=44)) event.returnValue = false;
}

function ControlNumber(e){
	var keynum,keychar,numcheck
	
	if(window.event){keynum = e.keyCode}
	else if(e.which){keynum = e.which}
	return ((keynum >= 48) && (keynum <= 57)) || keynum == 8 || keynum == 13
}
function ControlZipcode(e){
	var keynum,keychar,numcheck
	
	if(window.event){keynum = e.keyCode}
	else if(e.which){keynum = e.which}
	return ((keynum >= 48) && (keynum <= 57)) || keynum == 8 || keynum == 13 || keynum == 32
}
function ControlPhone() {
	if (!Br.IE) return;
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32)  && (event.keyCode!=40) && (event.keyCode!=41) && (event.keyCode!=43))
		event.returnValue = false;
}

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) { 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,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=470px;dialogHeight=450px");
		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=470,height=450,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";
}

function ShowImage(DPG) {window.open('/ShowImage.asp?IMG=' + DPG, "Foto","scrollbars=0,status=0,toolbar=0,location=0,directories=0,height=600,width=600,resizable=1");}
function SHAvIco(bshow) {if (getE('avIco')) {getE('avIco').style.display=(bshow ? 'block' : 'none');}}
function ShowHide(element) {
	var e = getE( element );
	if (e.style.display=="none") {
		if (!Br.OP) SelectHide('hidden');
		e.style.display = "" }
	else {
		if (!Br.OP) SelectHide('visible');
		e.style.display = "none" };
}

function ShowHideEx(element) {
	var e = getE( element );
	e.style.display  = (e.style.display=="none" ? "" : "none");
	
	if (getE('dlogin') && element == 'advsearch' ) { getE('dlogin').style.display="none";getE('d1').style.zIndex=10;getE('d2').style.zIndex=0;};
	if (getE('advsearch') && element == 'dlogin' ) { getE('advsearch').style.display="none";getE('d1').style.zIndex=0;getE('d2').style.zIndex=10;};
	
	if (getE('advsearch') && getE('imgSA') ) getE('imgSA').src = ( getE('advsearch').style.display=='none' ? '/img/bt-searchAdv.gif' : '/img/bt-searchAdvI.gif');
}
function ShowHideEx2(element) {
	var e = getE( element );
	e.style.display  = (e.style.display=="none" ? "" : "none");
	
	if (e.style.display == "") 
	    { getE('dlogin').style.display="none"; getE('d1').style.zIndex=10;getE('d2').style.zIndex=0;}
	else    
	    { getE('dlogin').style.display="block"; getE('d1').style.zIndex=0;getE('d2').style.zIndex=10;}
	    
	
	if (getE('advsearch') && getE('imgSA') ) getE('imgSA').src = ( getE('advsearch').style.display=='none' ? '/img/bt-searchAdv.gif' : '/img/bt-searchAdvI.gif');
}

function styleChange(elementId,classNameStr) {	var e = getE( elementId );	e.className = classNameStr;}


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 )
	}
}

var fadeInOut;
function fadeInObject ( objID, speed, opacity ) { // fce necha plynule zobrazit libovolny objekt na strance dle jeho ID; speed je 1-100; opacity je nepovinna vychozi hodnota
	window.clearTimeout(fadeInOut);
	var obj = getE(objID);
	if (!(opacity>0)) opacity = 0;
	if (!(speed>0)) speed = 25;
	opacity+=speed;
	if (Br.IE) {
		obj.style.filter = 'alpha(Opacity='+opacity+')';
		if (opacity<100) { fade=setTimeout("fadeInObject('"+objID+"',"+speed+","+opacity+");", 0) } else { obj.style.filter='' }
	} else if (Br.NS) {
		obj.style.MozOpacity = opacity/100;
		if (opacity<100) { fade=setTimeout("fadeInObject('"+objID+"',"+speed+","+opacity+");", 0) } else { obj.style.MozOpacity=1; }
	}
	if (obj.style.display=='none') obj.style.display='block';
}
function fadeOutObject ( objID, speed, opacity ) { // fce necha plynule zmiznout libovolny objekt na strance dle jeho ID; speed je 1-100; opacity je nepovinna vychozi hodnota
	window.clearTimeout(fadeInOut);
	var obj = getE(objID);
	if (!(opacity>0)) opacity = 100;
	if (!(speed>0)) speed = 5;
	opacity-=speed;
	if (Br.IE) {
		obj.style.filter = 'alpha(Opacity='+opacity+')';
		if (opacity>0) { fade=setTimeout("fadeOutObject('"+objID+"',"+speed+","+opacity+");", 0) } else { obj.style.display='none'; obj.style.filter=''; }
	} else if (Br.NS) {
		obj.style.MozOpacity = opacity/100;
		if (opacity>0) { fade=setTimeout("fadeOutObject('"+objID+"',"+speed+","+opacity+");", 0) } else { obj.style.display='none'; obj.style.MozOpacity=1; }
	}
	if (obj.style.display=='block') obj.style.display='none';
}

function hideShopInfoboxDialog() {
	var e = getE( "shopinfobox" );
	fadeOutObject ( "shopinfobox", 10 );
	clearTimeout;
	if (!Br.OP) SelectHide('visible');
}


function showShopConfirmDialog() {
	clearTimeout;
	
	//hideShopInfoboxDialog();
	if (Br.IE) {
		if (getE('PN1')) getE('PN1').style.visibility='hidden';
		if (getE('PN2')) getE('PN2').style.visibility='hidden';
		if (getE('filter1')) getE('filter1').style.visibility='hidden';
		if (getE('filter2')) getE('filter2').style.visibility='hidden';
		if (getE('producerSelector')) getE('producerSelector').style.visibility='hidden';
	}
	var e = getE( "shopinfobox" );
	
	e.style.position = "absolute";
	e.style.top = topScroll() + 300+'px';
	e.style.left = (document.body.clientWidth/2 - 180)+'px';
	fadeInObject ( "shopinfobox", 0 );
	if (getE('boxformcount')) getE('boxformcount').focus();
}

function hideShopConfirmDialog() {

	if (getE('itemsOnPageSelect')) { getE('itemsOnPageSelect').style.visibility='visible'; }
	if (getE('PN1')) getE('PN1').style.visibility='visible';
	if (getE('PN2')) getE('PN2').style.visibility='visible';
	if (getE('filter1')) getE('filter1').style.visibility='visible';
	if (getE('filter2')) getE('filter2').style.visibility='visible';
	var e = getE( "shopinfobox" );
	fadeOutObject ( "shopinfobox", 10 );
}

function GetBuy(frm,sAction,sTarget) {
    getE( "shopinfobox").style.display='none';
	frm.action = sAction;
	frm.target = sTarget;
	frm.submit();
}

function EmailControl(sEmail){
	var regEx  = new RegExp(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/); 
	regEx.ignoreCase = true;
		
	if (regEx.test(sEmail) == false)	{
	    alert('Nesprávný formát e-mailu');
		return false;
	}
	return true;
}

function CheckWatchDogForm()
{
	var emailObj         = document.forms.WatchDogForm.sEmail;
	var loginPassObj = document.forms.WatchDogForm.sLoginPass
	if (!EmailControl(emailObj.value))  {emailObj.focus(); return false;}
	if (loginPassObj.value.length < 5)
	{
	    alert('Heslo musí obsahovat minimálně  5 znaků!');
		loginPassObj.focus();
		return false
	}
	return true;
}
function SendItemSestavy(id) {
    return true; 
}

function checkCount( myCount, minCount, sUnit, onlyMultiplied ) {
	myCount = parseInt(myCount.replace(",","."));
	minCount = parseInt(minCount.replace(",","."));
	if ( myCount == 0 ) return true;
	if ( myCount < minCount ) {
	    alert('Toto zboží lze objednat v minimálním počtu '+minCount+' '+sUnit+'.'); return false;
	}
	if ( (onlyMultiplied==1) && ( (myCount*10) % (minCount*10) != 0) ) {
	    alert('Toto zboží lze zakoupit pouze v násobcích '+minCount+' '+sUnit+'.'); return false;
	}
	return true;
}

function checkCountSpolukup( myCount, minCount, maxCount, sUnit, onlyMultiplied ) {
	myCount = parseInt(myCount.replace(",","."));
	maxCount = parseInt(maxCount.replace(",","."));
	minCount = parseInt(minCount.replace(",","."));
	if ( myCount == 0 ) return true;
	if ( myCount < minCount ) {
	    alert('Toto zboží lze objednat v minimálním počtu '+minCount+' '+sUnit+'.'); return false;
	}
	if ( myCount > maxCount ) {
	    alert('Toto zboží lze objednat maximálně v počtu '+maxCount+' '+sUnit+'.'); return false;
	}
	if ( (onlyMultiplied==1) && ( (myCount*10) % (minCount*10) != 0) ) {
	    alert('Toto zboží lze zakoupit pouze v násobcích '+minCount+' '+sUnit+'.'); return false;
	}
	return true;
}

function confirmEmptyBasket()    {	return confirm('"&GLS(190,"Přejete si zrušit objednávku a vyprázdnit košík?")&"');}
function GoToPage(nPage, sParam) {  document.location.href = '?pgID=' + nPage + sParam;}
function trim(str)               {  return str.replace(/^\s*|\s*$/g,"");}

function ShowCalendar(oid)
 {
  var cal = document.getElementById('divcal');
  var calframe = document.getElementById('diviframcal');
  var tbox = document.getElementById(oid);
  var ssrc = '/Includes/Calendar_INC.asp?el=' + oid + '&selDate=' + tbox.value;
  
  cal.style.top = tbox.offsetTop + tbox.offsetHeight; cal.style.left = tbox.offsetLeft;
  calframe.src = ssrc;
  cal.style.display = 'block';
 }
 
function Bookmark(url,title){
	if (window.sidebar){window.sidebar.addPanel(title, url,"");}
	else if( document.all) {window.external.AddFavorite(url, title);}
	else {return true;}
}
 
var TRHeader=null
var TRHeaderBackground = null  
function setValueToSendComment(cmtTitle,cmtParent) {getE("cmtTitle").value='RE: ' + cmtTitle ; getE("cmtParent").value=cmtParent;getE('cmtText').focus();}
function checkSendForumData(bIgnore)
{
    if (!ChckF('cmtTitle','Vyplňte nadpis.')) {return false;}
    if (!ChckF('cmtName','Vyplňte jméno.'))   {return false;}
    if ( !EmailControl(getE('cmtEmail').value) ) {getE('cmtEmail').focus(); return false;}

	if (getE("cmtText").value.length == 0)                      { getE("cmtText").focus();  alert("Text je prázdný.") ; return false; }
	if (getE("sChckCodeF").value==getE("sChckCodeF").defaultValue){ getE("sChckCodeF").focus();alert("Vyplňte ověřovací kód.") ; return false; }
	
	getE("cmtTitle").value = removescript(getE("cmtTitle").value); getE("cmtName").value  = removescript(getE("cmtName").value); getE("cmtText").value  = removescript(getE("cmtText").value);
    return true;
}

function checkForumData()
{
	if( !EmailControl(getE("cmtWatchEmail").value, true) ){ return false;}
	if (getE("sChckCode2").value==getE("sChckCode2").defaultValue){alert("Vyplňte číslo na obrázku.") ;return false ;}
    return true;
}

function get_Y_Position(id){
    var curtop = 0;var obj = getE(id);
	while (obj.offsetParent) { curtop += obj.offsetTop; obj = obj.offsetParent; } 
	return parseInt(curtop)
}	

function removescript(stext){
    stext = stext.replace(new RegExp(/</g), '&lt;');
    stext = stext.replace(new RegExp(/>/g), '&gt;');
    stext = stext.replace(new RegExp(/script/g), 's.c.r.i.p.t');
    return stext;
}

function showparamdesc(id,idcat)
{
    var msg = window.open('/paramDescription.asp?ID=' + id +'&catid=' + idcat,'ParamDescription','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=470,height=450,left=50,top=50'); msg.focus();
}

function shBasketItem(id_1,id_2)
{
    if (getE(id_1).style.display == 'none' )    { getE(id_1).style.display = '';getE(id_2).style.display = 'none'; }
    else                                        { getE(id_2).style.display = '';getE(id_1).style.display = 'none'; }
}

var nCurrentImageIndex = 0;
function addImg(nIndex)
{
    if ( arrImages.length-2 < nCurrentImageIndex+nIndex || nCurrentImageIndex+nIndex<0) { alert('Jste na konci seznamu.'); return false; }

    nCurrentImageIndex = nCurrentImageIndex+nIndex;
    var aImage = arrImages[ nCurrentImageIndex ].split('||');
    getE('addimg_1').innerHTML =  '<a href="javascript:ShowImage(\'/FotoCache/BigAdd/' + arrImagesURL[ nCurrentImageIndex ] + '\');" title=""Zobrazit velký obrázek - ' + aImage[1] + '"" ><img src="/FotoCache/Add/' + aImage[0] + '" title=""Zobrazit velký obrázek - ' + aImage[1] + '"" /></a>';   
    aImage     = arrImages[ nCurrentImageIndex+1 ].split('||');
    getE('addimg_2').innerHTML =  '<a href="javascript:ShowImage(\'/FotoCache/BigAdd/' + arrImagesURL[ nCurrentImageIndex+1 ] + '\');" title=""Zobrazit velký obrázek - ' + aImage[1] + '"" ><img src="/FotoCache/Add/' + aImage[0] + '" title=""Zobrazit velký obrázek - ' + aImage[1] + '"" /></a>';   
    return false;
}


function sendBestPrice()
{
    if (!ChckF('url_bp','Vyplňte URL.')) {return false;}
    if (getE('price_bp').value + getE('pricewdph_bp').value == '' ) {alert("Vyplňte cenu"); getE('price_bp').focus(); return false;}
    if ( !EmailControl(getE('email_bp').value) ) {getE('email_bp').focus(); return false;}
    if (!ChckF('sChckCodeBP','Vyplňte ověřovací kód.')) {return false;}
    getE('bestprice').value = "send";
    return true;
}

function SHcomment(e, id)
{
  var src = (window.event) ? window.event.srcElement : e.target;
  if ( src == null || getE('comment_'+id) == null ) return false;   
  src.className = (src.className == 'dlEx4' ? 'dlEx4 dlEx5' : 'dlEx4');
  getE('comment_'+id).style.display = ( getE('comment_'+id).style.display == 'none' ? 'block' : 'none' );
}


var animationState = function()
{
     var src = getE('zoomA');
     var bState = ExtractCookies('ZOOM_OFF')=='1';
     if (cAnim) {bState = cAnim.Disabled;}
     if (bState) {src.title='Vypnout zvětšení okna produktu po najetí myši'; src.innerHTML = '<img src="/img/bt-zoomProduct_1.gif" alt="Zoom OFF" />'; }
     else        {src.title='Zapnout zvětšení okna produktu po najetí myši'; src.innerHTML = '<img src="/img/bt-zoomProduct_0.gif" alt="Zoom ON" />';  }
     if (cAnim) { cAnim.Disabled = !bState; }
     var vyprs=new Date(); vyprs.setDate(vyprs.getDate() + 14);
	 document.cookie="ZOOM_OFF=" + (bState ? '0' : '1' ) + "; expires="+vyprs.toGMTString()+";path=\/";
};

function setCookiesNoExpire(strName,strData){
    InsertCookies(strName,strData);
	//document.cookie=strName+"="+strData+"; expires=; path=\/;";
	//document.cookie=strName+"="+strData+"; expires=; path=\/;";
}

function addToRemember(id, logged)
{
    if (!logged) {alert('Pouze pro registrované zákazníky.'); return;}
    
    if (getE('iRemember')) {getE('iRemember').src='/Remember/ifrmRemember.asp?id='+id+'&Add=1;d=' + new Date(); }
    
}

function showHMcalc(nprice){
	var objWnd = window.open("/HomeCredit/HomeCredit.asp?nPrice=" + nprice,"_blank","scrollbars=no,height=450,width=600,left=10,top=10", true);
	objWnd.focus();
}
function showCetelemcalc(nprice){
	var objWnd = window.open("/cetelem/Kalkulacka.asp?CetelemPrice=" + nprice,"_blank","scrollbars=no,height=450,width=600,left=10,top=10", true);
	objWnd.focus();
}


function SelectMonth(nMonth){
        if (nMonth != "") {
                getE('dMonth').options.selectedIndex = parseInt(nMonth - 1);
        }
}

function SHMarks(floor)
{   
    var str = '';
    if (getE('divMarks')) getE('divMarks').style.display = (getE('divMarks').style.display=='none' ? 'block' : 'none' );
    if (getE('divMarks') && getE('idImgMarks')) 
    {
        if (getE('idImgMarks').src.search('_sr')>0) 
            getE('idImgMarks').src = (getE('divMarks').style.display=='none' ? '/img/bt-closeM_srOpen.gif' : '/img/bt-closeM_sr.gif' );
        else
        getE('idImgMarks').src = (getE('divMarks').style.display=='none' ? '/img/bt-closeM_'+floor+'.gif' : '/img/bt-close_'+floor+'.gif' );
    }
    return false;
}
function sendLogin(e)
{
    var key;
    if (window.event) { key = e.keyCode;}
	else if(e.which) { key = e.which;}
	if (key == 13) {getE('dagFormLogon').submit(); return false;}
	return true;
}
function onSF(frm, mincount, unit, multi) {
    var bRet = checkCount(frm.count.value, mincount, unit, multi);
    if (!bRet) { frm.count.value = mincount; }
    return bRet;
}

function disablePopUp(bForce) {
   getE('popupBanner').style.display = 'none';
   if (bForce) 
   {
       now = new Date();
       now.addHours(12);
       document.cookie = "DPU=on; expires=" + now.toGMTString() + ";path=\/"; 
    }
}
Date.prototype.addHours = function(n) { this.setHours(this.getHours() + n) }
Date.prototype.toDateString = function() { return [this.getDate(), this.getMonth() + 1, this.getFullYear()].join('-') }
Date.prototype.toString = function() { return [this.toDateString(), this.toTimeString()].join(' ') }
