


// KOMPATIBILITA

var Br = new BrCheck()


function BrCheck()
{
 this.VER = navigator.appVersion;
 this.AGENT = navigator.userAgent.replace(/[\/]/g,' ');
 this.DOM = document.getElementById ? true:false;

 this.OP5 = this.AGENT.indexOf("Opera 5")>-1       ?true:false;
 this.OP6 = this.AGENT.indexOf("Opera 6")>-1       ?true:false;
 this.OP7 = this.AGENT.indexOf("Opera 7")>-1       ?true:false;
 this.OP8 = this.AGENT.indexOf("Opera 8")>-1       ?true:false;
 this.OP  = (this.OP5 || this.OP6 || this.OP7 || this.OP8);

 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) {
	return document.getElementById(objectID);
}

function getF(formName) {
	return document.forms[formName];
}

function getFEx(formName, oDocument) {
	return oDocument.forms[formName];
}

function getEEx(objectID, oDocument) {
	return oDocument.getElementById(objectID);
}

function SetDSP(nDSP, sURL) {
	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 BuyOrSetVariableParams(sFormSuffix,sFormIndex, bType,x, y) 
{
		var sSelects, nWindowHeight;
	    gsFormIndex = sFormIndex;
	    gsFormSuffix = sFormSuffix;
	    var e = getE('BuyItem' + sFormIndex);
		
		if (bType == 0)
		{
    		y = y + topScroll() - 220;
	    	x = x - 165;
	    }
	   else
	   {
	    	y = y + topScroll()-230;
	    	x = x - 100;
	   } 

        getE("StateInfo1").style.left = x + 'px';
	    getE("StateInfo1").style.top = y + 'px';

        sSelects = "FormBuy" + sFormSuffix; // + sFormIndex;

		document.forms[sSelects].submit();
} 


function BuyOrSetParams(sFormIndex) {
	var e = getE( "ItemParameters" + sFormIndex );
	e.style.display = "inline";
	e.style.position = "relative";
	e.style.top =  window.event.srcElement.offsetTop + 20;
	e.style.left =  window.event.srcElement.offsetLeft - 60;	
	e.style.border =  "1px solid black";	
}
function CopyParamsBack() {
	getE("DivForPars" + gsFormSuffix + gsFormIndex).innerHTML = getE('DivForParams').innerHTML;
	getF("BuyForm" + gsFormSuffix + gsFormIndex).submit();
}

// ###   FCE PRO ROZKLIKAVANI KATEGORII   ###

function InsertCookiesCat(intId,idTree){
	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;
}

// ###   FCE PRO PriceList ###

function SHModalDlgPricelist()
{
	var strReturn = showModalDialog("/Includes/EmailPricelist.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=320px;dialogHeight=124px;");

    if (strReturn == "") return;
	document.location.href = "/EmailPricelist.asp?EmailPricelist=" + strReturn;
}

// ##########

function onAction(imgName){
       getE(imgName).src = eval(imgName + "on.src")
}

function offAction(imgName){
	if (oldImgName.substring(0,4)!=imgName.substring(0,4)){
		getE(imgName).src = eval(imgName + "off.src")
	}
}

function OpenWnd(strURL){
    
	var objWnd = window.open(strURL,"InfoDetail","scrollbars=no,height=330,width=350,left=10,top=10");
	objWnd.focus();
}
function OpenWndForPrint(strURL){
    //window.print();
	var objWnd = window.open(strURL,"Print page","scrollbars=no,height=500,width=800left=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()+";";
	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 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;
}
function ControlDate() {
     if (((event.keyCode <48) || (event.keyCode >57)) && (event.keyCode!=46)) event.returnValue = false;
}
//----------info okno-------------------------------------------------------
function InfoWindow(strAddress) {
       showModalDialog(strAddress,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=450pt;dialogHeight=320pt");
}
function ShowSearchMenu(x){
    if (x == 1){
        getE('Searchtable').style.display='';
    }else{
        getE('Searchtable').style.display='none';
    }
}

function ValidateAccount(sAccount) 
{

    return true;

}

function ControlSendEmailToFriend(){
    var obj1 = document.getElementById('SendToEmail');
    var obj2 = document.getElementById('SendFromEmail'); 
	
	if(obj1.value == ""){alert("Enter your e-mail.");obj1.focus();return false;}
	if(obj2.value == ""){alert("Enter your e-mail.");obj2.focus();return false;}
	
	if (EmailControl(obj1.value)==false) {obj1.focus();return false;}
	if (EmailControl(obj2.value)==false) {obj2.focus();return false;}
}

function ControlUserDataSubmit()
{
	var bFirm = (document.forms['UserDataForm'].Firm.value == "");
	var bFirstName = (document.forms['UserDataForm'].FirstName.value == "");
	var bLastName = (document.forms['UserDataForm'].LastName.value == "");
	
	if (bFirm && bFirstName && bLastName)
	{
		alert("Please fill in the Company name, Firstname or Surname.")
		document.forms['UserDataForm'].Firm.focus();
		return false
	}
	if (bFirm && bFirstName && !bLastName)
	{
		alert("Enter your name.");
		document.forms['UserDataForm'].FirstName.focus();
		return false
	}
	if (bFirm && bLastName && !bFirstName)
	{
		alert("Enter your surname.");
		document.forms['UserDataForm'].LastName.focus();
		return false
	}

	if(getF('UserDataForm').Email.value == ""){alert("Enter your e-mail.");getF('UserDataForm').Email.focus();return false}
	if(EmailControl(getF('UserDataForm').Email.value)==false) {getF('UserDataForm').Email.focus();return false;}
	if(!ValidateAccount(getF('UserDataForm').BankAccount.value)){alert("The Bank account is not valid. Please enter your bank account again or do not fill any text..");getF('UserDataForm').BankAccount.focus();return false};
	if(getF('UserDataForm').Login.value == ""){alert("Please fill in the Username.");getF('UserDataForm').Login.focus();return false}
	if(getF('UserDataForm').Login.value.length < 5){alert("Passwords must have a minimum length of 5 alphnumeric characters..");getF('UserDataForm').Login.focus();return false}
	if(getF('UserDataForm').Password.value == ""){alert("Enter your password.");getF('UserDataForm').Password.focus();return false}
	if(getF('UserDataForm').Password.value.length < 5){alert("The password must contain 5 characters at least..");getF('UserDataForm').Password.focus();return false}
	if(getF('UserDataForm').PasswordCheck.value == ""){alert("Enter your password again.");getF('UserDataForm').PasswordCheck.focus();return false}
	if(getF('UserDataForm').Password.value != getF('UserDataForm').PasswordCheck.value){alert("Entered passwords are not the same..");getF('UserDataForm').PasswordCheck.focus();return false}
	
	
  return true;
}

function ControlUserDataSubmitOrder()
{
	var bFirm = (document.forms['UserDataForm'].Firm.value == "");
	var bFirstName = (document.forms['UserDataForm'].FirstName.value == "");
	var bLastName = (document.forms['UserDataForm'].LastName.value == "");
	
	if (bFirm && bFirstName && bLastName)
	{
		alert("Please fill in the Company name, Firstname or Surname.")
		document.forms['UserDataForm'].Firm.focus();
		return false
	}
	if (bFirm && bFirstName && !bLastName)
	{
		alert("Enter your name.");
		document.forms['UserDataForm'].FirstName.focus();
		return false
	}
	if (bFirm && bLastName && !bFirstName)
	{
		alert("Enter your surname.");
		document.forms['UserDataForm'].LastName.focus();
		return false
	}

	if(getF('UserDataForm').Street.value == ""){alert("Your street.");getF('UserDataForm').Street.focus();return false}
	if(getF('UserDataForm').City.value == ""){alert("Your city.");getF('UserDataForm').City.focus();return false}
	if(getF('UserDataForm').ZipCode.value == ""){alert("Your postcode.");getF('UserDataForm').ZipCode.focus();return false}
	
	if(getF('UserDataForm').Login.value == ""){alert("Please fill in the Username.");getF('UserDataForm').Login.focus();return false}
	if(getF('UserDataForm').Login.value.length < 5){alert("Passwords must have a minimum length of 5 alphnumeric characters..");getF('UserDataForm').Login.focus();return false}
	if(getF('UserDataForm').Password.value == ""){alert("Enter your password.");getF('UserDataForm').Password.focus();return false}
	if(getF('UserDataForm').Password.value.length < 5){alert("The password must contain 5 characters at least..");getF('UserDataForm').Password.focus();return false}
	if(getF('UserDataForm').PasswordCheck.value == ""){alert("Enter your password again.");getF('UserDataForm').PasswordCheck.focus();return false}
	if(getF('UserDataForm').Password.value != getF('UserDataForm').PasswordCheck.value){alert("Entered passwords are not the same..");getF('UserDataForm').PasswordCheck.focus();return false}
	
	if(getF('UserDataForm').Email.value == ""){alert("Enter your e-mail.");getF('UserDataForm').Email.focus();return false}
	if(EmailControl(getF('UserDataForm').Email.value)==false) {getF('UserDataForm').Email.focus();return false;}
	if(getF('UserDataForm').Phone.value + getF('UserDataForm').Mobil.value == ""){alert("Fill in the phone or mobile number.");getF('UserDataForm').Phone.focus();return false}
	if(!ValidateAccount(getF('UserDataForm').BankAccount.value)){alert("The Bank account is not valid. Please enter your bank account again or do not fill any text..");getF('UserDataForm').BankAccount.focus();return false};

  return true;
}


function ControlPassword(NameOne,NameTwo){
	if (getE(NameOne).value != getE(NameTwo).value){
		alert("Wrong password.");
		getE(NameOne).value = "";
		getE(NameTwo).value = "";
		getE(NameOne).focus();
		return false;
	}else{
		return true;
	}
}

function EmailControl(f)
{
    return EmailControlRegExp(f, true);
}

function EmailControlRegExp(sEmail, bShowMsg)
 {

   if (sEmail=='' || sEmail=='Váš@email.cz')
   {
        if (bShowMsg) alert('Wrong e-mail format');
		return false;
  }
  
  var regEx  = new RegExp("^[_a-zA-Z0-9\.\-]+@(([_a-zA-Z0-9\-]{1,}\.){1,})+\.[a-zA-Z]{2,}$"); 
    
  regEx.ignoreCase = true;
  
  if (regEx.test(sEmail) == false)
  {
        if (bShowMsg) alert('Wrong e-mail format');
		return false;
  }
  return true;
}  
 
// ##### PriceList BEEND #######################################################
function DelProducer(nProd) {
	if (nDeleted==nProducers-1) return;
	getE("bEnabled" + nProd).value='0';
	getE("Producer" + nProd).style.display="none";
	nDeleted += 1;
}

function PutCategoriesIdNameToSelect(saCatIdName, nIndex, bStart) {
	var arrData, arrSubData, saCatID, el;
	arrData = saCatIdName.split("*");
	saCatID = "";
	for (var i=0; i<arrData.length-1; i++) {
	    arrSubData = arrData[i].split("/")
		el = document.createElement("OPTION")
	    el.value = arrSubData[0];
	    el.text = arrSubData[1];
		saCatID += arrSubData[0] + "$"
		if (bStart==true) {
			if (i==0) {
				el.text='-All categories-';
				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=400px;dialogHeight=600px");
		//window.open("/Includes/PriceListSelectCatsOfProd.asp?TREE="+nTree+"&ProID="+nProID+"&DIS="+bAlsoDisabled+"&CatIDs="+saCatID+"&ADM="+nUserType+"&ProNM="+sProNM+"&nIndex="+nIndex,"okno","toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=450,height=400,left=0,top=0");
		if (typeof(strReturn) == 'undefined') return;
		with(getE("Categ"+nIndex)){
			r = options.length;
	       		for (var i=0; i<r; i++) {
	               		options.remove(options.length-1);
	       		}
		}
		PutCategoriesIdNameToSelect(strReturn, nIndex, false);
	}else{
		window.open("/Includes/PriceListSelectCatsOfProd.asp?TREE="+nTree+"&ProID="+nProID+"&DIS="+bAlsoDisabled+"&CatIDs="+saCatID+"&ADM="+nUserType+"&ProNM="+sProNM+"&nIndex="+nIndex,"okno","toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=450,height=400,left=0,top=0");
	}
	
}
function ClearCategories(nIndex) {

	while(document.PL['Categ'+nIndex].length>0) {
		document.PL['Categ'+nIndex].options[0] = null;	
		}
	
	document.PL['CatID' + nIndex].value = "";
	document.PL['Categ'+nIndex].style.display = "none";
	getE("ChooseCateg"+nIndex).style.display  = "inline";
}

// ##### PriceList END #####

function ShowImage(nPoradi, nCommodity) 
{
	window.open('/ShowImage.asp?IMGNUM=' + nPoradi + '&ID=' + nCommodity , "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;
}



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;
}


function VazbySelect(s1,s2,pkDel){
//$$$$41||Dobírkou##43||Hotove##46||Predem (eBanka)##$$$$43||Hotove##46||Predem (eBanka)##$$$$
//0$$$$142$$$$143$$$$
	var s1pole,s2pole,s1pom,s1p,pkP,NazevP,iHtml;
//	alert(s1+'\n'+s2 +'\n ' +pkDel);
//	return true;//**************************************************************************************************
	iHtml = '<select tabindex="213" id="i213" size="1" name="PaymentType" class="INP RSEL"  style="width:201px">';
	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 += '<option value="' + pkP + '">' + NazevP + '</option>';
				  
			}
		}
	}
	iHtml +='</select>';
	getE('DivForVazby').innerHTML = iHtml;
}

function ZavriKosik(bHideCB)
{
	getE("StateInfo1").style.display="none";
}

function SearchExt_ShowHide()
{
    var objDiv = document.getElementById("SearchExt");
   
    if (objDiv.style.display == "none")
            objDiv.style.display = "block";
    else         
            objDiv.style.display = "none"; 
}

function topScroll() {
	if (window.innerHeight) {
		  return ( window.pageYOffset )
	} else if (document.documentElement && document.documentElement.scrollTop) {
		return ( document.documentElement.scrollTop )
	} else if (document.body) {
		  return ( document.body.scrollTop )
	}
}

function ChangeFilters(bState, sCookieName)
{
	var vyprs=new Date();
	vyprs.setDate(vyprs.getDate() + 14);
	var sCookie  = sCookieName + '=' + (bState==true ? '1' : '0') + ';';

    document.cookie = sCookie;
}

function LogOff_User()
{
	if(confirm('Logout?')){;document.forms.LogOff.submit();}
}

function SetDSP2(nType, sURL) {
	var vyprs=new Date();	
	vyprs.setDate(vyprs.getDate() + 14);

	
//	if (nType == 0)
	//	document.cookie='DSPx=0;expires='+vyprs.toGMTString()+';';
//	else	
		//document.cookie='DSPx=1;expires='+vyprs.toGMTString()+';';
	
	window.location.href=sURL + '&DSP=' + nType;
}

//zalozky

	var nActiveZal = 1;
	var bZalState_1 = true;
	var bZalState_2 = true;
	var bZalState_3 = false;
	var bZalState_4 = true;
	var bZalState_5 = true;
	
	function ZalEvent(nPosition, LANG)
	{
	    if (LANG=='') LANG='1';
	    
		if ( nPosition == nActiveZal )		return false;
		if ( !GetZalozkaState(nPosition) )	return false;
		
		document.getElementById('zal'+ nActiveZal).src	= 'img/zalozky_'+LANG+'/zal' + nActiveZal + '.gif';
		document.getElementById("divzal_"+nActiveZal).style.display = 'none';
		document.getElementById('zal'+ nPosition).src	= 'img/zalozky_'+LANG+'/zal' + nPosition + 'active.gif';
		document.getElementById("divzal_"+nPosition).style.display = '';
		
		nActiveZal = nPosition;
	}
	
	function GetZalozkaState(nPosition)
	{
		if (nPosition == 1)	return bZalState_1;
		if (nPosition == 2)	return bZalState_2;
		if (nPosition == 3)	return bZalState_3;
		if (nPosition == 4)	return bZalState_4;
		if (nPosition == 5)	return bZalState_5;
		return false;
	}
	
    function DownloadFiles(nIdFile, nIdCommodity)	{getE('downloadiframe').src = "/DownLoadFile.asp?IDFILE="+ nIdFile + "&IDCOMMODITY=" + nIdCommodity; }

    function DownloadFilesIB(sAlias, sFile)	{getE('downloadiframe').src = "/DownLoadFile.asp?IDFILE=0&IDCOMMODITY=0&ALIAS=" + sAlias + "&FILE=" + sFile; }
    //function DownloadFilesIB(sAlias, sFile)
	//{ 
    //var surl = "/DownLoadFile.asp?IDFILE=0&IDCOMMODITY=0&ALIAS=" + sAlias + "&FILE=" + sFile;
    // window.open(surl,"InfoDetail","scrollbars=no,height=330,width=350,left=10,top=10");
    //}
	
	// specialitka kontron VAT
	function SetVATDiv(nType)	
	{
	
	    if (nType == 0 ) 
	    {
	        if (getE('VAT1').checked) 
	        {
				getE('vatdiv1').style.display = 'none';	
		        getE('vatdiv2').style.display = 'none';	
	        }
	        if (getE('VAT2').checked)
   	        {
				getE('vatdiv1').style.display = '';	
		        getE('vatdiv2').style.display = 'none';	
	        }

	        if (getE('VAT3').checked)
  	        {
				getE('vatdiv1').style.display = 'none';	
		        getE('vatdiv2').style.display = '';	
	        }
	    } 
	   else
	   { 
    		getE('vatdiv1').style.display = (nType == 2 ? '' : 'none');	
	    	getE('vatdiv2').style.display = (nType == 3 ? '' : 'none');	
	    }
	}
	function CheckBilling()
	{
		if (getE('VAT2'))
		{
			if ( getE('VAT2').checked && getE('VAT').value=='' )
			{
				alert('Enter VAT.')
				getE('VAT').focus();
				return false;
			}
		}
		return true;
	}
	
	var gb_CloseTypeCount = 0;
	
	function SetDelivery()
	{
		var bHASP = 0;
		var i = 0

		if (gb_CloseTypeCount == 0) return false;
		for (i=1;i<=gb_CloseTypeCount;i++)
		{

			if (getE('CT_'+i).value == 'HASP')
				bHASP = 1;
		}
	
		if (bHASP == 0)
		{
		    getE('DeliveryTypeSW').style.display='';
		    getE('DeliveryTypeHASP').style.display='none';
		    getE('DT').value=1;
	    }
    	else	
    	{
    	   getE('DT').value=2;
    	   getE('DeliveryTypeSW').style.display='none';
           getE('DeliveryTypeHASP').style.display='';
		}
	}

// klik na MAC - dodam pozdeji	
	function OnMacLaterClick(i)
	{
        if ( getE('MAC_Later_'+i).checked )  getE('MACaddress_'+i).value = '';
   	}

// klik na zpusob SW / HASP   	
   function OnSW_HASPClick(i)
	{
	    var bHASP = ( getE('CT_' + i).value == 'HASP' );

	   if (bHASP)         getE('LicenceNaJmeno_'+i).value = '';
	   //getE('LicenceNaJmeno_'+i).disabled = bHASP;
	   
	   SetDelivery();
   	}	
   	
  // odeslani formulare Shipping & delivery 	
	function CheckShipping()
	{
	    var bHASP = 0;
		var i = 0

		if (gb_CloseTypeCount == 0) return false;

		for ( i=1;i<=gb_CloseTypeCount;i++ )
		{
			if ( getE('CT_'+i).value == 'SW' )
		        if ( getE('LicenceNaJmeno_' + i).value == ''  )	          {       alert('Please fill in the License to the name.');  getE('LicenceNaJmeno_' + i).focus(); return false;      } 
		    if ( getE('MAC_'+i).value == '1'  )    
		    {
		        if ( !getE('MAC_Later_'+i).checked  &&  getE('MACaddress_'+i).value == '') {       alert('Enter the MAC address or choose "I will send the MAC address later".');  getE('MACaddress_' + i).focus(); return false;      } 
		    } 
		}
		
		
	
		if ( getE('DeliveryTypeSW') ) 
		        
		        if ( getE('DeliveryTypeSW').value==0 && getE('DeliveryTypeSW').style.display != 'none' )  {       alert('Please choose the type of delivery.');  getE('DeliveryTypeSW').focus(); return false; } 
		else
		    if ( getE('DeliveryTypeHASP') ) 
		        if ( getE('DeliveryTypeHASP').value==0 && getE('DeliveryTypeHASP').style.display != 'none'  )  {       alert('Please choose the type of delivery.');  getE('DeliveryTypeHASP').focus(); return false; }  
		       
		       
		        
        return true;
	}
	
	// odeslani formulare Payment
	function CheckPayment()
	{
	    if ( getE('PaymentType').value == 0 )	    {	            alert('Please choose the type of payment.');  getE('PaymentType').focus(); return false; }  	    
	    
	    if (getE('Date_obj').value != '' )
	    {
			var sdate = getE('Date_obj').value;
			
			if (sdate.length != 10) {alert('Wrong date format (dd.mm.yyyy)');getE('Date_obj').focus();return false;}
			if (sdate.substring(0,2) > 31 || sdate.substring(0,2) < 1) {alert('Wrong date format (dd.mm.yyyy)');getE('Date_obj').focus();return false;}
			if (sdate.substring(3,5) > 12 || sdate.substring(3,2) < 1) {alert('Wrong date format (dd.mm.yyyy)');getE('Date_obj').focus();return false;}
			if (sdate.substring(6,10) < 1000) {alert('Wrong date format (dd.mm.yyyy)');getE('Date_obj').focus();return false;}
		}
	   return true;
	}
	
	// odeslani formulare Confirmation
	function CheckConfirmation()
	{
	    if ( getE('PaymentType').value == 0 )	    {	            alert('Please choose the Payment method (one step backward).');  return false; }  	    
	   return true;
	}
	
	function PopupPayment(nType, nPayment, nX, nY)
	{

        if (nPayment==0) return false;
		var shtml;

		shtml= getE('PaymentInfo_' + nPayment).innerHTML;
		if ( shtml.length == 0) return false;

		
		if (nType == 1)
		{
			nY = nY + topScroll()+15;
			nX = nX + 10;
			
			getE('PaymentInfo_' + nPayment).style.left		= nX + 'px';
			getE('PaymentInfo_' + nPayment).style.top		= nY + 'px';	
		}
		else
		{
			nY = nY + topScroll()+10;
			nX = nX + 10-165;
			
			getE('PaymentInfo_' + nPayment).style.left		= nX + 'px';
			getE('PaymentInfo_' + nPayment).style.top	= nY + 'px';	
	
		}

        if ( getE('PaymentInfo_' + nPayment) )		getE('PaymentInfo_' + nPayment).style.display = '';
		

	}
	function HidePopupPayment()
	{
		var i
		for (i=1;i<14;i++)
				 if ( getE('PaymentInfo_' + i) ) getE('PaymentInfo_' + i).style.display = 'none'
	}
	
	
	
	function PopupSupport(nType, nX, nY)
	{
		var shtml;

		shtml= getE('TT_' + nType).innerHTML;
		if ( shtml.length == 0) return false;

		
			nY = nY + topScroll()-190;
			nX = nX - 220;
			
			nY= nY +55;
			getE('TT_' + nType).style.left	= nX + 'px';
			getE('TT_' + nType).style.top	= nY + 'px';	
	
		   if ( getE('TT_' + nType) )		 getE('TT_' + nType).style.display = '';
	}
	function HidePopupSupport()
	{
		var i;
		for (i=1;i<5;i++)				getE('TT_' + i).style.display = 'none'
	}
	
    function PopupDownLoad(nType, sText, nX, nY)
    {
            if (nType == 0) 
            {
                nY = nY + topScroll()-195;
                nX = nX - 485;
                getE('DownloadToolTip').style.left	= nX + 'px';
            }
            else
            {
                nY = nY + topScroll()-125;
                nX = nX - 445;
                getE('DownloadToolTip').style.left	= nX + 'px';
            }
			

            getE('DownloadToolTip').innerHTML = sText;

			
			getE('DownloadToolTip').style.top	= nY + 'px';	
	
		    getE('DownloadToolTip').style.display = '';
    }
	function HidePopupDownLoad()
	{
		    getE('DownloadToolTip').style.display = 'none';
	}


	function onClickInquiry(nId)
	{
		getE('InqAns').value=nId;
		document.forms.frmInq.submit();
	}



    function PopupOrder(nType, nX, nY)
	{
		var shtml;
        if ( getE('OrderInfo_' + nType) )
        {
		    shtml= getE('OrderInfo_' + nType).innerHTML;
		    if ( shtml.length == 0) return false;


            if (nType > 0)
            {
		        nY = nY + topScroll()-130;
		        nX = nX - 305;
        		
		        getE('OrderInfo_' + nType).style.left		= nX + 'px';
		        getE('OrderInfo_' + nType).style.top		= nY + 'px';	
	
                if ( getE('OrderInfo_' + nType) )		getE('OrderInfo_' + nType).style.display = '';
            }
    	}	
	}
	function HidePopupOrder()
	{
		var i;
		for (i=1;i<5;i++)				 if ( getE('OrderInfo_' + i) ) getE('OrderInfo_' + i).style.display = 'none'
	}
	



// -- kontrola search string
function CheckSearchString()
{
	var sValue = document.forms['fmrsearch'].EXPS.value;
	
	if (sValue == '' )
	{
		alert('Please enter the search term.'); 
		return false;
	}
	
	sValue = sValue.replace(/^\s*|\s*$/g,"");
	
	if (sValue.length < 3 ) 
	{
		alert("{undefined}"); 
		return false;
	}
	return true;
}
