//zjisteni IE prohlizece a dany do globalni promenne
var IE= null;
var ua = navigator.appName.toLowerCase();
if(ua.indexOf('explorer')>-1 ) {IE=true;}
var objItem;
//pozice posledniho kliku----------------------------
var oClientX = 0;
var oClientY = 0;
//posunuti abs prvku podle poctu sloupcu
var intDistCol = 0;
//------hlidani zmeny---------------
var gnCh = 0;
function RunOnBeforeUnload(){
	if (gnCh == 1){window.event.returnValue = 'Pravděpodobně jste změnili data na této stránce. Aby změny vstoupily v platnost, musíte data uložit. Opačném případě se data neuloží.';}
}
//--------------------------------------
function NonDiacritic(strText){
	
	var strDiak = "áäčďéěíĺľňóô öŕšťúů üýřžÁÄČĎÉĚÍĹĽŇÓÔ ÖŔŠŤÚŮ ÜÝŘŽ"; 
	var strNonDiak = "aacdeeillnoo orstuu uyrzAACDEEILLNOO ORSTUU UYRZ";
	var strResult = ""; 

	for(var i = 0; i < strText.length; i++){ 
		if (strDiak.indexOf(strText.charAt(i)) != -1){ 
			strResult += strNonDiak.charAt(strDiak.indexOf(strText.charAt(i))); 
		}else{
			strResult += strText.charAt(i); 
		}
	} 
	return strResult; 
} 

//--------------------------------------
function RunPositionH1(intBodyWidth){
  if(objGet('itemH1') != null){
//     objGet('itemH1').style.left = (objGet('MainContentTest').offsetLeft+183).toString() + "px";
  if(document.body.offsetWidth > intBodyWidth){

        if(IE){
            objGet('itemH1').style.left = (((document.body.offsetWidth-intBodyWidth)/2)+188).toString() + "px";
          }else{
            objGet('itemH1').style.left = (((document.body.offsetWidth-intBodyWidth)/2)+179).toString() + "px";
          }
     }
     else{
        objGet('itemH1').style.left = (188).toString() + "px";
     }
 }
}

function QueryStatusScript(){
	if(EmailControl(QueryStatusForm.email.value) && objGet('QueryStatusForm').notice.value.indexOf('http://') < 0 ){
		objGet('QueryStatusForm').action = 'QueryOnlineStatus.asp';
		objGet('QueryStatusForm').submit();
	}
}
function SelectHidden(intAction){
	if(IE){
		if(navigator.appVersion.indexOf('MSIE 7') < 0){
			var allObjects = document.getElementsByTagName("select");
			for (var i = 0; i < allObjects.length; i++){
				if(intAction == 1){allObjects[i].style.visibility = 'hidden'}
				if(intAction == 2){allObjects[i].style.visibility = 'visible'}
			}
		}
	}
}
function ControlScript(strScript,strValue,strId){
	window.frames['WinStat'].location.href='/'+strScript+'.asp?value='+strValue+'&amp;id='+strId;
}
//--registrace firma-koncak--------
function FZ_show(intAction){
	var i;
	var objTag;
	objTag = document.getElementsByTagName("*");
	if(intAction == 0){
		for(i = 0; i < objTag.length; i++){
			if(objTag[i].className == 'FZ_show'){objTag[i].className = 'FZ_hidden'}
			if(objTag[i].className == 'FZ_show_r'){objTag[i].className = 'FZ_hidden_r'}
			if(objTag[i].className == 'ZF_hidden'){objTag[i].className = 'ZF_show'}
		}
	}else{
		for(i = 0; i < objTag.length; i++){
			if(objTag[i].className == 'FZ_hidden'){objTag[i].className = 'FZ_show'}
			if(objTag[i].className == 'FZ_hidden_r'){objTag[i].className = 'FZ_show_r'}
			if(objTag[i].className == 'ZF_show'){objTag[i].className = 'ZF_hidden'}
		}
	}
}
//--zakladni dialogovy box---------------
var gstrDialogText = "";
function winH() {
   if (window.innerHeight)
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      return document.body.clientHeight;
   else
      return screen.height;
}
function winW() {
   if (window.innerWidth)
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      return document.body.clientWidth;
   else
      return screen.width;
}
function ActualSize(){
	oHeight = winH();
	oWidth = winW();
}
function DialogClear(){
	objGet('Dialog').className = 'Dialog'
	objGet('DialogSub').innerHTML = "";
	gstrDialogText = "";
	SelectHidden(2);
}
function LoginDialogClear(){
	objGet('LoginDialog').className = 'LoginDialog'
//	objGet('DialogSub').innerHTML = "";
	gstrDialogText = "";
	SelectHidden(2);
}
function StandartDialog(strText){
	if(gstrDialogText.length == 0){
		gstrDialogText = strText;
	}else{
		gstrDialogText = gstrDialogText + "<br /><br />" + strText;
	}
	strText = strText.replace('\n','<br />')
	var strTextDialog = '<div class="tac" id=""DialogTemp"">' + gstrDialogText + '</div><br />';
	Dialog(0,0,7,strTextDialog,2,250,'');
}
function Dialog(oX,oY,intTypXY,strText,intButt,intWidth,strScript){
    var y = 0;
    var x = 0;
    SelectHidden(1);
	if(intTypXY == 1){
        if (IE){
                var e = event.srcElement;
                while (typeof e == 'object' && e.tagName != 'BODY'){
                        y += e.offsetTop;
                        x += e.offsetLeft;
                        e = e.offsetParent;
                };
        }else{
                var y = oY + document.documentElement.scrollTop;
                var x = oX - 60;
        }
        x = (x).toString() + "px"
        y = (y-140).toString() + "px"
	}else if(intTypXY == 2){
		if (IE){
			var y = oY + document.documentElement.scrollTop;
			var x = oX;
			x = (x).toString() + "px"
			y = (y).toString() + "px"
		}else{
			var y = oY + 50 + document.documentElement.scrollTop;
			var x = oX;
			x = (x).toString() + "px"
			y = (y).toString() + "px"
		}
	}else if(intTypXY == 3){
		if (IE){
			var y = oY;
			var x = oX;
			x = (x).toString() + "px"
			y = (y).toString() + "px"
		}else{
			var y = oY;
			var x = oX;
			x = (x).toString() + "px"
			y = (y).toString() + "px"
		}
  }else{
    	ActualSize()
    	oX = oWidth;
    	oY = oHeight;
        x = ((oX-intWidth)/2).toString() + "px"
        y = ((oY/3) + document.documentElement.scrollTop).toString() + "px"	    
    }

	if(intButt == '1'){
		strText = strText + '<div class="tac"><input type="button" value="ANO" onclick="' + strScript + '" class="inpGreenSm w80" /> <input type="button" onclick="DialogClear();" value="NE" class="inpGreySm w80" /></div>';
	}
	if(intButt == '2'){
		strText = strText + '<div class="tac"><input onclick="DialogClear();" id="buttFocus" type="button" value="OK" class="inpGreenSm w80" /></div>';
	}
	if(intButt == '3'){
		strText = strText + '<div class="tac"><input type="button" value="ANO" onclick="DialogClear();" class="inpGreenSm w80" /> <input type="button" value="NE" onclick="' + strScript + '" class="inpGreySm w80" /></div>';
	}
	if(intButt == '4'){
		strText = strText + '<div class="tac"><input type="button" value="OK" onclick="' + strScript + '" class="inpGreenSm w80" /> <input type="button" value="Zavřít" onclick="DialogClear();" class="inpGreySm w80" /></div>';
	}
	if(intButt == '5'){
		strText = strText + '<div class="tac"><input type="button" value="ANO" onclick="DialogClear();" class="inpGreySm w80" /> <input type="button" value="NE" onclick="' + strScript + '" class="inpGreySm w80" /></div>';
	}
	if(intButt == '6'){
		strText = strText + '<div class="tac"><input onclick="' + strScript + '" type="button" value="OK" class="inpGreenSm w80" /></div>';
	}
    intWidth = intWidth.toString() + "px";

	objGet('DialogSub').style.width = intWidth;
	objGet('DialogSub').innerHTML = strText;
    objGet('Dialog').style.top = y;
	objGet('Dialog').style.left = x;
	objGet('Dialog').className = 'DialogActiv'
	if(objGet('buttFocus')){objGet('buttFocus').focus()};
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;

}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

