// -- pozice mysi
if (document.layers) 
{ // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else {
    document.onmousemove = captureMousePosition;
}

var xMousePos = 0; // Horizontal position of the mouse on the screen
var yMousePos = 0; // Vertical position of the mouse on the screen
var xMousePosMax = 0; // Width of the page
var yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    /*if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
    
window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;  */
    
}

// KOMPATIBILITA

var Br = new BrCheck()
var gCCompIDs = ''
function BrCheck()
{
	this.VER	= navigator.appVersion;
	this.AGENT	= navigator.userAgent;
	this.DOM	= document.getElementById ? true:false;

	this.OP5	= this.AGENT.indexOf("Opera 5")>-1							?true:false;
	this.OP6	= this.AGENT.indexOf("Opera 6")>-1							?true:false;
	this.OP7	= this.AGENT.indexOf("Opera 7")>-1							?true:false;
	this.OP		= (this.OP5 || this.OP6 || this.OP7);

	this.IE4	= (document.all && !this.DOM && !this.OP)					?true:false;
	this.IE5	= (this.VER.indexOf("MSIE 5")>-1 && this.DOM && !this.OP)	?true:false; 
	this.IE6	= (this.VER.indexOf("MSIE 6")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE7	= (this.VER.indexOf("MSIE 7")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE8	= (this.VER.indexOf("MSIE 8")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE		= (this.IE4 || this.IE5 || this.IE6 || this.IE7 || this.IE8);

	this.NS4	= (document.layers && !this.DOM)							?true:false;
	this.NS7	= (this.DOM && parseInt(this.VER) >= 5 && this.AGENT.lastIndexOf('Netscape')<this.AGENT.lastIndexOf('7'))?true:false;
	this.NS6	= (this.DOM && parseInt(this.VER) >= 5 && !this.NS7)		?true:false;
	this.NS		= (this.NS4 || this.NS6 || this.NS7);

	return this;
}

function getE(objectID) {
	return document.getElementById(objectID);
}

function getF(formName) {
	return document.forms[formName];
}

function getFEx(formName, oDocument) {
	return oDocument.forms[formName];
}

function getEEx(objectID, oDocument) {
	return oDocument.getElementById(objectID);
}


function CheckImgWidth(ImgId){
	if (document.getElementById(ImgId).width){
		if (document.getElementById(ImgId).width > 100){
			document.getElementById(ImgId).width = 100;	
		} ;
		
	}
}

function parentbgchange(sClass, obj){
	obj.childNodes[0].className = sClass;
	obj.childNodes[1].className = sClass;
}


function SetDSP(nDSP, sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (nDSP==1) {
		document.cookie="DSP=1; expires="+vyprs.toGMTString()+";";
	} else {
		document.cookie="DSP=0; expires="+vyprs.toGMTString()+";";
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

function SetAlsoNotStored(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookies('COMANS')=='1') {
		document.cookie="COMANS=0; expires="+vyprs.toGMTString()+";";
	} else {
		document.cookie="COMANS=1; expires="+vyprs.toGMTString()+";";
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

// ###### CONTROLA FORMU PRI ODELSANI OBJEDNAVKY NEREGISTROVANEHO KLIENTA ########

function ControlDataOrderNoRegistrer(){
	var sMess = '';
	if (getF('OrderForm').FirstName.value == '' 	|| getF('OrderForm').FirstName.value.length < 3)	{sMess = sMess + 'Vyplňte prosím správně Jméno!\n'; getF('OrderForm').FirstName.focus();}
	if (getF('OrderForm').LastName.value == '' 	|| getF('OrderForm').LastName.value.length < 3)	{sMess = sMess + 'Vyplňte prosím správně Příjmení!\n'; getF('OrderForm').LastName.focus();}
//	if (getF('OrderForm').Firm.value == '' 	&& getF('OrderForm').FirstName.value == '' && getF('OrderForm').LastName.value == '')	{sMess = sMess + 'Vyplňte prosím správně název Firmy, jste-li soukromá osoba zadejte jméno a příjmení!\n'; getF('OrderForm').Firm.focus();}
	if (getF('OrderForm').Street.value == '' 		|| getF('OrderForm').Street.value.length < 3)		{sMess = sMess + 'Vyplňte prosím správně Ulici!\n'; getF('OrderForm').Street.focus();}
	if (getF('OrderForm').City.value == '' 		|| getF('OrderForm').City.value.length < 3)		{sMess = sMess + 'Vyplňte prosím správně Město!\n'; getF('OrderForm').City.focus();}
	if (getF('OrderForm').ZipCode.value == '' 			|| getF('OrderForm').ZipCode.value.length < 3)			{sMess = sMess + 'Vyplňte prosím správně PSČ!\n'; getF('OrderForm').ZipCode.focus();}
	if (getF('OrderForm').Email.value == '')		{sMess = sMess + 'Vyplňte prosím správně email!\n'; getF('OrderForm').Email.focus();}
  if (EmailControlNEW(getF('OrderForm').Email.value) != true)		{sMess = sMess + 'Vyplňte prosím správně E-mail!\n'; getF('OrderForm').Email.focus();}
	if (getF('OrderForm').Phone.value == '' 		&& getF('OrderForm').Mobil.value == '')		{sMess = sMess + 'Vyplňte prosím správně Telefon nebo Mobil!\n'; getF('OrderForm').Phone.focus();}
	//if (getF('OrderForm').Mobil.value == '' 		|| getF('OrderForm').Mobil.value.length < 8)		{sMess = sMess + 'Vyplňte prosím správně Mobil!\n'; getF('OrderForm').Mobil.focus();}
	if (sMess == ''){
		document.getElementById('OrderForm').submit();
		return true;
	}else{
		alert(sMess);
		return false;
	}
}

function EmailControlNEW(f){
  
  if
(f.replace(/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/,"")=="") {

		return true
	} else {
		return false;
	}
}


// ######  / CONTROLA FORMU PRI ODELSANI OBJEDNAVKY NEREGISTROVANEHO KLIENTA ########

function SetCloseout(sURL) {
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);

	if (ExtractCookies('COMCLO')=='1') {
		document.cookie="COMCLO=0; expires="+vyprs.toGMTString()+";";
	} else {
		document.cookie="COMCLO=1; expires="+vyprs.toGMTString()+";";
	}
	if (getE('RedirOnListCagChange')!=null) window.location.href=sURL;
}

// ###   FCE PRO zaskrtnutí a odeslání pk zboží pro Compare.asp   ###

function CompareSelected() {
	var sapkTblCommodity, CompareAdd;
	sapkTblCommodity = "";
	//aby to fungovalo vsude mozzila ie atd....
	for (var x=0; x<document.forms.length;x++){
		if (document.forms[x].name.indexOf("BuyFormBody")){
			if (document.forms[x].CompareAdd){
				if(document.forms[x].CompareAdd.checked){
					if (sapkTblCommodity=="") {
						sapkTblCommodity = document.forms[x].CompareAdd.value;
					}else{
						sapkTblCommodity += "|" + document.forms[x].CompareAdd.value;
					}
				}
			}
		}
	}
	if (sapkTblCommodity.indexOf('|') == -1) {

		alert('Pro porovnání je nutno vybrat nejméně 2 výrobky ...');
	} else {
		window.open('/Compare.asp?CMP=' + sapkTblCommodity, "Compare","scrollbars=1,status=0,toolbar=0,location=0,directories=0,height=500,width=720,left=10,top=10,resizable=1,");
	}
}

function CompareRemoveOne(sapkTblCommodity, sComToRem) {
	var apkTblCommodity, aLen;
	if (sapkTblCommodity == '') {
		window.close();
		return;
	}
	apkTblCommodity = sapkTblCommodity.split(',');
	aLen = apkTblCommodity.length;
	if (aLen == 1) {
		window.close();
		return;
	}
	sapkTblCommodity = '';
	for (var i=0; i<aLen; i++) {
		if (apkTblCommodity[i]!=sComToRem) {
			if (sapkTblCommodity=='') {
				sapkTblCommodity = apkTblCommodity[i];
			} else {
				sapkTblCommodity += "," + apkTblCommodity[i];
			}
		}
	}
	window.location.href = '/Compare.asp?DPGs=' + 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   ###
function objOffsetX(obj)
{
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
		return curleft;
}

function objOffsetY(obj)
{
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
		return curtop;
}


var gsFormSuffix, gsFormIndex, gsTimer;

function BuyAndShowWindow(sFormSuffix,sFormIndex) {
		var sSelects, nWindowHeight;
  	
    gsFormIndex = sFormIndex;
	  gsFormSuffix = sFormSuffix;

	  var e = getE('BuyItem' + sFormIndex);
    var y = findPosY(e);
    var x = findPosX(e);
	
	  getE("StateInfo1").style.left = x - 250 + 'px';
	  getE("StateInfo1").style.top = y - 160 + 'px';
		document.forms["BuyForm" + sFormSuffix + sFormIndex].submit();
}

function BuyAndShowWindowList(sFormSuffix,sFormIndex) {
		var sSelects, nWindowHeight;
  	
    gsFormIndex = sFormIndex;
	  gsFormSuffix = sFormSuffix;

	  var e = getE('BuyItem' + sFormIndex);
    var y = findPosY(e);
    var x = findPosX(e);
	
	  getE("StateInfo1").style.left = x - 450 + 'px';
	  getE("StateInfo1").style.top = y - 160 + 'px';
		document.forms["BuyForm" + sFormSuffix + sFormIndex].submit();
}

function BuyAndShowWindowListDetail(sFormSuffix,sFormIndex) {
		var sSelects, nWindowHeight;
  	
    gsFormIndex = sFormIndex;
	  gsFormSuffix = sFormSuffix;

	  var e = getE('BuyItem' + sFormIndex);
    var y = findPosY(e);
    var x = findPosX(e);
	
	  getE("StateInfo1").style.left = x - 450 + 'px';
	  getE("StateInfo1").style.top = y - 160 + 'px';
		document.forms["BuyForm" + sFormIndex].submit();
}

function ShowInfoWindow(sFormSuffix,sFormIndex) {
		var sSelects, nWindowHeight;
  	
    gsFormIndex = sFormIndex;
	  gsFormSuffix = sFormSuffix;

	  var e = getE('InfoItem' + sFormIndex);
    var y = findPosY(e);
    var x = findPosX(e);


  if (sFormIndex.toString() == "2"){
    getE("StateInfo1").style.left = x - 150 + 'px';
	  getE("StateInfo1").style.top = y - 20 + 'px';
	  } else
    { getE("StateInfo1").style.left = x - 50 + 'px';
	  getE("StateInfo1").style.top = y - 260 + 'px';
    }
		document.forms["InfoForm" + sFormSuffix + sFormIndex].submit();
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
		return curleft;
	
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
		return curtop;
}

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 InsCo(intId,idTree){
	document.cookie="category"+idTree+"="+intId+";";
	document.cookie="category"+idTree+"="+intId+";";
}
function checkParent(src, dest) {
	while (src!=null) {
		if (src.tagName == dest) return src;
			src = src.parentElement;
	}
	return null;
}

function outlineCat() {
	var open = event.srcElement;
	var el = checkParent(open, "TD");
	if (null!=el) {
		var pos = 0;
		for (var pos=0; pos<el.children.length; pos++) {
			if ("TABLE"==el.children[pos].tagName) {
				if (el.children[0].src.indexOf("/img/catTree/plus.gif")>0) {
					el.children[0].src = "/img/catTree/minus.gif";
				}else{
					el.children[0].src = "/img/catTree/plus.gif";
				}
				break;
			}
		}
	    if (pos==el.children.length) return;
	} else return;
	el = el.children[pos];
	if ("TABLE"==el.tagName) {
		if (""==el.style.display) {
			el.style.display = "none";
		} else {
			el.style.display = "";
		}
	}
	event.cancelBubble = true;
}

// ###   FCE PRO PriceList ###

function SHModalDlgPricelist()
{
	var strReturn = showModalDialog("/Includes/EmailPricelist.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=320px;dialogHeight=124px;");

    if (strReturn == "") return;
	document.location.href = "/EmailPricelist.asp?EmailPricelist=" + strReturn;
}

// ##########

function onAction(imgName){
       getE(imgName).src = eval(imgName + "on.src")
}

function offAction(imgName){
	if (oldImgName.substring(0,4)!=imgName.substring(0,4)){
		getE(imgName).src = eval(imgName + "off.src")
	}
}

function OpenWnd(strURL){
  var d = (strURL.indexOf('?')>-1 ? '&d=' + (new Date).getTime() : '?d=' + (new Date).getTime());
	var objWnd = window.open(strURL+d,"InfoDetail","scrollbars=yes,height=500,width=900,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")
		ActionCookies('BZbuy');
	else if (strReturn == "2")
		window.location.href = "/order.asp";
}
function AddBuyDetail(strName, intPrice, intDph, strCode) {
	var strData,strReturn
	strData = strName+"&"+intPrice+"&"+intDph+"&"+strCode
	strReturn = showModalDialog("/AddUpdBuy.asp",strData,"status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=200pt");
	if (strReturn == "1"){
		window.opener.ActionCookies('BZbuy')
	}else if (strReturn == "2"){
		window.opener.location.href="/order.asp";
		window.close();
	}
}
function ActionCookies(strName){
	var strString,strSum1,strSum2,intSuma;
	strSum2 = new Array();
	intSuma = 0;

	strString = ExtractCookies(strName);
	if (strString > ""){
		strSum1 = strString.split("#");
		for (var i=0; i< strSum1.length-1; i++){
			strSum2[i] = strSum1[i].split("&");
			intSuma += BarterComma(strSum2[i][1])*BarterComma(strSum2[i][4]);
		}
		getE('CompletPrice').value =  FormatNumber(intSuma);
	}
}
function DeleteCookies(strName){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie=strName+"=; expires="+vyprs.toGMTString()+";";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie=strName+"=; expires="+vyprs.toGMTString()+";";
	getE('CompletPrice').value = "0.00";
}
function InsTreeCook(intId,idTree){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie="category"+idTree+"="+intId+"; expires="+vyprs.toGMTString()+";";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie="category"+idTree+"="+intId+"; expires="+vyprs.toGMTString()+";";
}

function InsertCookies(strName,strData){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+"; domain=huramobil.cz;path=/";
  vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+"; domain=huramobil.cz;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 ParseCookies(strName){
	var strCook = ExtractCookies(strName)
	if (strCook != "none"){
		var strList = strCook.split("a");
		for (var i=0; i < strList.length-1; i++){
			if(typeof(getE(strList[i]+'a')) == "object"){getE(strList[i]+'a').click();}
		}
	}
}
function FormatNumber(text){
	var mezi = BarterComma(text);
	mezi = ''+Math.round(parseFloat(mezi) * 100);
	var desetiny = mezi.substring(mezi.length-2, mezi.length);
	var cele = mezi.substring(0,mezi.length-2);
	if (parseFloat(mezi) < 1){
	        var mezi = "0."+desetiny;
	}else{
	        var mezi = cele+"."+desetiny;
	}
	return mezi;
}
function FormatFloat(nNumber,nDecimal){
	var sNumber = BarterComma(nNumber);
	sNumber = ''+Math.round(parseFloat(sNumber) * Math.pow(10,nDecimal));
	var sDedimal = sNumber.substring(sNumber.length-nDecimal, sNumber.length);
	var nInt = sNumber.substring(0,sNumber.length-nDecimal);
	if (parseFloat(sNumber) < 1){
	        var sNumber = "0."+sDedimal;
	}else{
	        var sNumber = nInt+"."+sDedimal;
	}
	return sNumber;
}
function FormatCurrency(nNumber,nDecimal){
	var sCurrency, iInsertSpace;
	sCurrency = FormatFloat(nNumber, nDecimal).replace('.',',');
	iInsertSpace = sCurrency.indexOf(',') - 3;
	while (iInsertSpace>0) {
		sCurrency = sCurrency.substring(0,iInsertSpace) + ' ' + sCurrency.substring(iInsertSpace,sCurrency.length);
		iInsertSpace -= 3;
	}
	if (nDecimal==0) sCurrency = sCurrency.substring(0,sCurrency.indexOf(","));
	return sCurrency;
}
function BarterComma(text){
	var mezi = ''+text;
	if (mezi.indexOf(',') != -1){
		mezi = mezi.split(",");
		mezi = mezi[0]+"."+mezi[1];
	}else{
		mezi = text;
	}
	return parseFloat(mezi);
}
function ControlNumber() {
     if (((event.keyCode <48) || (event.keyCode >57)) && (event.keyCode!=13)) event.returnValue = false;
}
function ControlPhone() {
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32)  && (event.keyCode!=40) && (event.keyCode!=41) && (event.keyCode!=43))
		event.returnValue = false;
}
function ControlPSC() {
    if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32))
		event.returnValue = false;
}
//----------info okno-------------------------------------------------------
function InfoWindow(strAddress) {
       showModalDialog(strAddress,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=450pt;dialogHeight=320pt");
}
function WriteDate(){
	var strDay=new Date();
	var d=strDay.getDay();
	if (d==1) document.writeln('pondělí');
	else { if (d==2) document.writeln('úterý');
	else { if (d==3) document.writeln('středa');
	else { if (d==4) document.writeln('čtvrtek');
	else { if (d==5) document.writeln('pátek');
	else { if (d==6) document.writeln('sobota');
	else { if (d==0) document.writeln('neděle'); }}}}}};
	document.writeln(strDay.getDate(),'.',strDay.getMonth()+1,'.',strDay.getFullYear());
	}
function ShowSearchMenu(x){
    if (x == 1){
        getE('Searchtable').style.display='';
    }else{
        getE('Searchtable').style.display='none';
    }
}
function LocInfo(){
	getE('StateInfo2').innerHTML="  probíná připojování...";
	var e = event.srcElement;
	var y = 0;
	var x = 0;
	while (typeof e == 'object' && e.tagName != 'BODY'){
		y += e.offsetTop;
		e = e.offsetParent;
	};
	x = (window.screen.width/2)+375
	getE('StateInfo1').style.top=y-140;
	getE('StateInfo1').style.left=x;
}

function PositionInfo(strText){
	getE('StateInfo3').innerHTML=strText;
	getE('StateInfo2').innerHTML="  probíhá připojování...";
	var e = event.srcElement;
	var y = 0;
	var x = event.clientX;
	while (typeof e == 'object' && e.tagName != 'BODY'){
		y += e.offsetTop;
		e = e.offsetParent;
	};
	getE('StateInfo1').style.top=y-140;
	if (document.body.clientWidth < 933){
	  getE('StateInfo1').style.left=x-175;
	}else{
	  getE('StateInfo1').style.left=780;
	}
}
function LocState(strCode,intCount){
	window.parent.frames['WinStat'].location.href="/InfoState.asp?ID="+strCode+"&CN="+intCount
	PositionInfo("On-line stav");
}
function ChangeStorage(bState){
	if(bState){
		for(var i = 0; i < getE('S').length; i++){
			getE('S')[i].value="0"
		}
	}else{
		for(var i = 0; i < getE('S').length; i++){
			getE('S')[i].value="-1"
		}
	}
}
function ChangeCloseout(bState){
	if(bState){
		for(var i = 0; i < getE('C').length; i++){
			getE('C')[i].value="1"
		}
	}else{
		for(var i = 0; i < getE('C').length; i++){
			getE('C')[i].value="3"
		}
	}
}
function ValidateAccount(sAccount) {
	var u1,u2,t1,t2,i;
	var vahy = new Array("1","2","4","8","5","10","9","7","3","6")
	u1 = sAccount.substring(0,sAccount.length - 10);
	u2 = sAccount.substring(sAccount.length - 10,12);
	t1 = 0;t2 = 0;
	for(i=u1.length ;i>0;i--) {
		t1 += u1.charAt(i - 1)*vahy[10 - i];
	}	  
	for(i=u2.length ;i>0;i--) {
		t2 += u2.charAt(i - 1)*vahy[10 - i];
	}
	if (((t2%11) == 0)&&((t1%11 == 0))) {
		return true;
	} else {
		return false;
	}
}
function ControlUserDataSubmit(){

    if(getF('UserDataForm').FirstName.value == ""){alert("Vyplňte jméno.");return false}
	if(getF('UserDataForm').LastName.value == ""){alert("Vyplňte příjmení.");return false}
	
	
	if(getF('UserDataForm').Street.value == ""){alert("Vyplňte ulici.");return false}
	if(getF('UserDataForm').City.value == ""){alert("Vyplňte město.");return false}
	if(getF('UserDataForm').ZipCode.value == ""){alert("Vyplňte PSČ.");return false}
	if(getF('UserDataForm').Phone.value + getF('UserDataForm').Mobil.value == ""){alert("Vyplňte telefon, nebo mobil.");return false}
	if(getF('UserDataForm').Email.value == ""){alert("Vyplňte email.");return false}
	if(!ValidateAccount(getF('UserDataForm').BankAccount.value)){alert("Bankovní účet není platné, zkuste jej zadat znovu, nebo pole nevyplňujte.");return false};
	if(getF('UserDataForm').Login.value == ""){alert("Vyplňte přistupové jméno.");return false}
	if(getF('UserDataForm').Login.value.length < 5){alert("Přistupové jméno musí mít nejméně 5 znaků.");return false}
	if(getF('UserDataForm').Password.value == ""){alert("Vyplňte heslo.");return false}
	if(getF('UserDataForm').Password.value.length < 5){alert("Heslo musí mít minimálně 5 znaků.");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}
	return true;
}
function ControlDataOrder(){
var pocetdel,pocetpay,pkdel;

}


function ControlPassword(NameOne,NameTwo){
	if (getE(NameOne).value != getE(NameTwo).value){
		alert("Špatně zadané heslo.");
		getE(NameOne).value = "";
		getE(NameTwo).value = "";
		getE(NameOne).focus();
		return false;
	}else{
		return true;
	}
}
function EmailControl(f){
	if ((f=='' || f=='Váš@email.cz') ||(f.indexOf('@') < 1 || f.indexOf('@') != f.lastIndexOf('@') || f.lastIndexOf('.') < f.lastIndexOf('@')+2  || f.lastIndexOf('.') > (f.length-3) || f.lastIndexOf('.') < (f.length-4))){
		alert('Nesprávný formát emailu');
		return false;
		}
	return true;
}

function EmailControlNEW(f){
  
  if
(f.replace(/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/,"")=="") {

		return true
	} else {
    return false;
	}
}

// ##### 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();

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(element) {
	var e = getE( element );
	if (e.style.display=="none") { e.style.display = "" } else { e.style.display = "none" };
}

function styleChange(elementId,classNameStr) {
	var e = getE( elementId );
	e.className = classNameStr;
}


// ShopConfirmBox - Count Dialog
function showCountDialog( formname, code, minCount, onlyMultiplied ) {
	var e = getE( "shopconfirmbox" );
	e.style.display = "";
	e.style.position = "absolute";
	e.style.top = (document.body.scrollTop + document.body.clientHeight/2 +150)+'px';
	e.style.left = (document.body.clientWidth/2 - 100)+'px';
	document.forms.shopconfirmform.elements.original_form.value = formname;
	document.forms.shopconfirmform.elements.code.value = code;
	document.forms.shopconfirmform.elements.minCountForOrder.value = minCount;
	document.forms.shopconfirmform.elements.onlyMultipliedCount.value = onlyMultiplied;
	document.forms.shopconfirmform.elements.count.value = minCount;
	document.forms.shopconfirmform.elements.count.focus();
}
function hideCountDialog() {
	var e = getE( "shopconfirmbox" );
	e.style.display = "none";
}
function submitCountDialog() {
	var orig_form;    orig_form    = document.forms["BuyForm"+document.forms.shopconfirmform.elements.original_form.value].elements;
	var shopbox_form; shopbox_form = document.forms.shopconfirmform.elements;

	if ( !((shopbox_form.count.value > 0) && (shopbox_form.count.value < 1000000000)) ) {
		hideCountDialog();
		return false;
	}
	
	if (!checkCount( shopbox_form.count.value, shopbox_form.minCountForOrder.value, shopbox_form.onlyMultipliedCount.value )) return false;
	
	orig_form.Count.value = shopbox_form.count.value;
	orig_form.submit();
}

function checkCount( myCount, minCount, onlyMultiplied ) {
	if ( myCount == 0 ) return true;
	if ( myCount < minCount ) {
		alert('Toto zboží lze objednat v minimálním počtu '+minCount+' ks.'); return false;
	}
	if ( (onlyMultiplied==1) && ( (myCount % minCount) != 0) ) {
		alert('Toto zboží lze zakoupit pouze v násobcích '+minCount+' ks.'); return false;
	}
	return true;
}

// AvaibilityBox - Avaibility Dialog
function showAvaibilityDialog( code, posX, posY, count ) {
	
	getE('StateInfo2').innerText = 'probíhá připojování...';
	getE('StateInfo1').style.top = posY;
	getE('StateInfo1').style.left= posX;
	
	getE('StateInfo3').innerHTML = "Dostupnost";
	getE('StateInfo1').style.display = "block";
	document.frames.WinStat.document.location = "/InfoState.asp?ID=" + code + "&amp;CN=" + count;
}
function hideAvaibilityDialog() {
	var e = getE( "avaibilitybox" );
	e.style.display = "none";
//	var e = getE( "avaibilitybox" );
//	e.style.display = "none";
}



function katmenuOver( menuItem ) {
	var e;
	e = getE( "menuL"+menuItem );
	e.className = "leftcornerA";
	e = getE( "menuC"+menuItem );
	e.className = "centerA";
	e = getE( "menuR"+menuItem );
	e.className = "rightcornerA";
}

function katmenuOut( menuItem ) {
	var e;
	e = getE( "menuL"+menuItem );
	e.className = "leftcorner";
	e = getE( "menuC"+menuItem );
	e.className = "center";
	e = getE( "menuR"+menuItem );
	e.className = "rightcorner";
}
function VazbySelectm(pkDel,string, cena, priceSum){
var pole;

// Znemoznime prejit na dalsi KROK
//--var im = getE('btStep4');
//--im.src = 'http://www.huramobil.cz/img/BTstep4d.gif';
//--im.disabled = 'disabled';

//--document.forms.DPForm.pkTblPaymentType.value = "";

pole = string.split('|');
	for (i=0;i<pole.length-1; i++) {
		getE(pole[i]).style.display='none';
	}
	getE(pkDel).style.display='block';
    
  getE('idTblDeliveryType').value = pkDel; 
  
  if(getE('chlabel_38_'+pkDel))
  {
    getE('price_38_'+pkDel).value = Math.round((1*priceSum)*.03);
    getE('chlabel_38_'+pkDel).innerHTML = "<strong>Platební kartou online ("+Math.round((1*priceSum)*.03)+" Kč)</strong>";
  }
  
}

function setPaymentPK(pkPayment){
var im;
/*
var im = getE('btStep4')
im.src = 'http://www.huramobil.cz/img/BTstep4.gif';
im.disabled = '';
*/
getE('idTblPaymentType').value = pkPayment; 
//document.forms.DPForm.btStep4.src = '/img/BTstep4.gif';

}



function CenaCelkem(cena, pkPayment)
{
var cenacelkem;
	cenacelkem=parseInt(getE('cena').value)+parseInt(cena);	
	getE('popis').value='Cena za dopravu a platbu činí: '+cenacelkem+' Kč';
	getE('popis').style.visibility='visible';
	//alert(pkPayment);
	if(arrPaymentAlert[pkPayment] != ""){
		alert(arrPaymentAlert[pkPayment]);
	}
}

function VazbySelect(s1,s2,pkDel){
//alert(s1+'\n'+s2 +'\n ' +pkDel);
	var s1pole,s2pole,s1pom,s1p,pkP,NazevP,iHtml;

	iHtml = '<div tabindex="213" id="i213" size="1" class="input_textm" style="width:220px">';
	s1pole = s1.split('$$$$');
	s2pole = s2.split('$$$$');
	for (i=0;i<s2pole.length-1; i++){
		if (s2pole[i] == pkDel){
			s1pom = s1pole[i].split('##');
			for(j=0;j<s1pom.length-1;j++){
				s1p = s1pom[j].split('||');
				pkP = s1p[0];
				NazevP = s1p[1];
				iHtml += '<input type="radio" name="PaymentType" value="' + pkP + '" >' + NazevP +'<br>';
				  
			}
		}
	}
	iHtml +='</div>';
	getE('DivForVazby').innerHTML = iHtml;

	
}



function ZalozkyDetail(id){
	var i;
	
	for(i=1;i<5;i++){
	//	alert('')
		if (i==id){
		//	getE("G"+i).className = "ZalozkaABG";
		//'	getE("L"+i).className = "ZalozkaAL";
		//'	getE("P"+i).className = "ZalozkaAP";
			if(getE("DPT"+i)){
				getE("DPT"+i).style.display = "";	
			}
			}
		else
			{
		//	getE("G"+i).className = "ZalozkaNBG";
		//	getE("L"+i).className = "ZalozkaNL";
		//	getE("P"+i).className = "ZalozkaNP";
			if(getE("DPT"+i)){
				getE("DPT"+i).style.display = "none";
			}
			}
		}
	
}



function ZalozkyDetailPopis(id){
	var i;
	for(i=1;i<5;i++){
		if (i==id){	
			if(getE("ZA"+i)){
				getE("ZA"+i).style.display = "";	
				if(getE("Z" + i)){
					getE("Z" + i).className = "testmA";
				}
			}
		}
		else
		{		
			if(getE("ZA"+i)){
				getE("ZA"+i).style.display = "none";
				if(getE("Z" + i)){
					getE("Z" + i).className = "testm";
				}
			}
		}
	}
	
}

function SwitchFlod(id){
	var i;
	var oldClass;
	var arrClass;
	var newClass;
	for(i=0;i<10;i++){
		if (i==id){	
			
			if(getE("F"+i)){
				getE("F"+i).style.display = "block";
				if(getE("FF" + i)){
					oldClass = getE("FF" + i).className
					arrClass = oldClass.split(" ")	
					newClass = "" + arrClass[0] + " " + arrClass[1] + " dOR";
					getE("FF" + i).className = newClass;
				}
			}
		}
		else
		{		
			if(getE("F"+i)){
				getE("F"+i).style.display = "none";
				if(getE("FF" + i)){
					oldClass = getE("FF" + i).className
					arrClass = oldClass.split(" ")	
					newClass = "" + arrClass[0] + " " + arrClass[1];
					getE("FF" + i).className = newClass;					
				}
			}
		}
	}
	
}


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 + ";";
	} else if (("&"+strKeysValues.toLowerCase()).indexOf("&"+strKey.toLowerCase()+"=")==-1) {
		document.cookie = strName + "=" + strKeysValues + "&" + strKey + "=" + strValue + ";";
	} 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 + ";";
	}
}
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 formsubmit(formname){
	document.forms[formname].submit();
}

