function ShowCalendar(oid)
 {
  var cal = document.getElementById('divcal');
  var calframe = document.getElementById('diviframcal');
  var tbox = document.getElementById(oid);
  var ssrc = '/Includes/Calendar_INC.asp?el=' + oid + '&selDate=' + tbox.value;
  
  cal.style.top = tbox.offsetTop + tbox.offsetHeight;
  cal.style.left = tbox.offsetLeft;
  
  calframe.src = ssrc;
  cal.style.display = 'block';
 }
 

function CheckAuction(){

	if (getE('bInAuction').checked == true){
		getE('ClearanceItem').checked = false;
		getE('ClearanceItem').value = '0';
		alert('Zboží nemůže být zařazeno do výprodeje pokud je zároveň v Holandské dražbě!');
	}			
}

function CheckClearance(){
	if (getE('ClearanceItem').checked == true){
		getE('bInAuction').checked = false;
		getE('bInAuction').value = '0';
		alert('Zboží nemůže být zařazeno do Holandské dražby pokud je zároveň ve výprodeji!');
	}			
}

function CheckAuctionLang(nLang){

	if (getE('bInAuction' + nLang).checked == true){
		getE('ClearanceItem'+nLang).checked = false;
		getE('ClearanceItem'+nLang).value = '0';
		alert('Zboží nemůže být zařazeno do výprodeje pokud je zároveň v Holandské dražbě!');
	}			
}

function CheckClearanceLang(nLang){
	if (getE('ClearanceItem'+nLang).checked == true){
		getE('bInAuction'+nLang).checked = false;
		getE('bInAuction'+nLang).value = '0';
		alert('Zboží nemůže být zařazeno do Holandské dražby pokud je zároveň ve výprodeji!');
	}			
}

function ShowDateVykaz(strItem) {
     var strReturn = showModalDialog("/Administration/SelectDateVykaz.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=250pt;dialogHeight=180pt");
     if (strReturn == undefined){return;}
     	//strItem.value = strReturn;
  	//   window.location = "/Administration/EditNews.asp?dDateDone="+strReturn;

	getE('dStartTime').value =  strReturn;
}



// globalni promenna------------------
var strContentElBarto = "";
var gb_nCurrentPrice        = 0 //0...nas cena  1..ekonomicka cena
//------------------------------------
function SelectKomodita() {
    Client.style.display = 'none';
    Komodita.style.display = 'inline';
    Price.style.display = 'none';
}
function SelectCeny() {
    Client.style.display = 'none';
    Komodita.style.display = 'none';
    Price.style.display = 'inline';
}
function SelectClient() {
	Client.style.display = 'inline';
	Komodita.style.display = 'none';
	Price.style.display = 'none';
}