var gbODShowed = 0;
var goOD;
var gnODTimer = 100;
function showorderdialog(obj, txt, x, y, type, close, url, width, scriptYes, scriptNo, title, e) {

    //vycistime zavirani aby se nam to neschovalo
    if (goOD) { clearTimeout(goOD); goOD = null }
    objGet('orderdialogsub').setAttribute("class", "");

    if (!width) { width = 285; }

    if (type == 1) { objGet('orderdialogsub').setAttribute("class", "store"); }
    if (type == 2) {
        objGet('orderdialogsub').setAttribute("class", "alert");
        objGet('orderdialogsub').onmouseout = "";
    } else {
        if (type == 4) {objGet('orderdialogsub').setAttribute("class", "store");objGet('orderdialogsub').onmouseout = "";} else {objGet('orderdialogsub').onmouseout = function() { goOD = setTimeout(function() { gbODShowed = 0; closeorderdialog(); }, gnODTimer) }}
    }
    if (type == 3) { objGet('orderdialogsub').setAttribute("class", "store"); }
    //pokud je obj na pozicionovani vemem to podle nej v opacnem pripade to tepnem doprostred okna
    if (obj) {
        x = findPosX(obj) + x;
        y = findPosY(obj) + y;
    } else {
        y = y + winH();
        x = x + winW();
        x = ((x - width) / 2).toString();
        y = ((y / 3) + document.documentElement.scrollTop).toString();
    }
    //zaviraci butonky popr ze svym skriptem
    if (close == 1) { txt += '<div><input type="button" value="OK" onclick="objGet(\'orderdialog\').style.display = \'none\'" class="inpGreySm" /></div> ' }
    if (close == 2) { txt += '<div class="tac"><input type="button" value="OK" onclick="' + url + '" class="inpGreySm" /></div> ' }
    if (close == 3) { txt += '<div class="tac"><input type="button" value="ANO" onclick="objGet(\'orderdialog\').style.display = \'none\';' + scriptYes + '" class="inpGreenSm" />&nbsp;&nbsp;&nbsp;<input type="button" value="NE" onclick="objGet(\'orderdialog\').style.display = \'none\';' + scriptNo + '" class="inpGreySm" /></div> ' }
    if (close == 5) { txt += '<div><input type="button" value="Zavřít" onclick="objGet(\'orderdialog\').style.display = \'none\'" class="inpGreySm" /></div>' }
    //z titulkem
    if (type == 4 && title) {
        objGet('orderdialogsub').className = 'wtitle store';
        title = '<div class="title">' + title + '</div><img src="/img/inp-ord-dialog-close.gif" onclick="objGet(\'orderdialog\').style.display = \'none\'" alt="Zavřít" class="inp-close"  />'; objGet('orderdialogsub').innerHTML = title + '<div class="padd">' + txt + '</div>'
    } else {
        objGet('orderdialogsub').innerHTML = txt;
    }

    objGet('orderdialog').style.display = 'block';

    // uprava aby se to zobrazovalo spise jako napoveda tzn nad prvkem
    if (type == 1 || !type) {
        if (obj) {
            var yadd = objGet('odtop').offsetTop - objGet('odbottom').offsetTop;
            y += yadd;
            y += -32;
        }
    }
    if (width) {
        $('#o-top').css("width", width - 20);
        $('#orderdialog').css("width", width);
    }

    // samotne zobrazeni nahodime na pozici pribalime textik a zobrazime
    objGet('orderdialog').style.top = y + 'px';
    objGet('orderdialog').style.left = x + 'px';
    // gbODShowed = 1;

    //esc klavesa
    document.onkeyup = function(e) {
        if (e == null) { keycode = event.keyCode; } else { keycode = e.which; }
        if (keycode == 27) { gbODShowed = 0; closeorderdialog(e); }
    }
}

function closeorderdialog(o) {
    if (gbODShowed == 0) {
        objGet('orderdialog').style.display = 'none';
        clearTimeout(goOD); goOD = null;
        if (o) {o.className = '';}
    }
}

function akinfo() {
    var odiv = objGet('akdiv');
    var oimg = objGet('akimg');
    if (odiv.style.display == 'block') {
        odiv.style.display = 'none';
        //oimg.src = '/img/inp-order-akinfo-close.gif';
    } else {
        odiv.style.display = 'block';
        //oimg.src = '/img/inp-order-akinfo-close.gif';
    }
}

function ShowTitle2(idText, strCount, id) {

    var text = new Array();
    text[1] = gsKA01;
    text[2] = gsKA02;
    text[3] = gsKA03;
    text[9] = gsKA04;

    if (strCount.length > 0) { strCount = strCount + " " }

    text[4] = strCount + gsKB01;
    text[5] = strCount + gsKB02;
    text[6] = strCount + gsKB03;
    text[7] = strCount + gsKB04;
    text[8] = strCount + gsKB05;
    if (gstrTimeStock.length > 0) {
        //objGet('showElem').innerHTML = text[idText] + '<br />Aktualizováno dnes ' + gstrTimeStock;
        showorderdialog(objGet(id), text[idText] + '<br />Aktualizováno dnes ' + gstrTimeStock, -12, 19, true);
    } else {
        //objGet('showElem').innerHTML = text[idText];
        showorderdialog(objGet(id), text[idText], -12, 19, true);
    }
}


//--dialogovy box------------------
function DialogBox(oX, oY, intTypXY, idobj) {
    if (objGet('DialogBox').className == 'DialogBox') {

        var y = 0;
        var x = 0;

        if (intTypXY == 1) {
            if (IE) {
                var e = event.srcElement;
                
                while (e!= null && typeof e == 'object' && e.tagName != 'BODY') {
                    y += e.offsetTop;
                    x += e.offsetLeft;
                    e = e.offsetParent;
                };
                
            } else {
                var y = oY + document.documentElement.scrollTop;
                var x = oX - 60;
            }

            if (idobj != 'undefined') {
                y = findPosY(objGet(idobj));
                x = findPosX(objGet(idobj));
            }


            x = (x).toString() + "px"
            y = (y - 140).toString() + "px"
        } else {
            ActualSize()
	    	oX = oWidth;
	    	oY = oHeight;
	    	//280 aby to bylo na stredu.
	        x = ((oX - 280)/2).toString() + "px"
	        y = ((oY/3) + document.documentElement.scrollTop).toString() + "px"
        }

        objGet('DialogBox').style.top = y;
        objGet('DialogBox').style.left = x;


        objGet('DialogBox').className = 'DialogBoxActiv'
    } else {
        objGet('DialogBox').className = 'DialogBox'
    }
}
//--dotaz na online dostupnost----------
function GetQueryStatus(oX,oY){
	if(objGet('QueryStatus').className == 'QueryStatus'){
        if (IE){
                var e = event.srcElement;
                var y = 0;
                var x = 0;
                while (typeof e == 'object' && e.tagName != 'BODY'){
                        y += e.offsetTop;
                        x += e.offsetLeft;
                        e = e.offsetParent;
                };
        }else{
                var y = oY + document.documentElement.scrollTop;
                var x = oX - 60;
        }
        x = (x-175).toString() + "px"
        y = (y-140).toString() + "px"
        objGet('QueryStatus').style.top = y;
		objGet('QueryStatus').style.left = x;
		objGet('QueryStatus').className = 'QueryStatusActiv'
		objGet('EmailQuery').focus();
	}else{
		objGet('QueryStatus').className = 'QueryStatus'
	}
}
//---navigace zalozkami-----------------
function NextUrl(strNext,strActual){
	if(strActual.length == 0){
		window.location.href = strNext;
	}else{
	   try{
    		objGet('OrderForm').UrlNext.value = strNext;
    		objGet('OrderForm').AddUpdData.click();
	   }catch(e){
        window.location.href = strNext;  
     }
	}
	return false;
}
//---vrati top umisteni---------------------
function returnTop(strId){
	var y = 0;
	if(typeof objGet(strId) == 'object'){
		var objElem = objGet(strId);
		y = parseFloat(objElem.offsetHeight);
		while(typeof objElem == 'object' && objElem.tagName != 'BODY'){
			y += objElem.offsetTop;
			objElem = objElem.offsetParent;
		};
	}
	return y;
}
//---vrati top umisteni---------------------
function returnLeft(strId){
	var x = 0;
	if(typeof objGet(strId) == 'object'){
		var objElem = objGet(strId);
		x = parseFloat(objElem.offsetLeft);
		while(typeof objElem == 'object' && objElem.tagName != 'BODY'){
			x += objElem.offsetLeft;
			objElem = objElem.offsetParent;
		};
	}
	return x;
}
//---SSL logovani----------------------------
function SSLlog(boolCheck){
	if(boolCheck){
		objGet('LoginForm').action = 'https://www.alza.cz/Secure/LoginSSL.asp'
	}else{
		objGet('LoginForm').action = objGet('LoginForm').action;
	}
}
//------zobrazovani volby sloupcu-------------------------
//function ShowColButt(intAction){
//	if(intAction == 1){
//		if(IE){
	//		var x = returnLeft('ImgCountCol')-2;