function VisibDiv(x, y)
{
	var ifr = document.getElementById('subc');
	//var ifr = window.frames['subc'];
	//alert(x);
	gxdiv = document.getElementById('s' + x);
//alert(gxdiv);		
	if (gxdiv.style.display == 'block') {
		document.getElementById('impl' + x).src = '/Img/cat_arrow.gif';
		document.getElementById('impl' + x).alt = 'Zobrazit podkategorie';
		document.getElementById('impl' + x).title = 'Zobrazit podkategorie';
		gxdiv.style.display= 'none'
	} else {
		ifr.src = '/subm.asp?CatID=' + x + '&kategorie=' + y;
		//alert('haha')
		if (typeof(gxprev) != 'undefined')
		{
			document.getElementById('s' + gxprev).style.display= 'none';
			document.getElementById('impl' + gxprev).src = '/Img/cat_arrow.gif';
			document.getElementById('impl' + gxprev).alt = 'Zobrazit podkategorie';
			document.getElementById('impl' + gxprev).title = 'Zobrazit podkategorie';
		}
//			gxdiv.style.display= 'block';
			document.getElementById('impl' + x).src = '/Img/cat_arrow_down.gif';
			document.getElementById('impl' + x).alt = 'Skrýt podkategorie';
			document.getElementById('impl' + x).title = 'Skrýt podkategorie';
	}
	gxprev = x;
	//
	//InsertCookies('XSubC',x);
}

