// ###   FCE PRO DIALOG ZADANI VOLITELNYCH PARAMETRU   ###
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

var gsFormSuffix, gsFormIndex;

function GLS(nIdJS,nIdSQL,sSentence) {
	return gsGLS[nIdJS];
}

// KOMPATIBILITA

var Br = new BrCheck()


function BrCheck()
{
	this.VER	= navigator.appVersion;
	this.AGENT	= navigator.userAgent;
	this.DOM	= document.getElementById ? true:false;
	
	this.OP5	= this.AGENT.indexOf("Opera 5")>-1							?true:false;
	this.OP6	= this.AGENT.indexOf("Opera 6")>-1							?true:false;
	this.OP7	= this.AGENT.indexOf("Opera 7")>-1							?true:false;
	this.OP		= (this.OP5 || this.OP6 || this.OP7);

	this.IE4	= (document.all && !this.DOM && !this.OP)					?true:false;
	this.IE5	= (this.VER.indexOf("MSIE 5")>-1 && this.DOM && !this.OP)	?true:false; 
	this.IE6	= (this.VER.indexOf("MSIE 6")>-1 && this.DOM && !this.OP)	?true:false;
	this.IE		= (this.IE4 || this.IE5 || this.IE6);

	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) {
	if (Br.IE)
		return document.all[objectID]?document.all[objectID]: document.getElementsByName(objectID)[0];
	else
	 {
  	return document.getElementById(objectID)?document.getElementById(objectID):document.getElementsByName(objectID)[0];
	 }
}

function getF(formName) {
	return document.forms[formName];
}
// ###   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?LANG=' + USER.LanguageID + '&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?LANG=' + USER.LanguageID  + '&CMP=' + sapkTblCommodity;
}
function LocInfo(){
	document.all.StateInfo2.innerHTML=GLS(0,128,"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;
	document.all.StateInfo1.style.top=y-140;
	document.all.StateInfo1.style.left=x;
}

function PositionInfo(strText){
	document.all.StateInfo3.innerHTML=strText;
	document.all.StateInfo2.innerHTML=GLS(0,128,"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;
	};
	document.all.StateInfo1.style.top=y-140;
	if (document.body.clientWidth < 933){
	  document.all.StateInfo1.style.left=x-175;
	}else{
	  document.all.StateInfo1.style.left=780;
	}
}
function LocState(strCode,intCount){
	window.parent.frames['WinStat'].location.href='/InfoState.asp?LANG=' + USER.LanguageID + '&amp;ID='+strCode+'&CN='+intCount
	PositionInfo(GLS(1,129,"On-line stav"));
}
function ChangeStorage(bState){
	if(bState){
		for(var i = 0; i < document.all['S'].length; i++){
			document.all['S'][i].value="0"
		}
	}else{
		for(var i = 0; i < document.all['S'].length; i++){
			document.all['S'][i].value="-1"
		}
	}
}
function ChangeCloseout(bState){
	if(bState){
		for(var i = 0; i < document.all['C'].length; i++){
			document.all['C'][i].value="1"
		}
	}else{
		for(var i = 0; i < document.all['C'].length; i++){
			document.all['C'][i].value="3"
		}
	}
}

function AdvertisingOpen(ID){
     var msg = window.open("PopUpAdvertising.asp?LANG=" + USER.LanguageID + "&amp;ID="+ID,"Reklama","scrollbars=yes,height=200,width=350,left=10,top=10");
     msg.focus()
}


function BuyOrSetVariableParams(sFormSuffix,sFormIndex) {
	var sSelects, nWindowHeight;
	gsFormIndex = sFormIndex;
	gsFormSuffix = sFormSuffix;

	sSelects = document.all["DivForPars" + sFormSuffix + sFormIndex].innerHTML;
	// ve skeletu musí být ve fci GetFormattedParams "ParamItem" psáno CASE-SENSITIVE !!!
	if (sSelects == "") {
		document.all["BuyForm" + sFormSuffix + sFormIndex].submit();
	} else {
		// 22 je výška selectu - definováno raději i podle stylu!
		// nWindowHeight = 86 + 22 * (sSelects.split("ParamItem").length);
		document.all.DivForParams.innerHTML = document.all["DivForPars" + sFormSuffix + sFormIndex].innerHTML;
		document.all.ParamCaption.innerText = document.all["BuyForm" + sFormSuffix + sFormIndex].NameItem.value;
		document.all.ParamTbl.style.top =  window.event.srcElement.offsetTop + 20;
		document.all.ParamTbl.style.left =  window.event.srcElement.offsetLeft - 60;
		document.all.ParamTbl.style.display = 'inline';
	}
}

function CopyParamsBack() {
	document.all["DivForPars" + gsFormSuffix + gsFormIndex].innerHTML = document.all.DivForParams.innerHTML;
	document.all["BuyForm" + gsFormSuffix + gsFormIndex].submit();
}

// ###   FCE PRO ROZKLIKAVANI KATEGORII   ###

function InsertCookiesCat(intId,idTree){
	document.cookie="category"+idTree+"="+intId+";";
	document.cookie="category"+idTree+"="+intId+";";
}
function checkParent(src, dest) {
	while (src!=null) {
		if (src.tagName == dest) return src;
			src = src.parentElement;
	}
	return null;
}

function outlineCat() {    
	var open = event.srcElement;
	var el = checkParent(open, "TD");
	if (null!=el) {
		var pos = 0;
		for (var pos=0; pos<el.children.length; pos++) {
			if ("TABLE"==el.children[pos].tagName) {
				if (el.children[0].src.indexOf("/img/catTree/plus.gif")>0) {
					el.children[0].src = "/img/catTree/minus.gif";
				}else{
					el.children[0].src = "/img/catTree/plus.gif";
				}
				break;
			}
		}
	    if (pos==el.children.length) return;
	} else return;
	el = el.children[pos];
	if ("TABLE"==el.tagName) {
		if (""==el.style.display) {
			el.style.display = "none";
		} else {
			el.style.display = "";
		}
	}
	event.cancelBubble = true;
}

// ###   FCE PRO PriceList ###

function SHModalDlgPricelist()
{
	var strReturn = showModalDialog("/Includes/EmailPricelist.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=320px;dialogHeight=124px;");

    if (strReturn == "") return;
	document.location.href = '/EmailPricelist.asp?LANG=' + USER.LanguageID + '&EmailPricelist=' + strReturn;
}

// ##########

function onAction(imgName){
       document.all[imgName].src = eval(imgName + "on.src")
}

function offAction(imgName){
	if (oldImgName.substring(0,4)!=imgName.substring(0,4)){
		document.all[imgName].src = eval(imgName + "off.src")
	}
}

function OpenWnd(strURL){
	var objWnd = window.open(strURL,"InfoDetail","scrollbars=no,height=500,width=400,left=10,top=10");
	objWnd.focus();
}

function OpenWndParam(strURL,strParams){
         var objWnd = window.open(strURL,"InfoDetail",strParams);
         objWnd.focus();
}


function AddBuy(strName,strKey, intPrice, intDph, strCode) {
	var strData,strReturn
	strData = strName+"&"+intPrice+"&"+intDph+"&"+strCode
	strReturn = showModalDialog("/AddUpdBuy.asp?LANG=" + USER.LanguageID,strData,"status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=200pt");
	if (strReturn == "1")
		ActionCookies('CLI','BZbuy');
	else if (strReturn == "2")
		window.location.href = "/order.asp?LANG=" + USER.LanguageID;
}
function AddBuyDetail(strName,strKey, intPrice, intDph, strCode) {
	var strData,strReturn
	strData = strName+"&"+intPrice+"&"+intDph+"&"+strCode
	strReturn = showModalDialog("/AddUpdBuy.asp?LANG=" + USER.LanguageID,strData,"status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=200pt");
	if (strReturn == "1"){
		window.opener.ActionCookies('CLI','BZbuy')
	}else if (strReturn == "2"){
		window.opener.location.href="/order.asp?LANG=" + USER.LanguageID;
		window.close();
	}
}
function ActionCookies(strName,strKey){
	var strString,strSum1,strSum2,intSuma;
	strSum2 = new Array();
	intSuma = 0;

	strString = ExtractCookieEx(strName,strKey);
	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]);
		}
		document.all.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()+";";
	document.all.CompletPrice.value = "0.00";
}
function InsTreeCook(intId,idTree){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie="category"+idTree+"="+intId+"; expires="+vyprs.toGMTString()+";";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie="category"+idTree+"="+intId+"; expires="+vyprs.toGMTString()+";";
}
function InsertCookies(strName,strData){
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() - 365);
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+";";
	vyprs.setDate(365 + 365 + vyprs.getDate());
	document.cookie=strName+"="+strData+"; expires="+vyprs.toGMTString()+";";
}