//			var y = returnTop('ImgCountCol')+1;
//		}else{
//			var x = (returnLeft('ImgCountCol')/2);
//			var y = returnTop('ImgCountCol');		
//		}
//		x = x.toString();
//		x = x + "px";
//		y = y.toString();
//		y = y + "px";
//		objGet('ColButt').style.top = y;
//		objGet('ColButt').style.left = x;
//		ShowElement('ColButt');
//	}else{
//		setTimeout("HideElement('ColButt');",200);
//	}
//}

//------zobrazovani volby sloupcu-------------------------
var langTimeoutId = 0;

function ShowLangButt(){

	  if(langTimeoutId != 0){
	     clearTimeout(langTimeoutId);
	  }
	  
//Stare pozicovani	  
//	//	if(IE){
//	//		var x = returnLeft('ImgLangCol')-1355;
//	//		var y = returnTop('ImgLangCol')-5;
//	//	}else{
//			var x = (document.body.offsetWidth/2) + 410 + intDistCol;//(returnLeft('ImgLangCol')/2)-45;
//			var y = 20;returnTop('ImgLangCol')-2;		
//	//	}
//		x = x.toString();
//		x = x + "px";
//		y = y.toString();
//		y = y + "px";
//Nove zkusim pozicovat pomoci jQuery
		var pos = $("#ImgLangCol").offset();
		objGet('LangButt').style.top = pos.top + "px";
		objGet('LangButt').style.left = pos.left + "px";
		objGet('LangButt').style.display = 'block';
    //ShowElement('LangButt');

//		HideLangButt();

}

function HideLangButt(){
  langTimeoutId = setTimeout("objGet('LangButt').style.display = 'none';",250);
}

//------zobrazovani volby sloupcu-------------------------
var multiBasketTimeoutId = 0;

function ShowMultiBasket(){

	  if(multiBasketTimeoutId != 0){
	     clearTimeout(multiBasketTimeoutId);
	  }
	  
//		if(IE){
//			var x = returnLeft('multiBasketSelect')-1075;
//			var y = returnTop('multiBasketSelect')-10;
//		}else{
//			var x = (returnLeft('multiBasketSelect')/2)-115;
//			var y = returnTop('multiBasketSelect')-10;		
//		}
//		x = x.toString();
		var x, y;
		var pos = $("#multiBasketSelect").offset();
		x = pos.left + "px";
//		y = y.toString();
		y = pos.top+15 + "px";
		objGet('multiBasket').style.top = y;
		objGet('multiBasket').style.left = x;
		objGet('multiBasket').style.display = 'block';

}

function HideMultiBasket(){
  multiBasketTimeoutId = setTimeout("objGet('multiBasket').style.display = 'none';",250);
}

//------zobrazovani login-------------------------
var loginTimeoutId = 0;

function ShowLogin(){

	  if(loginTimeoutId != 0){
	     clearTimeout(loginTimeoutId);
	  }
	  
		if(IE){
			var x = returnLeft('loginButt')-95;
			var y = returnTop('loginButt');
		}else{
			var x = (returnLeft('loginButt')/2)-90;
			var y = returnTop('loginButt');		
		}
		x = x.toString();
		x = x + "px";
		y = y.toString();
		y = y + "px";
		objGet('loginForm').style.top = y;
		objGet('loginForm').style.left = x;
		objGet('loginForm').style.display = 'block';
		
		objGet('loginInp').focus();
    //ShowElement('LangButt');

//		HideLangButt();

}

function HideLogin(){
  loginTimeoutId = setTimeout("objGet('loginForm').style.display = 'none';",250);
}

//------zobrazovani volby sloupcu-------------------------
var colTimeoutId = 0;

function ShowColButt(){

	  if(colTimeoutId != 0){
	     clearTimeout(colTimeoutId);
	  }
	  var x, y;
//		if(IE){
//			var x = (document.body.offsetWidth/2) + 280 + intDistCol;
//			var y = 160;
//		}else{
//			var x = (document.body.offsetWidth/2) + 280 + intDistCol;
//			var y = 160;		
//		}
//		x = x.toString();
		var pos = $("#ImgCountCol").offset();
		x = pos.left + "px";
//		y = y.toString();
		y = pos.top+15 + "px";

		objGet('ColButt').style.top = y;
		objGet('ColButt').style.left = x;
		objGet('ColButt').style.display = 'block';
    //ShowElement('LangButt');

//		HideLangButt();

}

function HideColButt(){
  colTimeoutId = setTimeout("objGet('ColButt').style.display = 'none';",250);
}

//objGet('ColButt').style.display == 'none'
//---fakt adresa shodna s dodaci-------------
function invoicAddress(boolCheck){
	if(boolCheck){
		objGet('addressTab').style.display = 'none';
	}else{
		objGet('addressTab').style.display = 'block';
	}
}
//----zobrazeni advanc hledani-----------------------
function ShowAdvSearch(){
	if(objGet('AdvSearch').style.display == 'none'){
		objGet('AdvSearch').style.display = 'block';
	}else{
		objGet('AdvSearch').style.display = 'none';
	}
}
//----kontrola hledani-----------------------
function ContrSearch(strText){
	if(strText.toLowerCase() == 'tv'){
		document.SearchForm.EXPS.value = 'televize (kategorie)';
		return true;
	}
	if(strText.length < 3){
		alert('Zadejte aspoň 3 znaky.');
		return false;
	}else{
		return true;
	}
}
function ContrSearch2(obj){
	var strExps = obj.EXPS.value
	var strText
	strText = strExps;
	if(strExps.length > 0){obj.action = '/SearchAdvanced.asp'};
	if(strExps.length < 3){
		StandartDialog('Zadejte aspoň 3 znaky.');
		return false;
	}else{
		obj.submit();
	}
}
//----prace s querystringem------------------
function getQuery(sName){
	var arrTemp = window.location.search.substr(1).split("&");
	var arrHttp = new Array();
	for(var i = 0; i < arrTemp.length; i++){
		arrHttp[arrTemp[i].split("=")[0]] = unescape(arrTemp[i].split("=")[1]);
		}
	return arrHttp[sName]
}
//----------------------------x = nazev prvku
function objGet(x) {
	if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);
	else if (Boolean(document.ids)) return eval('document.ids.'+x);
	else return null;
}
//----------menu-----------------------------
var gPm = 0
function Pm(strId){
	try{
		if(objGet("c"+strId).className == "PMh"){
			PmPosition(strId);
			objGet("c"+strId).className = "PMs";
		}else{
			window.setTimeout("PmHid('"+strId+"')",100);
		}
	}catch(e){
		//nic...
	}
}
function PmHid(strId){
	if(gPm == 0){
		objGet("c"+strId).className = "PMh";
	}
}
function cPmHid(strId){
	window.setTimeout("PmHid('"+strId+"')",100);
}
function PmPosition(strId){
	var objElem = objGet(strId);
	var x = -5;
	//var y = 12;
	//if(!IE){y = y - 100}
	//y += parseFloat(objElem.offsetTop);
	while (typeof objElem == 'object' && objElem.tagName != 'BODY'){
		x += parseFloat(objElem.offsetLeft);
		//y += parseFloat(objElem.offsetTop);
		objElem = objElem.offsetParent;
	}
	x = x.toString() + "px";
	//y = y.toString() + "px";
	objGet("c"+strId).style.left = x;
	objGet("c"+strId).style.top = "90px";
}
//Strankovani doporucenych produktu
function ShowRelatedCommodity(nId,nPage,sName,bBestseller){
  var bestseller = "&bestseller=0";
  if (bBestseller == 1){
    bestseller = "&bestseller=1";
  }
	if(objGet(sName) != null){	
	    objGet(sName).innerHTML = "<div class='wait'><img src='/Img/ajax-loader-big.gif' alt='Waiting' /></div>";
//	    window.location = '/FilesForExecute/RelatedCommodity.asp?item='+nId+'&page='+nPage+bestseller+'';
      loadInc('/FilesForExecute/RelatedCommodity.asp?item='+nId+'&page='+nPage+bestseller+'', 'relatedContent');
		}
}