var goCurrentImg;

function cl_min (ev) {
	if (window.event) {ev = window.event}
	
	var hi = document.getElementById("hi"+this.iid);
	//alert(hi.firstChild.firstChild.firstChild);	
	//return
	//var td = hi.firstChild.firstChild.firstChild;
	hi.innerHTML = "<img src='" + this.thsrc + "' alt='Náhled' />"
//"" + this.sName + "<br />
//	img.src = this.thsrc;
	hi.style.width = this.thw;
	hi.style.height = this.thh;
	hi.style.left = "5px";//this.offsetLeft; //(objPos(this).x +10) + "px";//leftPosition(this) + "px";
	hi.style.top = "-17px"; //this.offsehiop; //(objPos(this).y + 10) + "px";//(topPosition(this) + 35) + "px";
	if (goCurrentImg){goCurrentImg.style.display = "none"}
	hi.style.display = "block";
	goCurrentImg = hi;
}

//function cl_min (ev) {
//	if (window.event) {ev = window.event}
//	var hi = document.getElementById("hi"+this.iid);
//	var img = hi.firstChild;
//	img.src = this.thsrc;
//	img.width = this.thw;
//	img.height = this.thh;
//	hi.style.left = "10px";//this.offsetLeft; //(objPos(this).x +10) + "px";//leftPosition(this) + "px";
//	hi.style.top = "-20px"; //this.offsehiop; //(objPos(this).y + 10) + "px";//(topPosition(this) + 35) + "px";
//	hi.style.display = "block";
//}

