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.IE7 = (this.VER.indexOf("MSIE 7") > -1 && this.DOM && !this.OP) ? true : false;
	this.IE8 = (this.VER.indexOf("MSIE 8") > -1 && this.DOM && !this.OP) ? true : false;
	this.IE9 = (this.VER.indexOf("MSIE 9") > -1 && this.DOM && !this.OP) ? true : false;
  this.IEto8 = (this.IE4 || this.IE5 || this.IE6 || this.IE7 || this.IE8);
	this.IE = (this.IE4 || this.IE5 || this.IE6 || this.IE7 || this.IE8 || this.IE9);

	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;
}


// ###   FCE PRO DIALOG ZADANI VOLITELNYCH PARAMETRU   ###
var gsFormSuffix, gsFormIndex;

function BoxImgWidthCheck(obj){
	obj.style.display="block";
	if(obj.offsetWidth > 130){
		obj.style.width="130";
	}
	
}

function EmailControlRegExp(sEmail, bShowMsg)
 {

	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('Nesprávný formát emailu');
        return false;
  }else{
		return true
  }
}

function MenuAssign(objFrom, objTo, objValues, nAdding){

	if (objFrom.selectedIndex<0) {return;}
	var oOption = document.createElement("OPTION");

	oOption.text=objFrom.item(objFrom.selectedIndex).text;
	oOption.value=objFrom.value;
	objTo.options.add(oOption);
   
	for(var i = 0; i < objFrom.length;i++){
		if(i == objFrom.selectedIndex){
		objFrom[i] = null;
		}
	}

	if (nAdding==1){
		objValues.value+=oOption.value+", ";
	}else{
		objValues.value+=objValues.value.replace(oOption.value+", ", "");
	}
}