//Strankovani doporucenych produktu
function ShowRelatedCommodityDetail(nId,nPage,sName,bBestseller){
  var bestseller = "&bestseller=0";
  if (bBestseller == 1){
    bestseller = "&bestseller=1";
  }
	if(objGet(sName) != null){	
	    objGet(sName).innerHTML = "<div class='wait'><img src='/Img/ajax-loader-big.gif' alt='Waiting' /></div>";
//	    window.location = '/FilesForExecute/RelatedCommodityDetail.asp?item='+nId+'&page='+nPage+bestseller+'';
      loadInc('/FilesForExecute/RelatedCommodityDetail.asp?item='+nId+'&page='+nPage+bestseller+'', 'relatedContent');
		}
}
//zobrazeni title-----------------------------------------
function ShowRelatedTitle(sTitle){
	objGet('DialogSub').innerHTML = sTitle;
	objGet('Dialog').className = 'DialogActiv'
	objGet('Dialog').style.width = '200px';
   }
function ShowTitle(idText,strCount){

	var text = new Array();
	text[1] = gsKA01;
	text[2] = gsKA02;
	text[3] = gsKA03;
	text[9] = gsKA04;

	if(strCount.length > 0){strCount = strCount + " "}

	text[4] = strCount + gsKB01;
	text[5] = strCount + gsKB02;
	text[6] = strCount + gsKB03;
	text[7] = strCount + gsKB04;
	text[8] = strCount + gsKB05;
	if(gstrTimeStock.length > 0 ){
	    objGet('showElem').innerHTML = text[idText] + '<br />Aktualizováno dnes ' + gstrTimeStock;
	}else{
	    objGet('showElem').innerHTML = text[idText];
	}
	objGet('showElem').style.background='#C7E506';
    objGet('showElem').style.visibility = "visible";
}
function getMouse(e){
	var x;
	var y;
	if (!IE) {
	    x =   e.pageX + 10;
	    y =   e.pageY + 10;
	}else{
		x = window.event.clientX + document.documentElement.scrollLeft + 10;
		y = window.event.clientY + document.documentElement.scrollTop + 10;
	}
    x = x.toString() + "px"
    y = y.toString() + "px"

    if(objGet('showElem').style.visibility == "visible"){
		objGet('showElem').style.left = x;
	    objGet('showElem').style.top  = y;
	}else{
		objGet('Dialog').style.left = x;
	    objGet('Dialog').style.top  = y;	
	}
}
function HideTitle(){
	if(objGet('showElem').style.visibility == "visible"){
    	objGet('showElem').style.visibility = "hidden";
    }else{
		DialogClear();	   
	} 
}
//sbalovaci text------------------------------------------
function ListRoll(elem){
	
 	var obj;
	var objPar = objGet(elem);

	for(var i = 0; i < objPar.childNodes.length; i++){
		if(objPar.childNodes[i].tagName == 'UL'){
			obj = objPar.childNodes[i];
			break;
		}
	}

 	if(obj.style.display == ''){obj.style.display = "none"}

	obj.style.display = (obj.style.display == "none" ? "block" : "none");

	if(obj.style.display == 'block'){
		objPar.className = "ListRoll2"
	}else{
		objPar.className = "ListRoll"
	}
 }