function cl_mout (ev) {
	if (window.event) {ev = window.event}
	var hi = document.getElementById("hi"+this.iid);
	hi.style.display = "none";
}

function lf(n,ev,f,w,h,iid, sName){
	
	if (Br.IE || Br.OP) {
		n.thsrc = f;
		n.thw = w;
		n.thh = h;
		n.iid = iid;
		n.sName = sName;
		n.onmouseover = cl_min;
		n.onmouseout = cl_mout;
		n.onmouseover(ev);
	}
}

function showBestSetOffAll(){
	for (var i=6; i<11; i++) {
  document.getElementById("bestSetoff"+i).style.display="block";  
  }
  
  document.getElementById("nextBestSetOff").style.display="none";  
  
}

function showtopitem(){
	for (var i=6; i<11; i++) {
  document.getElementById("topitem"+i).style.display="block";  
  }
 
  document.getElementById("nextTopSale").style.display="none";  
   
  
}

function showBestWatch(){
	for (var i=6; i<11; i++) {
  document.getElementById("BestWatch"+i).style.display="block";  
  }
  
  document.getElementById("nextBestWatch").style.display="none";  
  
}
function controlfulltext(str)
{
  if (str.replace(/^\s*|\s*$/g,"").length < 3) 
  {
    alert ('Řetězec musí obsahovat minimálně 3 znaky...');
    return false;
  }
  else return true;
}