function BuyOrSetVariableParams(sFormSuffix, sFormIndex, nPrice, gifts, sType) 
{
	var sSelects, nWindowHeight, el, sGifts;
	gsFormIndex = sFormIndex;
	gsFormSuffix = sFormSuffix;
	var posX, posY;
	var arrGiftPart, arrRadio = new Array(), arrRadioPopisek = new Array(), arrRadioLabel = new Array();
	//var br_ = document.createElement("div")
	var x = 0;
	
	var objBuyForm = document.forms["BuyForm" + sFormSuffix + sFormIndex];
	
	sSelects = document.getElementById("DivForPars" + sFormSuffix + sFormIndex).innerHTML;
	
	document.getElementById('giftlists').innerHTML = "";
	if(nPrice != 0 && sType == 'standart')
  {
		
		if(arrGifts){
			
			for(i=0;i < arrGifts.length;i++){
				
				arrGiftPart = arrGifts[i].split("|");
				//alert(nPrice > arrGiftPart[2] && nPrice < arrGiftPart[3]);
				//alert(nPrice > arrGiftPart[2] && nPrice < arrGiftPart[3]);
				if(nPrice > arrGiftPart[2] && nPrice < arrGiftPart[3] && gifts.indexOf('~'+ arrGiftPart[0].toLowerCase() +'~') != -1) {	
					//OMFG POSRANE IE
					if(false && Br.IEto8)
          {
						arrRadio[x]	=  document.createElement("<input name='gift' />");
						arrRadioLabel[x] = document.createElement("<label for='" + arrGiftPart[0] + "'></label>");
					}else{
						arrRadio[x]	=  document.createElement("input");	
						arrRadio[x].setAttribute('Name','gift');
						arrRadioLabel[x] = document.createElement("label");
						arrRadioLabel[x].setAttribute("for", arrGiftPart[0]);
					}
					arrRadio[x].setAttribute('id', arrGiftPart[0]);
					arrRadio[x].setAttribute('type', "radio");
					arrRadio[x].setAttribute('value', arrGiftPart[0]);
					
					//naplne text
					arrRadioPopisek[x]  = document.createTextNode(arrGiftPart[1]);
					//dame do labelu a nastavime pro co
					arrRadioLabel[x].appendChild(arrRadioPopisek[x]);
					//pridame 
					document.getElementById('giftlists').appendChild(arrRadio[x]);
					document.getElementById('giftlists').appendChild(arrRadioLabel[x]);
					document.getElementById('giftlists').innerHTML += "<br />";
					
					x += 1;
				}
			}
		}
    }
    else if(sType == 'disc')
    {
  
  		if(arrGifts){
  			
  			for(i=0;i < arrGifts.length;i++){
  				
  				arrGiftPart = arrGifts[i].split("|");
  				//alert(nPrice > arrGiftPart[2] && nPrice < arrGiftPart[3]);
  				//alert(nPrice > arrGiftPart[2] && nPrice < arrGiftPart[3]);
  				if(nPrice > arrGiftPart[2] && nPrice < arrGiftPart[3] && arrGiftPart[4] == 'disc'){	
  					//OMFG POSRANE IE
  					if(false && Br.IEto8){
  						arrRadio[x]	=  document.createElement("<input name='gift' />");
  						arrRadioLabel[x] = document.createElement("<label for='" + arrGiftPart[0] + "'></label>");
  					}else{
  						arrRadio[x]	=  document.createElement("input");	
  						arrRadio[x].setAttribute('Name','gift');
  						arrRadioLabel[x] = document.createElement("label");
  						arrRadioLabel[x].setAttribute("for", arrGiftPart[0]);
  					}
  					arrRadio[x].setAttribute('id', arrGiftPart[0]);
  					arrRadio[x].setAttribute('type', "radio");
  					arrRadio[x].setAttribute('value', arrGiftPart[0]);
  					
  					//naplne text
  					arrRadioPopisek[x]  = document.createTextNode(arrGiftPart[1]);
  					//dame do labelu a nastavime pro co
  					arrRadioLabel[x].appendChild(arrRadioPopisek[x]);
  					//pridame 
  					document.getElementById('giftlists').appendChild(arrRadio[x]);
  					document.getElementById('giftlists').appendChild(arrRadioLabel[x]);
  					document.getElementById('giftlists').innerHTML += "<br />";
  					
  					x += 1;
  				}
  			}
  		}
      
	  }
				
	// ve skeletu musí být ve fci GetFormattedParams "ParamItem" psáno CASE-SENSITIVE !!!
	if (sSelects == "" && x == 0) {
		objBuyForm.submit();
	} else {
		if(sSelects != ""){
			var divtocopy = document.getElementById('paramlists');
			divtocopy.innerHTML = "";
			divtocopy.innerHTML = sSelects;
			document.getElementById('header1').innerHTML = "<b>Výběr parametrů k výrobku</b>";
		}
		if (x > 0){
		document.getElementById('header2').innerHTML = "<strong>Výběr dárku</strong>";
		}
		
		posY = mY;//--prevzate pozice mysi z jquery funkce -- //(findPosY(document.getElementById('Position' + sFormSuffix + sFormIndex)) - 50);
		posX = mX;//findPosX(document.getElementById('Position' + sFormSuffix + sFormIndex));
		
		if(Br.IE7){
			//posX = posX - 210;
		}
		
		document.getElementById('ParamCaption').innerHTML = 'Nákupní dialog';
    document.getElementById('ParamTbl').style.zIndex = 999;
		document.getElementById('ParamTbl').style.position = "absolute";
		document.getElementById('ParamTbl').style.top =  (posY-50) + 'px';
		document.getElementById('ParamTbl').style.left = (posX - 100) + 'px';
		document.getElementById('ParamTbl').style.display = 'block';		
	}
}

function getF(formName) {
	return document.forms[formName];
}