//platby------------------------------------------------
function AlertPplDanzas(nId){
	if(nId == 217 || nId == 220){
		if(window.confirm("U zboží ve Vašem košíku negarantujeme doručení do 23.12.2004. Může být doručeno až 27.12.2004 a následující pracovní dny.\n\nSouhlasíte a přejete si pokračovat?")){
				ShowPayment(arrPayment[nId]);
				alert(arrDelivery[nId]);
			}else{
				return false;
			}
		}else{
			ShowPayment(arrPayment[nId]);
			alert(arrDelivery[nId]);
		}
}
//doprava a platby--------------------------------------------------------------
var ReWaitDel = 0
var ReWaitPay = 0
var intCelkem = 0
var intDarkSek = 0
var boolAura = 0
function Relation(){
	var objP = objGet("PaymentPriceCell");
	var objD = objGet("DeliveryPriceCell");
	var objPD = objGet("DelPayVat");
	var objM = objGet("DelPayMess");
	var strMess = "";
	objM.innerHTML = "";
	if(intDelActual > 0 || intPayActual > 0){
		var arrRel = strRelation.split("|");
		var arrSub;
		for(var i = 0; i < arrRel.length; i++){
			arrSub = arrRel[i].split(";")
			//doprava
			if(arrSub[2] == intDelActual){
				if(arrSub[2] == "219"){
					objD.innerHTML = "";
				}else{
					if(arrSub[6] == "0.00"){
						objD.innerHTML = gsJS36 + " ";
					}else{
						objD.innerHTML = gsJS32 + ": " + arrSub[6].replace('.00',',-') + " ";
					}
					var strDomain = window.location.hostname
					strDomain = strDomain.substring(strDomain.length - 2, strDomain.length)
					if(parseFloat(arrSub[5]) > intPriceSum && (parseFloat(arrSub[5])*0.8) < intPriceSum && strDomain == 'cz'){
						if(parseFloat(arrSub[4]) == 0){
							strMess = "<br />Když nakoupíte ješte za " + ((Math.round(parseFloat(arrSub[5]) - intPriceSum)*100)/100).toString().replace('.00','') + " Kč, nebudeme Vám účtovat dopravné.";
						}else{
							strMess = "<br />Když nakoupíte ješte za " + ((Math.round(parseFloat(arrSub[5]) - intPriceSum)*100)/100).toString().replace('.00','') + " Kč, bude dopravné pouze " + arrSub[4].toString() + " Kč.";
						}
					}
					
					//kontrola zda doprava neni vetsi nez hodnota zbozi	
					if(intPriceSum < arrSub[6]){
						objM.innerHTML = strMess + "<br />" + gsJS34;
					}else{
						objM.innerHTML = strMess;
					}

				}
			}
			//platba
			//if(arrSub[1] == intPayActual){	
			if(arrSub[1] == intPayActual && arrSub[2] == intDelActual) {
				if(arrSub[7] == "0.00" || arrSub[7] == "0."){
					objP.innerHTML = "";
				}else{
					objP.innerHTML = gsJS30 + ": " + arrSub[7].replace('.00',',-') + " ";
				}
			}
			//pokud je platba i doprava ulozim volbu
			if((intDelActual > 0 && intPayActual > 0) && (arrSub[1] == intPayActual && arrSub[2] == intDelActual)){document.OrderForm.DeliveryPayment.value = arrSub[0]}
			
		}
	}else{
		objP.innerHTML = "";
		objD.innerHTML = "";
		document.OrderForm.DeliveryPayment.value = "0";
	}
	var stGrTx = objP.innerHTML + objD.innerHTML;
	if(stGrTx != "" && stGrTx != gsJS36 + " "){
		objPD.innerHTML = "(" + gsJS33 + ")";
	}else{
		objPD.innerHTML = "";
	}
}
function HideBox(intType,intId){
	var strName;
	var strString;
	var arrItem;
	if(intType == 0){
		strName = "DelSub";
		strString = strDelCompl;
		objGet("InfoDelivery").style.display = "none";		
	}else{
		strName = "PaySub";
		strString = strPayCompl;
		objGet("InfoPayment").style.display = "none";		
	}
	arrItem = strString.split("|")
	for(var i = 0; i < arrItem.length; i++){
		if(arrItem[i] != intId){
			objGet(strName + arrItem[i].toString()).checked = false;
		}
	}
	if(objGet(strName + intId.toString()).checked == false){
		if(intType == 1){
			strName = "Del";
			strString = strDelCompl;
			intPayActual = 0;
		}else{
			strName = "Pay";
			strString = strPayCompl;
			intDelActual = 0;
		}
		arrItem = strString.split("|")
		for(var i = 0; i < arrItem.length; i++){
			if(arrItem[i] != intId){
				objGet(strName + arrItem[i].toString()).disabled = false;
				objGet(strName + 'Sub' + arrItem[i].toString()).disabled = false;
			}
		}
	}
}
function ShowPayDel(intId, intTyp, strName, bPaymentCard, bBank, sName) {
    var strSub;
    var arrCompl;
    var strTable = "";
    var strClear;
    if (intTyp == 0) {
        intDelActual = intId;
        strClear = "DelSub";
        if (objGet('DelSub' + intId).checked == false) { objGet("DeliveryPriceCell").innerHTML = "" }
    } else {
        intPayActual = intId;
        strClear = "PaySub";
        if (objGet('PaySub' + intId).checked == false) { objGet("PaymentPriceCell").innerHTML = "" }
    }

    objGet("CardYesNo").value = "0";
    if (strName.indexOf('Aura') == -1) {
        objGet("TypeCardDiv").style.display = "none";
    }
    objGet("proformaDiv").style.display = "none";
    objGet("proformaSub").checked = true;
    //objGet("DeliveryPriceCell").innerHTML = "";
    document.OrderForm.DeliveryPayment.value = "0";


    HideBox(intTyp, intId);

    if (strName.toLowerCase() == 'kartou osobně' && LoadSubCookies('sett', 'repr') != "ok" && intTyp == 1) {

        if (window.confirm(arrAltPay[intId])) {
            window.location.replace('/Order/OrderRePrice.asp?reprice=ok&del=' + intDelActual + '&pay=' + intPayActual);
        } else {
            alert('Zvolte jiný způsob platby.');
            objGet("PaySub" + intId).checked = false;
            intPayActual = 0
        }

    } else if (LoadSubCookies('sett', 'repr') == "ok" && strName.toLowerCase() != 'kartou osobně' && intTyp == 1) {

        window.location.replace('/Order/OrderRePrice.asp?reprice=no&del=' + intDelActual + '&pay=' + intPayActual);

    } else if (LoadSubCookies('sett', 'repr') == "ok" && strName.toLowerCase() == 'kartou osobně' && intTyp == 1 && objGet("PaySub" + intId.toString()).checked == false) {

        window.location.replace('/Order/OrderRePrice.asp?reprice=no&del=' + intDelActual + '&pay=0');

    } else if (objGet(strClear + intId.toString()).checked == true) {

        //-------------------------
        if (bPaymentCard == 1) {
            objGet("TypeCardDiv").style.display = "block";
            objGet("CardYesNo").value = "2";
            ClearCard();
        } else {
            if (boolAura == 0) { objGet("TypeCardDiv").style.display = "none"; }
            objGet("CardYesNo").value = "1";
        }
        if (bBank == 1) {
            objGet("proformaDiv").innerHTML = '<input id="proformaSub" type="hidden" name="proforma" value="1"/>';
            objGet("proformaDiv").style.display = "block";
        } else {
            objGet("proformaDiv").style.display = "none";
            objGet("proformaSub").checked = false;
        }

        //-------------------------
        if (intTyp == 0) {
            arrCompl = strPayCompl.split("|");
            strSub = arrDel[intId];
        } else {
            arrCompl = strDelCompl.split("|");
            strSub = arrPay[intId];
        }
        strSub = '|' + strSub + '|'
        //-------------------------
        for (var i = 0; i < arrCompl.length; i++) {
            if (strSub.indexOf('|' + arrCompl[i] + '|') >= 0) {
                if (intTyp == 0) {
                    objGet("Pay" + arrCompl[i]).disabled = false;
                    objGet("PaySub" + arrCompl[i]).disabled = false;
                } else {
                    objGet("Del" + arrCompl[i]).disabled = false;
                    objGet("DelSub" + arrCompl[i]).disabled = false;
                }
            } else {
                if (intTyp == 0) {
                    objGet("Pay" + arrCompl[i]).disabled = true;
                    objGet("PaySub" + arrCompl[i]).disabled = true;
                } else {
                    objGet("Del" + arrCompl[i]).disabled = true;
                    objGet("DelSub" + arrCompl[i]).disabled = true;
                }
            }
        }
        if (intTyp == 0) {
            if (intSpec == 0) {
                objGet("InfoDelivery").innerHTML = strDelHead.replace("$$$", " - " + sName) + '<div>' + arrAltDel[intId] + '<br class="clear" /></div>';
                objGet("InfoDelivery").style.display = "block";
            }
        } else {
            objGet("InfoPayment").innerHTML = strPayHead.replace("$$$", " - " + sName) + '<div>' + arrAltPay[intId] + '<br class="clear" /></div>';
            objGet("InfoPayment").style.display = "block";
        }
    }

    Relation();

}

function test() {
    window.focus();
}

function ClearCard(){
	//objGet('SelectCard').innerText = "";
	objGet("idVISA").checked = false;
	objGet("idVisaElectron").checked = false;
	objGet("idMasterCard").checked = false;
	objGet("idMaestro").checked = false;
} 
//------------------------------------------------------------------------------
function Lsc(nId,nActId,strStock,strCloseOut){
	//if(window.location.pathname == '/Wizard.asp'){return};
	if(objGet('i'+nId) != null){
		if(objGet('i'+nId).src.indexOf("/Img/Plus.gif") > -1){
			window.frames['WinStat'].location.replace(gstrLangLink + '/WriteSubTree.asp?Id='+nId+'&Act='+nActId+'&stock='+strStock+strCloseOut);
		}else{
			objGet('i'+nId).src = "/Img/Plus.gif";
			objGet('s'+nId).style.display = "none";
		}
	}
}
function Lsc2(nId,nActId,strStock,strCloseOut){
	//if(window.location.pathname == '/Wizard.asp'){return};
	if(objGet('ii'+nId) != null){
		if(objGet('ii'+nId).src.indexOf("/Img/Plus.gif") > -1){
			window.frames['WinStat'].location.replace(gstrLangLink + '/WriteSubTree.asp?Id='+nId+'&Act='+nActId+'&stock='+strStock+strCloseOut+'&two=ok');
		}else{
			objGet('ii'+nId).src = "/Img/Plus.gif";
			objGet('ss'+nId).style.display = "none";
		}
	}
}
//----Cookies-------
function SaveCookies(name, value, expires, path, domain, secure ){
	DeleteCookies( name, '/', '' );
	var argv = SaveCookies.arguments;
	var argc = SaveCookies.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +	((expires == null) ? "" : ("; expires=" +	expires.toGMTString())) +	((path == null) ? "; path=/" : ("; path=" + path)) +	((domain == null) ? "" : ("; domain=" + domain)) +	((secure == true) ? "; secure" : "");
}
function SaveSubCookies (Name, SubName, Value){
	if (Value == null || Value.length == 0) return;
	var arrTemp = LoadCookies(Name);
	var arrCook = new Array();
	if (arrTemp.length > 2) {
		arrTemp = arrTemp.split("&");
		for(var i = 0; i < arrTemp.length; i++){
			arrCook[arrTemp[i].split("=")[0]] = unescape(arrTemp[i].split("=")[1]);
		}
	}
	arrCook[SubName] = Value;   
	var data = "";
	for (var item in arrCook) {
		data += item + "=" + escape(arrCook[item]) + "&";
	}
	data = data.substring(0,data.length - 1);  
	var argv = arguments;
	var argc = argv.length;
	var expires = (argc > 3) ? argv[3] : null;
	var path = '/';
	var arrDomain = window.location.hostname.split('.');
	var domain = arrDomain[arrDomain.length-2] + '.' + arrDomain[arrDomain.length-1];
	var secure = (argc > 6) ? argv[6] : false;
	document.cookie = Name + "=" + data + ((expires == null) ? "" : ("; expires=" +	expires.getUTCDate())) +	((path == null) ? "" : ("; path=" + path)) +	((domain == null) ? "" : ("; domain=" + domain)) +	((secure == true) ? "; secure" : "");
}
function LoadSubCookies(Name,SubName){

	var arrTemp = LoadCookies(Name).split("&");

	var arrCook = new Array();
	for(var i = 0; i < arrTemp.length; i++){
		arrCook[arrTemp[i].split("=")[0]] = unescape(arrTemp[i].split("=")[1]);
		}
	
	return arrCook[SubName]
	}