function ShowHideOnline(sID, bShow, sCode)
{
  //alert('x: ' + xMousePos + '; y: ' + yMousePos);
  //debugger;
  var el = document.getElementById(sID);
  /*el.style.top = xMousePos + 'px';
  el.style.left = yMousePos + 'px';*/
  el.style.top = '300px';
  el.style.left = '300px';
  var sShow = ( bShow ? '' : 'none' );
  var url = "http://www.huramobil.cz/ajxOnlineAvail.asp?sCode=" + sCode; //1004358
  //alert(url);
  FAjax(url, sID);
  //el.innerHTML = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;
  el.style.display = sShow;
}

//-------------------------------------------------------------------------------------------------------------------------
function FAjax(url, sTarget){
	var tg = document.getElementById(sTarget);
	tg.innerHTML = "";
	if (window.XMLHttpRequest) {
		httpRequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
		  httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (eror) {
		  httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	var d = new Date();
	var sekundy = (d.getHours()*3600)+(d.getMinutes()*60)+d.getSeconds();
	httpRequest.open("GET", url+"&t="+sekundy, true);
	httpRequest.onreadystatechange= function () {processRequest(sTarget); } ;
	httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
	httpRequest.send(null);
}
//-------------------------------------------------------------------------------------------------------------------------
function processRequest(sTarget){

  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
      var tg = document.getElementById(sTarget);
	  //var headers = httpRequest.getAllResponseHeaders(  );
	 // if(tg.style.visibility == 'hidden'){
		tg.style.visibility = 'visible';
		tg.innerHTML = httpRequest.responseText;
	  //}else{tg.style.visibility = 'hidden'; tg.innerHTML = "";}
    }
    else
    {
        alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
    }
  }
}
//-------------------------------------------------------------------------------------------------------------------------
function ViewPaymentLegend(sID, aIDs)
{
  var arr = aIDs.split('|');
  for(var a=0; a<arr.length-1; a++ )
  {
    getE(arr[a]).style.display = 'none';
  }
  getE(sID).style.display = 'block';
}
//-------------------------------------------------------------------------------------------------------------------------
function ViewDeliveryLegend(sID, aIDs, aIDs1)
{
  var arr = aIDs1.split('|');
  for(var a=0; a<arr.length-1; a++ )
  {
    getE(arr[a]).style.display = 'none';
  }
  arr = aIDs.split('|');
  for(var a=0; a<arr.length-1; a++ )
  {
    getE(arr[a]).style.display = 'none';
  }
  getE(sID).style.display = 'block';
}
//-------------------------------------------------------------------------------------------------------------------------
function ShowHideFrm(what)
{
  var aDivs = new Array('flo', 'fa', 'oth', 'del', 'lo', 'no', 'btns');
  getE('gWhatForm').value = what;
  if(what == '')
    return false;
  if(getE('required_deliveryfirstname'))
    getE('required_deliveryfirstname').style.visibility = 'hidden';
  if(getE('required_deliverylastname'))
    getE('required_deliverylastname').style.visibility = 'hidden';
  if(getE('required_deliverystreet'))
    getE('required_deliverystreet').style.visibility = 'hidden';
  if(getE('required_deliverycity'))
    getE('required_deliverycity').style.visibility = 'hidden';
  if(getE('required_deliveryzipcode'))
    getE('required_deliveryzipcode').style.visibility = 'hidden';
  switch(what)
  {
    case 'Loguj':
      var aOnOff = new Array('block', 'none', 'none', 'none', 'none', 'none', 'none');
    break;
    case 'Regni':
      var aOnOff = new Array('none', 'block', 'block', 'block', 'block', 'block', 'block');
    break;
    case 'Kup':
      var aOnOff = new Array('none', 'none', 'block', 'block', 'none', 'block', 'block');
      if(getE('required_deliveryfirstname'))
        getE('required_deliveryfirstname').style.visibility = 'visible';
      if(getE('required_deliverylastname'))
        getE('required_deliverylastname').style.visibility = 'visible';
      if(getE('required_deliverystreet'))
        getE('required_deliverystreet').style.visibility = 'visible';
      if(getE('required_deliverycity'))
        getE('required_deliverycity').style.visibility = 'visible';
      if(getE('required_deliveryzipcode'))
        getE('required_deliveryzipcode').style.visibility = 'visible';
    break;
  }
  
  for(var a=0; a < aDivs.length; a++)
  {
    getE(aDivs[a]).style.display = aOnOff[a];
  }
  return true; 
}
//-------------------------------------------------------------------------------------------------------------------------
function CheckDeliveryAndPayment()
{
  var ret  = true;
  if(getE('idTblDeliveryType').value == '' || getE('idTblDeliveryType').value == '0')
  {
    alert('Není vybrána doprava!');
    return false;
  }
  if(getE('idTblPaymentType').value == '' || getE('idTblPaymentType').value == '0')
  {
    alert('Není vybrána platba!');
    ret = false;
  }
  return ret;
}