function ExtractCookies(strName){
	var cookieList=document.cookie.split("; ");
	var cookieArray = new Array();
	var name = "#"
	for (var i=0; i < cookieList.length; i++){
		if(cookieList[i].indexOf(strName)>-1){
			if( cookieList[i].indexOf("=")>-1){name = cookieList[i].split("=");}
		}
	}
	if (name != "#"){
		return name[1];
	}else{
		return "none";
	}
}

function ExtractCookieEx(strName, strKey){
	var strKeysValues = ExtractCookie(strName);
	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 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 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 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(document.all[strList[i]+'a']) == "object"){document.all[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 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(e){
  if (Number(e.value.replace(",","."))) {return e.value} else {e.value = '';}
}

//----------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 EmailControl(f){
	if ((f=='' || f=='vas@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(gsGLS[529]);
		return false;
		}
	return true;
}
function ShowSearchMenu(x){
    if (x == 1){
        document.all.SearchTable.style.display='';
    }else{
        document.all.SearchTable.style.display='none';
    }
}

function pageLoad() {
	var o;
	o = getE("imgkos");
	if (o!=null) {
		var i = document.images.length;
		for (var ii=0; ii<i; ii++) {
			oImg = document.images[ii];
			if (oImg.id=="imgkos") {
				oImg.style.display = "";
				ImgResize(oImg);
			}
		}
	}
	mnInit();
}	

function ImgResize(oImg)
{
  oImg.style.display='';
	if (oImg.offsetHeight > oImg.offsetWidth) 
	{
		if (oImg.offsetHeight >100) oImg.style.height ="100";
	} else {
		if (oImg.offsetWidth >100) oImg.style.width ="100";
	}
}

function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}
function AddCategory2(intTree){
  var arrData,arrSubData;
  var asCat;
  var strReturn = showModalDialog("/SelectCategory.asp?TREE="+intTree+"&CAT="+document.all.IdItem.value,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=300pt");
          if (strReturn == undefined){alert(GLS(2, 134,"Nebylo nic vybráno.")); return false}
          var el,r;
          with(document.all['strCategory'+intTree]){
                 r = options.length;
                 for (var i=0; i<r; i++) {
                         options.remove(options.length-1);
                 }
          }
          arrData = strReturn.split("*");
          asCat = "";
          for (var i=0; i<arrData.length-1; i++) {
              arrSubData = arrData[i].split("/");
              asCat = asCat + arrSubData[0]+"$$";
          }
          for (var i=0; i<arrData.length-1; i++) {
              arrSubData = arrData[i].split("/");
              el = document.createElement("OPTION");
              el.value = asCat;
              el.text = arrSubData[1];
              document.all['strCategory'+intTree].options.add(el);
          }
}
function ControlUserDataSubmit(){
	if (document.UserDataForm.FirstName!=null && document.UserDataForm.LastName!=null && document.UserDataForm.Firm!=null) 
		if((document.UserDataForm.FirstName.value == "" || document.UserDataForm.LastName.value == "") && document.UserDataForm.Firm.value == ""){alert(GLS(3, 133,"Vyplňte jméno a příjmení nebo název firmy."));return false}
	if (document.UserDataForm.Street!=null) 
		if(document.UserDataForm.Street.value == ""){alert(GLS(4, 105,"Vyplňte ulici."));return false}
	if (document.UserDataForm.City!=null) 
		if(document.UserDataForm.City.value == ""){alert(GLS(5, 106,"Vyplňte město."));return false}
	if (document.UserDataForm.ZipCode!=null) 
		if(document.UserDataForm.ZipCode.value == ""){alert(GLS(6, 107,"Vyplňte PSČ."));return false}
	if (document.UserDataForm.Email!=null) 	
		if(document.UserDataForm.Email.value == ""){alert(GLS(7, 109,"Vyplňte email."));return false}
	if (document.UserDataForm.Mobil!=null) 	
		if(document.UserDataForm.Mobil.value == ""){alert(GLS(8, 108,"Vyplňte mobil."));return false}
	if (document.UserDataForm.Phone!=null) 	
		if(document.UserDataForm.Phone.value == ""){alert(GLS(410,"Vyplňte telefon."));return false}
  if (document.UserDataForm.sRegLogin!=null) 	
		if(document.UserDataForm.sRegLogin.value == ""){alert(GLS(9, 110,"Vyplňte přihlašovací jméno."));return false}
	if (document.UserDataForm.sRegLogin!=null) 
		if(document.UserDataForm.sRegLogin.value.length < 5){alert(GLS(10, 111,"Přihlašovací jméno musí mít minimálně 5 znaků."));return false}
	if (document.UserDataForm.sRegPassword!=null) {
		if(document.UserDataForm.sRegPassword.value == ""){alert(GLS(11, 112,"Vyplňte heslo."));return false}
		if(document.UserDataForm.sRegPassword.value.length < 5){alert(GLS(12, 113,"Heslo musí mít minimálně 5 znaků."));return false}
	}
	
	return true;
}

function ControlDataOrder(){
	if(document.OrderForm.DeliveryType.value == "-"){alert(GLS(13,130,"Vyberte způsob dopravy."));return false}
	if(document.OrderForm.PaymentType.value == "-"){alert(GLS(14,131,"Vyberte způsob platby."));return false}
	return true;
}

function ControlReklamaceSubmit(){

	if(document.ReklamaceForm.FirstName.value == ""){alert(GLS(15,135,"Vyplňte jméno."));return false}
	if(document.ReklamaceForm.LastName.value == ""){alert(GLS(16,136,"Vyplňte příjmení."));return false}
	if(document.ReklamaceForm.Street.value == ""){alert(GLS(4,105,"Vyplňte ulici."));return false}
	if(document.ReklamaceForm.City.value == ""){alert(GLS(5,106,"Vyplňte město."));return false}
	if(document.ReklamaceForm.ZipCode.value == ""){alert(GLS(6,107,"Vyplňte PSČ."));return false}
	if(document.ReklamaceForm.Email.value == ""){alert(GLS(7,109,"Vyplňte Email."));return false}
	
	return true
}
function ControlPriceList(){

	if(document.formCenik.strCategory1.value == ""){alert(GLS(17,132,"Zvolte kategorii."));return false}
	
	return true
}
// ###	 FCE PRO BOXIKY SE SUBKATEGORIEMI	 ###

function CheckBuy(oForm) {
	if (oForm.count==null ) {alert(GLS(18,139,"Nejsou zadány alternativní komodity."));return false;}
	if (oForm.count[0].tagName!="SELECT") {
		if (oForm.count.options(oForm.count.selectedIndex).value == '') {
			alert(GLS(19,138,"Zvolte množství."))
			return false;
		} else
			return true;
	} else {
		for (i=0; i<oForm.count.length; i++) {
			if (oForm.count[i].options(oForm.count[i].selectedIndex).value!='')
				return true;
		}
		alert(GLS(19,138,"Zvolte množství."))
		return false;
	}
}

function checkQuickOrder(oForm) {
	var k=1;
	for (i=0; i<oForm.kod.length; i++) {

	if (oForm.kod[i].value=='')
		k++;
	}
	if (k-1==oForm.kod.length) {
		alert(gsGLS[20])
		return false;
	}
	return true;
}
function vypocti() {
	if (document.getElementById("objem").value=="" || document.getElementById("vyptlak").value=="" || document.getElementById("practlak").value=="" || document.getElementById("vzduch").value=="" || document.getElementById("vytlac").value=="") {
		alert(GLS(21,137,"Vyplňte hodnoty"));
		return;
	}
	//alert (Math.round(document.getElementById("vytlac").value) +" > "+Math.round(document.getElementById("vzduch").value));
  if (Math.round(document.getElementById("vytlac").value) > Math.round(document.getElementById("vzduch").value)) {
		alert(GLS(22,141,"Výkon kompresoru je vyšší než spotřeba připojeného nářadí!"));
		document.getElementById("cas").value="";
		return;
	}
	if (document.getElementById("vzduch").value==0) {
		alert(GLS(23,142,"Spotřeba vzduchu připojeného nářadí není zadána!"));
		document.getElementById("cas").value="";
		return;
	}
	if (document.getElementById("vzduch").value==document.getElementById("vytlac").value) {
		alert(GLS(24,143,"Spotřeba vzduchu připojeného nářadí musí být větší než výkon kompresoru!"));
		document.getElementById("cas").value="";
		return;
	}

	d = ((document.getElementById("objem").value*(document.getElementById("vyptlak").value-document.getElementById("practlak").value))/(document.getElementById("vzduch").value-document.getElementById("vytlac").value))/1440;
	h = Math.floor(d *24);
	m = Math.floor(d* 1440 - h *60);
	s = Math.floor(d * 1440 * 60 - m * 60 - h*60*60);
	if (h<10)
		h = '0'+h;
	if (m<10)
		m = '0'+m;
	if (s<10)
		s = '0'+s;

	document.getElementById("cas").value=h +':'+ m +':'+ s;
	 
	InsertCookieEx("COM", "objem=", document.getElementById("objem").value);
	InsertCookieEx("COM", "vyptlak=", document.getElementById("vyptlak").value);
	InsertCookieEx("COM", "practlak=", document.getElementById("practlak").value);
	InsertCookieEx("COM", "vzduch=", document.getElementById("vzduch").value);
	InsertCookieEx("COM", "vytlac=", document.getElementById("vytlac").value);
}
function SelectParam(sParamValue) {
	oOpt = getE('idSelPar').options;
	for (var i=0; i<oOpt.length; i++)
		if (oOpt[i].value==sParamValue) oOpt[i].selected = true;
}
function ExtractQuery(strKey) {
	s = window.location.href;
	i = s.indexOf("?");
	if (i!=-1) {
		aQS = s.substr(i+1).split("&");
		for (i=0; i<aQS.length; i++) {
			l = aQS[i].indexOf("=");
			if (l!=-1) {
				if (aQS[i].substr(0,l)==strKey)
					return unescape(aQS[i].substr(l+1));
			} else if (aQS[i]==strKey)
				return null;
		}
	} else
		return null;
}

function controlMaxNumber(obj,value,nMax){
		if(value > nMax && value >= 1){
        obj.value=nMax; }
    if(value<1) 
     {    
        obj.value=1;
     }
}

// REGISTRACE NOVÉHO ZÁKAZNÍKA
ulice=/^[a-ž,A-Ž]{1,40} {0,2}$/;
ulicecp=/^[a-ž,A-Ž]{1,40} {0,2}[0-9]{1,6}$/;
cislo5=/^[0-9]{3} {0,20}[0-9]{2} {0,20}$/;
cislo12=/^[+]{0,1}[0-9, ]{7,30}$/;
emaily=/^[_a-zA-Z0-9\.\-]+[_a-zA-Z0-9\-]@[_a-zA-Z0-9\-]+[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/;
cico=/^[0-9]{8}$/;
cdic=/^[a-z,A-Z]{2}[0-9]{8,10}$/;
cislo=/^[0-9, ]{1,16}$/;
login=/^[a-z|A-Z|0-9]{6,16}$/;

function ControlInput1()
{
message='';

if (trim(document.forms.UserDataForm.FirstName.value) == '') message=message+gsGLS[25]+'\n';
if (trim(document.forms.UserDataForm.LastName.value) == '') message=message+gsGLS[26]+'\n';
if (trim(document.forms.UserDataForm.Street.value) == '') message=message+gsGLS[27]+'\n';
if (trim(document.forms.UserDataForm.City.value) == '') message=message+gsGLS[28]+'\n';
if (trim(document.forms.UserDataForm.ZipCode.value) == '') message=message+gsGLS[29]+'\n';
if (trim(document.forms.UserDataForm.Email.value) == '' ) message=message+gsGLS[30]+'\n';
if ((document.forms.UserDataForm.Phone.value == '') && (document.forms.UserDataForm.Mobil.value == '')) message=message+gsGLS[31]+'\n';

message=message+fn_ControlCountryByZipCode(document.forms.UserDataForm.ZipCode.value,document.forms.UserDataForm.Country.value);


//if(!ulice.test(document.forms.UserDataForm.Street.value) && document.forms.UserDataForm.Street.value!='') message+'V názvu ulice se vyskytují nepovolené znaky.\n';
//if(ulice.test(document.forms.UserDataForm.Street.value) && !ulicecp.test(document.forms.UserDataForm.Street.value) && document.forms.UserDataForm.Street.value!='') message=message+gsGLS[32]+'\n';
//if(!cislo.test(document.forms.UserDataForm.ZipCode.value) && document.forms.UserDataForm.ZipCode.value!='') message=message+gsGLS[34]+' '+gsGLS[33]+'\n';
//if(!cislo12.test(document.forms.UserDataForm.Phone.value) && document.forms.UserDataForm.Phone.value!='') message=message+gsGLS[35]+' '+gsGLS[33]+'\n';
//if(!cislo12.test(document.forms.UserDataForm.Mobil.value) && document.forms.UserDataForm.Mobil.value!='') message=message+gsGLS[36]+' '+gsGLS[33]+'\n';
//if(!cislo12.test(document.forms.UserDataForm.Fax.value) && document.forms.UserDataForm.Fax.value!='')  message=message+gsGLS[37]+' '+gsGLS[33]+'\n';
if(!emaily.test(document.forms.UserDataForm.Email.value) && document.forms.UserDataForm.Email.value!='' )  message=message+'-----------------------------------------\n'+gsGLS[42]+' '+gsGLS[33]+'\n';


if (message > '') {alert(message); return false;}
else {
    document.getElementById("step1").style.display='none';
    document.getElementById("step1_ico").className='';
    document.getElementById("step2").style.display='block';
    document.getElementById("step2_ico").className='act2';
    return true;
    }
}

function BackStep2()
{
    document.getElementById("step1").style.display='block';
    document.getElementById("step1_ico").className='act1';
    document.getElementById("step2").style.display='none';
    document.getElementById("step2_ico").className='';
   return false;
}

function ControlInput2()
{
message='';

//if(ulice.test(document.forms.UserDataForm.DeliveryStreet.value) && !ulicecp.test(document.forms.UserDataForm.DeliveryStreet.value) && document.forms.UserDataForm.DeliveryStreet.value!='')  message=message+gsGLS[32]+'\n';
//if(!cislo5.test(document.forms.UserDataForm.DeliveryZipCode.value) && document.forms.UserDataForm.DeliveryZipCode.value!='') message=message+gsGLS[34]+' '+gsGLS[33]+'\n';
//if(!cislo12.test(document.forms.UserDataForm.DeliveryPhone.value) && document.forms.UserDataForm.DeliveryPhone.value!='')message=message+gsGLS[35]+' '+gsGLS[33]+'\n';
//if(!cislo12.test(document.forms.UserDataForm.DeliveryMobil.value) && document.forms.UserDataForm.DeliveryMobil.value!='') message=message+gsGLS[36]+' '+gsGLS[33]+'\n';
//if(!cislo12.test(document.forms.UserDataForm.DeliveryFax.value) && document.forms.UserDataForm.DeliveryFax.value!='')  message=message+gsGLS[37]+' '+gsGLS[33]+'\n';
//if(!emaily.test(document.forms.UserDataForm.DeliveryEmail.value) && document.forms.UserDataForm.DeliveryEmail.value!='' )  message=message+gsGLS[42]+' '+gsGLS[33]+'\n';
//if(!cico.test(document.forms.UserDataForm.ICO.value.replace(/ /g,'')) && document.forms.UserDataForm.ICO.value!='') message=gsGLS[39]+' '+gsGLS[33]+'\n';
//if(!cdic.test(document.forms.UserDataForm.DIC.value.replace(/ /g,'')) && document.forms.UserDataForm.DIC.value!='') message=message+gsGLS[38]+' '+gsGLS[33]+'\n';
if (!login.test(document.forms.UserDataForm.sRegLogin.value) && document.forms.UserDataForm.sRegLogin.type!='hidden') message=message+gsGLS[527]+'\n';
if (!login.test(document.forms.UserDataForm.sRegPassword.value) && login.test(document.forms.UserDataForm.sRegLogin.value) && document.forms.UserDataForm.sRegLogin.type!='hidden') message=message+gsGLS[528]+'\n';
if (document.forms.UserDataForm.souhlas){
if (!document.forms.UserDataForm.souhlas.checked==true) message=message+gsGLS[526]+'\n';
}

message=message+fn_ControlDIC(document.forms.UserDataForm.DIC.value,document.forms.UserDataForm.Country.value);

//if (message > '') message=message+'-----------------------------------------\n';
//{
// if(!cislo.test(document.forms.UserDataForm.BankAccount.value) && document.forms.UserDataForm.BankAccount.value!='')  message=message+gsGLS[98]+' '+gsGLS[33]+'\n';
// if(!cislo.test(document.forms.UserDataForm.BankCode.value) && document.forms.UserDataForm.BankCode.value!='' )  message=message+gsGLS[99]+' '+gsGLS[33]+'\n';
//}
if (message > '') {alert(message); return false;}
else return true;
}

function fn_ControlCountryByZipCode(sZipCode,sCountryCode)
{
  if (sCountryCode=="CZ")  {  sZIP=/^[1-7]{1}[0-9]{4}$/; }
  else if (sCountryCode=="SK")  {  sZIP=/^[0,8,9]{1}[0-9]{4}$/; }
  else if (sCountryCode=="HU")  {  sZIP=/^[0-9]{4}$/; }
  else {sZIP=/^.*$/;}
  
  if (!sZIP.test(sZipCode.replace(" ",""))) return gsGLS[728]+'\n';
  else return '';
}

function fn_ControlDIC(sDic,sCountryCode)
{
  // if (sCountryCode=="CZ")  {  rDIC=/^CZ[0-9]{10}$/; sDicFormat='CZxxxxxxxxxx ('+gsGLS[794].replace('<!-- #xx# -->','10')+')'; }
  if (sCountryCode=="SK")  {  rDIC=/^SK[0-9]{10}$/; sDicFormat='SKxxxxxxxxxx ('+gsGLS[794].replace('<!-- #xx# -->','10')+')'; }
  else if (sCountryCode=="PL")  {  rDIC=/^PL[0-9]{10}$/; sDicFormat='PLxxxxxxxxxx ('+gsGLS[794].replace('<!-- #xx# -->','10')+')'; }
  else if (sCountryCode=="HU")  {  rDIC=/^HU[0-9]{8}$/; sDicFormat='HUxxxxxxxx ('+gsGLS[794].replace('<!-- #xx# -->','8')+')'; }
  else {rDIC=/^.*$/;}
  
  //alert (sDic)
  
  if (!rDIC.test(sDic) && sDic>'') return gsGLS[793].replace('<!-- #dicform# -->',sDicFormat)+'\n';
  else return '';
}

function fn_setCountryByZipCode(sZipCode)
{
  sCZ=/^[1-7]{1}[0-9]{4}$/;
  sSK=/^[0,8,9]{1}[0-9]{4}$/;
  sHU=/^[0-9]{4}$/;
  sELSE=/^[0-9]{4,6}$/;
  
  document.UserDataForm.Country.disabled=true;
  
  if (sCZ.test(sZipCode.replace(" ",""))) { 
    for (i=0;document.UserDataForm.Country.options[i];i++)
      {
        if (document.UserDataForm.Country.options[i].value=='CZ') document.UserDataForm.Country.selectedIndex=i;
      }
    }
    
  else if (sSK.test(sZipCode.replace(" ",""))) { 
    for (i=0;document.UserDataForm.Country.options[i];i++)
      {
        if (document.UserDataForm.Country.options[i].value=='SK') document.UserDataForm.Country.selectedIndex=i;
      }
    }
    
  else if (sHU.test(sZipCode.replace(" ",""))) { 
    for (i=0;document.UserDataForm.Country.options[i];i++)
      {
        if (document.UserDataForm.Country.options[i].value=='HU') document.UserDataForm.Country.selectedIndex=i;
      }
    }
    
  else if (sELSE.test(sZipCode.replace(" ","")))
    {
    document.UserDataForm.Country.disabled=false;
    }
  else
    {
    alert(gsGLS[34]+' '+gsGLS[33]);
    document.UserDataForm.ZipCode.value='';
    document.UserDataForm.ZipCode.focus();
    }

}

function fn_control_callbox(callinterest,phonecall,namecall)
  {
    var message; message="";
  
    if (namecall.value=="" || namecall.value==namecall.defaultValue) {message=gsGLS[724]+'\n'+message;namecall.focus();}
    if (!cislo.test(phonecall.value)) {message=gsGLS[723]+'\n'+message;phonecall.focus();}
    if (callinterest.value=="") {message=gsGLS[722]+'\n'+message;callinterest.focus();}
    
    if (message>"") {alert(message);return false;}
    else return true;
  }



function ControlInputAll()
{
 document.getElementById("step4").style.display='none';
 if (!ControlInput1())  {alert('chyba v prvnim kroku');return false;}
 else if (!ControlInput2())  {alert('chyba v druhem kroku');return false;}
 else if (!ControlInput3())  {alert('chyba v tretim kroku');return false;}
 else if (!ControlInput4())  {alert('chyba v ctvrtem kroku');return false;}
 else return true
}

function ControlEmail(obj)
{

  if(!emaily.test(obj.value) && obj.value!='')
  {
   alert(gsGLS[43]);
   obj.value="@";
   obj.focus();
   return false;
  }

}

function showloading(stext)
{
  if(document.getElementById('obsah')) document.getElementById('obsah').style.display='none';
  document.getElementById('onlineloading').style.display='block';
  document.getElementById('onlineloading').innerHTML=stext;
}

function hideloading(stext)
{
  if(getE('obsah')) getE('obsah').style.display='';
  document.getElementById('onlineloading').style.display='none';
  document.getElementById('onlineloading').innerHTML="";
}


function showQuestionForm(scode,nprice,sname)
{
// oForm=document.forms['betterpriceform'];
// document.forms['watchdogform'].style.display='none';
// oForm.style.display='block';
document.getElementById("dt_wd").innerHTML='<div style="filter:alpha(opacity=95); -moz-opacity:0.95; opacity:0.95; -khtml-opacity:.95;background:white;border:1px solid #747474;padding:100px 0 100px 0;"><img style="margin:auto;display:block;" src="/img/preloader.gif"></div>';
dt_get_question(scode,nprice,sname)
window.scrollTo(111,111);
}


function showBetterPriceForm(scode,nprice,sname)
{
// oForm=document.forms['betterpriceform'];
// document.forms['watchdogform'].style.display='none';
// oForm.style.display='block';
document.getElementById("dt_wd").innerHTML='<div style="filter:alpha(opacity=95); -moz-opacity:0.95; opacity:0.95; -khtml-opacity:.95;background:white;border:1px solid #747474;padding:100px 0 100px 0;"><img style="margin:auto;display:block;" src="/img/preloader.gif"></div>';
dt_get_better_price(scode,nprice,sname)
window.scrollTo(111,111);
}

function showWatchDogForm(scode,nprice)
{
document.getElementById("dt_wd").innerHTML='<div style="filter:alpha(opacity=95); -moz-opacity:0.95; opacity:0.95; -khtml-opacity:.95;background:white;border:1px solid #747474;padding:100px 0 100px 0;"><img style="margin:auto;display:block;" src="/img/preloader.gif"></div>';
dt_get_watch_dog(scode,nprice);
window.scrollTo(111,111);
}

function showSendEmail(scomseourl,sname)
{
document.getElementById("dt_wd").innerHTML='<div style="filter:alpha(opacity=95); -moz-opacity:0.95; opacity:0.95; -khtml-opacity:.95;background:white;border:1px solid #747474;padding:100px 0 100px 0;"><img style="margin:auto;display:block;" src="/img/preloader.gif"></div>';
dt_get_emailsend(scomseourl,sname);
window.scrollTo(111,111);
}

function dt_folder()
{
  var aFolders = new Array()
  aFolders[0] = "#dt_description"
  aFolders[1] = "#dt_parameters"
  aFolders[2] = "#dt_leasing"
  aFolders[3] = "#dt_opinfo"
  aFolders[4] = "#dt_merchant_info" 

  var oFolder, oFolderTitle

  this.show=fn_show;
  
  function fn_show(sFolderId)
  {
    if(oFolder) {oFolder.style.display='none';}
    if(oFolderTitle) {oFolderTitle.className='dt_folder';}

    if (oFolderTitle=document.getElementById(sFolderId+'_fd'))
    {
    if (oFolder=document.getElementById(sFolderId))
      {
      oFolder.style.display='block';
      oFolderTitle.className='dt_folder dt_active';
      }
     } 
  }


}

var blink_timer;
var n_blink_count=12;

function dt_get_availability(scode,ncount)
{
    
    /*wnd.close();*/
    var op="0";
    if (document.getElementById('dt_opinfo_fd'))
    {
    if(document.getElementById('dt_opinfo_fd').className=="dt_folder dt_active") op="1";
    }
    
    url="/axah_availability.asp?scode="+scode+"&count="+ncount+"&op="+op.toString();
  //  wnd=window.open(url,'','');
  //  alert(url);
   // window.parent.document.getElementById(elementContainer).innerHTML = '<blink class="redtxt">Loading...<\/blink>';
    var sreturnvalue = ''
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.onreadystatechange = function() {processAXAH();};
    theHttpRequest.open("GET", url);
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.send(false);

        function processAXAH(){
           if (theHttpRequest.readyState == 4) {
               if (theHttpRequest.status == 200) {
                  svalues=unescape(decodeURI(theHttpRequest.responseText));
                  avalues=svalues.split("|");    
                  document.getElementById("dt_avail").innerHTML=(avalues[0]);
                  document.getElementById("dt_delivery").innerHTML=(avalues[1]);
                  if(ncount>1) {document.getElementById("dt_avail_count").innerHTML="&nbsp;("+ncount+GLS(368,"Ks")+")";}                                 
                  if(document.getElementById("dt_avail_op")){document.getElementById("dt_avail_op").innerHTML=(avalues[0]);}
                  if(document.getElementById("dt_delivery_op")){document.getElementById("dt_delivery_op").innerHTML=(avalues[1]);}
                  if(document.getElementById("dt_avail_count_op")){document.getElementById("dt_avail_count_op").innerHTML="("+ncount+GLS(368,"Ks")+")";}
                  if (n_blink_count<12 && n_blink_count>0) n_blink_count=0;
                  clearTimeout(blink_timer);
                  fn_blink_avail(); 
                  } else {
                   alert('data error');
               }
           }
        }
    //alert (sreturnvalue);
    //return sreturnvalue;

}



function fn_blink_avail()
{
  clearTimeout(blink_timer);
  if (n_blink_count==12) {n_blink_count=0}
  else
  {
    if(document.getElementById("dt_avail_sign_op")) obj_op=document.getElementById("dt_avail_sign_op"); 
    obj=document.getElementById("dt_avail_sign");
    if(document.getElementById("dt_avail_sign2_op")) obj2_op=document.getElementById("dt_avail_sign2_op"); 
    obj2=document.getElementById("dt_avail_sign2");
   
   
   if (obj.style.color=="") {obj.style.color="#9F0006";obj.style.background="#FFFFFF";obj2.style.color="#9F0006";obj2.style.background="#FFFFFF";}
   else {obj.style.color="";obj.style.background="";obj2.style.color="";obj2.style.background="";}
    
   if (document.getElementById("dt_avail_sign_op"))
   { 
   if (obj_op.style.color=="") {obj_op.style.color="#9F0006";obj_op.style.background="#FFFFFF";obj2_op.style.color="#9F0006";obj2_op.style.background="#FFFFFF";}
   else {obj_op.style.color="";obj_op.style.background="";obj2_op.style.color="";obj2_op.style.background="";}
   }
   
   n_blink_count++;
   blink_timer=setTimeout("fn_blink_avail()",400); 
  }
}


function dt_get_emailsend(scomseourl,sname)
{
  var  url="/axah_sendemail.asp?scomseourl="+encodeURI(scomseourl.toString())+"&sname="+encodeURI(sname.toString());
//    wnd=window.open(url,'','');
//    alert(url);
    var sreturnvalue = ''
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.onreadystatechange = function() {processAXAH();};
    theHttpRequest.open("GET", url);
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.send(false);

        function processAXAH(){
           if (theHttpRequest.readyState == 4) {
               if (theHttpRequest.status == 200) {
                  svalues=unescape(theHttpRequest.responseText)
                  document.getElementById("dt_wd").innerHTML=svalues;
                  } else {
                   alert('nepovedlo se ziskat data');
               }
           }
        }
}

function dt_get_watch_dog(scode,nprice)
{
    
    /*wnd.close();*/
   url="/axah_watch_dog.asp?scode="+encodeURI(scode.toString())+"&nprice="+nprice.toString();
  //  wnd=window.open(url,'','');
  //  alert(url);
   // window.parent.document.getElementById(elementContainer).innerHTML = '<blink class="redtxt">Loading...<\/blink>';
    var sreturnvalue = ''
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.onreadystatechange = function() {processAXAH();};
    theHttpRequest.open("GET", url);
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.send(false);

        function processAXAH(){
           if (theHttpRequest.readyState == 4) {
               if (theHttpRequest.status == 200) {
                  svalues=unescape(decodeURI(theHttpRequest.responseText))
                  document.getElementById("dt_wd").innerHTML=svalues;
                  } else {
                   alert('nepovedlo se ziskat data');
               }
           }
        }
    //alert (sreturnvalue);
    //return sreturnvalue;

}

function dt_get_better_price(scode,nprice,sname)
{

  var  url="/axah_better_price.asp?scode="+encodeURI(scode.toString())+"&nprice="+nprice.toString()+'&sname='+encodeURI(sname.toString());
   // url=encodeURI(url);   
  // wnd=window.open(url,'','');

  
    var sreturnvalue = ''
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.onreadystatechange = function() {processAXAH();};
    theHttpRequest.open("GET", url);
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.send(false);

        function processAXAH(){
           if (theHttpRequest.readyState == 4) {
               if (theHttpRequest.status == 200) {
                  svalues=unescape(decodeURI(theHttpRequest.responseText))
                  document.getElementById("dt_wd").innerHTML=svalues;
                  } else {
                   alert('nepovedlo se ziskat data');
               }
           }
        }
}

function dt_get_question(scode,pkcommodiy,sname)
{

  var  url="/axah_question.asp?scode="+encodeURI(scode.toString())+"&pkcommodity="+pkcommodiy.toString()+'&sname='+encodeURI(sname.toString());
   // url=encodeURI(url);   
  // wnd=window.open(url,'','');

  
    var sreturnvalue = ''
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.onreadystatechange = function() {processAXAH();};
    theHttpRequest.open("GET", url);
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.send(false);

        function processAXAH(){
           if (theHttpRequest.readyState == 4) {
               if (theHttpRequest.status == 200) {
                  svalues=unescape(decodeURI(theHttpRequest.responseText))
                  document.getElementById("dt_wd").innerHTML=svalues;
                  } else {
                   alert('nepovedlo se ziskat data');
               }
           }
        }
}


/*seznam faktur k objednavce*/
function dt_get_invoiceslist(sordernumber)
{

  //alert(sordernumber);

  var url="/axah_invoiceslist.asp?nordernumber="+encodeURI(sordernumber.toString());
   // url=encodeURI(url);   
  //wnd=window.open(url,'','');

    var sreturnvalue = ''
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.onreadystatechange = function() {processAXAH();};
    theHttpRequest.open("GET", url);
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.send(false);

        function processAXAH(){
           if (theHttpRequest.readyState == 4) {
               if (theHttpRequest.status == 200) {
                  svalues=unescape(decodeURI(theHttpRequest.responseText))
                  document.getElementById("invoices").innerHTML=svalues;
                  } else {
                   alert('nepovedlo se ziskat data');
               }
           }
        }
}

function getNewHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

	function isTime(fTime)
	{	var status = true
		a = fTime.split(":")
		if (a.length!=3) {status = false}
		if (isNaN(a[0]) || a[0]<0 || a[0]>23) {status = false}
		if (isNaN(a[1]) || a[1]<0 || a[1]>59) {status = false}
		if (isNaN(a[2]) || a[2]<0 || a[2]>59) {status = false}
		return status
	}

	function isDate(fDate)
	{	var status = true
		a = fDate.split(".")
		if (a.length!=3) {status = false}
		if (isNaN(a[0]) || a[0]<1 || a[0]>31) {status = false}
		if (isNaN(a[1]) || a[1]<1 || a[1]>12) {status = false}
		if (isNaN(a[2]) || a[2]<1900 || a[2]>2100) {status = false}
		if ((a[1]==4 || a[1]==6 || a[1]==9 || a[1]==11) && (a[0]>30)) {status = false}
		if (a[1]==2 && a[2]%4==0) {if ((a[0]>29)) {status = false}}
		if (a[1]==2 && a[2]%4!=0) {if ((a[0]>28)) {status = false}}
		return status
	}
	
	function hc_calculator(shash, spar1, spar2, spar3)
  {
  var url
  url = "https://i-calc-train.homecredit.net/icalc/entry.do";

    var sreturnvalue = '';
    var theHttpRequest = getNewHttpObject();
    theHttpRequest.open("POST", url, true);
    theHttpRequest.onreadystatechange = function() {processAXAH();};
    theHttpRequest.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
    theHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    theHttpRequest.send("sh="+shash+"&shop="+spar1+"&o_price="+spar2+"&time_request="+spar3);

        function processAXAH(){
           if (theHttpRequest.readyState == 4) {     
               if (theHttpRequest.status == 200) {
                  svalues=theHttpRequest.responseText
                  document.getElementById('hc_calculator').innerHTML=svalues;                 
                  } else {
                   alert('nepovedlo se ziskat data');
               }
           }
         }
  }
  
//rotace obrazku na detailni strance
  var so_current; var so_timer;
  so_current=0;
  
  function so_init() {
      if(!document.getElementById || !document.createElement || !document.getElementById("imageContainer"))return;
      
      css = document.createElement("link");
      css.setAttribute("href","slide.css");
      css.setAttribute("rel","stylesheet");
      css.setAttribute("type","text/css");
      document.getElementsByTagName("head")[0].appendChild(css);
      
      imgs = document.getElementById("imageContainer").getElementsByTagName("img");
     // alert (imgs.length);
      for(i=1;i<imgs.length;i++) {imgs[i].xOpacity = 0;imgs[i].style.display="none";}
      imgs[0].style.display = "block";
      imgs[0].style.position = "absolute";
      imgs[0].style.top = 0;
      imgs[0].xOpacity = 1;

      if (imgs[1]) {setOpacity(imgs[1]);imgs[1].style.position="absolute";imgs[1].style.top=0;imgs[1].style.display="block";}
      
      so_timer=setTimeout(so_xfade,8000);
      }
      
      function so_xfade() {
      cOpacity = imgs[so_current].xOpacity;
      nIndex = imgs[so_current+1]?so_current+1:0;     
      nOpacity = imgs[nIndex].xOpacity;
      
      cOpacity-=.04;
      nOpacity+=.04;
      
      
      imgs[so_current].xOpacity = cOpacity;
      imgs[nIndex].xOpacity = nOpacity;
      
      // alert(imgs[so_current].xOpacity);
      
      setOpacity(imgs[so_current]);
      setOpacity(imgs[nIndex]);
      
      if(cOpacity<=0) {
      imgs[so_current].style.display = "none";
      //alert(nIndex);
      so_current = nIndex;
      
        if (imgs[so_current+1]) {setOpacity(imgs[so_current+1]);imgs[so_current+1].style.position="absolute";imgs[so_current+1].style.top=0;}
        else {setOpacity(imgs[0]);imgs[0].style.position="absolute";imgs[0].style.top=0;}
      
      clearTimeout(so_timer);
      so_timer=setTimeout(so_xfade,6000);
      } else {
      so_timer=setTimeout(so_xfade,50);
      imgs[so_current+1]?imgs[so_current+1].style.display="block":imgs[0].style.display="block";
      }
          
      }
      
      function setOpacity(obj) {
      if(obj.xOpacity>.99) {
      obj.xOpacity = 1;
      return;
      }
      obj.style.opacity = obj.xOpacity;
      obj.style.MozOpacity = obj.xOpacity;
      obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
      }

function hide_tree(root,sclassname)
  {
  obj_a=root.nextSibling;
  obj_div=root.parentNode;
  
 // alert (obj_div);
  
  for(x=0;obj_div.parentNode.getElementsByTagName('div')[x]!=obj_div;x++);
  
  for(i=x+1;obj=obj_div.parentNode.getElementsByTagName('div')[i];i++)
    {
     if (obj.className=='catlvl') {
     obj.parentNode.removeChild(obj)
     i=i-1;
      //obj.innerHTML="";//
    //  obj.style.display="none";
     // alert("remove");
     }
     
    }
    
    root.style.display="none";
    root.onclick='';
    obj_div.className=sclassname;
    obj_div=root.parentNode;
    

   // alert(obj_div.nextSibling)
    /*pro IE >} */
//     while (obj_div=obj_div.nextSibling)
//     {
//      if (obj_div.style) 
//      {
//      obj_div.style.display="block";
//      obj_div.style.border="1px solid red";
//      }
//      //obj_div.style.border="none";
//     }

   
    obj_a.href="";
  
  return false;
  }
  
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
  
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function removeHTMLTags(strInputCode){ 	
 		 	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "<" : ">";
 		});
 		return strInputCode.replace(/<\/?[^>]+(>|$)/g, "").replace(/&nbsp;/g,"");
}