function LoadCookies(Name){
	var Data = " "+document.cookie+";";
	var NameCookies = " "+Name+"=";
	var End, Result;
	var Begin = Data.indexOf(NameCookies);
	if (Begin!=-1){
		Begin+=NameCookies.length;
		End = Data.indexOf(";", Begin);
		Result = Data.substring(Begin, End);
		Result = unescape(Result);
	} else {
		Result = '0';
	}
	return Result;
}
function DeleteCookies( name, path, domain ) {
	if ( LoadCookies( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

//-----------------
//----ride text----
function SlideShow(strText){
	var intIndex;
	var arrText;
	var intLenght;
	arrText = strText.split("$");
	intLength = arrText.length;
	intIndex = parseFloat(LoadCookies("RideText"));
	if (intIndex > intLength-2){intIndex = 0;}
 	if(IE){
		objGet('Slide').innerHTML = arrText[intIndex];
	 	intIndex += 1;
	 	SaveCookies("RideText", intIndex, 1);
	 	objGet('Slide').start();
	}else{
		objGet('Slide').innerHTML = arrText[intIndex];
	 	intIndex += 1;
 		SaveCookies("RideText", intIndex, 1);
		setTimeout('SlideShow(strText)',10000);
	}
 }
//--------------
function ShowDate(strItem) {
    objItem = strItem
    if(IE){
        var strReturn = showModalDialog("/SelectDate.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=250pt;dialogHeight=200pt");
        if (strReturn == undefined){return;}
        strItem.value = strReturn;
    }else{
       var objWnd = window.open("/SelectDateInc.htm","Date","scrollbars=no,height=230,width=330,left=10,top=10");
       objWnd.focus();
    }
}
function AddChangeNameBasket(strName){
    if ( strName == "$new$"){
    	if (IE) {
        	var strReturn = showModalDialog("/QueryPage.htm","","status:no; center:yes; help:no; minimize:no;dialogWidth=200pt;dialogHeight=80pt");
        }else{
        	var strReturn = window.prompt("Zadejte název košíku.","Nový košík");
        }
    	if(!strReturn) return 0;
        if (strReturn == ""){
                alert('Nebyl zadán žádný text.');
                return
        }else{
                document.FormNameBasket.NewNameBasket.value = strReturn
                document.FormNameBasket.submit()
        }
     }else{
        document.FormNameBasket.ListNameBasket.value = strName
        document.FormNameBasket.submit()
     }
}

function OpenWnd(strURL){
         var objWnd = window.open(strURL,"InfoDetail","scrollbars=no,resizable=yes,height=500,width=400,left=10,top=10");
         objWnd.focus();
}
function GetCetelem(intPrice){
		var nW = 450;
		var nH = 320;
		var posW;
		var posH;
		posW = (document.body.clientWidth/2) - (nW/2)
		posH = (screen.height/2) - (nH/2)
		var objWin = window.open("/Secure/WebCalculatorCetelem.asp?price=" + intPrice,"Info","scrollbars=no,resizable=no,height="+nH.toString()+"px,width="+nW.toString()+"px,left="+posW.toString()+"px,top="+posH.toString()+"px");
		objWin.focus();
}
function GetCetelemSk(intPrice){
		var nW = 450;
		var nH = 380;
		var posW;
		var posH;
		posW = (document.body.clientWidth/2) - (nW/2)
		posH = (screen.height/2) - (nH/2)
		var objWin = window.open("/Secure/WebCalculatorCetelemSlovakia.asp?price=" + intPrice,"Info","scrollbars=no,resizable=no,height="+nH.toString()+"px,width="+nW.toString()+"px,left="+posW.toString()+"px,top="+posH.toString()+"px");
		objWin.focus();
}
function OpenWin(strURL,nW,nH){
		var posW
		var posH
		posW = (document.body.clientWidth/2) - (nW/2)
		posH = (screen.height/2) - (nH/2)
		var objWin = window.open(strURL,"Info","scrollbars=no,resizable=yes,height="+nH.toString()+"px,width="+nW.toString()+"px,left="+posW.toString()+"px,top="+posH.toString()+"px");
		objWin.focus();
}
function OpenHref(strURL){
	var objWin = window.open(strURL,"Info","scrollbars=yes,resizable=yes,height=500px,width=650px,left=10px,top=10px");
	return (typeof(objWin)!="object")?true:false;
}
function OpenUrl(strURL,nW,nH,sScroll){
	var objWin = window.open(strURL,"Info","scrollbars="+sScroll+",resizable=yes,height="+nH+"px,width="+nW+"px,left=10px,top=10px");
	return (typeof(objWin)!="object")?true:false;
}
function ControlNumber() {
    if ((event.keyCode != 43) && (event.keyCode != 9)  && ((event.keyCode < 48) || (event.keyCode > 57))) event.returnValue = false;
}
function NoSpace(){
     if (event.keyCode == 32) event.returnValue = false;
}
function DelSpace(strId){
	var Temp = objGet(strId).value
	for(var i = 0; i < Temp.length; i++){
		if(Temp.indexOf(' ') > 0){Temp = Temp.replace(' ','')}
	}
	objGet(strId).value = Temp
}
function DelSpace2(e){
	var Temp = e.value
	for(var i = 0; i < Temp.length; i++){
		if(Temp.indexOf(' ') > 0){Temp = Temp.replace(' ','')}
	}
	e.value = Temp
}
//----------info okno-------------------------------------------------------
function InfoWindow(strAddress) {
       showModalDialog(strAddress,"Info","status:no; center:yes; help:no; minimize:no;dialogWidth=450pt;dialogHeight=320pt");
}
function Wlh(strAddress) {
       window.location.href = strAddress;
}
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 RunEmailControl(adresa){
	 re = /^[+_a-zA-Z0-9-]+(\.[+_a-zA-Z0-9-]+)*@[\.a-zA-Z0-9-]+\.[a-zA-Z0-9-]{2,4}$/;
    return adresa.search(re) == 0;
}
function EmailControl(address){
	if(RunEmailControl(address)){
		return true;
	}else{
		alert(gsJS14)
		return false
	}
}

function ShowSearchMenu(x){
    if (x == 1){
        document.all.SearchTable.style.display='';
    }else{
        document.all.SearchTable.style.display='none';
    }
}
function PositionInfo(strText,oX,oY){
        objGet('StateInfo3').innerHTML=strText;
        objGet('StateInfo2').innerHTML="  probíhá připojování...";
        var x = oX;
        if (IE){
                var e = event.srcElement;
                var y = 0;
                while (typeof e == 'object' && e.tagName != 'BODY'){
                        y += e.offsetTop;
                        e = e.offsetParent;
                };
        }else{

                var y = oY + document.documentElement.scrollTop + 50;
        }
        x = (x+20).toString() + "px"
        y = (y-140).toString() + "px"
        objGet('StateInfo1').style.top = y;
		objGet('StateInfo1').style.left = x;
}
function LocState(strCode,intCount,oX,oY){
//	if(IE){
		oClientX = oX;
		oClientY = oY;
//	}else{
//		oClientX = findPosX(objGet('Submit' + strCode)) + 50;
//		oClientY = findPosY(objGet('Submit' + strCode)) - 50;
//	}
    window.parent.frames['WinStat'].location.href = gstrLangLink + "/InfoState.asp?ID="+strCode+"&CN="+intCount
	//PositionInfo(gsBV17,oX,oY);
}
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 ControlUserDataSubmit(strDomain){
	if(strDomain == 'sk' && !ControlSkDic()) 		{alert("Zadejte správný formát DIČ.");return false}
	if(strDomain == 'sk' && !RunSkDicControl()) 	{return false}
	if(document.OrderForm.Country.value == "")		{alert(gsJS02);return false}
	if(document.OrderForm.Firm.value == "")			{alert(gsJS03);return false}
	if(document.OrderForm.Street.value == "")		{alert(gsJS04);return false}
	if(document.OrderForm.City.value == "")			{alert(gsJS05);return false}
	if(document.OrderForm.Phone.value == "")		{alert(gsJS06);return false}
	if(document.OrderForm.Email.value == "")		{alert(gsJS07);return false}
	if(document.OrderForm.Login.value == "")		{alert(gsJS08);return false}
	if(document.OrderForm.Login.value.length < 5)	{alert(gsJS09);return false}
	if(document.OrderForm.Password.value == "")		{alert(gsJS10);return false}
	if(document.OrderForm.Password.value.length < 5){alert(gsJS11);return false}
	if(document.OrderForm.Password.value != document.OrderForm.PasswordControl.value){alert(gsJS12);return false}
	return EmailControl(document.OrderForm.Email.value);
	return true
}
function ControlUserDataSubmitEasy(){
	if(document.OrderForm.Country.value == "")		{alert(gsJS02);return false}
	if(document.OrderForm.Firm.value == "")			{alert(gsJS03);return false}
	if(document.OrderForm.Street.value == "")		{alert(gsJS04);return false}
	if(document.OrderForm.City.value == "")			{alert(gsJS05);return false}
	if(document.OrderForm.ZipCode.value == "")		{alert(gsJS13);return false}
	if(document.OrderForm.Phone.value == "")		{alert(gsJS06);return false}
	if(document.OrderForm.Email.value == "")		{alert(gsJS07);return false}
	return EmailControl(document.OrderForm.Email.value);
	return true
}
function ControlDataOrder(sNoStor, sNoStock, sLongNo) {
    //gsJS19 + gsJS20 + 
    // + gsJS25
    if (sNoStock.length > 0) { showorderdialog(null, gsJS21 + "<br /><br />" + GetNameForOrder(sNoStock) + "<br />" + gsJS22, 0, 0, 2, 1, '', 300); return false }
    if (sLongNo.length > 0) { showorderdialog(null, gsJS23 + "<br /><br />" + sNoStock + "<br />" + gsJS24, 0, 0, 2, 1, '', 300); return false }
    if (sNoStor.length > 0) {
        if (window.confirm(gsJS26 + " " + sNoStor + " " + gsJS27 + "\n-----------------\n" + gsJS28)) {
            return true;
        } else {
            return false;
        }
    }
    return true
}
function GetNameForOrder(strString){
	var strResult = '';
	var arrName = strString.split(',');
	for(var i = 0; i < arrName.length - 1; i++){
		strResult += '(' + arrName[i] + ') ' + objGet('href' + arrName[i]).innerHTML + "<br />";
	}
	return strResult;
}
function ControlPassword(NameOne,NameTwo){
  if (document.all[NameOne].value != document.all[NameTwo].value){
  alert(gsJS29);
  document.all[NameOne].value = "";
  document.all[NameTwo].value = "";
  document.all[NameOne].focus();
  return false;
  }else{
  return true;
  }
}
//zahlasovani ankety funguje pod netscapem(4.7+) mozilou(1.3) ie....
function VoteInquiry(plngAns){
	document.forms.frmInq.InqAns.value = plngAns;
	document.forms.frmInq.submit();
}
function init(){
	objGet('EXPS').value = objGet('EXPS').value;
//	objGet('EXPS').focus();
	objGet('EXPS').onclick = ClearExps;
	objGet('EXPS').onkeypress = ClearExps;
}
function ClearExps(){if(this.value == gsV23)this.value = '';}

function opacity(id, opacStart, opacEnd, millisec) {

    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0;

    

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++;
        }
        
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++;
        }
    }
}