//-------------------------------------------------------------------------------------------------------------------------
function CheckSubmitData(nLogin)
{
  //debugger;
  var aLabel, aCheckInp, strAlert, bReturn, bError;
  bError = false;
  strAlert = '';
  aLabel = new Array('Prosíme, vyplňte JMÉNO !', 'Prosíme, vyplňte PŘÍJMENÍ !', 'Prosíme, vyplňte ULICI !', 'Prosíme, vyplňte MĚSTO !', 'Prosíme, vyplňte PSČ !', 'Prosíme, vyplňte TELEFON nebo MOBIL !', 'Prosíme, vyplňte EMAIL !', 'Prosíme, vyplňte PŘIHLAŠOVACÍ JMÉNO !', 'Prosíme, vyplňte HESLO !');//, 'Prosíme, vyplňte HESLO pro kontrolu !');
  
  if(getE('gWhatForm').value == 'Regni' || getE('gWhatForm').value == 'Kup')
  {
    if(nLogin ==0 && getE('gWhatForm').value == 'Regni')
    {
      aCheckInp = new Array('firstname', 'lastname', 'street', 'city', 'zipcode', 'phone', 'email', 'login', 'password');//, 'passwordagain');
    }
    else
    {
      
      if( nLogin == 10 )  // 10 - je osobni odber , takze hlidame zadani jen techto 4 poli
      {
        aLabel = new Array('Prosíme, vyplňte JMÉNO !', 'Prosíme, vyplňte PŘÍJMENÍ !', 'Prosíme, vyplňte TELEFON nebo MOBIL !', 'Prosíme, vyplňte EMAIL !');
        aCheckInp = new Array('firstname', 'lastname', 'phone', 'email');
      }
      else
      {
        if(nLogin != 10)
          aCheckInp = new Array('firstname', 'lastname', 'street', 'city', 'zipcode', 'phone', 'email');
      }
    }
  }
  else if(getE('gWhatForm').value == 'KupX')
  {
    aCheckInp = new Array('deliveryfirstname', 'deliverylastname', 'deliverystreet', 'deliverycity', 'deliveryzipcode', 'phone', 'email');
  }
  else
  {
    return false;
  }
  
  bReturn = true;
  for(var a = 0; a < aCheckInp.length; a++)
  {
    if(getE(aCheckInp[a]))
    {
      if(getE(aCheckInp[a]).value == '' || getE(aCheckInp[a]).value == 'pro zasláni sms o stavu zakázky') 
      {
        strAlert += aLabel[a] + '\n';
        bError = true;
        bReturn = false;
      }
    }
  }
  
  if(getE('gWhatForm').value == 'Regni' && nLogin == 0)
  {
    if(getE('password').value != getE('passwordagain').value)
    {
      strAlert += 'Prosíme, vyplňte HESLO pro kontrolu !\n';
      bError = true;
      bReturn = false;
    }
  }
  
  if(bError)
    alert(strAlert);
    
  if(bReturn && getE('note').value!='')
  {
    if(!confirm('Objednávka je odesílána s „POZNÁMKOU“ a její vyřízení NEBUDE provedeno automaticky robotem. V případě, že není poznámka důležitá k vyřízení objednávky toto pole prosím nevyplňujte. Výrazně tím urychlíte vyřízení své objednávky. Přejete si objednávku odeslat s vyplněnou „POZNÁMKOU“ ?\n\nOK - ODESLAT S POZNÁMKOU\nSTORNO - ODESLAT BEZ POZNÁMKY'))
    {
      getE('note').value = '';
    }
  }
  
  return bReturn;
}
//-------------------------------------------------------------------------------------------------------------------------
function ShowHideRotator(sID)
{
  getE(sID).style.display = (getE(sID).style.display == '' ? 'none' : '');
}
//-------------------------------------------------------------------------------------------------------------------------
function OpnWindCetelem(sPrice)
{
  var sUrl = "/cetelem/kalkulacka.asp?price=" + sPrice + "&IDOrder=0";
  //alert(sUrl);
  window.open(sUrl, "cetelcalc", "status=0, toolbar=0, location=0, menubar=0, directories=0, scrollbars=1, height=400, width=500, left=10, top=10");
}
//-------------------------------------------------------------------------------------------------------------------------
function HelpCetelem()
{
  var sUrl = "/InfoPage.asp?TP=FT&ID=28&pop=up";
  //alert(sUrl);
  window.open(sUrl, "cetelhelp", "status=0, toolbar=0, location=0, menubar=0, directories=0, scrollbars=1, height=500, width=800, left=10, top=10");
}
//-------------------------------------------------------------------------------------------------------------------------
function extractNumberEX(obj, decimalPlaces, allowNegative)
{
  var temp = obj.value;

  // avoid changing things if already formatted correctly
  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;

  // first replace all non numbers
  var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
  var reg1 = new RegExp(reg1Str, 'g');
  temp = temp.replace(reg1, '');

  if (allowNegative) {
    // replace extra negative
    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) {
      // keep only first occurrence of .
      // and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
      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);

  // check for backspace or delete, or if Ctrl was pressed
  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);
}
//-------------------------------------------------------------------------------------------------------------------------
 // --onkeypress="return blockNonNumbers(this, event, false, false);" onkeyup="extractNumberEX(this,0,false);" onblur="extractNumberEX(this,0,false);" 