function CopyParamsBack() {
	//alert('ga');
	var objFormParams		= document.forms['BuyForm' + gsFormSuffix + gsFormIndex]; //.ParamItem
	var objRadios			= document.forms['giftchanger'].gift;
	var checkedcode = "";
	
	if(document.getElementById('paramlists').innerHTML != ""){
		var objFormParamsTemp	= document.forms['paramchanger'];//.ParamItem
		if (objFormParamsTemp){
			for (i = 0;i < objFormParamsTemp.length;i++){
				if (objFormParamsTemp.length == 1){
					objFormParams.ParamItem.selectedIndex = objFormParamsTemp.ParamItem.selectedIndex;
				}else{
          if (objFormParams.ParamItem[i] != null) {
					   objFormParams.ParamItem[i].selectedIndex = objFormParamsTemp.ParamItem[i].selectedIndex;
          }	
				}
			}
		}
	}
	
	if(objRadios){
	if(!objRadios.length){
		if(objRadios.checked){checkedcode = objRadios.value;}
	}else{
		for(y = 0;y < objRadios.length;y++){if(objRadios[y].checked){checkedcode = objRadios[y].value;}}	
	}
	
  	if(checkedcode.length > 0)
    {
      if(getE('BuyForm' + gsFormSuffix + gsFormIndex))
  		  getE('BuyForm' + gsFormSuffix + gsFormIndex).value = checkedcode;
      if(getE('sGiftCode'))
  		  getE('sGiftCode').value = checkedcode;
  	}
	}
	
	
	document.getElementById('ParamTbl').style.display='none';
  if(getE('frmBuyForm' + gsFormSuffix + gsFormIndex))
	 getE('frmBuyForm' + gsFormSuffix + gsFormIndex).submit();
  else
    document.forms['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 findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			//alert(obj.tagName);
			//alert(curleft);
			//alert(obj.offsetParent);
			//alert(obj.offsetParent.tagName);
			//alert(obj.offsetLeft);
			//alert(obj.offsetParent.offsetLeft);
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
		return curleft;
	
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
		return curtop;
}


function outlineCat() {    
	var open = event.srcElement;
	var el = checkParent(open, "TD");
	if (null!=el) {
		var pos = 0;
		for (var pos=0; pos<el.children.length; pos++) {
			if ("TABLE"==el.children[pos].tagName) {
				if (el.children[0].src.indexOf("/img/catTree/plus.gif")>0) {
					el.children[0].src = "/img/catTree/minus.gif";
				}else{
					el.children[0].src = "/img/catTree/plus.gif";
				}
				break;
			}
		}
	    if (pos==el.children.length) return;
	} else return;
	el = el.children[pos];
	if ("TABLE"==el.tagName) {
		if (""==el.style.display) {
			el.style.display = "none";
		} else {
			el.style.display = "";
		}
	}
	event.cancelBubble = true;
}

// ###   FCE PRO PriceList ###

function SHModalDlgPricelist()
{
	var strReturn = showModalDialog("/Includes/EmailPricelist.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=320px;dialogHeight=124px;");

    if (strReturn == "") return;
	document.location.href = "/EmailPricelist.asp?EmailPricelist=" + strReturn;
}

// ##########

function onAction(imgName){
       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=au,width=400,left=10,top=10");
	objWnd.focus();
}

function OpenWndM(strURL){
	var objWnd = window.open(strURL,"InfoDetail","scrollbars=yes,left=10,top=10");
	objWnd.focus();
}

function OpenWndSizeable(strUrl, width, height){
	//var adds = 
	var objWnd = window.open(strUrl,"","scrollbars=yes,height=" + height + ",width=" +width +  ",left=10,top=10");
	objWnd.focus();
}

function AddBuy(strName, intPrice, intDph, strCode) {
	var strData,strReturn
	strData = strName+"&"+intPrice+"&"+intDph+"&"+strCode
	strReturn = showModalDialog("/AddUpdBuy.asp",strData,"status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=200pt");
	if (strReturn == "1")
		ActionCookies('BZbuy');
	else if (strReturn == "2")
		window.location.href = "/order.asp";
}
function AddBuyDetail(strName, intPrice, intDph, strCode) {
	var strData,strReturn
	strData = strName+"&"+intPrice+"&"+intDph+"&"+strCode
	strReturn = showModalDialog("/AddUpdBuy.asp",strData,"status:no; center:yes; help:no; minimize:no;dialogWidth=350pt;dialogHeight=200pt");
	if (strReturn == "1"){
		window.opener.ActionCookies('BZbuy')
	}else if (strReturn == "2"){
		window.opener.location.href="/order.asp";
		window.close();
	}
}
function ActionCookies(strName){
	var strString,strSum1,strSum2,intSuma;
	strSum2 = new Array();
	intSuma = 0;

	strString = ExtractCookies(strName);
	if (strString > ""){
		strSum1 = strString.split("#");
		for (var i=0; i< strSum1.length-1; i++){
			strSum2[i] = strSum1[i].split("&");
			intSuma += BarterComma(strSum2[i][1])*BarterComma(strSum2[i][4]);
		}
		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 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(){
     if ((event.keyCode <48) || (event.keyCode >57)) event.returnValue = false;
}
//----------info okno-------------------------------------------------------
function InfoWindow(strAddress) {
       showModalDialog(strAddress,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=450pt;dialogHeight=320pt");
}
function WriteDate(){
	var strDay=new Date();
	var d=strDay.getDay();
	if (d==1) document.writeln('pondělí');
	else { if (d==2) document.writeln('úterý');
	else { if (d==3) document.writeln('středa');
	else { if (d==4) document.writeln('čtvrtek');
	else { if (d==5) document.writeln('pátek');
	else { if (d==6) document.writeln('sobota');
	else { if (d==0) document.writeln('neděle'); }}}}}};
	document.writeln(strDay.getDate(),'.',strDay.getMonth()+1,'.',strDay.getFullYear());
	}
function 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('Nesprávný formát emailu');
		return false;
		}
	return true;
}
function ShowSearchMenu(x){
    if (x == 1){
        document.all.SearchTable.style.display='';
    }else{
        document.all.SearchTable.style.display='none';
    }
}
function LocInfo(){
	document.all.StateInfo2.innerHTML="  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="  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?ID="+strCode+"&CN="+intCount
	PositionInfo("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 ControlDetailSend()
{
  var ret = true;
  var msg = '';
  if(getE('email_from').value == '' || !EmailControlRegExp(getE('email_from').value, 0)){msg+= 'Zadejte Váš e-mail!\nVe správném formátu.\n\n'; ret = false; }
  if(getE('email_to').value == '' || !EmailControlRegExp(getE('email_to').value, 0)){msg+= 'Zadejte e-mail adresáta!\nVe správném formátu.\n\n'; ret = false; }
  if(getE('body').value == ''){msg+= 'Zadejte text zprávy!\n\n'; ret = false; }
  
  if(!ret)
    alert(msg);
    
  return ret;
}

function ControlUserDataSubmit(){
	if(document.UserDataForm.FirstName.value == "" ||document.UserDataForm.LastName.value == ""){alert("Vyplňte jméno a příjmení.");return false}
	if(document.UserDataForm.Street.value == ""){alert("Vyplňte ulici.");return false}
	if(document.UserDataForm.City.value == ""){alert("Vyplňte město.");return false}
	if(document.UserDataForm.ZipCode.value == ""){alert("Vyplňte PSČ.");return false}
	//if(document.UserDataForm.Phone.value == ""){alert("Vyplňte telefon.");return false}
	if(document.UserDataForm.Email.value == ""){alert("Vyplňte email.");return false}
	if(document.UserDataForm.Login.value == ""){alert("Vyplňte přihlašovací jméno.");return false}
	if(document.UserDataForm.Login.value.length < 5){alert("Přihlašovací jméno musí mít minimálně 5 znaků.");return false}
	if(document.UserDataForm.Password.value == ""){alert("Vyplňte heslo.");return false}
	if(document.UserDataForm.Password.value.length < 5){alert("Heslo musí mít minimálně 5 znaků.");return false}
	return true
}

function ControlUserDataOrderSubmit(){
	if(document.UserDataForm.FirstName.value == "" ||document.UserDataForm.LastName.value == ""){alert("Jméno a příjmení.");return false}
	if(document.UserDataForm.Street.value == ""){alert("Vyplňte ulici.");return false}
	if(document.UserDataForm.City.value == ""){alert("Vyplňte město.");return false}
	if(document.UserDataForm.ZipCode.value == ""){alert("Vyplňte PSČ.");return false}
	if(document.UserDataForm.Email.value == ""){alert("Vyplňte email.");return false}
	if(document.UserDataForm.DeliveryType.value == "-"){alert("Vyberte způsob dopravy.");return false}
	if(document.UserDataForm.PaymentType.value == "-"){alert("Vyberte způsob platby.");return false}
	return true
}

function ControlDataOrder(){
	if(document.OrderForm.DeliveryType.value == "-"){alert("Vyberte způsob dopravy.");return false}
	if(document.OrderForm.PaymentType.value == "-"){alert("Vyberte způsob platby.");return false}
	return true;
}

function ControlPriceList(){

  if(document.formCenik.strCategory1.value == ""){alert("Zvolte kategorii.");return false}
  
  return true
}

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('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 SwitchLogin(){
		//document.getElementById('FirstShow').style.display = "none";
		//document.getElementById('FirstHidden').style.display = "block";
		document.getElementById('FirstShow').innerHTML = document.getElementById('FirstHidden').innerHTML;
		document.getElementById('FirstHidden').innerHTML = "";
}
function ChangeInnerHtmlCategory(obj){
	if (document.getElementById('m'+obj)){
		var img = document.getElementById('i'+obj).src;
		var oldInnerHtml = document.getElementById('r'+obj).innerHTML;
		//hodime zpravny obrazek
		document.getElementById('m'+obj).src = img;
		//a zobrazime a vymenime html aby to mohlo donekonecna se prohazovat
		document.getElementById('r'+obj).innerHTML = document.getElementById('h'+obj).innerHTML;
		document.getElementById('h'+obj).innerHTML = oldInnerHtml;
	}
}
function SortUpDown(Value, form){
	//alert(form);
	//var objForm = document.forms.PNsort[0];
	form.SORT.value = Value;
	form.submit();
}
function openWndImage(sImage,sParams)
{
	var obj=window.open('/viewImage.asp?img=' + sImage,'',sParams);
	obj.focus();
}
function OpenDisabledBuyInfo(sName){
	OpenWnd('/includes/notbuy.asp?ComName='+sName);
}
function ShowImage(sImgPath) {
		window.open('/ShowImage.asp?IMG=' + sImgPath, "Foto","scrollbars=0,status=0,toolbar=0,location=0,directories=0,height=100,width=100,resizable=1");
}

String.prototype.trim = function() { return this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, ''); }
function getE(objectID) { return document.getElementById(objectID); }
function getTN(sValue) { if (sValue == '' || sValue == ' ') { return document.createTextNode('\u00a0'); } return document.createTextNode(sValue); }
function getCE(sElement) { return document.createElement(sElement); }
function RemoveCh(Node) { if (Node == null) return false; while (Node.childNodes.length > 0) { Node.removeChild(Node.childNodes[0]); } }
function GetSRC(e) { return (window.event) ? window.event.srcElement : e.target; }
function setE(id, attr, value) { var el = getE(id); if (el != null) { el[attr] = value; } }

// *************************************************************************************************

// status, args nechany z duvodu kompatibility
function showMyModalDialog(url, title, sizeX, sizeY, status, args, top) //top znaci jak daleko od vrchu okna
{
    var wo = document;
    var frameID = '';
    if (window != window.top) {
        wo = window.top.document;
        frameID = window.self.name;
    }

    if (getE('modalIframe')) { return; }

    if (Br.IE6) {
        var clona = wo.createElement('iframe');
        clona.id = 'clona';
        clona.src = '/administration/clonaIE6.htm';
        wo.body.appendChild(clona);
    }
    else {
        var div = wo.createElement('div');
        div.id = 'clona';
        wo.body.appendChild(div);
    }


    var clona = wo.createElement('div');
    clona.id = 'clona1'; // margin nelze pouzit, bug v IE

    url += ((url.indexOf("?") > -1) ? "&" : "?") + "title=" + title + "&frameID=" + frameID;

    clona.innerHTML = "<iframe name='modalIframe' id='modalIframe' width='" + sizeX + "' height='" + sizeY + "' frameborder='0' scrolling='auto' src='" + url + "'></iframe>";

    wo.body.appendChild(clona);
    if (top !== undefined) {
        wo.getElementById('modalIframe').style.top = top;
    }
}


function prmtest(id, value) {
    params_1.newValueReturn(id, value);
}
function CloseMyModalDialog() {

    if (window.top.document.getElementById('clona1') && window.top.document.getElementById('clona')) {
        window.top.document.body.removeChild(getE('clona1'));
        window.top.document.body.removeChild(getE('clona'));
    }
}


function tp(el)
{

  var element = getE('tooltipX');
  var content = 'TEST';
  new Effect.Tooltip(element, content, {title : 'title', className: 'class', offset: {x:0, y:0}});

}