//change the opacity for different browsers 
function changeOpac(opacity, id) {


    var object = objGet(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";

    if (eval(opacity) > 0) {
        objGet(id).style.display = 'block';
        //objGet('hintBody').style.display = 'block';
    }
    if (eval(opacity) == 0) {
        objGet(id).style.display = 'none';
        //objGet('hintBody').style.display = 'none';
    }
}

function ShowElement(id)
{
  opacity(id, 0, 100, 500);
}

function HideElement(id)
{
  opacity(id, 100, 0, 500);
}

function floorActivate(intId){

  var classArr = objGet('firstFloor'+intId).className.split(' ');
  var strClassName = 'hint ';
  for(var i = 0; i < classArr.length; i++){

      strClassName += classArr[i] + ' ';

  }
  objGet('firstFloor'+intId).className = strClassName;
  
  setTimeout("floorDeActivate("+ intId + ");",200);
}

function floorDeActivate(intId){
  var classArr = objGet('firstFloor'+intId).className.split(' ');
  var strClassName = '';
  for(var i = 0; i < classArr.length; i++){
  if(classArr[i].replace(/^\s*|\s*$/g,'') == 'hint'){
      //strClassName += 'activeFloor ';
    }else{
      strClassName += classArr[i].replace(/^\s*|\s*$/g,'') + ' ';
    }
  }
  objGet('firstFloor'+intId).className = strClassName.replace(/^\s*|\s*$/g,'');

    intId = intId + 1;
    
    if(intId <= 4){
      floorActivate(intId);
    }
}

function extractNumber(obj, decimalPlaces, allowNegative) {
    var temp = obj.value;

    // avoid changing things if already formatted correctly
    var reg0Str = '[0-9]*';
    if (decimalPlaces > 0) {
        reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
    } else if (decimalPlaces < 0) {
        reg0Str += '\\.?[0-9]*';
    }
    reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
    reg0Str = reg0Str + '$';
    var reg0 = new RegExp(reg0Str);
    if (reg0.test(temp)) return true;

    // first replace all non numbers
    var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
    var reg1 = new RegExp(reg1Str, 'g');
    temp = temp.replace(reg1, '');

    if (allowNegative) {
        // replace extra negative
        var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
        var reg2 = /-/g;
        temp = temp.replace(reg2, '');
        if (hasNegative) temp = '-' + temp;
    }

    if (decimalPlaces != 0) {
        var reg3 = /\./g;
        var reg3Array = reg3.exec(temp);
        if (reg3Array != null) {
            // keep only first occurrence of .
            //  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
            var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
            reg3Right = reg3Right.replace(reg3, '');
            reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
            temp = temp.substring(0, reg3Array.index) + '.' + reg3Right;
        }
    }

    obj.value = temp;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative) {
    var key;
    var isCtrl = false;
    var keychar;
    var reg;

    //alert('ff');
    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }

    
    if (isNaN(key)) return true;

    keychar = String.fromCharCode(key);
    //opera ctrl+v 
    if(ctrlKey && key == 90) {return true};

    // check for backspace or delete, or if Ctrl was pressed
    if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27) || isCtrl){
        return true
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
    var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;

    return isFirstN || isFirstD || reg.test(keychar);
}

function LeftBrowsing(bBrowse){
  SaveCookies("LeftBrowsing", bBrowse , null, null, gstrServerAddressRoot);
}