//-------------------------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------------------------
function setAdd(nPrice)
{
  if(getE('soucet'))
  {
    //getE('soucet').innerHTML = getE('DeliveryPrice').value + " + " + nPrice + " = " + ((getE('DeliveryPrice').value*1)+ (nPrice*1)) + " Kč bez DPH (" + Math.round(((getE('DeliveryPrice').value*1)+ (nPrice*1))*1.2) + " Kč s DPH)";
    getE('prpay').innerHTML = '+ '+Math.round((nPrice*1.2))+' Kč s DPH';
    var v = (getE('sumPr').value.replace(',', '.')*1) + Math.round(((getE('DeliveryPrice').value*1) + (nPrice*1))*1.2);
    getE('soucet').innerHTML = '<strong>' + formatNumber(v,2,' ',',','','','-','') + " Kč s DPH</strong>";    
  }
}
//-------------------------------------------------------------------------------------------------------------------------
function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) 
{
  var x = Math.round(num * Math.pow(10,dec));
  if (x >= 0) n1=n2='';
  var y = (''+Math.abs(x)).split('');
  var z = y.length - dec; 
  if (z<0) z--; 
  for(var i = z; i < 0; i++) 
    y.unshift('0'); 
  if (z<0) z = 1; 
  y.splice(z, 0, pnt); 
  if(y[0] == pnt) y.unshift('0'); 
  while (z > 3) 
  {
    z-=3; y.splice(z,0,thou);
  }
  var r = curr1+n1+y.join('')+n2+curr2;
  return r;
}
//-------------------------------------------------------------------------------------------------------------------------
function TabSel()
{

}
//-------------------------------------------------------------------------------------------------------------------------