function CenyRad() {
	Price.style.display = 'inline';
	Client.style.display = 'none';
	Komodita.style.display = 'none';
}
function EmailControl(f){
	if ((f=='' || f=='Váš E-mail.. ') (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 ShowDate(strItem) {
     var strReturn = showModalDialog("/Administration/SelectDate.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=250pt;dialogHeight=200pt");
     if (strReturn == undefined){return;}
     strItem.value = strReturn;
}

function ChangeStateOrder(intState){
	var Childstate, lengthItem;

	if (intState == 0){
		Childstate = 0
	}else if(intState == 3){
		Childstate = 2
	}else if(intState == 4){
		Childstate = 4
	}else{
		Childstate = 1
	}

    if(typeof (document.EditOrder.IdItem[1]) == "object"){
		lengthItem = document.EditOrder.IdItem.length;
		for(var i = 0; i < lengthItem; i++){
			document.EditOrder.StateItem[i].value = Childstate;
		}
	}else{
		document.EditOrder.StateItem.value = Childstate;
	}
}

function ShowOffers(intId) {
	if (document.all[intId].style.display == "none"){
		document.all[intId].style.display = "";
	}else{
		document.all[intId].style.display = "none";
	}
}


function FrameLocation(strURL) {
	alert(strURL);
	window.frames['ActionFrame'].location.href = strURL;
}

function WriteNameAction(strName) {
	if(strName != ""){
		window.parent.document.all.NameAction.innerHTML = strName;
	}else{
		window.parent.document.all.NameAction.innerHTML = "Administrace katalogu"
	}
}

/*
function ChangeCategory(strString){
	
	var arrData;//3##Kapky##0##imgCat##imgCatForPrint##False'
	arrData = strString.split("##");
	document.forms.EditCategory.elements.IDCategory.value = arrData[0];
	document.forms.EditCategory.elements.NameCategory.value = arrData[1];
	document.forms.EditCategory.elements.ParentSelect.value = arrData[2];
	document.forms.EditCategory.elements.ImageCat.value = arrData[3];
	document.forms.EditCategory.elements.ImageCatPrint.value = arrData[4];
	document.forms.EditCategory.elements.nOrderCat.value = arrData[9];
//	document.getElementById('ImgCat1').src = '/Foto/ImgCategory/'+arrData[3];
//	document.getElementById('ImgCat2').src = '/Foto/ImgCategory/Over/'+arrData[3];
//	document.getElementById('ImgCatPrint').src = '/Foto/ImgCategory/'+arrData[4];
	window.frames.FrameDescription.location.href='BlankWhite.htm';
	if(arrData[5].toString() == "True"){
		document.EditCategory.bDisabled.checked = "True";
	}else{
		document.EditCategory.bDisabled.checked = "" ;
	}
	document.forms.EditCategory.elements.nOrderCat.value = arrData[8];
	
	// fkceditor
	//var oEditor = FCKeditorAPI.GetInstance('FCKeditor1')
	//oEditor.Value = arrData[9];
	
	
}
function EmptyCategory() {
	document.EditCategory.NameCategory.value = "";
	document.EditCategory.IDCategory.value = 0;
	document.EditCategory.ParentSelect.value = 0;
	document.EditCategory.ImageCat.value = "";
	document.EditCategory.ImageCatPrint.value = "";
	document.images.ImgCat1.src = "";
	document.images.ImgCat2.src = "";
	document.images.ImgCatPrint.src = "";
}
*/

function ChangeCategory(strString){
	var arrData;
	arrData = strString.split("##");
	
	document.forms.EditCategory.elements.IDCategory.value = arrData[0];
	document.forms.EditCategory.elements.NameCategory.value = arrData[1];
	document.forms.EditCategory.elements.ParentSelect.value = arrData[2];
	document.forms.EditCategory.elements.ImageCat.value = arrData[3];
	document.forms.EditCategory.elements.ImageCatPrint.value = arrData[4];
	document.forms.EditCategory.elements.nOrderCat.value = arrData[9];
	document.forms.EditCategory.elements.sSeoCategoryTitle.value = arrData[10];
    document.forms.EditCategory.elements.sSeoCategoryKeywords.value = arrData[11];
    document.forms.EditCategory.elements.sSeoCategoryAnnotation.value = arrData[12];
    
//	document.getElementById('ImgCat1').src = '/Foto/ImgCategory/'+arrData[3];
//	document.getElementById('ImgCat2').src = '/Foto/ImgCategory/Over/'+arrData[3];
//	document.getElementById('ImgCatPrint').src = '/Foto/ImgCategory/'+arrData[4];
	window.frames.FrameDescription.location.href='BlankWhite.htm';
	if(arrData[5].toString() == "True"){
		document.EditCategory.bDisabled.checked = "True";
	}else{
		document.EditCategory.bDisabled.checked = "" ;
	}
	// fkceditor
	//var oEditor = FCKeditorAPI.GetInstance('FCKeditor1')
	//oEditor.Value = arrData[9];
	//alert(arrData[13]);
	
	 document.forms.EditCategory.elements.nType.value = arrData[14];
	 
	 if(arrData[15].toString() == "True"){
		document.EditCategory.bNotForXML.checked = "True";
	}else{
		document.EditCategory.bNotForXML.checked = "" ;
	}
	
	document.forms.EditCategory.elements.sTextKatalog.value = arrData[16];
  document.forms.EditCategory.elements.sCategoryUrl.value = arrData[17];
	
}

function EmptyCategory() {
	document.EditCategory.NameCategory.value = "";
	document.EditCategory.IDCategory.value = 0;
	document.EditCategory.ParentSelect.value = 0;
	document.EditCategory.ImageCat.value = "";
	document.EditCategory.ImageCatPrint.value = "";
	document.images.ImgCat1.src = "";
	document.images.ImgCat2.src = "";
	document.images.ImgCatPrint.src = "";
	document.EditCategory.sSeoCategoryTitle.value = "";
    document.EditCategory.sSeoCategoryKeywords.value = "";
    document.EditCategory.sSeoCategoryAnnotation.value = "";	
}


function ControlParent(idCat) {
	if(idCat == document.EditCategory.IDCategory.value){
		alert("Kategorie nemůže být nadřazená sama sobě.");
		document.EditCategory.ParentSelect.value = 0;
	}
}

function SearchParameterString(sParamName, sParamValue, sRowName){
	var strReturn = showModalDialog("/administration/ListOfParamsValues.asp?sParamName=" + sParamName + "&sParamValue=" + sParamValue,"","status:no; center:yes; help:no; minimize:no;dialogWidth=200pt;dialogHeight=100pt");

	if (strReturn == ""){alert('Nebyl zadán žádný text.');return};
    if (strReturn == undefined){return;};
    var strValue = strReturn;
    var strText = strReturn;

	sRowName.value = strText;
}
function InsertImage(Action){
	var strReturn = showModalDialog("ListImage.asp?STAT="+Action,"","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt;");
	if (strReturn == undefined){return;};
	document.all.ImageItem.value = strReturn;
	ChangeImage();
}
function PictureManager(strRootDir)
{
	var strReturn = showModalDialog("/administration/picturemanager.asp?rootDir=" + strRootDir,"PictureManager","status:no; center:yes; help:no; minimize:no;dialogWidth=800pt;dialogHeight=600pt;");
	if (strReturn == undefined){return;};
	document.all.ImageItem.value = strReturn;
	ChangeImage();
}

function PictureManagerAnim(strRootDir, targ)
{
	var strReturn = showModalDialog("/administration/picturemanager.asp?gsTarget="+targ+"&rootDir=" + strRootDir,"PictureManager","status:no; center:yes; help:no; minimize:no;dialogWidth=800pt;dialogHeight=600pt;");
	if (strReturn == undefined){return;}
  getE('sImageBackground').value = strReturn;
  ChangeImage();  
}


function InsertAddRelated(intNoInput){

	var strReturn = showModalDialog("ListRelated.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

	if (typeof(strReturn) == 'undefined'){return;}
	var arrString;
	arrString = strReturn.split("|"); 
	if(typeof(document.all.RelatedCode.length) == "number"){
		document.all.IdCommodityRelated[intNoInput].value = arrString[0];
		document.all.RelatedCode[intNoInput].value = arrString[1];
		document.all.RelatedName[intNoInput].value = arrString[2];
	}else{
		document.all.IdCommodityRelated.value = arrString[0];
		document.all.RelatedCode.value = arrString[1];
		document.all.RelatedName.value = arrString[2];
	}
}
function InsertAddAlternative(intNoInput){

	var strReturn = showModalDialog("ListAlternative.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

	if (typeof(strReturn) == 'undefined'){return;};
	var arrString;
	arrString = strReturn.split("|"); 
	if(typeof(document.all.AlternativeCode.length) == "number"){
		document.all.IdCommodityAlternative[intNoInput].value = arrString[0];
		document.all.AlternativeCode[intNoInput].value = arrString[1];
		document.all.AlternativeName[intNoInput].value = arrString[2];
	}else{
		document.all.IdCommodityAlternative.value = arrString[0];
		document.all.AlternativeCode.value = arrString[1];
		document.all.AlternativeName.value = arrString[2];
	}
}
function UploadFile(sPath){
         var strReturn = showModalDialog("/administration/UploadFileModal.asp?path=" + sPath,"","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

         if (strReturn == undefined){return;};
}
function InsertAddImage(intNoInput){
	
	var strReturn = showModalDialog("ListAddImage.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

	if (strReturn == undefined){return;};
	if(typeof(document.all.ImageAddItem.length) == "number"){
	       document.all.ImageAddItem[intNoInput].value = strReturn;
	}else{
	       document.all.ImageAddItem.value = strReturn;
	}
}
function InsertImageAdvertising(objForm){

	var strReturn = showModalDialog("/ElBarto/ListImg.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");

	if (strReturn == undefined){return;}
	if(strReturn.substring(strReturn.length-3) == "swf"){
	    objForm.Body.value = "<embed width='468px' height='60px' src='/ImgGalery/"+strReturn+"' />";
	}else{
	    var strUrl = prompt("Zadejte URL na kterou má obrázek odkazovat.","http://");
//		alert("<a href='"+strUrl+"' target='blank'><img src='/ImgGalery/"+strReturn+"' /></a>");
	    objForm.Body.value = "<a href='"+strUrl+"' target='blank'><img src='/ImgGalery/"+strReturn+"' alt='' /></a>";
	}
}
function InsertAddFile(intNoInput){	

	var strReturn = showModalDialog("ListAddFiles.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
	if (strReturn == undefined){return;};
		if(typeof(document.all.FileAddName.length) == "number"){
		      document.all.FileAddPath[intNoInput].value = strReturn;
		}else{
		      document.all.FileAddPath.value = strReturn;
		}
}

function InsertImageCat(Action){
	var strReturn = showModalDialog("ListImageCat.asp?STAT="+Action,"","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
	if (strReturn == undefined){return;}
	document.all.ImageCat.value = strReturn;
	document.all.ImgCat1.src = '/Foto/ImgCategory/'+strReturn;
	document.all.ImgCat2.src = '/Foto/ImgCategory/Over/'+strReturn;
}
function InsertImageCatPrint(Action){
      var strReturn = showModalDialog("ListImageCat.asp?NUM=1&STAT="+Action,"","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
      if (strReturn == undefined){return;}
      document.all.ImageCatPrint.value = strReturn;
      document.all.ImgCatPrint.src = '/Foto/ImgCategory/'+strReturn;
}

function PrintOrder(strPkOrder){
	var msg = window.open('OrderPrintAdmin.asp?ID='+strPkOrder,'okno','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=700,height=500,left=20,top=20');
	msg.focus();
}

function DeleteOrder(strPkOrder){
	if (confirm("Opravdu chcete objednávku č.: "+strPkOrder+" smazat?")){
		return true;
	}else{
		return false;
	}
}

function InsertTemplate(){
	var arrReturn
	var strReturn = showModalDialog("ListTemplate.asp","","status:no; center:yes; help:no; minimize:no;dialogWidth=300pt;dialogHeight=300pt");
	if(strReturn != undefined){
		arrReturn = strReturn.split("&");
		if(arrReturn[0] == "Param"){window.location.href=window.location.pathname+"?IdItem="+document.all.IdItem.value+"&PRM="+arrReturn[1]}
		if(arrReturn[0] == "All"){window.location.href="AddCommodityItem.asp?TMP=1&IdItem="+arrReturn[1]}
	}
}

function ControlNumber(){
	if ((event.keyCode <48) || (event.keyCode >57)) event.returnValue = false;
}

function ControlFloat(){
	if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode !=46)) event.returnValue = false;
}

function AddCategory(intTree){
	var arrData,arrSubData,apkTblCommodityCategory;
	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('Nebylo nic vybráno.');return}
	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("*");
	apkTblCommodityCategory = new Array();
	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];
		document.all['strCategory'+intTree].options.add(el);
		apkTblCommodityCategory[i] = arrSubData[0];
	}
	ComParamAddUpdFromCategories(apkTblCommodityCategory);
}
function SendBulkMail(bNews,bCustomer,intID){
	if(bNews){
		bNews = 1;
	}else{
		bNews = 0;
	}
	if(bCustomer){
		bCustomer = 1;
	}else{
		bCustomer = 0;
	}
	var msg = window.open('SendBulkMail.asp?TypeMail=Client&NWS='+bNews+'&CST='+bCustomer+'&GRP='+intID,'okno','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=870,height=740,left=20,top=20');
	msg.focus();
}
function SendMail(strAddress){
	var msg = window.open(strAddress,'win','toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=700,height=500,left=20,top=20');
	msg.focus();
}
function InsertElBarto(strContent){
	strContentElBarto = strContent;
	var msg = window.open('ShowOneElBarto.asp','EditWindow','toobar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=700,height=550,left=20,top=20');
	msg.focus();
}

// SELECT on/off
function SelectExcept(o){
	return !( (o.id == "AMenu1")||(o.id == "TabMenu1")||(o.id == "TabMenu5")||(o.id == "TabMenu6")||(o.id == "CellMenu1")||(o.id == "CellMenu2")||(o.id == "ImgMenu1")); 
}
function SelectHide(sStyle){
	SelectHideEx(sStyle,document);
	for (var i=0;i<window.frames.length;i++){
		SelectHideEx(sStyle,window.frames[i].document);
	}
}
function SelectHideEx(sStyle,odocument){	
	var o;
	o = odocument.getElementsByTagName("select");
	if (o !=null ){
		if (o.tagName == 'SELECT') {
			if (SelectExcept(o)) o.style.visibility=sStyle;
		} else {
			for(var i=0;i<o.length;i++){
				if (SelectExcept(o[i])) o[i].style.visibility=sStyle;
			}
		}
	}
}

function SelectClanek(strItemPk, strItemTitle) {
	var strReturn = showModalDialog("/Administration/Competition/SelectArticle.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=400px;dialogHeight=250px");
	var arrPkAndTitle;
	if (strReturn == undefined){return;}
	arrPkAndTitle = strReturn.split("##");
	strItemPk.value = arrPkAndTitle[0];
	strItemTitle.value = arrPkAndTitle[1];
}


function ChangePrice(sOurPrice, sMena, sEcoPrice, sEcoDesc, nPriceForHidden, nPriceEcoForHidden)
{
	var objPriceName		= document.getElementById('priceName');
	var objPriceValue		= document.getElementById('priceValue');
	var objPriceButton		= document.getElementById('priceBT') ;
	var objConf				= document.getElementById('confBT');
	var objHiddenPrice		= document.getElementById('Price');
	var objHiddenPriceWDPH  = document.getElementById('PriceWDPH');
	
	if (gb_nCurrentPrice == 0)
	{
		objPriceName.innerHTML = 'Ekonomická cena:';
		objPriceValue.innerHTML = sEcoPrice + ' ' + sMena;
		objPriceValue.title='Ekonomická cena včetně DPH'
		
		// tlacitko ceny
		objPriceButton.title     = 'Naše cena';
		objPriceButton.className = 'willOurPriceBT';
		
		// konfigurator
		objConf.title = 'Konfigurátor není dostupný';
		objConf.className = 'configurationDisabledBT';
	
		objHiddenPrice.value	 = nPriceEcoForHidden;
		objHiddenPriceWDPH.value = sEcoPrice;
		
		
	}
	else
	{
		objPriceName.innerHTML = 'Naše cena:';
		objPriceValue.innerHTML = sOurPrice + ' ' + sMena;
		objPriceValue.title='Naše cena včetně DPH'
		
		// tlacitko ceny
		objPriceButton.title     = sEcoDesc;
		objPriceButton.className = 'willBetterPriceBT';
		
		// konfigurator
		objConf.title = 'Konfigurátor';
		objConf.className = 'configurationBT';
		
		objHiddenPrice.value	 = nPriceForHidden;
		objHiddenPriceWDPH.value = sOurPrice;
	}
	gb_nCurrentPrice = !gb_nCurrentPrice;
} 

function OnClickKonfiguratorBT(nIDCommodity)
{
    if (gb_nCurrentPrice == 1)
    {
            alert("Konfigurátor není dostupný, klikněte na tlačítko 'NAŠE CENA'.");
            return false;           
    } 
    else
   {
        document.location.href = '/Configuration.asp?CFG=1&ID=' +nIDCommodity;
   }  
 
}

var g_arrChangedComponents = new Array();

function OnChangeComponent(objRadio, idZarazeni, nCommodityPrice, sNameField, nPriceNoDPH, nValueDph, nIdCommodity)
{

	var nIdCommodity = objRadio.value;
	var objOldRadio	 = document.getElementById('radio' + document.getElementById('ProdSel'+idZarazeni).value);
	objOldRadio.checked = false;
	objRadio.checked	= true;
	
	document.getElementById('ProdSel'+idZarazeni).value = nIdCommodity;
	
	// nacteni a vypocet cen / cenovych rozilu
	var nOurPrice  = parseFloat(BarterComma(document.getElementById('ourprice').value));
	var nCurrPrice = parseFloat(BarterComma(document.getElementById('currentprice').value));
	var nDflPrice  = parseFloat(BarterComma(document.getElementById('ProdPriceWDPH'+idZarazeni).value));
	var nPrice     = nCurrPrice - nDflPrice + parseFloat(nCommodityPrice);
	var nPriceDiff = Math.abs(nPrice - nOurPrice);
	
	//alert (nCurrPrice +  ' - ' + nDflPrice + ' - ' +nCommodityPrice);
	var sMenaCode = document.getElementById('mena').value;
	
	document.getElementById('currentprice').value     = FormatFloat(nPrice,2).replace('.',','); 
	document.getElementById('price_forall').innerHTML = FormatCurrency(nPrice,2) + " " + sMenaCode;
	
	if (nPrice > nOurPrice)
		document.getElementById('price_forallDiff').innerHTML = '+' + FormatCurrency(nPriceDiff,2) + " " + sMenaCode;	
	if (nPrice < nOurPrice)
		document.getElementById('price_forallDiff').innerHTML = '-' + FormatCurrency(nPriceDiff,2) + " " + sMenaCode;	
	if (nPriceDiff == parseFloat(0))	
		document.getElementById('price_forallDiff').innerHTML = "0 " + sMenaCode;	
	
	document.getElementById('ProdPrice'+idZarazeni).value     = nPriceNoDPH;
	document.getElementById('ProdDPH'+idZarazeni).value       = nValueDph;
	document.getElementById('ProdSel'+idZarazeni).value       = nIdCommodity;
	document.getElementById('ProdPriceWDPH'+idZarazeni).value = nCommodityPrice;
	document.getElementById('NameDfl'+idZarazeni).innerHTML   = sNameField;
	document.getElementById('NameDfl'+idZarazeni).title       = 'Vybraná položka - ' + sNameField;
	
	document.getElementById('PriceDfl'+idZarazeni).innerHTML  = FormatCurrency(nCommodityPrice,2) + " " + sMenaCode;
	
	SaveChangedComponents(idZarazeni);
}

// zaznamenani operaci s konfiguratorem - pouzito pri ukladani do db/kosiku
function SaveChangedComponents(idZarazeni)
{
	var sValue	   	    = "";
	var nPoradi         = document.getElementById('PozZarazeni'		 + idZarazeni).value;
	var nCount          = document.getElementById('ProdCount'		 + idZarazeni).value;
	var nIdProdDfl      = document.getElementById('ProdSelDfl'		 + idZarazeni).value;
	var nIdProdSel      = document.getElementById('ProdSel'			 + idZarazeni).value;
	var nPriceWDPHDfl   = document.getElementById('ProdPriceWDPHDfl' + idZarazeni).value;
    var nPriceWDPHSel   = document.getElementById('ProdPriceWDPH'	 + idZarazeni).value;
    var nPriceDfl       = document.getElementById('ProdPriceDfl'     + idZarazeni).value;
    var nPriceSel       = document.getElementById('ProdPrice'	     + idZarazeni).value;
    var nDPHDfl	        = document.getElementById('ProdDPHDfl'       + idZarazeni).value;
    var nDPHSel         = document.getElementById('ProdDPH'	         + idZarazeni).value;
    
    // id ||| cena bez dph ||| dph ||| cena s dph ||| mnozstvi |~| aktualni zbozi
    if (nIdProdDfl != nIdProdSel)
          sValue = nIdProdDfl + "|||" + nPriceDfl + "|||" + nDPHDfl + "|||" + nPriceWDPHDfl + "|||-" + nCount + 
                   "|~|" + nIdProdSel + "|||" + nPriceSel + "|||" + nDPHSel + "|||" + nPriceWDPHSel + "|||" + nCount
    
	g_arrChangedComponents[nPoradi] = sValue;
}

// priprava dat pro volani procedur

function SetDataForSaveConfig()
{
	var sValueArr  = "";
	var sResultArr = "";
	var sDelimiter = ""
	
	for (i=0;i<g_arrChangedComponents.length;i++)
	{
		sValueArr  = g_arrChangedComponents[i];
		sDelimiter = "~~~";
		
   		if (sValueArr != "" && sValueArr != undefined)	
		{
			    if (sResultArr == "") {sDelimiter = "";}
			    sResultArr = sResultArr + sDelimiter  + sValueArr;
		}
	}
	document.getElementById('ResultConfig').value = sResultArr;
	//alert("-- " + document.getElementById("ResultConfig").value);
}
////////////////////////////////////////////////////////////////////
// Function:	IsDate
// Descript:	
// Input:	obj -> form control
//				name -> name of this control
//				datastyle -> "EU" | "US"
// Output:	true | false
//////////////////////////////////////////////////////////////////// 
function IsDate(obj, name, datastyle)
{
	if(CheckDate(obj, datastyle) == false)
	{
		if(name)
			alert('Údaj v poli: ' + name + ' není platné datum!');
		obj.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckDate(objName, strDatestyle)
{
	var strDate;
	var strDateArray;
	var strDay= "";
	var strMonth= "";
	var strYear= "";
	var intday;
	var intMonth;
	var intYear;
	var booFound = false;
	var datefield = objName;
	var strSeparatorArray = new Array("-","/",".");
	var intElementNr;
	var err = 0;
	var strMonthArray = new Array(12);
	strMonthArray[0] = 1;
	strMonthArray[1] = 2;
	strMonthArray[2] = 3;
	strMonthArray[3] = 4;
	strMonthArray[4] = 5;
	strMonthArray[5] = 6;
	strMonthArray[6] = 7;
	strMonthArray[7] = 8;
	strMonthArray[8] = 9;
	strMonthArray[9] = 10;
	strMonthArray[10] = 11;
	strMonthArray[11] = 12;
	strDate = datefield.value;
	
	if(strDatestyle == "")
	{
		strDatestyle = "EU";
	}
	
	if(strDate.length < 1)
	{
		return false;
	}
	for(intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++)
	{
		if(strDate.indexOf(strSeparatorArray[intElementNr]) != -1)
		{
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
			if(strDateArray.length != 3)
			{
				err = 1;
				return false;
			}
			else
			{
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				strYear = strDateArray[2];
			}
			booFound = true;
		}
	}
	if(booFound == false)
	{
		if(strDate.length > 5)
		{
			strDay = strDate.substr(0, 2);
			strMonth = strDate.substr(2, 2);
			strYear = strDate.substr(4);
	   }
	}
	if(strYear.length == 2)
	{
		strYear = '20' + strYear;
	}

	// US style
	if(strDatestyle == "US")
	{
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
	}
	intday = parseInt(strDay, 10);
	if(isNaN(intday))
	{
		err = 2;
		return false;
	}
	intMonth = parseInt(strMonth, 10);
	if(isNaN(intMonth))
	{
		for(i = 0; i < 12; i++)
		{
			//if(strMonth.toUpperCase() == strMonthArray[i].toUpperCase())
			if(strMonth.toUpperCase() == strMonthArray[i])
			{
				intMonth = i + 1;
				strMonth = strMonthArray[i];
				i = 12;
		   }
		}
		if(isNaN(intMonth))
		{
			err = 3;
			return false;
	   }
	}
	intYear = parseInt(strYear, 10);
	if(isNaN(intYear))
	{
		err = 4;
		return false;
	}
	if(intYear < 1900 || intYear > 2078)
	{
		err = 4;
		return false;
	}
	if(intMonth > 12 || intMonth < 1)
	{
		err = 5;
		return false;
	}
	if((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || 
		intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))
	{
		err = 6;
		return false;
	}
	if((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && 
		(intday > 30 || intday < 1))
	{
		err = 7;
		return false;
	}
	if(intMonth == 2)
	{
		if(intday < 1)
		{
			err = 8;
			return false;
		}
		if(LeapYear(intYear) == true)
		{
			if(intday > 29)
			{
				err = 9;
				return false;
			}
		}
		else
		{
			if(intday > 28)
			{
				err = 10;
				return false;
			}
		}
	}
	if(strDatestyle == "US")
	{
		datefield.value = strMonthArray[intMonth - 1] + "/" + intday + "/" + strYear;
	}
	else
	{
		datefield.value = intday + "." + strMonthArray[intMonth - 1] + "." + strYear;
	}
	return true;
}

function LeapYear(intYear)
{
	if(intYear % 100 == 0)
	{
		if(intYear % 400 == 0) { return true; }
	}
	else
	{
		if((intYear % 4) == 0) { return true; }
	}
	return false;
}

function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}


var MaxLengthLock = false;

function MaxLengthCount(fieldObj,fieldMaxLength)
{

  if (!MaxLengthLock)
  {
    MaxLengthLock = true;
    if (fieldObj.value.length > fieldMaxLength)
    {
      alert("Text nesmí být delší než " + fieldMaxLength + " znaků!");
      fieldObj.value = fieldObj.value.substring(0,fieldMaxLength);
    }
    var percentage = parseInt(100 - (( fieldMaxLength - fieldObj.value.length) * 100)/fieldMaxLength);
    MaxLengthLock = false;
  }
}

var strContentElBarto;
function InsertFCK(strContent){
	strContentElBarto = strContent;
	var msg = window.open('ShowOneElbarto.asp','EditWindow','toobar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=700,height=550,left=20,top=20');
	msg.focus();
}

function InsertFCKComp(strContent){
	strContentElBarto = strContent;
	var msg = window.open('../ShowOneElbarto.asp','EditWindow','toobar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=700,height=550,left=20,top=20');
	msg.focus();
}


function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}

function changeEditPart (obj, lang, langCount){
  
  	for(var i = 1; i < langCount + 1; i++){
		  getE('editPart' + i).style.display = "none";    
      getE('langButt' + i).className = "";
      
		}
        
    getE('editPart' + lang).style.display = "";
    obj.className = "sel";

}



function poziceElementu(el)
{
	if (el.offsetParent)
	{
		var vystup=new Array(el.offsetLeft,el.offsetTop);
		while(el=el.offsetParent)
		{
			vystup[0]+=el.offsetLeft;
			vystup[1]+=el.offsetTop;
		}
		return vystup;
	}
}
function ShowCalendar(oid,pozice)
 {
  var cal = document.getElementById('divcal');
  var calframe = document.getElementById('diviframcal');
  var tbox;
  if(typeof(oid).toLowerCase()=='string')
  {
  	tbox = document.getElementById(oid);
  }
  else
  {
  	tbox = oid;
  }
  var ssrc = '/administration/Calendar_inc.asp?el=' + oid + '&selDate=' + tbox.value;

  if(pozice==undefined)
  {
  	cal.style.top = (tbox.offsetTop + tbox.offsetHeight)>52?(tbox.offsetTop + tbox.offsetHeight):"52";
  	    // 52px je vysoka hlavicka s menuem
  	cal.style.left = tbox.offsetLeft;
  }
  else
  {
  	var Left = pozice[0]-210;
  	var Top = pozice[1]-160;
  	if (Top<52){Top = 52;}
  	if (Left<0){Left = 0;}
  	cal.style.top = Top + 'px';
   	cal.style.left = Left + 'px';
  }

  calframe.src = ssrc;
  cal.style.display = 'block';
 }

$(document).ready(function() {

  $("#DelOnePic").click(function () {
  
    var sImgName = $("#DelPicName").val();
    if (sImgName == "") {alert("Zadejte název obrázku."); return false;}
  
         $.ajax({
             type: "GET",
             url: "/Administration/FotoCacheDelete.aspx",
             cache: false,
             async: false,
             data: ({sImgName: sImgName}),
             dataType: "html",
            beforeSend: function() {
                  $("#loadInfo").show();
              },
             error: function () {
                    alert("Chyba při mazání obrázku.");
                    $("#loadInfo").hide();  
                    return false;
             },
             success: function (data) {
                $("#loadInfo").hide();
                if (data != "") {
                    alert(  );
                    return false;
                }
             }
         });
  });


});