function NewsChange(nCategory){
  loadInc(gstrLangLink + '/FilesForExecute/GetNews.asp?newsCategory='+nCategory, 'alza-news');
}
var gOldCategoryNews = 0;
function NewsChange2(nCategory){
  if(gOldCategoryNews == 0){
    if(objGet('title-news'+681) != null)
      {
        gOldCategoryNews = 681;
      }
    else if(objGet('title-news'+686) != null)
      {
        gOldCategoryNews = 686;
      }
  }

  objGet('title-news'+gOldCategoryNews).style.display='none';
  gOldCategoryNews = nCategory;
  objGet('title-news'+nCategory).style.display='block';
}

//window.onload = function(e){
//	var strData = LoadCookies("root").toString();
//	if(window.location.pathname == '/'){
//	   setTimeout("floorActivate(0);",1000);
//	}
//	init()
//  objGet('BodyTag').style.backgroundColor = '#00285A';
//}

//----zobrazeni advanc hledani-----------------------
function ShowHideObject(sId){
	if(objGet(sId).style.display == 'none'){
		objGet(sId).style.display = 'block';
	}else{
		objGet(sId).style.display = 'none';
	}
}

//Strankovani doporucenych produktu
function ShowRelatedCommodityDetail(nId,nPage,sName,bBestseller){
  var bestseller = "&bestseller=0";
  if (bBestseller == 1){
    bestseller = "&bestseller=1";
  }
	if(objGet(sName) != null){	
	    objGet(sName).innerHTML = "<div class='wait'><img src='/Img/ajax-loader-big.gif' alt='Waiting' /></div>";
//	    window.location = '/FilesForExecute/RelatedCommodityDetail.asp?item='+nId+'&page='+nPage+bestseller+'';
      loadInc('/FilesForExecute/RelatedCommodity.asp?item='+nId+'&page='+nPage+bestseller+'', 'relatedContent');
		}
}

//Strankovani doporucenych produktu
function ShowCrossSelling(nPage){

	if(objGet('CrossSelling') != null){	
		    objGet('CrossSelling').innerHTML = "<div class='wait'><img src='/Img/ajax-loader-big.gif' alt='Waiting' /></div>";
		    //window.location = '/FilesForExecute/CrossSelling.asp?page='+nPage+'';
	      	loadInc('/FilesForExecute/CrossSelling.asp?page='+nPage+'', 'CrossSelling');
		}
}


function bannload(type, id) {

    var param = '["type", "' + type + '"], ["id", "' + id + '"]';
    param = '[' + param + ']';
    ajax.url = '/filesforexecute/bannersadd.asp';
    ajax.method = 'post';
    ajax.cbf = cbf;
    ajax.sendRQ(eval(param), true);

}

function addAjaxWait(){
	var ajaxWait = $('<div id="ajaxWaitGif"><span><img src="/Img/ajax-loader-big.gif" alt="Waiting" /></span></div>');
	$('#ContentPage').append(ajaxWait);
	var pos = $('#ContentPage').offset();
	ajaxWait.css({position: 'absolute',
		top:pos.top + 10, left:pos.left,
		height:$('#ContentPage').height() - 10,
		width:$('#ContentPage').width(),
		opacity:0.5,
		'background-color':'gray'
	}
	);
	ajaxWait.children('span').css({position:'relative'})
	ajaxWait.children('span').children('img').css({position:'absolute', top:($('#ContentPage').height()/2) - 33,left:($('#ContentPage').width()/2 ) - 33})
}

function removeAjaxWait(){
	$('#ajaxWaitGif').remove();
}


//Funkce na animaci akcni ceny
function AnimateActionPrice(){
	$('.lastAction, .actionBubble').hover(function(e){
//			var actionBubble = $('<div id="actionBubble">Akční nabídka</div>');
//			var position = $(this).position();
//			
//			$(this).parent().append(actionBubble);
			
			$(this).parent().children('.actionBubble').stop().animate({bottom:'60px'},{queue:false,duration:300});
		}, function(){
			$(this).parent().children('.actionBubble').stop().animate({bottom:'0px'},{queue:false,duration:300});
		}
	);
}

//Funkce na upraveni velikosti nadpisu
// Davam to do fce abych ji mohl zavolat i v pruvodci
function ComodityBoxResize(){
///////////////////////////////
// Funkce na vysku AlzaNameExt
		var lastLine, lastHeight
		lastLine = 'myFirstLine';
		lastHeight = 0;
		
		$(".AlzaName").each(function(){
			var line, height
			line = 	$(this).attr("class").substring($(this).attr("class").indexOf("AlzaNameLine"), $(this).attr("class").length);
			line = line.substring(0, (line.indexOf(' ')<= 0? line.length:line.indexOf(' '))); 
			height = $(this).height();
			
			if(lastLine != line){
				$("." + lastLine).css({'height':lastHeight + 'px'});
				lastLine = line;
				lastHeight = height;
			}
			
			if(height > lastHeight){
				lastHeight = height;
			}
		
		}
		)
		
		$("." + lastLine).css({'height':lastHeight + 'px'});

///////////////////////////////
// Ted projdu vsechny H3 ve kterych je jmeno

		lastLine = 'myFirstLine';
		lastHeight = 24;
		
		$(".itemDFirst h3, .itemD h3").each(function(){
			var line, height
			line = 	$(this).attr("class").substring($(this).attr("class").indexOf("H3Line"), $(this).attr("class").length);
			line = line.substring(0, (line.indexOf(' ')<= 0? line.length:line.indexOf(' '))); 
			height = $(this).height();
			
			if(lastLine != line){
				$("." + lastLine).css({'height':lastHeight + 'px'});
				lastLine = line;
				lastHeight = 0;			
			}
			
			if(height <= 24){
				height = 24;
			}else if(height > 24 && height <= 36){
				height = 36;
			}
			else{
				height = height;
			}
			
			if(height > lastHeight){
				lastHeight = height;
			}
		
		}
		)
		
		$("." + lastLine).css({'height':lastHeight + 'px'});
}

function positionH1New(){
	if(objGet('h1body') != null) {
		var pos = $('#h1body').offset();
		$('#itemH1').css({'top':pos.top + 5, 'left':pos.left + 14});
	}	
}

$(document).ready(function(){

	//Vyjizdeni popisku v kategorii
//	$('.itemD').hover(function(){
//			$('span.description', this).stop().animate({top:'110px'},{queue:false,duration:300});
//		}, function(){
//			$('span.description', this).stop().animate({top:'160px'},{queue:false,duration:300});
//		});
//
//	$('.itemDLast').hover(function(){
//			$('span.description', this).stop().animate({top:'110px'},{queue:false,duration:300});
//		}, function(){
//			$('span.description', this).stop().animate({top:'160px'},{queue:false,duration:300});
//		});

// Oznaceni posledni akce ve vypisu kategorie
//	$('.itemD .lastAction').hover(function(e){
//			var actionBubble = $('<div id="actionBubble">Akční nabídka</div>');
//			var position = $(this).position();
//			
//			actionBubble.css({position: 'absolute',
//				'background-color':'#FDF988',
//				'border':'1px solid #4A494A',
//				'font-size':'12px',				
//				'left':e.pageX + 10,
//				'top':e.pageY + 10,
//				'padding':'10px',
//				'width':'100px',
//				'z-index':'11',
//				'opacity':'1',
//				'display':'none'
//			}
//			);
//			$('#ContentPage').append(actionBubble);
//			actionBubble.animate({'opacity':'1'}, 300).fadeIn('fast');
//		}, function(){
//			$('#actionBubble').remove();
//		}
//	);
	

	
//	$('.itemD .lastAction').mousemove(function(e){
//
//		$('#actionBubble').css({'left':e.pageX + 10,'top':e.pageY + 10});
//	});
	
//	$('.itemD .lastAction').mouseout(function(){
//		$('#actionBubble').remove();
//	});

	//Volam fci na animaci akcni ceny
	AnimateActionPrice();

	//Volam fci na resize boxiku
	ComodityBoxResize()
	
	//Pozicovani noveho nazvu 
	positionH1New();

});