/*jquery.ui.datepicker-cs.js*/
/* Czech initialisation for the jQuery UI date picker plugin. */
/* Written by Tomas Muller (tomas@tomas-muller.net). */
jQuery(function($){
	$.datepicker.regional['cs'] = {
		closeText: 'Zavřít',
		prevText: '&#x3c;Dříve',
		nextText: 'Později&#x3e;',
		currentText: 'Nyní',
		monthNames: ['leden','únor','březen','duben','květen','červen',
        'červenec','srpen','září','říjen','listopad','prosinec'],
		monthNamesShort: ['led','úno','bře','dub','kvě','čer',
		'čvc','srp','zář','říj','lis','pro'],
		dayNames: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
		dayNamesShort: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
		dayNamesMin: ['ne','po','út','st','čt','pá','so'],
		weekHeader: 'Týd',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['cs']);
});
/*jquery.deserialize.js*/
$.fn.deserialize = function(s, options) {
	var data = s.split("&")
	options = options || {}
	attr = options.attribute || "name"
  
	for (var i = 0; i < data.length; i++) {
		var pair = decodeURIComponent(data[i]).split("=")
			if(pair.length==2){
        var _name = pair[0]
		    var value = pair[1]
			  if( value != "")
          $("[" + attr + "='" + _name + "']",this).filter(function(){ return (this.value == value); }).attr("checked","checked");
          //$("[" + attr + "='" + _name + "'][value='"+value+"']", this).attr("checked","checked"); //hazi chybu pri spec znacih jako "
    
          $("[" + attr + "='" + _name + "'][type!='checkbox']", this).val(value);
	   }
  }
}

$.fn.deserializeParamSrch = function(s, options) {
	var data = s.split("&")

	options = options || {}
	attr = options.attribute || "name"

	for (var i = 0; i < data.length; i++) {
		var pair = decodeURIComponent(data[i]).replace(/\+/g," ").split("=")
			if(pair.length==2){
        var _name = pair[0]
		    var value = pair[1]
			  if(value != "")
        if($("[" + attr + "='" + _name + "']",this).filter(function(){ return (this.value == value); }))
          {
            if(_name.indexOf("sps_v_")>-1){
              var spsId = _name.replace("sps_v_","")
              var inpID = $("[" + attr + "='" + _name + "']",this).filter(function(){ return (this.value == value); }).attr("id");
              var divID = (''+inpID).replace("prchObj","prch");
              if($("#prch"+spsId+"x1").length>0)
                {
                fcprcheckswitch(divID,inpID,spsId+'')
                }
              //$("[" + attr + "='" + _name + "'][value='"+value+"']", this).attr("checked","checked");
            }
          }
        else
          $("[" + attr + "='" + _name + "']", this).val(value)
	     }
  }
}

/*jquery.cookie.js*/
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', '', {expires: -1});
 * @desc Delete a cookie by setting a date in the past.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toGMTString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toGMTString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
/*jquery.clickmenu.pack.js*/
{eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(8($){7 E={1e:8(){$(5).1D(\'>a\').X(8(){3(5.1L){1K.24=5.1L}})},1k:\'\',1x:2u,1t:10};$.1f.L=8(f){7 g=K;7 h=(($.13.1n)?4:2);7 k=$.1y({},E,f);7 l=8(a,b){3(a.F&&!a.J){Y(a.F)}R 3(a.F){9}3(a.J){a.F=1M(8(){$(A(z(a,\'U\'),\'W\')).S(\'1d\',s).S(\'1p\',u).S(\'1b\',k.1e);$(a).1H();a.J=K;a.F=N},b)}};7 m=8(b,c){3(b.F){Y(b.F)}3(!b.J){b.F=1M(8(){3(!C(b.H,\'I\')){9}$(A(z(b,\'U\'),\'W\')).1d(s).1p(u).1b(k.1e);3(!C(b.H,\'1E\')){$(b).17(\'1C\',b.H.1o-h)}b.J=V;$(b).20();3($.13.1n){7 a=$(z(b,\'U\')).18();3(a<1w){a=1w}$(b).17(\'18\',a)}b.F=N},c)}};7 o=8(e){7 p=(e.2o=="1d"?e.2m:e.1N)||e.1P;2h(p&&p!=5){2f{p=p.H}2c(e){p=5}}3(p==5){9 K}9 V};7 q=8(e){7 a=A(5.H,\'W\');7 b=1u 1v("(^|\\\\s)I(\\\\s|$)");P(7 i=0;i<a.1s;i++){3(b.1r(a[i].1q)){$(a[i]).Q(\'I\')}}$(5).O(\'I\');3(g){t(5,k.1t)}};7 s=8(e){3(!o(e)){9 K}3(e.T!=5){3(!D(5,e.T)){9}}t(5,k.1x)};7 t=8(a,b){7 c=z(a,\'M\');7 n=a.H.1c;P(;n;n=n.19){3(n.15==1&&n.11.14()==\'W\'){7 d=z(n,\'M\');3(d&&d.F&&!d.J){Y(d.F);d.F=N}}}7 e=a.H;P(;e;e=e.H){3(e.15==1&&e.11.14()==\'M\'){3(e.F){Y(e.F);e.F=N;$(e.H).O(\'I\')}}}$(a).O(\'I\');3(c&&c.J){3(c.F){Y(c.F);c.F=N}R{9}}$(a.H.1I(\'M\')).X(8(){3(5!=c&&5.J){l(5,b);$(5.H).Q(\'I\')}});3(c){m(c,b)}};7 u=8(e){3(!o(e)){9 K}3(e.T!=5){3(!D(5,e.T)){9}}7 a=z(5,\'M\');3(!a){$(5).Q(\'I\')}R{3(!a.J){$(5).Q(\'I\')}}};7 v=8(e){7 a=z(5,\'M\');7 b=e.1P||e.1N;7 p;3(!g){$(5).Q(\'I\')}R 3(!a&&b){p=B(e.T,\'U\',\'L\');3(p.1a(b)){$(5).Q(\'I\')}}R 3(b){p=B(e.T,\'U\',\'L\');3(!a.J&&(p.1a(b))){$(5).Q(\'I\')}}};7 w=8(){7 a=z(5,\'M\');3(a&&a.J){y();$(5).O(\'I\')}R{t(5,k.1t);g=V;$(1J).1G(\'1F\',x)}9 K};7 x=8(e){7 a=K;7 b=B(e.T,\'U\',\'L\');3(b){$(b.1I(\'M\')).X(8(){3(5.J){a=V}})}3(!a){y()}};7 y=8(){$(\'1i.L G.12\').X(8(){3(5.F){Y(5.F);5.F=N}3(5.J){$(5).1H();5.J=K}});$(\'1i.L 1m\').Q(\'I\');$(\'1i.L>1m 1m\').S(\'1d\',s).S(\'1p\',u).S(\'1b\',k.1e);$(1J).S(\'1F\',x);g=K};7 z=8(a,b){3(!a){9 N}7 n=a.1c;P(;n;n=n.19){3(n.15==1&&n.11.14()==b){9 n}}9 N};7 A=8(a,b){3(!a){9[]}7 r=[];7 n=a.1c;P(;n;n=n.19){3(n.15==1&&n.11.14()==b){r[r.1s]=n}}9 r};7 B=8(a,b,c){7 d=a.H;7 e=1u 1v("(^|\\\\s)"+c+"(\\\\s|$)");P(;d;d=d.H){3(d.15==1&&d.11.14()==b&&e.1r(d.1q)){9 d}}9 N};7 C=8(a,b){7 c=1u 1v("(^|\\\\s)"+b+"(\\\\s|$)");3(c.1r(a.1q)){9 V}9 K};7 D=8(a,b){7 n=a.1c;P(;n;n=n.19){3(n==b){9 V}}9 K};9 5.X(8(){3(1K.1g&&1g.1l&&!1g.1l.1a){1g.1l.1a=8(a){9!!(5.23(a)&16)}}3(!C(5,\'L\')){$(5).O(\'L\')}$(\'1i\',5).1B();3($.13.1n&&(!$.13.1V||22($.13.1V)<=6)){3($.1f.1A){$(\'G.12\',5).1A()}R{$(\'G.12\',5).21(\'<1Z 1z="1Y:1X;1h:1j;2t:0;1C:0;z-2r:-1;2q:2p();\'+\'18:1W(5.H.1o);1U:1W(5.H.1T)"/>\')}}$(5).1G(\'2n\',8(){y()});7 b=A(5,\'W\');P(7 j=0;j<b.1s;j++){3(z(z(z(b[j],\'M\'),\'U\'),\'W\')){$(b[j]).1b(w)}}$(b).I(q,v).O(\'1E\').1D(\'>G\').O(\'1R\');3(k.1k){$(\'G.1R G.12\',5).1Q(\'<2l 2i="\'+k.1k+\'" Z="2g" />\')}$(5).1O(\'<G Z="2e"></G>\').2d(\'<G 1z="2j: 2k; 2b: 2a;"></G>\')})};$.1f.L.29=8(o){$.1y(E,o)}})(1S);(8($){$.1f.1B=8(){9 5.X(8(){7 a=$(\'<G Z="12"></G>\').28(0);3($(5).17(\'1h\')==\'1j\'){$(a).17({1h:\'27\',18:5.1o,1U:5.1T})}R{$(a).17(\'1h\',\'1j\')}$(5).O(\'26\').1O(a).1Q(\'<G Z="2s"></G><G Z="25"></G><G Z="2v"></G>\')})}})(1S);',62,156,'|||if||this||var|function|return||||||||||||||||||||||||||||||||timer|div|parentNode|hover|isVisible|false|clickMenu|DIV|null|addClass|for|removeClass|else|unbind|target|UL|true|LI|each|clearTimeout|class||nodeName|outerbox|browser|toUpperCase|nodeType||css|width|nextSibling|contains|click|firstChild|mouseover|onClick|fn|Node|position|ul|absolute|arrowSrc|prototype|li|msie|offsetWidth|mouseout|className|test|length|mainDelay|new|RegExp|100|subDelay|extend|style|bgiframe|shadowBox|left|find|main|mousedown|bind|hide|getElementsByTagName|document|window|href|setTimeout|toElement|wrap|relatedTarget|before|inner|jQuery|offsetHeight|height|version|expression|block|display|iframe|show|append|parseInt|compareDocumentPosition|location|shadowbox2|innerBox|relative|get|setDefaults|hidden|visibility|catch|after|cmDiv|try|liArrow|while|src|clear|both|img|fromElement|closemenu|type|mask|filter|index|shadowbox1|top|300|shadowbox3'.split('|'),0,{}))}

/*jquery.columnmanager.js*/
/*
 * jQuery columnManager plugin
 * Version: 0.2.5
 *
 * Copyright (c) 2007 Roman Weich
 * http://p.sohei.org
 *
 * Dual licensed under the MIT and GPL licenses 
 * (This means that you can choose the license that best suits your project, and use it accordingly):
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

(function($) 
{
	var defaults = {
		listTargetID : null,
		onClass : '',
		offClass : '',
		hideInList: [],
		colsHidden: [],
		saveState: false,
		onToggle: null,
		show: function(cell){
			showCell(cell);
		},
		hide: function(cell){
			hideCell(cell);
		}
	};
	
	var idCount = 0;
	var cookieName = 'columnManagerC';

	/**
	 * Saves the current state for the table in a cookie.
	 * @param {element} table	The table for which to save the current state.
	 */
	var saveCurrentValue = function(table)
	{
		var val = '', i = 0, colsVisible = table.cMColsVisible;
		if ( table.cMSaveState && table.id && colsVisible && $.cookie )
		{
			for ( ; i < colsVisible.length; i++ )
			{
				val += ( colsVisible[i] == false ) ? 0 : 1;
			}
			$.cookie(cookieName + table.id + logedUser, val, {expires: 9999});
		}
	};
	
	/**
	 * Hides a cell.
	 * It rewrites itself after the browsercheck!
	 * @param {element} cell	The cell to hide.
	 */
	var hideCell = function(cell)
	{
		if ( jQuery.browser.msie )
		{
			(hideCell = function(c)
			{
				c.style.setAttribute('display', 'none');
			})(cell);
		}
		else
		{
			(hideCell = function(c)
			{
				c.style.display = 'none';
			})(cell);
		}
	};

	/**
	 * Makes a cell visible again.
	 * It rewrites itself after the browsercheck!
	 * @param {element} cell	The cell to show.
	 */
	var showCell = function(cell)
	{
		if ( jQuery.browser.msie )
		{
			(showCell = function(c)
			{
				c.style.setAttribute('display', 'block');
			})(cell);
		}
		else
		{
			(showCell = function(c)
			{
				c.style.display = 'table-cell';
			})(cell);
		}
	};

	/**
	 * Returns the visible state of a cell.
	 * It rewrites itself after the browsercheck!
	 * @param {element} cell	The cell to test.
	 */
	var cellVisible = function(cell)
	{
		if ( jQuery.browser.msie )
		{
			return (cellVisible = function(c)
			{
				return c.style.getAttribute('display') != 'none';
			})(cell);
		}
		else
		{
			return (cellVisible = function(c)
			{
				return c.style.display != 'none';
			})(cell);
		}
	};

	/**
	 * Returns the cell element which has the passed column index value.
	 * @param {element} table	The table element.
	 * @param {array} cells		The cells to loop through.
	 * @param {integer} col	The column index to look for.
	 */
	var getCell = function(table, cells, col)
	{
		for ( var i = 0; i < cells.length; i++ )
		{
			if ( cells[i].realIndex === undefined ) //the test is here, because rows/cells could get added after the first run
			{
				fixCellIndexes(table);
			}
			if ( cells[i].realIndex == col )
			{
				return cells[i];
			}
		}
		return null;
	};

	/**
	 * Calculates the actual cellIndex value of all cells in the table and stores it in the realCell property of each cell.
	 * Thats done because the cellIndex value isn't correct when colspans or rowspans are used.
	 * Originally created by Matt Kruse for his table library - Big Thanks! (see http://www.javascripttoolbox.com/)
	 * @param {element} table	The table element.
	 */
	var fixCellIndexes = function(table) 
	{
		var rows = table.rows;
		var len = rows.length;
		var matrix = [];
		for ( var i = 0; i < len; i++ )
		{
			var cells = rows[i].cells;
			var clen = cells.length;
			for ( var j = 0; j < clen; j++ )
			{
				var c = cells[j];
				var rowSpan = c.rowSpan || 1;
				var colSpan = c.colSpan || 1;
				var firstAvailCol = -1;
				if ( !matrix[i] )
				{ 
					matrix[i] = []; 
				}
				var m = matrix[i];
				// Find first available column in the first row
				while ( m[++firstAvailCol] ) {}
				c.realIndex = firstAvailCol;
				for ( var k = i; k < i + rowSpan; k++ )
				{
					if ( !matrix[k] )
					{ 
						matrix[k] = []; 
					}
					var matrixrow = matrix[k];
					for ( var l = firstAvailCol; l < firstAvailCol + colSpan; l++ )
					{
						matrixrow[l] = 1;
					}
				}
			}
		}
	};
	
	/**
	 * Manages the column display state for a table.
	 *
	 * Features:
	 * Saves the state and recreates it on the next visit of the site (requires cookie-plugin).
	 * Extracts all headers and builds an unordered(<UL>) list out of them, where clicking an list element will show/hide the matching column.
	 *
	 * @param {map} options		An object for optional settings (options described below).
	 *
	 * @option {string} listTargetID	The ID attribute of the element the column header list will be added to.
	 *						Default value: null
	 * @option {string} onClass		A CSS class that is used on the items in the column header list, for which the column state is visible 
	 *						Works only with listTargetID set!
	 *						Default value: ''
	 * @option {string} offClass		A CSS class that is used on the items in the column header list, for which the column state is hidden.
	 *						Works only with listTargetID set!
	 *						Default value: ''
	 * @option {array} hideInList	An array of numbers. Each column with the matching column index won't be displayed in the column header list.
	 *						Index starting at 1!
	 *						Default value: [] (all columns will be included in the list)
	 * @option {array} colsHidden	An array of numbers. Each column with the matching column index will get hidden by default.
	 *						The value is overwritten when saveState is true and a cookie is set for this table.
	 *						Index starting at 1!
	 *						Default value: []
	 * @option {boolean} saveState	Save a cookie with the sate information of each column.
	 *						Requires jQuery cookie plugin.
	 *						Default value: false
	 * @option {function} onToggle	Callback function which is triggered when the visibility state of a column was toggled through the column header list.
	 *						The passed parameters are: the column index(integer) and the visibility state(boolean).
	 *						Default value: null
	 *
	 * @option {function} show		Function which is called to show a table cell.
	 *						The passed parameters are: the table cell (DOM-element).
	 *						Default value: a functions which simply sets the display-style to block (visible)
	 *
	 * @option {function} hide		Function which is called to hide a table cell.
	 *						The passed parameters are: the table cell (DOM-element).
	 *						Default value: a functions which simply sets the display-style to none (invisible)
	 *
	 * @example $('#table').columnManager([listTargetID: "target", onClass: "on", offClass: "off"]);
	 * @desc Creates the column header list in the element with the ID attribute "target" and sets the CSS classes for the visible("on") and hidden("off") states.
	 *
	 * @example $('#table').columnManager([listTargetID: "target", hideInList: [1, 4]]);
	 * @desc Creates the column header list in the element with the ID attribute "target" but without the first and fourth column.
	 *
	 * @example $('#table').columnManager([listTargetID: "target", colsHidden: [1, 4]]);
	 * @desc Creates the column header list in the element with the ID attribute "target" and hides the first and fourth column by default.
	 *
	 * @example $('#table').columnManager([saveState: true]);
	 * @desc Enables the saving of visibility informations for the columns. Does not create a column header list! Toggle the columns visiblity through $('selector').toggleColumns().
	 *
	 * @type jQuery
	 *
	 * @name columnManager
	 * @cat Plugins/columnManager
	 * @author Roman Weich (http://p.sohei.org)
	 */
	$.fn.columnManager = function(options)
	{
		var settings = $.extend({}, defaults, options);

		/**
		 * Creates the column header list.
		 * @param {element} table	The table element for which to create the list.
		 */
		var createColumnHeaderList = function(table)
		{
			if ( !settings.listTargetID )
			{
				return;
			}
			var $target = $('#' + settings.listTargetID);
			if ( !$target.length )
			{
				return;
			}
			//select headrow - when there is no thead-element, use the first row in the table
			var headRow = null;
			if ( table.tHead && table.tHead.length )
			{
				headRow = table.tHead.rows[0];
			}
			else if ( table.rows.length )
			{
				headRow = table.rows[0];
			}
			else
			{
				return; //no header - nothing to do
			}
			var cells = headRow.cells;
			if ( !cells.length )
			{
				return; //no header - nothing to do
			}
			//create list in target element
			var $list = null;
			if ( $target.get(0).nodeName.toUpperCase() == 'UL' )
			{
				$list = $target;
			}
			else
			{
				$list = $('<ul></ul>');
				$target.append($list);
			}
			var colsVisible = table.cMColsVisible;
			//create list elements from headers
			for ( var i = 0; i < cells.length; i++ )
			{
				if ( $.inArray(i + 1, settings.hideInList) >= 0 )
				{
					continue;
				}
				colsVisible[i] = ( colsVisible[i] !== undefined ) ? colsVisible[i] : true;
				var text = $(cells[i]).text(), 
					addClass;
					
				if ( text.length<2)
				{
					text = $(cells[i]).attr("title");
					if (text.length<2 )
					{
					 text = $(cells[i]).html();	
           if ( !text.length )
					   {  
						  text = 'undefined';
					   }
					}
				}
				if ( colsVisible[i] && settings.onClass )
				{
					addClass = settings.onClass;
				}
				else if ( !colsVisible[i] && settings.offClass )
				{
					addClass = settings.offClass;
				}
				var $li = $('<li class="' + addClass + '">' + text + '</li>').click(toggleClick);
				$li[0].cmData = {id: table.id, col: i};
				$list.append($li);
			}
			table.cMColsVisible = colsVisible;
		};

		/**
		 * called when an item in the column header list is clicked
		 */
		var toggleClick = function()
		{
			//get table id and column name
			var data = this.cmData;
			if ( data && data.id && data.col >= 0 )
			{
				var colNum = data.col, 
					$table = $('#' + data.id);
				if ( $table.length )
				{
					$table.toggleColumns([colNum + 1], settings);
					//set the appropriate classes to the column header list
					var colsVisible = $table.get(0).cMColsVisible;
					if ( settings.onToggle )
					{
						settings.onToggle.apply($table.get(0), [colNum + 1, colsVisible[colNum]]);
					}
				}
			}
		};

		/**
		 * Reads the saved state from the cookie.
		 * @param {string} tableID	The ID attribute from the table.
		 */
		var getSavedValue = function(tableID)
		{
			var val = $.cookie(cookieName + tableID + logedUser);
			if ( val )
			{
				var ar = val.split('');
				for ( var i = 0; i < ar.length; i++ )
				{
					ar[i] &= 1;
				}
				return ar;
			}
			return false;
		};

        return this.each(function()
        {
			this.id = this.id || 'jQcM0O' + idCount++; //we need an id for the column header list stuff
			var i, 
				colsHide = [], 
				colsVisible = [];
			//fix cellIndex values
			fixCellIndexes(this);
			//some columns hidden by default?
			if ( settings.colsHidden.length )
			{
				for ( i = 0; i < settings.colsHidden.length; i++ )
				{
					colsVisible[settings.colsHidden[i] - 1] = true;
					colsHide[settings.colsHidden[i] - 1] = true;
				}
			}
			//get saved state - and overwrite defaults
			if ( settings.saveState )
			{
				var colsSaved = getSavedValue(this.id);
				if ( colsSaved && colsSaved.length )
				{
					for ( i = 0; i < colsSaved.length; i++ )
					{
						colsVisible[i] = true;
						colsHide[i] = !colsSaved[i];
					}
				}
				this.cMSaveState = true;
			}
			//assign initial colsVisible var to the table (needed for toggling and saving the state)
			this.cMColsVisible = colsVisible;
			//something to hide already?
			if ( colsHide.length )
			{
				var a = [];
				for ( i = 0; i < colsHide.length; i++ )
				{
					if ( colsHide[i] )
					{
						a[a.length] = i + 1;
					}
				}
				if ( a.length )
				{
					$(this).toggleColumns(a);
				}
			}
			//create column header list
			createColumnHeaderList(this);
        }); 
	};

	/**
	 * Shows or hides table columns.
	 *
	 * @param {integer|array} columns		A number or an array of numbers. The display state(visible/hidden) for each column with the matching column index will get toggled.
	 *							Column index starts at 1! (see the example)
	 *
	 * @param {map} options		An object for optional settings to handle the on and off CSS classes in the column header list (options described below).
	 * @option {string} listTargetID	The ID attribute of the element with the column header.
	 * @option {string} onClass		A CSS class that is used on the items in the column header list, for which the column state is visible 
	 * @option {string} offClass		A CSS class that is used on the items in the column header list, for which the column state is hidden.
	 * @option {function} show		Function which is called to show a table cell.
	 * @option {function} hide		Function which is called to hide a table cell.
	 *
	 * @example $('#table').toggleColumns([2, 4], {hide: function(cell) { $(cell).fadeOut("slow"); }});
	 * @before <table id="table">
	 *   			<thead>
	 *   				<th>one</th
	 *   				<th>two</th
	 *   				<th>three</th
	 *   				<th>four</th
	 *   			</thead>
	 * 		   </table>
	 * @desc Toggles the visible state for the columns "two" and "four". Use custom function to fade the cell out when hiding it.
	 *
	 * @example $('#table').toggleColumns(3, {listTargetID: 'theID', onClass: 'vis'});
	 * @before <table id="table">
	 *   			<thead>
	 *   				<th>one</th
	 *   				<th>two</th
	 *   				<th>three</th
	 *   				<th>four</th
	 *   			</thead>
	 * 		   </table>
	 * @desc Toggles the visible state for column "three" and sets or removes the CSS class 'vis' to the appropriate column header according to the visibility of the column.
	 *
	 * @type jQuery
	 *
	 * @name toggleColumns
	 * @cat Plugins/columnManager
	 * @author Roman Weich (http://p.sohei.org)
	 */
	$.fn.toggleColumns = function(columns, cmo)
	{
        return this.each(function() 
        {
			var i, toggle, di, 
				rows = this.rows, 
				colsVisible = this.cMColsVisible;

			if ( !columns )
				return;

			if ( columns.constructor == Number )
				columns = [columns];

			if ( !colsVisible )
				colsVisible = this.cMColsVisible = [];

			//go through all rows in the table and hide the cells
			for ( i = 0; i < rows.length; i++ )
			{
				var cells = rows[i].cells;
				for ( var k = 0; k < columns.length; k++ )
				{
					var col = columns[k] - 1;
					if ( col >= 0 )
					{
						//find the cell with the correct index
						var c = getCell(this, cells, col);
						//cell not found - maybe a previous one has a colspan? - search it!
						if ( !c )
						{
							var cco = col;
							while ( cco > 0 && !(c = getCell(this, cells, --cco)) ) {} //find the previous cell
							if ( !c )
							{
								continue;
							}
						}
						//set toggle direction
						if ( colsVisible[col] == undefined )//not initialized yet
						{
							colsVisible[col] = true;
						}
						if ( colsVisible[col] )
						{
							toggle = cmo && cmo.hide ? cmo.hide : hideCell;
							di = -1;
						}
						else
						{
							toggle = cmo && cmo.show ? cmo.show : showCell;
							di = 1;
						}
						if ( !c.chSpan )
						{
							c.chSpan = 0;
						}
						//the cell has a colspan - so dont show/hide - just change the colspan
						if ( c.colSpan > 1 || (di == 1 && c.chSpan && cellVisible(c)) )
						{
							//is the colspan even reaching this cell? if not we have a rowspan -> nothing to do
							if ( c.realIndex + c.colSpan + c.chSpan - 1 < col )
							{
								continue;
							}
							c.colSpan += di;
							c.chSpan += di * -1;
						}
						else if ( c.realIndex + c.chSpan < col )//a previous cell was found, but doesn't affect this one (rowspan)
						{
							continue;
						}
						else //toggle cell
						{
							toggle(c);
						}
					}
				}
			}
			//set the colsVisible var
			for ( i = 0; i < columns.length; i++ )
			{
				this.cMColsVisible[columns[i] - 1] = !colsVisible[columns[i] - 1];
				//set the appropriate classes to the column header list, if the options have been passed
				if ( cmo && cmo.listTargetID && ( cmo.onClass || cmo.offClass ) )
				{
					var onC = cmo.onClass, offC = cmo.offClass, $li;
					if ( colsVisible[columns[i] - 1] )
					{
						onC = offC;
						offC = cmo.onClass;
					}
					$li = $("#" + cmo.listTargetID + " li").filter(function(){return this.cmData && this.cmData.col == columns[i] - 1;});
					if ( onC )
					{
						$li.removeClass(onC);
					}
					if ( offC )
					{
						$li.addClass(offC);
					}
				}
			}
			saveCurrentValue(this);
		});
	};

	/**
	 * Shows all table columns.
	 * When columns are passed through the parameter only the passed ones become visible.
	 *
	 * @param {integer|array} columns		A number or an array of numbers. Each column with the matching column index will become visible.
	 *							Column index starts at 1!
	 *
	 * @param {map} options		An object for optional settings which will get passed to $().toggleColumns().
	 *
	 * @example $('#table').showColumns();
	 * @desc Sets the visibility state of all hidden columns to visible.
	 *
	 * @example $('#table').showColumns(3);
	 * @desc Show column number three.
	 *
	 * @type jQuery
	 *
	 * @name showColumns
	 * @cat Plugins/columnManager
	 * @author Roman Weich (http://p.sohei.org)
	 */
	$.fn.showColumns = function(columns, cmo)
	{
        return this.each(function() 
        {
			var i,
				cols = [],
				cV = this.cMColsVisible;
			if ( cV )
			{
				if ( columns && columns.constructor == Number ) 
					columns = [columns];

				for ( i = 0; i < cV.length; i++ )
				{
					//if there were no columns passed, show all - or else show only the columns the user wants to see
					if ( !cV[i] && (!columns || $.inArray(i + 1, columns) > -1) )
						cols.push(i + 1);
				}
				
				$(this).toggleColumns(cols, cmo);
			}
		});
	};

	/**
	 * Hides table columns.
	 *
	 * @param {integer|array} columns		A number or an array of numbers. Each column with the matching column index will get hidden.
	 *							Column index starts at 1!
	 *
	 * @param {map} options		An object for optional settings which will get passed to $().toggleColumns().
	 *
	 * @example $('#table').hideColumns(3);
	 * @desc Hide column number three.
	 *
	 * @type jQuery
	 *
	 * @name hideColumns
	 * @cat Plugins/columnManager
	 * @author Roman Weich (http://p.sohei.org)
	 */
	$.fn.hideColumns = function(columns, cmo)
	{
        return this.each(function() 
        {
			var i,
				cols = columns,
				cV = this.cMColsVisible;
			if ( cV )
			{
				if ( columns.constructor == Number ) 
					columns = [columns];
				cols = [];

				for ( i = 0; i < columns.length; i++ )
				{
					if ( cV[columns[i] - 1] || cV[columns[i] - 1] == undefined )
						cols.push(columns[i]);
				}
				
			}
			$(this).toggleColumns(cols, cmo);
		});
	};
})(jQuery);
/*jquery.hint.js*/
/**
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/

(function ($) {

$.fn.hint = function (blurClass) {
  if (!blurClass) { 
    blurClass = 'blur';
  }
    
  return this.each(function () {
    // get jQuery version of 'this'
    var $input = $(this),
    
    // capture the rest of the variable to allow for reuse
      title = $input.attr('title'),
      $form = $(this.form),
      $win = $(window);

    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }

    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title
      
      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
};

})(jQuery);
/*jquery.popup.js*/
//0 means disabled; 1 means enabled;
var popStatus = 0;

//loading popup with jQuery magic!
function openPopup(strTitle,strMsg,timeOut,contClass,background){
	//loads popup only if it is disabled
  
  //if(popStatus==0){
    var popupNr = $(".popupcont").size()+1;
    var popupid = "popupcont"+popupNr;
    
    
		$("body").append("<div id='"+popupid+"' class='popupcont "+contClass+"'><div class='outer'><div class='inner'><div class='hdr'><div class='l'>&#160;</div><div class='c'><p>"+strTitle+"</p></div><div class='r'><a class='popupclose'>x</a></div><br class='clear'/></div><div class='cnt'><div class='out'><div class='in'>"+strMsg+"</div></div><br class='clear' /></div><div class='ftr'><div class='l'>&#160;</div><div class='c'>&#160;</div><div class='r'>&#160;</div></div></div></div><br class='clear'/></div>");
    if(background){
      $("body").append("<div id='popupbckg'>&#160;</div>");
      $("#popupbckg").css({
			 "opacity": "0.7"
		  });
		  $("#popupbckg").fadeIn("slow");
		  }
		centerPopup($("#"+popupid));
    $("#"+popupid).slideToggle("slow");
		//popStatus = 1;
	  popupInit($("#"+popupid),timeOut);
  //}

  return $("#"+popupid);
}


function closePopup(popupcont){
 closePopup(popupcont,"slow");
}

function closePopup(popupcont,speed){
	//if(popStatus==1){
	  popupcont.slideToggle(speed);
    window.setTimeout(function(){popupcont.remove();},1000);	
    
    if($(".popupcont").size() < 1)
    {
      $("#popupbckg").fadeOut(speed);	
      window.setTimeout(function(){$("#popupbckg").remove();},1000);
      //popStatus = 0;
    }
	//}
}

function centerPopup(popupcont){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var scrollTop  = $(window).scrollTop();
	popupcont.css("visibility","hidden");
  popupcont.css("display","block");
  var popupHeight = popupcont.height();
	var popupWidth = popupcont.width();
  popupcont.css("visibility","visible");
	popupcont.css("display","none");
	popupcont.css({
		"position": "absolute",
		"top": windowHeight/2+scrollTop-popupHeight/2+$(".popupcont").size()*15,
		"left": windowWidth/2-popupWidth/2+$(".popupcont").size()*15
	});
	//only need force for IE6
	
	$("#popupbckg").css({
		"height": windowHeight
	});
	
}

/*---inicializace akci---*/
function popupInit(popupcont,timeOut){
	//CLOSING POPUP
	//Click the x event!
	popupcont.click(function(){
		closePopup(popupcont);
	});
	//Click out event!
	popupcont.children(".popupclose").click(function(){
		closePopup(popupcont);
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popStatus==1){
			closePopup(popupcont);
		}
	});
	
	if(timeOut>0)
	 window.setTimeout(function(){closePopup(popupcont);},timeOut);
}

/*default.js*/
var isCallbackMode = false;
var strId="";
//zobrazovani leveho stromu
function lm_strid_active(id){
  var idNone, idBlock, el, d
  if(id > 0){
    idNone = 0
    idBlock = 1
    d = new Date(2050, 12, 31)
  }else{
    idNone = 1
    idBlock = 0
    d = new Date(2000, 12, 31)
  }  
  document.cookie = "i6_lm_strtype=" + id + "; expires=" + d.toGMTString() + "; path=/"

  el = document.getElementById('div_strid_' + idNone)
  if(el){
    if(el.style.display != 'none'){
      el.style.display = 'none'
      document.getElementById('td_strid_' + idNone).setAttribute('className', 'td_strid_hide')
      document.getElementById('td_strid_' + idNone).setAttribute('class', 'td_strid_hide')
      document.getElementById('div_strid_' + idNone).setAttribute('className', 'div_strid_hide')
      document.getElementById('div_strid_' + idNone).setAttribute('class', 'div_strid_hide')
    }
  }
  el = document.getElementById('div_strid_' + idBlock)
  if(el){
    if(el.style.display != 'block'){
      document.getElementById('td_strid_' + idBlock).setAttribute('className', 'td_strid_block')
      document.getElementById('td_strid_' + idBlock).setAttribute('class', 'td_strid_block')
      document.getElementById('div_strid_' + idBlock).setAttribute('className', 'div_strid_block')
      document.getElementById('div_strid_' + idBlock).setAttribute('class', 'div_strid_block')
      el.style.display = 'block'
    }
  }
}

//Zmena nazvu z fulltext na fulltextsiv pro vyhledavani SivCide - pro ACI
function ChangeFullText(form){
  var fullt = form.elements[0]
  if(fullt.value.substring(0, 1) == "/"){
    fullt.name = "fulltextsiv"
    fullt.value = fullt.value.substring(1)
  }
} 

//Scripty pro toolbar tb
function tbClick(input){
  var form = input.form
  switch(input.name){
    case 'cmdNew':
      document.location = form.redirect.value + '-1' + '&u_tbClick=cmdNewWith'
      break;
    case 'cmdNewWith':
      tbCmdDis(true, form, 0, 1)
      form[form.PK_name.value].value = -1
      form.action.value = 'new'
      form.redirect.value = form.redirect.value + 'PRIMARY_KEY'
      break;
    case 'cmdChange':
      tbCmdDis(true, form, 1, 0)
      form.action.value = 'change'
      if(form.redirect.value.substr(form.redirect.value.length - form.PK_value.value.length) != form.PK_value.value) form.redirect.value = form.redirect.value + form.PK_value.value
      //form.redirect.value = form.redirect.value + form.PK_value.value
      break;
    case 'cmdDelete':
      if(DelConfirm()){
        document.location.href = '?cls=' + form.cls.value + '&' + form.PK_name.value + '=' + form.PK_value.value + '&action=delete&redirect=' + escape(form.redir_del.value)
      }
      break;
    case 'cmdSubmit':
      //form.submit()
      break;
    case 'cmdReset':
      form.reset()
      tbCmdDis(false, form, 0, 2)
      break;
  }
}
        
function tbCmdDis(blnDisabled ,form, restricted, empty){
  form.cmdNew.disabled = blnDisabled
  form.cmdNewWith.disabled = blnDisabled
  form.cmdChange.disabled = blnDisabled
  form.cmdDelete.disabled = blnDisabled
  form.cmdSubmit.disabled = !blnDisabled
  form.cmdReset.disabled = !blnDisabled
  var tab
  if(blnDisabled) tab = 'tabedit' 
    else tab = 'tabform'
  document.getElementById('tbfrm').className = tab
  
    if ($)
    {
      if(blnDisabled)
        $("#tbfrm").parents(".tabdetailpart").addClass("editing");
      else
         $("#tbfrm").parents(".tabdetailpart").removeClass("removeclass");
    }
  
  for(var i = 0, e; i < form.elements.length; i++){
    e = form.elements[i]
    if(e.type == 'button' || e.type == 'submit'){         //jestlize je nazev butonu obsazen v hidden prvku TB_disabled potom je tento buton disabled
      if(form.TB_disabled.value.indexOf(form.elements[i].name) >= 0) form[form.elements[i].name].disabled = true
      tbStyle(form.elements[i])
    }else{
      if(e.type != 'hidden') if(e.name.indexOf("_disabled") == -1 || (e.name.indexOf("_null") != -1 && empty == 2)) if(e.value != "#NA#") if(form.restricted_fields.value.indexOf(e.name + ",") == -1 || restricted == 0) form.elements[i].disabled = !blnDisabled
      //nepredplnovani prijmeni a jmena firemniho kontaktu
      if(e.name.indexOf("_null") != -1 && empty == 1){
        form.elements[i].value = '';
        form.elements[i].disabled = !blnDisabled;
        if (form.elements[i].name.indexOf("con") != -1) form.elements[i].name = form.elements[i].name.substr(0, e.name.indexOf("_disabled")) //pro typ kontaktu
      }
    }
  }
  if(form.name == "frmordedit") form.comname.disabled = true
}

function tbInit(what){
  var dis = ''
  for(var i = 0; i < document.forms.length; i++){
    var f = document.forms[i]
    for(var j = 0; j < f.elements.length; j++){
      var input = f.elements[j]
      if(input.name == 'TB_disabled') dis = input.value                     //do promenne dis nazvy butonu, ktere maji byt disabled
      if(input.type == 'button'){
        if(dis != '' && dis.indexOf(input.name) >= 0) input.disabled = true   //jestlize nazev butonu je obsazen v promenne dis je tento buton disabled
        if(input.name == what){
          if(input.disabled == false) input.click()
            else alert(GetLng("lngzj2"))
        }
        //tbStyle(input)
      }
      if(input.type != 'text' && input.type != 'hidden' && input.type != 'textarea' && input.type != 'select-one') tbStyle(input)
    }
  }
}

function tbStyle(input){
    if(input.disabled == true){
      input.style.cursor = 'default'
      switch(input.name){
        case 'cmdNew':
          input.className = 'toolbar toolbar_new_disable';
          break;
        case 'cmdNewWith':
          input.className = 'toolbar toolbar_new_with_disable';
          break;
        case 'cmdChange':
          input.className = 'toolbar toolbar_change_disable';
          break;
        case 'cmdDelete':
          input.className = 'toolbar toolbar_delete_disable';
          break;
        case 'cmdSubmit':
          input.className = 'toolbar toolbar_submit_disable';
          break;
        case 'cmdReset':
          input.className = 'toolbar toolbar_reset_disable';
          break;
      }
    }else{
      input.style.cursor = 'hand'
      switch(input.name){
        case 'cmdNew':
          input.className = 'toolbar toolbar_new_active';
          break;
        case 'cmdNewWith':
          input.className = 'toolbar toolbar_new_with_active';
          break;
        case 'cmdChange':
          input.className = 'toolbar toolbar_change_active';
          break;
        case 'cmdDelete':
          input.className = 'toolbar toolbar_delete_active';
          break;
        case 'cmdSubmit':
          input.className = 'toolbar toolbar_submit_active';
          break;
        case 'cmdReset':
          input.className = 'toolbar toolbar_reset_active';
          break;
      }
    }
}


//Script pro ikony - mouseover
/*
var icos = new Array(2)
icos[0] = new Image(); icos[0].src = 'img/empty.gif';
icos[1] = new Image(); icos[1].src = 'img/ico_mnuover.gif';
function icoSet(imgName, setOver){
  document.images[imgName].src = icos[setOver].src;
}
*/


//Smaze zaznam v klientech, dod. adresach a parametrech
function DelItem(u_mode, id1, id2){
  var action = 'u_mode='
  var msg = ''
  switch(u_mode){
    case 'contact':
      if(DelConfirm()){
        document.location.href = '?cls=contact&conid=' + id1 + '&action=delete&redirect=' + escape('?mtc=2&cls=contacts&catalogs=forcontact&concomid=' + id2)
      }
      break;
    case 'comshipto':
      if(DelConfirm()){
        document.location.href = '?cls=comshipto&cstid=' + id1 + '&action=delete&redirect=' + escape('?mtc=2&cls=comshiptos')
      }
      break;
    case 'cps':
      if(DelConfirm()){
        document.location.href = '?cls=conparset&cpsid=' + id1 + '&action=delete&redirect=' + escape('?mtc=2&cls=contacts&xsl=xcontactsp&conparsets=1&catalog=scategorysys&conid=' + id2)
      }
      break;
    case 'offer':
      if(DelConfirm()){
        document.location.href = '?cls=orditem&oriid=' + id1 + '&action=delete&redirect=' + escape('?mtc=1&cls=orders&xsl=xofferdea&ordid=' + id2)
      }
      break;
    case 'offers':
      if(DelConfirm()){
        document.location.href = '?cls=orders&ordid=' + id1 + '&action=delete&redirect=' + escape('?mtc=1&cls=orderss&xsl=xofferdea')
      }
      break;
  }
  return false;
}



//Odkaz na dane adresy pomoci javascriptu
function g(where, id, tag){
  if(tag == null) tag = ''
  var addr = ''
  switch (where){
    case 'sti':
      addr = '?mtc=0&cls=stoitem&stiid=' + id
      break;
    case 'ord':
      addr = '?mtc=1&cls=orders&ordid=' + id
      break;
    case 'ords':
      addr = '?mtc=1&cls=orderss&items=1&ordid=' + id
      break;
    case 'inv':
      addr = '?mtc=1&cls=invoice&invid=' + id
      break;
    case 'del':
      addr = '?mtc=1&cls=deliveries&items=1&delid=' + id
      break;
    case 'offer':
      addr = '?mtc=1&cls=orders&xsl=xofferdea&ordid=' + id
      break;
    case 'com':
      addr = '?mtc=2&cls=company&catalogs=forcompany&comid=' + id
      break;
    case 'concom':
      addr = '?mtc=2&cls=company&catalogs=forcompany&concomid=' + id
      break;
    case 'con':
      addr = '?mtc=2&cls=contact&catalogs=forcontact&conid=' + id
      break;
    case 'ship':
      addr = '?mtc=2&cls=comshipto&catalog=country&cstid=' + id
      break;
      case 'rec':
      addr = '?mtc=1&cls=reclaim&recid=' + id
      break;
  }
  if(addr != '') document.location.href = addr
}



//Prevede produkt do kosiku nebo aktivni objednavky
//Je-li zadan argument tag typu objekt provadi vlozeni aktualniho radku, jinak projizdi vsechny formy a hleda zaskrtnute produkty
function buy(ordtype, ordid, callform){
  var stiids = new Array();
  var qtys = new Array();
  var n = 0
  var fs;
  var fsn = 0
  
  if(callform == null){
    fs = document.forms;
  }else{
    fs = new Array(0)
    fs[0] = callform;
  }
  
  fsn = fs.length
  for(var i = 0; i < fsn; i++){
    var f = fs[i]
    if(f.elements)
      if(f.qty && f.stiid)
        if(callform != null || (callform == null && f.stiid.checked))
          if(f.qty.value > 0)
            if(f.stiid.value > 0) {
      stiids[n] = (f.stiid.value - 0);
      qtys[n] = (f.qty.value - 0);
      n += 1
    }
  }
  
  if(n > 0){    
    var url = 'default.asp?';
    var prefqty = '';
    var prefstiid = 'stiid';
    //VEP - -3 = vlozit mezi oblibene produkty, -4 odstranit
    if ((ordtype == -1) || (ordtype == -2) || (ordtype == -3) || (ordtype == -4)){
      if (ordtype == -2){
        var url = 'print.asp?';
        url += 'cls=iisutil&action=stiparcomp'
      }else{
        if ((ordtype == -3) || (ordtype==-4))
        {
	        prefqty = 'qty'
	        if (ordtype == -3) {
	       	   url += 'cls=iisutil&action=stifavourites&method=add&redirect=%3Fcls%3Dstoitems%26stifavourites%3D1';
	        }else {
	           url += 'cls=iisutil&action=stifavourites&method=del&redirect=%3Fcls%3Dstoitems%26stifavourites%3D1';
	        }
        } else {
	        prefqty = 'orbqty'
	        url += 'cls=ordbaskets';
        }
      }
    }else{
      prefqty = 'oriqty'
      url += 'cls=orders&ordid=' + ordid + '&action=additem&redirect=' + escape('?mtc=1&cls=orders&ordid=' + ordid);
      if (ordtype == 2){
        url += escape('&xsl=xofferdea&u_edit=1')
      }else{
        url += escape('&xsl=xordersedit&blocations=1&catalogs=fororders&edititems=1&useraction=editnew' + (n == 1 ? '&useraction1=addnew' : '&usereditwhat=oriblock'));
      }
    }
    
    for(var i = 0; i < n; i++){
      if (ordtype == -2){
       url += '&stiid=' + stiids[i]
      }else{
        {
          url += '&' + prefstiid + '=' + stiids[i] + '&' + prefqty + '=' + qtys[i];
        }
      }
    }

    if(ordtype == -1){
      buyAsync(url); return false;
    }

    // porovnani produktu se otevira do noveho okna, ostatni veci do stejneho okna
    if (ordtype == -2){
      win = window.open(url, 'ProductsCompare', 'toolbar=yes,scrollbars=yes,location=no,status=yes,resizable=yes,width=950,height=600,top=25,left=25');
      win.focus();
      return false;
    }else{
      document.location.href = url
    }

  }else alert(GetLng("lngzj3"))
  return false
}

//obsluha panelu pro vyber co s oznacenyma produktama udelat
//bylo by asi dobre to jeste upravit, jako je to v B2C
//POZOR panel co je v XINCSTOITEMS.XSL vola misto teto funkce funkci: buy(ordtype, ordid, callform)
function ProductsChooser(msg){

  var p=0;
  var act = document.getElementById("products_chooser").value;

  switch (act){
  case "-1": //do kosiku - ZATIM NEFUNKCNI!!!
    var url = '?mode=ZObList';
    for (var i=1; document.getElementById("choosed"+i); i++){
      if (document.getElementById("choosed"+i).checked){
        url += '&ZObStiId=' + document.getElementById("choosed"+i).value + '&ZObQty=' + document.getElementById("choosedqty"+i).value;
        p += 1;
      }
    }
    break;
  case "-2": //porovnavani
    var url = 'print.asp?cls=iisutil&action=stiparcomp';
    for (var i=1; document.getElementById("choosed"+i); i++){
      if (document.getElementById("choosed"+i).checked){
        url += '&stiid=' + document.getElementById("choosed"+i).value;
        p += 1;
      }
    }
    break;
  case "-4": //odebrat z kosiku (CHYBA - z kosiku se zde odebira jinak nez v B2C)
    var url = '?cls=ordbaskets';
    for (var i=1; document.getElementById("choosed"+i); i++){
      if (document.getElementById("choosed"+i).checked){
        url += '&stiid=' + document.getElementById("choosed"+i).value + '&orbqty=0';
        p += 1;
      }
    }
    // alert(url);
    break;
  default:
    alert('!!! zatím funkční pouze porovnávání !!!');
    return;
  }

  if (p == 0){
    alert(msg);
  } else {
    // porovnani produktu se otevira do noveho okna, ostatni veci do stejneho okna
    if (act == -2){
      win = window.open(url, 'ProductsCompare', 'toolbar=yes,scrollbars=yes,location=no,status=yes,resizable=yes,width=950,height=600,top=25,left=25');
      win.focus();
      return;
    }else{
      document.location.href = url
    }
  }
}

function PasteToFormX(argstr){
  var a = argstr.split(',');
  var openerFormName, index
  if(a.length > 0) openerFormName = a[0]
  if(a.length > 1) argstr = a[1]
  if(a.length > 2) index = a[2]
  PasteToForm(openerFormName, argstr, index)
}

function PasteToForm(openerFormName, argstr, index){
  var frm = self.opener.document.forms[openerFormName];
  var args = argstr.split('&');
  var sName, sValue, iPoz, inp, isA
  if(index == null) index = 0
  for (var i = 0; i < args.length; i++){
     iPoz = args[i].indexOf('=');
     sName = iPoz > -1 ? args[i].substring(0, iPoz) : '';
     sValue = iPoz > -1 ? args[i].substring(iPoz + 1, args[i].length) : '';
     inp = frm.elements[sName]
     if(inp){
       isA = (inp.length ? true : false)
       if(isA) isA = (inp.type ? false : true)
       if(isA){//pole elementu
         if(inp.length > index) inp[index].value = sValue
       }else{
         if(index == 0) inp.value = sValue
       }
     }
     //if(eval('frm.' + sName)) eval('frm.' + sName + '.value = \'' + sValue + '\'');
  }
 self.close();
}


function DelConfirm(){
  return confirm(GetLng("lngzj1"));
}


function FormClear(form){
  var input, it
  for(var i = 0; i < form.elements.length; i++){
    input = form.elements[i]
    it = input.type
    if(input.disabled == null) return true
    if(it == 'text' || it == 'checkbox'){
      if(input.value == '' || input.value == input.title) input.disabled = true
    } else if(it == 'select-one'){
      if(input.selectedIndex < 0) input.disabled = true
      else if(input.options[input.selectedIndex].value == '') input.disabled = true
    }
  }
  return true
}

//pokud je firma zahranicni a neni vyplneno DIC, pak ComTax=0
function CheckComTax(form){
	if(form.comxcouid.value != 0 && form.comtaxnum.value == '') form.comtax.value = 0
}

function CheckFormVal(form){
  var EmptyVal = '';
  var ErrList = '';
  var ErrLine = '';

	//pokud je firma zahranicni a neni vyplneno DIC, pak ComTax=0  
  if(form.comtax)if(form.comxcouid)if(form.comxcouid.value != 0 && form.comtaxnum.value == '') form.comtax.value = 0

	//Firma
	if(form.comreg_company){
		if(form.comreg_company.value == 1){
			if(form.comregid) if(form.comregid.value == '') ErrList = ErrList + '   ' + GetLng("lngzj14") + '\n';
			if(form.comregid) if(form.comregid.value.indexOf(" ") != -1) ErrList = ErrList + '   ' + GetLng("lngzj14") + '\n';
			if(form.comregid) if ((form.comregid.value == '') || (isNaN(form.comregid.value)) || ((isFinite(form.comregid.value)) && (((form.comregid.value) < 1) || ((form.comregid.value) > 99999999)))) ErrList = ErrList + '   ' + GetLng("lngzj14a") + '\n';
		}
	}
  if(form.comtaxnum) if(form.comtaxnum.value.indexOf(" ") != -1) ErrList = ErrList + '   ' + GetLng("lngzj15") + '\n';
  if(form.comstreet) if(form.comstreet.value == '') ErrList = ErrList + '   ' + GetLng("lngzj22") + '\n';
  if(form.comcity) if(form.comcity.value == '') ErrList = ErrList + '   ' + GetLng("lngzj8") + '\n';
  if(form.compostcode) if(form.compostcode.value == '') ErrList = ErrList + '   ' + GetLng("lngzj9") + '\n';

  //Kontakt
  if(form.conlname) if(form.conlname.value == '') ErrList = ErrList + '   ' + GetLng("lngzj10") + '\n';
  if(form.confname) if(form.confname.value == '') ErrList = ErrList + '   ' + GetLng("lngzj11") + '\n';
  if(form.conemail){
    if(form.conemail.value == '') ErrList = ErrList + '   ' + GetLng("lngzj12") + '\n';
    if (!CheckEmail(form.conemail.value))ErrList = ErrList + '   ' + "E-mail nemá správný formát" + '\n';
  }
  if(form.contel1) if(form.contel1.value == '') if(form.name == 'Registration') ErrList = ErrList + '   ' + GetLng("lngzj13") + '\n';

  //je li v ConTel1 cislo na mobil (zacina na 6 a 7), zkopiruje se do ConTelMob (ConTelMob musi existovat aspon jako hidden a musi byt prazdne)
  if(form.contel1 && form.contelmob && form.contel1.value != '' && form.contelmob.value == '' && form.name == 'Registration') {
    str = form.contel1.value;
    var phoneRe = /^(\+\d{3})? ?\d{3} ?\d{3} ?\d{3}$/; 
    var res = phoneRe.test(str);
    if (!res) ErrList = ErrList + '   Špatný formát telefonního čísla, zadávajte prosím ve tvaru +XXX XXX XXX XXX\n';    
    str = str.replace(/\s/g, "");
    if (str.indexOf("00420") == 0) str = str.replace("00420", "") ;
    if (str.indexOf("+420") == 0) str = str.replace("+420", "") ;
    if (str.indexOf("6") == 0 || str.indexOf("7") == 0) {
      form.contelmob.value = form.contel1.value;
      //form.contel1.value = '';
    }
  }
  
  //Je-li vyplněno IČO musí být i DIČ
  //if(form.comregid && form.comtaxnum) if((form.comregid.value != '' && form.comtaxnum.value == '') || (form.comregid.value == '' && form.comtaxnum.value != '')) ErrLine = '\n - ' + GetLng("lngzj16") + '\n';
 
  //Heslo
  if(form.ConLogPswdOld) if(form.ConLogPswdOld.value == '') ErrList = ErrList + '   ' + GetLng("lngzj17") + '\n';
  if(form.ConLogPswdNew) if(form.ConLogPswdNew.value == '') ErrList = ErrList + '   ' + GetLng("lngzj18") + '\n';
  if(form.ConLogPswdNewConfirm) if(form.ConLogPswdNewConfirm.value == '') ErrList = ErrList + '   ' + GetLng("lngzj19") + '\n';
  if(form.ConLogPswdNew && form.ConLogPswdNewConfirm) if(form.ConLogPswdNew.value != form.ConLogPswdNewConfirm.value) ErrLine ='\n - ' + GetLng("lngzj20") + '\n';
  
  //ComShipTo
  if(form.cstname) if(form.cstname.value == '') ErrList = ErrList + '   ' + GetLng("lngzj21") + '\n';
  if(form.cststreet) if(form.cststreet.value == '') ErrList = ErrList + '   ' + GetLng("lngzj22") + '\n';
  if(form.cstcity) if(form.cstcity.value == '') ErrList = ErrList + '   ' + GetLng("lngzj8") + '\n';
  if(form.cstpostcode) if(form.cstpostcode.value == '') ErrList = ErrList + '   ' + GetLng("lngzj9") + '\n';
 
 if(ErrList != '' || ErrLine != ''){
    if(ErrList != ''){
    EmptyVal = ' - ' + GetLng("lngzj5") + '\n\n'
    }
    ErrList = GetLng("lngzj6") + '\n' + EmptyVal + ErrList + ErrLine + '\n' + GetLng("lngzj4");
    alert(ErrList);
    return false;
  }else 
    if(form.comregid) if(form.comregid.value != '') form.comsname.value = (form.comname.value != '' ? form.comname.value : form.confname.value + ' ' + form.conlname.value);
    if(form.comname) if(form.comname.value == '') form.comname.value = form.conlname.value + ' ' + form.confname.value;
    return true;
}
//kontrola formatu emailu
function CheckEmail(email){
  if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
    return true;
  else
    return false;
}

function ControlPhone() {
  if(window.event){
      if (((event.keyCode < 48) || (event.keyCode > 57)) && (event.keyCode != 32)  && (event.keyCode!=40) && (event.keyCode!=41) && (event.keyCode!=43))
		  event.returnValue = false;
		} /*else {
		  if (((charCode < 48) || (charCode > 57)) && (charCode != 32)  && (charCode!=40) && (charCode!=41) && (charCode!=43))
		  event.returnValue = false;		  
    }*/
}

function ShowQueues(stiid, queqtyrequired, quexqudid){
  window.open('print.asp?cls=queues&quedir=0&catalog=queuedefinition&queqtyrequired=' + queqtyrequired + '&stiid=' + stiid + (quexqudid == null ? "" : '&quexqudid=' + quexqudid), 'ShowQueues', 'toolbar=no,scrollbars=yes,location=no,status=no,width=500,height=280,top=100,left=150'); 
}

function SetPageT(){
  var objH1 = document.getElementsByTagName('h1');
  if(objH1.length > 0){
    //document.title = objH1[0].firstChild.nodeValue + ' - ' + document.title
    document.title = document.title + ' - ' + objH1[0].firstChild.nodeValue
  }
}

function SetPageTInit(){
  if(window.attachEvent){
    window.attachEvent("onload", SetPageT)
  }else if(window.addEventListener){
    window.addEventListener("load", SetPageT, false)
  }
}

// ===== AKTIVNI STROM - sbaleni/rozbaleni vetvi ve stromu kategorii =====
function tc_ch(node){
  if((document.getElementById('tc_n' + node)) && (document.getElementById('tc_nl' + node))){
    el = document.getElementById('tc_n' + node)
    ell = document.getElementById('tc_nl' + node)
    if(el.style.display == 'none' || (el.style.display == '' && el.className == 'tc_n_h')){
      el.style.display = 'block'
      ell.style.backgroundImage = "url('img/tc_nc.gif')"
    } else {
      el.style.display = 'none'
      ell.style.backgroundImage = "url('img/tc_no.gif')"
    }
  }
}
// ===== AKTIVNI STROM - pocatecni rozbaleni vetvi ve stromu kategorii =====
function tc_start_ch(nodes){
  if(document.getElementById('tc_code')){
    nodes += document.getElementById('tc_code').value;
  }
  node = '';
  for(var i = 0; i < nodes.length; i++){
    n = nodes.substring(i, i + 1);
    if(n == ','){
      if((document.getElementById('tc_n' + node)) && (document.getElementById('tc_nl' + node))){
        el = document.getElementById('tc_n' + node);
        ell = document.getElementById('tc_nl' + node);
        el.style.display = 'block';
        ell.style.backgroundImage = "url('img/tc_nc.gif')";
      }
      node = '';
      n = '';
    }
    node += n;
  }
}
function obj_on(obj){
  if (document.getElementById(obj)) {
    el = document.getElementById(obj)
    el.style.display = 'block'
  }
}
function obj_off(obj){
  if (document.getElementById(obj)) {
    el = document.getElementById(obj)
    el.style.display = 'none'
  }
}
function obj_swap(obj){
  if (document.getElementById(obj)) {
    el = document.getElementById(obj)
    if(el.style.display == 'block' || el.style.display == ''){
      el.style.display = 'none'
    } else {
      el.style.display = 'block'
    }
  }
}

function set_cookie(c_name,value,expiredays){
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";path=/;expires="+exdate.toGMTString());
}
function get_cookie(c_name){
  if (document.cookie.length>0){
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1){
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function OBJ(oId){
	var o;
	if (document.getElementById){
		if (document.getElementById(oId)){
			o = document.getElementById(oId);
		} else {
			if (document.forms[oId]){
				o = document.forms[oId];
			} else {
				o = null;
			}
		}
	} else {
		if (document.all[oId]){
			o = document.all[oId];
		} else {
			if (document.forms[oId]){
				o = document.forms[oId];
			} else {
				o = null;
			}
		}
	}
	return o;
}
//SetPageTInit()

//Ovladani zalozek na detailu produktu
function ShowStiTab(id_tab){
	for (var i = 0; i < document.getElementById("sti_tabs").childNodes.length; i++){
		if(id_tab == i){
			document.getElementById(i + "_tab").className = "sti_tab_block"
			document.getElementById(i + "_content").className = "sti_content_block"
		}else{
			document.getElementById(i + "_tab").className = "sti_tab_hidden"
			document.getElementById(i + "_content").className = "sti_content_hidden"
		}
	}
}
//Galerie
function ScrollImages(sDirection){
  if(!sEnabledScroll){return 0}
  var xMax = document.getElementById('scrollarea').scrollLeft;
  if(sDirection == 'L'){
    document.getElementById('scrollarea').scrollLeft = xMax + 40;
    xCurr = document.getElementById('scrollarea').scrollLeft;
    if(sEnabledScroll){setTimeout("ScrollImages('L')", 100);}
  } else {
    document.getElementById('scrollarea').scrollLeft = xMax - 40;
    xCurr = document.getElementById('scrollarea').scrollLeft;
    if(sEnabledScroll){setTimeout("ScrollImages('R')", 100);}
  }
}
function MoveImages(sDirection,bSeoUrl){
  var a_img = js_array.split(",");
  var a_img_name = js_array_name.split(",");  
  if(sDirection == 'L'){
    for (var i = 0; i < a_img.length; i++) {
      if (a_img[i]==sSelImg && a_img[i+1]){
        if (bSeoUrl=='True'){
          document.getElementById('origimg').src = a_img_name[i+1] + '_ies' + a_img[i+1] + '.jpg';
        }else{
          document.getElementById('origimg').src='img.asp?attid=' + a_img[i+1];
        }
        sSelImg = a_img[i+1];
        break;
      }
    }
  } else {
    for (var i = 0; i < a_img.length; i++) {
      if (a_img[i]==sSelImg && a_img[i-1]){
        if (bSeoUrl=='True'){
          document.getElementById('origimg').src = a_img_name[i-1] + '_ies' + a_img[i-1] + '.jpg';
        }else{
          document.getElementById('origimg').src='img.asp?attid=' + a_img[i-1];
        }      
        sSelImg = a_img[i-1];
      }
    } 
  }       
}
function Gallery(StiId,AttId){
  var sURL = 'print.asp?stiid='+StiId+'&attid='+AttId+'&cls=stoitem&xsl=xgallery';
  win = window.open(sURL, 'Enlargement', 'location=no,scrollbars=no');
  win.focus();
  return false;  
  
}
// změna stylu pro aktuální kategorii
function cattreebold(id){
	if(document.getElementById('tc_a_' + id)){
    	document.getElementById('tc_a_' + id).className = 'tc_a tc_a_active'
	  }
}
// pro parametrické vyhledávání (checkbox jako radio)
// po kliku na element vymění background a současně nastaví příslušný checkbox
// id=id klikacího elementu, idcheck=id přidruženého checkboxu, iid=id parametru
function fcprcheckswitch(id,idcheck,idd){
  var el, elcheck, elX, elcheckX
  if(document.getElementById(id)){
	el = document.getElementById(id);
	  if(document.getElementById(idcheck)){
	  	elcheck = document.getElementById(idcheck);

	        if(elcheck.checked == false) {
			el.style.background = "url('img/DECprCheckOn.gif') no-repeat 0 0";
			//elcheck.checked = true;
			if(document.getElementById('prchX'+idd)){
				elX = document.getElementById('prchX'+idd);
				if(document.getElementById('prchObjX'+idd)){
					elcheckX = document.getElementById('prchObjX'+idd);
					elX.style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
					elcheckX.checked = false;
				}
			}
			elcheck.click();
        	}else {
		      el.style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
		      //elcheck.checked = false;
		      elcheck.click();
		} 
	  }
  }
}

// pro parametrické vyhledávání (checkbox jako radio)
// nastaví se odpovídající checbox a jsou vynulovány všechny hodnoty daného parametru
// id=id parametru, count=počet možných hodnot
function fcprcheckoff(id,count){
  var el, elcheck
  if(document.getElementById('prchX'+id)){
    el = document.getElementById('prchX'+id);
    if(document.getElementById('prchObjX'+id)){
	elcheck = document.getElementById('prchObjX'+id);
	if(elcheck.checked == false) {
		el.style.background = "url('img/DECprCheckOn.gif') no-repeat 0 0";
		//elcheck.checked = true;
			for (var i = 0; i<count; i++) {
			  if(document.getElementById('prch'+id+'x'+(i+1))){
				  if(document.getElementById('prchObj'+id+'x'+(i+1))){
				      document.getElementById('prch'+id+'x'+(i+1)).style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
				      document.getElementById('prchObj'+id+'x'+(i+1)).checked = false;
				  }
			  }
			}
     elcheck.click(); 
      	}
       /* else {
		el.style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
		elcheck.checked = false;
		
	}*/
    }
  }
}

/*function fillCompareDetailsTable(){

  var tblComp = $(".comparedetails table")
  if(unescape($.cookie("comparedetails")).length > 20)
    {
      var arryData = unescape($.cookie("i6_comparedetails_data")).split('###');
      alert('cely string: '+arryData);
      
      for(zz=0;zz<arryData.length;zz++)
      {
        if($.trim(arryData[zz]).length>0)
        {
        alert('jeden radek: '+arryData[zz]);
        alert(GetValueFromArray(arryData[zz],'stiid')+GetValueFromArray(arryData[zz],'link')+GetValueFromArray(arryData[zz],'sticode')+GetValueFromArray(arryData[zz],'stiname')+GetValueFromArray(arryData[zz],'stiprice'));
        }
      }
    
      $(".comparedetails table *").remove();
      tblComp.append(unescape($.cookie("comparedetails")));
    }  
}*/

function initCompareElements(){
  
  updateCompareUI();
  
  $("#compcont").mouseenter(function(){
    //$(".comparedetails").show("slow");    
    if($("#comparedetailstable td").length>0)
    window.setTimeout(function(){$("#comparedetails").show("slow")},200);
  })
  
  $("#compcont").mouseleave(function(){
    //$(".comparedetails").hide("slow");
    if($("#comparedetailstable td").length>0)
    window.setTimeout(function(){$("#comparedetails").hide("slow")},1000);
  })    
    
/*   $(".comparedetails").mouseenter(function(){
    $(".comparedetails").show("slow");    
    //window.setTimeout(function(){$(".comparedetails").show("slow")},400);
  })
  
  $(".comparedetails").mouseleave(function(){
    //$(".comparedetails").hide("slow");
    window.setTimeout(function(){$(".comparedetails").hide("slow")},4000);
  })
  */  
  $("#compcont .btncomp").click(function(){
    
    if(Number($("#comparecount").text())>0){
        win = window.open("print.asp?"+$("#comparedetails form").serialize(), 'ProductsCompare', 'toolbar=yes,scrollbars=yes,location=no,status=yes,resizable=yes,width=950,height=600,top=25,left=25');
        win.focus();
      }
     else{
        openPopup('','<p>'+GetLng("lngnoitemsselected")+'</p>',5000,'msgerrcomp_empty',false);
     } 
    return false;
  });
  
  $("#compareanchor").click(function(){
    
    if(Number($("#comparecount").text())>0){
        win = window.open("print.asp?"+$(".comparedetails form").serialize(), 'ProductsCompare', 'toolbar=yes,scrollbars=yes,location=no,status=yes,resizable=yes,width=950,height=600,top=25,left=25');
        win.focus();
      }
     else{
        openPopup('','<p>'+GetLng("lngnoitemsselected")+'</p>',5000,'msgerrcomp_empty',false);
     } 
    return false;
  });
  
}

function updateCompareUI() {

  var itemsCount = 0 
  var arryData = unescape($.cookie("i6_comparedetails_data")).split('###');
  $("#comparedetailstable tr.item").remove();
  
  if (unescape($.cookie("i6_comparedetails_data")).length<10)
  {
    $("#comparecount").text(itemsCount);
    return;
  }
  for(zz=0;zz<arryData.length;zz++)
  {
    if($.trim(arryData[zz]).length>0)
    {
      stiid = GetValueFromArray(arryData[zz],'stiid'); 
      btnRemove = '<div class="btnn rmvcomp"><a href="javascript:removeCompareItem('+stiid+');" title="'+GetLng("lngremove")+'"><p>&#160;</p><strong><p>'+GetLng("lngremove")+'</p></strong><span>&#160;</span></a><br class="clear"/></div>'
      $("#comparedetailstable").append("<tr id='comp"+stiid+"' class='item'><td class='left'><input type='hidden' name='stiid' value='"+stiid+"'/></td><td class='code'>"+GetValueFromArray(arryData[zz],'sticode')+"</td><td class='name'>"+GetValueFromArray(arryData[zz],'stiname')+"</td><td class='prc wvat'>"+GetValueFromArray(arryData[zz],'stiprice')+"</td><td class='remove'>"+btnRemove+"</td><td class='right'>&#160;</td></tr>")
      itemsCount++;
    }
  }
  
  $("#comparecount").text(itemsCount);
  
  $("#comparedetailstable tr:even").addClass("color_row");
}

function addToCompare (stiid,link,sticode,stiname,stiprice){

var tblComp = $(".comparedetails table")
var arryData = unescape($.cookie("i6_comparedetails_data")).split('###');
 for(zz=0;zz<arryData.length;zz++)
  {
    if($.trim(arryData[zz]).length>0)
    { 
      if(stiid == GetValueFromArray(arryData[zz],'stiid'))
        { 
          openPopup('','<p>'+GetLng("lngprodexistinlist")+'</p>',3000,'msgerrcomp',false);
          updateCompareUI();
          return;
        }
    }
  }
  
  var strData = unescape(get_cookie("i6_comparedetails_data")+'');
  strData = strData + 'stiid$$$'+stiid+'@@@link$$$'+link+'@@@sticode$$$'+sticode+'@@@stiname$$$'+stiname+'@@@stiprice$$$'+stiprice+'###';
  $.cookie("i6_comparedetails_data",escape(strData),{expires: 9999});
  updateCompareUI();
  openPopup('','<p>'+GetLng("lngprodaddtocomp")+'</p>',5000,'msgaddcomp',false);
}

function removeCompareItem(stiid){
var newData ="" 
var arryData = unescape($.cookie("i6_comparedetails_data")).split('###');
 for(zz=0;zz<arryData.length;zz++)
  {
    if($.trim(arryData[zz]).length>0)
    {
      if(stiid != GetValueFromArray(arryData[zz],'stiid'))
        {
          newData +=arryData[zz]+'###'
        }
    }
  }
  
  
  $.cookie("i6_comparedetails_data",escape(newData),{expires: 9999});
  updateCompareUI();
}

function removeAllCompareItems(){
  
  $.cookie("i6_comparedetails_data","",{expires: 9999});
  updateCompareUI();
}

function initBasketFrame(){
var ajaxCall
//nebo nastavit mouse enter mouseleave
    $("#bsktcont").hover(
      function(){
        if( Number($.cookie("i6_basket_count")) > 0 && rq_cls!="ordbaskets"){
          if($("#bsktcont .basketdetailsframe .basketmainbox").length == 0)
            {   
              ajaxCall = updateBasketUI(false);
            }    
          $("#bsktcont .basketdetailsframe").css("display","block");
          $("#bsktcont").addClass("opened");
          }
        }
    ,
    function(){
        if(ajaxCall && ajaxCall != null)
           ajaxCall.abort();
        $("#bsktcont .basketdetailsframe").css("display","none");
        $("#bsktcont").removeClass("opened");
    }
  ) 
  
  //s animaci
  /*$("#bsktcont").hover(
      function(){
        if( Number($.cookie("i6_basket_count")) > 0 && rq_cls!="ordbaskets"){
          updateBasketUI(false);    
          window.setTimeout(function(){$("#bsktcont .basketdetailsframe").slideToggle("slow")},200);
          $("#bsktcont").addClass("opened");
          }
        }
    ,
    function(){
      if($("#bsktcont .basketdetailsframe").css("display")=="block"){
        window.setTimeout(function(){$("#bsktcont .basketdetailsframe").slideToggle("fast");window.setTimeout(function(){$("#bsktcont").removeClass("opened");},2)},500);
      }
    }
  ) 
  */
  
}

function updateBasketUI(onbackground){
  
 // $("#bsktcont .basketdetailsframe .cnt .out .in").load("default_jx.asp?cls=ordbaskets #basketitems");

  $("#bsktcont .basketdetailsframe .cnt .out .in").html(createLoadingCont());
  return $.ajax({
  url: "default_jx.asp?cls=ordbaskets&xsl=xordbaskets_jx.xsl",
  cache: false,
  success: function(html){   
      $("#bsktcont .basketdetailsframe .cnt .out .in").html(html);
      //if(!onbackground)
  // $("#bsktcont .basketdetailsframe").show("slow",function(){$("#bsktcont .basketdetailsframe").addClass("opened")})
  }
});
}

function thumbnailPrewievInit(tabId){	
	/* CONFIG */
		xOffset = 10;
		yOffset = 20;		
/* --------- */
	$(tabId+" .thumbimg > .out > .in > a").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<div id='thumbimg'><div class='outer'><div class='inner'><p><img src='"+ this.rel +"' alt='"+GetLng('lngthumbnotavail')+"' />"+ c +"</p></div></div></div>");								 
		$("#thumbimg")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#thumbimg").remove();
    });	
    
    
	$(tabId+" .thumbimg > .out > .in > a").mousemove(function(e){
		$("#thumbimg")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
  
		
};

function prodImg(stiid){
  try
  {
    $.prettyPhoto.open('img.asp?stiid='+stiid,'','');
  }
  catch(err)
  {
    $("#stigalleryul a[rel^='prettyPhoto']").prettyPhoto(); 
    $.prettyPhoto.open('img.asp?stiid='+stiid,'','');  
   }  
}

function GetValueFromArray(Str,sKey){

            var strVal,Arry
            Arry = Str.split("@@@")
            for(ii=0;ii<Arry.length;ii++)
            {
              if(Arry[ii].split('$$$')[0] == sKey)
              return Arry[ii].split('$$$')[1]
            }
}

function GetValueFromArray2(Str,sKey){

            var strVal,Arry
            Arry = Str.split("|")
            for(ii=0;ii<Arry.length;ii++)
            {
              if(Arry[ii].split('=')[0] == sKey)
              return Arry[ii].split('=')[1]
            }
            
}

function iif(is,y,n){
  if (is)
    return y
  else
    return n
  }

function initStockFilter(){
    updateStockFilterUI();
    $("#stilist_fltr_stores input[name='onstockiqud'] ").change(function(){SetStockFilter();});
}

function updateStockFilterUI(){
  $("#stilist_fltr_stores .onallstocks").addClass("imgcheckof");
  $("#stilist_fltr_stores .onallstocks").removeClass("imgcheckon");
  $("#stilist_fltr_stores .allprod").removeClass("imgcheckon");
  $("#stilist_fltr_stores .allprod").addClass("imgcheckof ");

  if($("#stilist_fltr_stores input[name='onstockiqud']:checked").length < 1)
    {$("#stilist_fltr_stores .allprod").addClass("imgcheckon");
    $("#stilist_fltr_stores .allprod").removeClass("imgcheckof");}
  else if($("#stilist_fltr_stores input[name='onstockiqud']").length == $("#stilist_fltr_stores input[name='onstockiqud']:checked").length )  
    {$("#stilist_fltr_stores .onallstocks").addClass("imgcheckon");
    $("#stilist_fltr_stores .onallstocks").removeClass("imgcheckof")}
        
}

function SetStockFilter(){
  var sUrl = $("#stilist_fltr_stores form").attr("rel");
  sUrl = sUrl+"&"+$("#stilist_fltr_stores form[name='filterboxform']").serialize();
  sUrl = sUrl.replace(/\?&/g,'?').replace(/&&/g,"?");
  if(isCallbackMode)
    loadProductList(GetFilterString());
  else
    window.location.href=sUrl;
  updateStockFilterUI();
}

function SelAllStockFilter(){
  $("#stilist_fltr_stores input[name='onstockiqud'] ").attr("checked","checked");
  updateStockFilterUI();
}

function SetAllStockFilter(){
  SelAllStockFilter();
  SetStockFilter();
}

function SelNoStockFilter(){
  $("#stilist_fltr_stores input[name='onstockiqud'] ").attr("checked","");
  updateStockFilterUI();
}

function SetNoStockFilter(){
  //var sUrl = $("#stilist_fltr_stores form").attr("rel");
  SelNoStockFilter();
  SetStockFilter();
  
}

function SetProducer(obj){
  obj.parent().parent().find("input").attr("checked","checked");
  loadProductList(GetFilterString());
  updatePrucersUI();
}

function ClearProducers(){
  $("#stilist_fltr_producers input").attr("checked","");
  $("#stilist_fltr_producers .allprod input").attr("checked","checked");
  loadProductList(GetFilterString()); 
  updatePrucersUI(); 
}

function updatePrucersUI(){
  if($("#stilist_fltr_producers input:checked").length == 0)
    $("#stilist_fltr_producers .allprod input").attr("checked","checked");
  else if ($("#stilist_fltr_producers input:checked").length == 2)
    $("#stilist_fltr_producers .allprod input").attr("checked","");  
}

function GetFilterString(){
  
  if(!isCallbackMode)
    prepareFilterButtonsForAjax();
  var fltrUrl = "cls=spresenttrees&strid="+strId;
   //parametricky filter
  fltrUrl = fltrUrl+"&"+$('#fltrparamsinput form[name="stiparinf_spresenttree"] input[id][value!=""]').serialize()+''
  //statusy
  fltrUrl = fltrUrl+"&"+$('#stistssrch form input[value!=""][name="status"]').serialize()+''
  //cenovy interval
  if( $('#stiprcsrch input[name="changed"]').length > 0)
    if(fltrUrl.length > 1)
      fltrUrl = fltrUrl+"&stipricedeafrom="+$('#stiprcsrch .stipricedeafrom').val()+"&stipricedeato="+$('#stiprcsrch .stipricedeato').val();
    else
      fltrUrl = $('#stiprcsrch').serialize();
  //sklady;
  fltrUrl = fltrUrl+"&"+$("#stilist_fltr_stores form[name='filterboxform']").serialize();
  //vyrobci
  //$("#stilist_fltr_producers input").attr("name","scaid");//prejmenuji aby slo primo serialize
  fltrUrl = fltrUrl+"&"+$("#stilist_fltr_producers form[name='scaid_list']").serialize();
  fltrUrl = 'default_jx.asp?'+fltrUrl;
  fltrUrl = fltrUrl.replace(/\?&/g,'?').replace(/&&/g,"&");
  return fltrUrl;
  
}

function LoadFilterState(){
  var hashUrl = window.location.hash;
  if(hashUrl && hashUrl.length>0)
  {
    loadCategoryParams();
    loadProductList(hashUrl.replace("#","default_jx.asp?"));
    prepareFilterButtonsForAjax();
  }
  
}

function SetFilterByUrl(sUrl){
  makeFilterbuttonsForAjax();
  
  sUrl= sUrl.replace("#","");
  $("#stilist_fltr_producers form[name='scaid_list']").deserialize(sUrl);
  if($("#stilist_fltr_producers form[name='scaid_list'] input:checked").length>0)
      $("#filterstop .cnt").css("display","block");
  $("#fltrparamsinput form[name='stiparinf_spresenttree']").deserializeParamSrch(sUrl);
  if($("#fltrparamsinput form[name='stiparinf_spresenttree'] input[value!='']:checked").length>0){
      $("#filtersbtm .cnt").css("display","block"); 
      $("#fltrparamscnt").css("display","block");} 
  
  //cena
  $("#stiprcsrch").deserialize(sUrl);
  if(appPrcRangeVat && appPrcRangeVat!=0){
    $("#stiprcsrch input[name='stipricedeafrom']").val(Math.ceil($("#stiprcsrch input[name='stipricedeafrom']").val()*(1+appPrcRangeVat/100)/appPrcRangeStep)*appPrcRangeStep);
    $("#stiprcsrch input[name='stipricedeato']").val(Math.ceil($("#stiprcsrch input[name='stipricedeato']").val()*(1+appPrcRangeVat/100)/appPrcRangeStep)*appPrcRangeStep);
    }
  var prcFrom = $("#stiprcsrch input[name='stipricedeafrom']").val();
  var prcTo = $("#stiprcsrch input[name='stipricedeato']").val();
  var prcCode = $('#stipricedefcurcode.stipricedefcurcode').val();
  if(Number(prcTo)>=0 && Number(prcFrom)>=0)
  {
    $("#slider-range").slider({values: [Number(prcFrom),Number(prcTo)]});
  	$('#stipricedeafrominfo').text(formatNumber(prcFrom,0,' ','','',' '+prcCode,'',''));
  	$('#stipricedeatoinfo').text(formatNumber(prcTo,0,' ','','',' '+prcCode,'',''));
	}
  //sklady
	$("#stilist_fltr_stores form").deserialize(sUrl);
	initStockFilter();
}

function insActiveFilterMsg(){
  $("#filtersbtm").after("<div class='boxcont prmfltact'><div class='cnt'><div class='out'><div class='in'><span>Máte zapnutý jeden nebo více filtrů v této větvi. Filtrování může způsobit, že nebude zobrazena celá naše nabídka.</span><div class='btnn'><a title='Zrušit filtry' href='javascript:document.location=&#39;default.asp?cls=spresenttrees&strid=&#39;+getURLParameter(window.location.hash,\"strid\")'><p>&nbsp;</p><strong><p>Zrušit filtry</p></strong><span>&nbsp;</span></a><br class='clear'/></div></div></div></div></div><div class='clear'>&nbsp;</div>");
}

function getURLParameter(sUrl,name) {
    if(sUrl=="")
    sUrl=location.search;
    return unescape(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(sUrl)||[,null])[1]
    );
}

function initParamItemAsClosable(){
  //$("#stilist_fltr_fltrparams .paramitem").addClass("closed");
  $("#categoryparams").wrapInner("<div id='closedditems' class='closedditems'/>")
  $("#categoryparams").prepend("<div id='openeditems' class='openeditems'/>")
  
  $("#categoryparams .paramitem:has(input[value!='']:checked)").appendTo($("#openeditems")).removeClass("closed").addClass("opened");
  
  $("#categoryparams .paramitem .name").click(function(){
    if($(this).parents(".paramitem.opened").length>0)
      {
        var paramObj = $(this).parents(".paramitem").find("input[value!='']")        
        fcprcheckoff(paramObj.attr("name").replace("sps_v_",""),paramObj.length)
        $(this).parents(".paramitem").prependTo($("#closedditems"));
        $(this).parents(".paramitem").removeClass("opened");
        $(this).parents(".paramitem").addClass("closed");
      }
    else
    {
        $(this).parents(".paramitem").appendTo($("#openeditems"));
        $(this).parents(".paramitem").removeClass("closed");
        $(this).parents(".paramitem").addClass("opened");
    }   
  });
}

/*default_tree.js*/

//Nacitani podkategorii
function LTreeProcess(url){
	if(url != ''){
	  if(window.ActiveXObject){
	  	httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	  }else{
	    httpRequest = new XMLHttpRequest();
	  }
	  httpRequest.open("GET", url, false);
	  httpRequest.setRequestHeader("Content-Type", "text/html; charset=utf-8");
	  httpRequest.send(null);
	  if(httpRequest.readyState == 4){
			if(httpRequest.status == 200){
	      return httpRequest.responseText;
	    }
	  }
	}else{
	  return;
	}
}

//Prvni uroven vyrobcu
function LTreeGetProducers(lngStrType){
	document.getElementById('div_strid_1').innerHTML = LTreeProcess("default_tree.asp?strtype=" + lngStrType);
}

//Zjisteni elementu nad kterym udalost vznikla
function LTreeGetSubCategories(evt){
	if(!evt)var evt = window.event;
	if(evt){var srcElement = evt.srcElement ? evt.srcElement : evt.target;}	//FF nezna srcElement
	evt.cancelBubble = true;
	LTreeInnerHtml(srcElement);
}

var arrInnerHTML = new Array;
function LTreeInnerHtml(el){
	with(el.parentNode){
		if(el.tagName.toLowerCase() == 'span'){	//jen pokud se klikne na plus/minus
			if(className == 'i6lt_plus'){
					arrInnerHTML[id] = innerHTML;
					document.getElementById(id).innerHTML = LTreeProcess("default_tree.asp?strid=" + id.replace('i6sub_',''));
					innerHTML = arrInnerHTML[id] + innerHTML;
					className = 'i6lt_minus';
			}else if(className == 'i6lt_minus'){
					innerHTML = arrInnerHTML[id];
					className = 'i6lt_plus';
			}
		}
	}
}

//Vypsani aktualne vybranych podkategorii
function LTreeSelOnLoadTC(intStrId, strStrIdList){
	var arrStrIds, arrStrId
	//vyrobce
	if(intStrId > -1)LTreeGetProducers(intStrId);
	//rozbaleni subkategorii
	arrStrIds = strStrIdList.split(',');
	for(var i = 0; i <= arrStrIds.length - 1; i++){
		if(arrStrIds[i] != ''){
			arrStrId = document.getElementById('i6sub_' + arrStrIds[i]);
			if(arrStrId){
					LTreeInnerHtml(arrStrId.childNodes[0]);
	        if((arrStrIds.length -2 ) == i){
						arrStrId.childNodes[1].className='active actual';
	        }else{
	        	arrStrId.childNodes[1].className='active';
			    }
	    }
		}
	}
}

//Vypsani aktualne vybranych podkategorii
function LTreeSelOnLoad(defaultStrId){
	var arrStrIds, arrStrId, cookProducers
	cookProducers = document.cookie.indexOf('i6_lm_strtype=', 0)
	if(cookProducers > -1){
		var pos2 = document.cookie.indexOf(';', cookProducers);
		if(pos2 == - 1){
			LTreeGetProducers(document.cookie.substring(cookProducers + 14));
		}else{
			LTreeGetProducers(document.cookie.substring(cookProducers + 14, pos2));
		}
	}
	arrStrIds = ''
	if(document.getElementById('tc_code')){	//aktualni vetve
	  arrStrIds = document.getElementById('tc_code').value.split(',');
	}else if(defaultStrId){	//defaultne vybrane vetve
		defaultStrId = defaultStrId.toString()	//z hitorickych duvodu, kdy se parametr defaultStrId volal jako cislo
		arrStrIds = defaultStrId.split(',');
	}
	for(var i = 0; i <= arrStrIds.length - 1; i++){
		arrStrId = document.getElementById('i6sub_' + arrStrIds[i]);
		if(arrStrId){
				LTreeInnerHtml(arrStrId.childNodes[0]);
        if((arrStrIds.length -2 ) == i)
				{
				  arrStrId.childNodes[1].className='active actual';
        }
        else
         {
          arrStrId.childNodes[1].className='active';
		      }
    }
  }
}

/*default_basket.js*/
/* zobrazeni objednavek do kterych je mozno pridavat polozky */
function TbNewOrder(TbStyle){
	if(document.getElementById('tb_new_order_step')){//krokove objednavani
		document.getElementById('tb_new_order_step').style.display = TbStyle;
	}else{
		var TbTr = document.getElementById('tb_new_order').getElementsByTagName('tr')
		for(var i = 0; i < TbTr.length; i++){
			TbTr[i].style.display = TbStyle
		}
	}
	document.getElementById('show_always').style.display = 'block'
}

/* zneaktivneni hidden prvku pri prepoctu kosiku */
function HeadClear(form){
	form.catalogs.disabled = true;
	form.step_to_order.disabled = true;
	form.user_action.disabled = true;
	return true;
}

/*  */
function CheckOrigNr(){
	var OrdIdAppend = 0
	//kontrola na ordcodeo jen pokud se nevklada do jiz existujici objednavky
	if(document.basket.ordid){
		for(var i = 0; i < document.basket.ordid.length; i++){
			if(document.basket.ordid[i].checked == 1)OrdIdAppend = document.basket.ordid[i].value
		}
	}
	if(OrdIdAppend == 0){
		if(document.basket.ordcodeo.value == ""){
			//if(!document.getElementById('anonymousbuy')){
				alert(GetLng("lngzj5") + "\n- " + GetLng("lngyournr"))
				document.basket.ordcodeo.focus()
				return false;
			//}
		}else{
			document.cookie = "i6_basket_price=0; expires=Thu, 01-Jan-1970 00:00:01 GMT";
			document.cookie = "i6_basket_count=0; expires=Thu, 01-Jan-1970 00:00:01 GMT";
		}
	}else{
		document.basket.redirect.value = document.basket.redirect.value + "&ordappend=1&oriidmax=" + document.getElementById('oriidmax_' + OrdIdAppend).value
	}
}

/* export nabidky jen z oznacenych produktu */
function GetOnlySelected(){
	if(frmGetOffer.onlyselected.checked){
		frmGetOffer.offerfromselected.value = ''
		var url = '-1'
		for(var i=1; document.getElementById("choosed"+i); i++){
			if(document.getElementById("choosed"+i).checked){
				url += ',' +  document.getElementById("choosed"+i).value
			}
		}
		if(url == '-1'){
    	alert('Nejsou vybrány žádné produkty pro zobrazení nabídky.')
			return false
		}
		if(url != '-1'){
			frmGetOffer.offerfromselected.value = url
		}
	}
} 

/* zobrazeni povolenych plateb na zaklade vybrane dopravy demtype=2 <=> paytype=2, demtype!=2 <=> paytype!=2 */
function ShowAllowedPayWay(intDemType){
  var form = document.forms[name='basket'];
	var OrdDemType_Default = document.getElementById('orddemtype_default').value;
	var OrdXPawId_Default = document.getElementById('ordxpawid_default').value;
	var cnt = 0;
	var chckpay = -1;
	if(intDemType == -1 && OrdDemType_Default != '' && OrdDemType_Default != 'NaN')intDemType = OrdDemType_Default;
	if(intDemType > -1){
		$('#PayWayDiv').removeClass("ds_none");
		if(form.ordxpawid.length){
			for(var i = 0; i < form.ordxpawid.length; i++){
				form.ordxpawid[i].checked = false;
				form.ordxpawid[i].parentNode.style.display = 'none';
				if(intDemType == 2 && form.ordxpawid[i].getAttribute('valtype') == 2 || intDemType != 2 && form.ordxpawid[i].getAttribute('valtype') != 2){ //dobirkova doprava ma dobirkouvou platbu; nedobirkova ma nedobirkovou
					cnt = cnt + 1
					if(cnt == 1 && chckpay == -1)chckpay = i
					form.ordxpawid[i].parentNode.style.display = 'block';
					if(OrdXPawId_Default == form.ordxpawid[i].value)form.ordxpawid[i].checked = true;
				}
			}
			if(cnt == 1)form.ordxpawid[chckpay].checked = true; //checked kdyz je pouze jedna vyhovujici platba
		}else{
			form.ordxpawid.parentNode.style.display = 'block';
			form.ordxpawid.checked = true;
		}
	}
}

/* zobrazeni poznamky dopravneho */
function ShowDemNoteExt(intDemId){
	document.getElementById('demnoteext').innerHTML = "";
	if(document.getElementById('demnote_' + intDemId))document.getElementById('demnoteext').innerHTML = document.getElementById('demnote_' + intDemId).value;
}

/* kontrola na vybrani zpusobu dopravneho a platby */
function checkDelPay(form){
	var delChecked = false;
	var payChecked = false;
	
	//mozno vkladat do jiz existujici objednavky - pak se nekontroluje doprava a platba
  var OrdIdAppend = 0
	if(form.ordid){
		for(var i = 0; i < form.ordid.length; i++){
			if(form.ordid[i].checked == 1)OrdIdAppend = form.ordid[i].value
		}
	}
	form.ordappend.value = -1;
	if(OrdIdAppend > 0){
		form.ordappend.value = OrdIdAppend;
	}else{
		if(form.orddemid.length){
			for(var i = 0; i < form.orddemid.length; i++){
				if(form.orddemid[i].checked)delChecked = true;
			}
		}else{
			if(form.orddemid.checked)delChecked = true;
		}
		if(form.ordxpawid){
			if(form.ordxpawid.length){
				for(var i = 0; i < form.ordxpawid.length; i++){
					if(form.ordxpawid[i].checked)payChecked = true;
				}
			}else{
				if(form.ordxpawid.checked)payChecked = true;
			}
		}
		if(!delChecked){
			alert(GetLng("lngzjchoosedelivery"));
	    return false;
	  }
	  if(!payChecked){
			alert(GetLng("lngzjchoosepayment"));
	    return false;
	  }
	}
}

/*  kontrola na vyplneni povinnych poli pri nakupu bez registrace */
function CheckAnonymousBuy(form){
	var mandatcst = document.getElementById('setcomshipto').value;	//1 kdyz se vyplnuje dodaci adresa
	var mandat = 1;
	var sendlogin = 1;
	
	//zjisteni zda se bude registrovat nebo jen jednorazovy nakup
	for(var j = 0; j < form.anonymousbuysendlogin.length; j++){
		if(form.anonymousbuysendlogin[j].checked){
			sendlogin = form.anonymousbuysendlogin[j].value;
			break;
		}
	}
	
	//pokud osobne bez registrace, pak nejsou povinna pole adresy
	if(document.getElementById('demtype').value == 1 && sendlogin == 0){	
		mandat = 0;
		mandatcst = 0;
	}
	
	var ErrList = new Array(
		[form.confname, 1, GetLng("lngzjfillname")],
	  [form.conlname, 1, GetLng("lngzjfillsurname")],
	  [form.comstreet, mandat, GetLng("lngzjfillstreet")],
	  [form.comcity, mandat, GetLng("lngzjfillcity")],
	  [form.compostcode, mandat, GetLng("lngzjfillpostcode")],
	  [form.contel1, 1, GetLng("lngzjfilltel")],
	  [form.conemail, 1, GetLng("lngzjfillemail")],
		[form.cstname, mandatcst, GetLng("lngzjfillcstname")],
	  [form.cststreet, mandatcst, GetLng("lngzjfillcststreet")],
	  [form.cstcity, mandatcst, GetLng("lngzjfillcstcity")],
	  [form.cstpostcode, mandatcst, GetLng("lngzjfillcstpostcode")]
	)
	
	for(var i = 0; i < ErrList.length; i++) {
  	if(ErrList[i][1] == 1){	//pokud je povinne vyplneni
	    if(ErrList[i][0].value == ''){
	      alert(ErrList[i][2]);
	      ErrList[i][0].focus();
	      return false;
	    }
		}
  }
  
  /* kontrola formatu telefonu */
  //var regul = /^(\+[0-9]{3})? ?[0-9]{3} ?[0-9]{3} ?[0-9]{3}$/;
  var regul = /^[+]?[()/0-9. -]{9,}$/;	//minimálne 9 znaku - cislice 0–9, kulate zavorky, lomitko, tecka, pomlcka a mezera; muze predchazet znak +
	if(!regul.test(form.contel1.value)){
    alert(GetLng("lngzjrepairtel"));
		form.contel1.focus();
		return false;
	}
	
	/* kontrola formatu emailu */
	var regul = /[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/;
	if(!regul.test(form.conemail.value)){
    alert(GetLng("lngzjrepairemail"));
		form.conemail.focus();
		return false;
	}
	
  if(form.comemail.value == '')form.comemail.value = form.conemail.value;
  if(form.comtel1.value == '')form.comtel1.value = form.contel1.value;
  if(form.comname.value == '')form.comname.value = form.conlname.value + ' ' + form.confname.value;
  if(form.comregid.value != '')form.comsname.value = form.comname.value;

  //je li v ConTel1 cislo na mobil (zacina na 6 a 7), zkopiruje se do ConTelMob (ConTelMob musi existovat aspon jako hidden a musi byt prazdne)
  if(form.contel1 && form.contelmob){
  	if(form.contel1.value != '' && form.contelmob.value == ''){
	    var str = form.contel1.value;
	    str = str.replace(/\s/g, "");
	    if(str.indexOf("00420") == 0) str = str.replace("00420", "");
	    if(str.indexOf("+420") == 0) str = str.replace("+420", "");
	    if(str.indexOf("6") == 0 || str.indexOf("7") == 0){
	      form.contelmob.value = form.contel1.value;
	    }
		}
  }

  document.cookie = "i6_basket_price=0; expires=Thu, 01-Jan-1970 00:00:01 GMT";
	document.cookie = "i6_basket_count=0; expires=Thu, 01-Jan-1970 00:00:01 GMT";
	
	//redirect na stranku s objednavkou
	if(sendlogin == 1){
		if(form.redirect.value.indexOf('sessionpswd=1') == -1)form.redirect.value = form.redirect.value + '&sessionpswd=1&contact=1&company=1&catalog=country&cls=orders&ordid=PRIMARY_KEY';
	}else{
		//form.redirect.value = form.redirect.value + '&cls=iisutil&action=anonymousbuy&anonymousbuy=' + form.anonymousbuy.value;
		if(form.redirect.value.indexOf('anonymousbuy=') == -1)form.redirect.value = 'default.asp?mtc=1&u_mode=1&cls=iisutil&action=anonymousbuy&anonymousbuy=' + form.anonymousbuy.value;
	}
	//return(CheckPhoneFormat(form.contel1) && CheckEmailFormat(form.conemail));
	return true;
}

/* kontrola formatu telefonu */
function CheckPhoneFormat(phone){
	//var regul = /^(\+[0-9]{3})? ?[0-9]{3} ?[0-9]{3} ?[0-9]{3}$/;
	var regul = /^[+]?[()/0-9. -]{9,}$/;	//minimálne 9 znaku - cislice 0–9, kulate zavorky, lomitko, tecka, pomlcka a mezera; muze predchazet znak +
	if(!regul.test(phone.value)){
    alert(GetLng("lngzjrepairtel"));
		phone.focus();
		return false;
	}else{
		return true;
	}
}

/* kontrola formatu emailu */
function CheckEmailFormat(email){
	var regul = /[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/;
	if(!regul.test(email.value)){
    alert(GetLng("lngzjrepairemail"));
		email.focus();
		return false;
	}else{
		return true;
	}
}

/* zobrazeni poli pro zadani dodaci adresy */
function ShowHideCst(value){
	document.getElementById('setcomshipto').value = value;
	document.getElementById('step_cst').style.display = 'none';
	if(value == 1)document.getElementById('step_cst').style.display = 'block';
	//moznost pridani dodaci adresy prihlasenemu uzivateli
	if(document.getElementById('ordcstid')){
		var ordcstid = document.getElementById('ordcstid')
		if(value == 1){
			ordcstid.value = "";
			ordcstid.disabled = true;
		}else{
			ordcstid.disabled = false;
		}
	}
}

/* zobrazeni poli pro prihlaseni */
function ShowHideLogin(value){
	if(value == 1){		
		document.getElementById('step2_newdata').style.display = 'none';
		document.getElementById('loggincontact').style.display = 'block';
		document.getElementById('btnnOrd3Buy').className = 'btnn disabled';
		if(document.getElementById('putconlogname'))document.getElementById('putconlogname').focus();
	}else{
		document.getElementById('step2_newdata').style.display = 'block';
		document.getElementById('loggincontact').style.display = 'none';
		document.getElementById('btnnOrd3Buy').className = 'btnn';
		if(document.getElementById('putconfname'))document.getElementById('putconfname').focus();
	}
}

/*menu.js*/
function MenuHeadJQ(){
  $("#menu li").hover(
    function(){        
        $('#submenu ul').css("display","none");
        $('#menu li').removeClass("over");
        if($(this).children("span").length>0)
        $('#topmenu_'+$(this).children("span").attr("id").substr(9,1)).css("display","block");
        $(this).addClass("over");},
    function(){}
  );
  $("#menu li").removeClass("over");

}

function MenuHead(){

if($)
  {
  MenuHeadJQ();
  }
else
  {  
    if (document.all && document.getElementById || 1!=0) {
    	menuHead = document.getElementById("menu");
      for (i=0; i < menuHead.childNodes.length; i++) {
        menuItems = menuHead.childNodes[i];
        if (menuItems.nodeName == "LI") {
          menuItems.onmouseover = 
  	        function overItems(){
  	          this.className += " over";
  	          //ShowHideSelect('hidden') 'v horizontalnim pripade se nemusi skryvat
  		      }
          menuItems.onmouseout = 
          	function outItems(){
  	          this.className = this.className.replace(" over", "");
  	          this.className = this.className.replace("over", "");
  	          //ShowHideSelect('visible')
          	}
        }
      }
    }
  }
}	


//skryje a zobrazi SELECT
function ShowHideSelect(vis){
	sel = document.getElementsByTagName('select');
	for(i = 0; i < sel.length; i++){
    sel[i].style.visibility = vis;
  }
}


function topmenuclick(thi,n,name,classn){
	if (n>=thi && thi>0){
		for(var i=1;i<(n+1);i++){
			if (document.getElementById(name+i)) {
			    el = document.getElementById(name+i)
				
			    el.style.display = 'none'
			  }
		}
		if (document.getElementById(name+thi)) {
		    el = document.getElementById(name+thi)
		    el.style.display = 'block'
		  }
		for(var i=1;i<(n+1);i++){
		if (document.getElementById(name+'X'+i)) {
  			document.getElementById(name+'X'+i).className = classn
		  }
		}
		if (document.getElementById(name+'X'+thi)) {
  			document.getElementById(name+'X'+thi).className = classn+" act"
		  }
	}
}

/*jquery.jcarousel.js*/
{eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(9($){$.1s.A=9(o){z 4.14(9(){2H r(4,o)})};8 q={W:F,23:1,1G:1,u:7,15:3,16:7,1H:\'2I\',24:\'2J\',1i:0,B:7,1j:7,1I:7,25:7,26:7,27:7,28:7,29:7,2a:7,2b:7,1J:\'<N></N>\',1K:\'<N></N>\',2c:\'2d\',2e:\'2d\',1L:7,1M:7};$.A=9(e,o){4.5=$.17({},q,o||{});4.Q=F;4.D=7;4.H=7;4.t=7;4.R=7;4.S=7;4.O=!4.5.W?\'1N\':\'2f\';4.E=!4.5.W?\'2g\':\'2h\';8 a=\'\',1d=e.J.1d(\' \');1k(8 i=0;i<1d.K;i++){6(1d[i].2i(\'A-2j\')!=-1){$(e).1t(1d[i]);8 a=1d[i];1l}}6(e.2k==\'2K\'||e.2k==\'2L\'){4.t=$(e);4.D=4.t.18();6(4.D.1m(\'A-H\')){6(!4.D.18().1m(\'A-D\'))4.D=4.D.B(\'<N></N>\');4.D=4.D.18()}X 6(!4.D.1m(\'A-D\'))4.D=4.t.B(\'<N></N>\').18()}X{4.D=$(e);4.t=$(e).2M(\'>2l,>2m,N>2l,N>2m\')}6(a!=\'\'&&4.D.18()[0].J.2i(\'A-2j\')==-1)4.D.B(\'<N 2N=" \'+a+\'"></N>\');4.H=4.t.18();6(!4.H.K||!4.H.1m(\'A-H\'))4.H=4.t.B(\'<N></N>\').18();4.S=$(\'.A-11\',4.D);6(4.S.u()==0&&4.5.1K!=7)4.S=4.H.1u(4.5.1K).11();4.S.V(4.J(\'A-11\'));4.R=$(\'.A-19\',4.D);6(4.R.u()==0&&4.5.1J!=7)4.R=4.H.1u(4.5.1J).11();4.R.V(4.J(\'A-19\'));4.H.V(4.J(\'A-H\'));4.t.V(4.J(\'A-t\'));4.D.V(4.J(\'A-D\'));8 b=4.5.16!=7?1n.1O(4.1o()/4.5.16):7;8 c=4.t.2O(\'1v\');8 d=4;6(c.u()>0){8 f=0,i=4.5.1G;c.14(9(){d.1P(4,i++);f+=d.T(4,b)});4.t.y(4.O,f+\'U\');6(!o||o.u===L)4.5.u=c.u()}4.D.y(\'1w\',\'1x\');4.R.y(\'1w\',\'1x\');4.S.y(\'1w\',\'1x\');4.2n=9(){d.19()};4.2o=9(){d.11()};4.1Q=9(){d.2p()};6(4.5.1j!=7)4.5.1j(4,\'2q\');6($.2r.2s){4.1e(F,F);$(2t).1y(\'2P\',9(){d.1z()})}X 4.1z()};8 r=$.A;r.1s=r.2Q={A:\'0.2.3\'};r.1s.17=r.17=$.17;r.1s.17({1z:9(){4.C=7;4.G=7;4.Y=7;4.12=7;4.1a=F;4.1f=7;4.P=7;4.Z=F;6(4.Q)z;4.t.y(4.E,4.1A(4.5.1G)+\'U\');8 p=4.1A(4.5.23);4.Y=4.12=7;4.1p(p,F);$(2t).1R(\'2u\',4.1Q).1y(\'2u\',4.1Q)},2v:9(){4.t.2w();4.t.y(4.E,\'2R\');4.t.y(4.O,\'2S\');6(4.5.1j!=7)4.5.1j(4,\'2v\');4.1z()},2p:9(){6(4.P!=7&&4.Z)4.t.y(4.E,r.I(4.t.y(4.E))+4.P);4.P=7;4.Z=F;6(4.5.1I!=7)4.5.1I(4);6(4.5.16!=7){8 a=4;8 b=1n.1O(4.1o()/4.5.16),O=0,E=0;$(\'1v\',4.t).14(9(i){O+=a.T(4,b);6(i+1<a.C)E=O});4.t.y(4.O,O+\'U\');4.t.y(4.E,-E+\'U\')}4.15(4.C,F)},2T:9(){4.Q=1g;4.1e()},2U:9(){4.Q=F;4.1e()},u:9(s){6(s!=L){4.5.u=s;6(!4.Q)4.1e()}z 4.5.u},2V:9(i,a){6(a==L||!a)a=i;6(4.5.u!==7&&a>4.5.u)a=4.5.u;1k(8 j=i;j<=a;j++){8 e=4.M(j);6(!e.K||e.1m(\'A-1b-1B\'))z F}z 1g},M:9(i){z $(\'.A-1b-\'+i,4.t)},2x:9(i,s){8 e=4.M(i),1S=0,2x=0;6(e.K==0){8 c,e=4.1C(i),j=r.I(i);1q(c=4.M(--j)){6(j<=0||c.K){j<=0?4.t.2y(e):c.1T(e);1l}}}X 1S=4.T(e);e.1t(4.J(\'A-1b-1B\'));1U s==\'2W\'?e.2X(s):e.2w().2Y(s);8 a=4.5.16!=7?1n.1O(4.1o()/4.5.16):7;8 b=4.T(e,a)-1S;6(i>0&&i<4.C)4.t.y(4.E,r.I(4.t.y(4.E))-b+\'U\');4.t.y(4.O,r.I(4.t.y(4.O))+b+\'U\');z e},1V:9(i){8 e=4.M(i);6(!e.K||(i>=4.C&&i<=4.G))z;8 d=4.T(e);6(i<4.C)4.t.y(4.E,r.I(4.t.y(4.E))+d+\'U\');e.1V();4.t.y(4.O,r.I(4.t.y(4.O))-d+\'U\')},19:9(){4.1D();6(4.P!=7&&!4.Z)4.1W(F);X 4.15(((4.5.B==\'1X\'||4.5.B==\'G\')&&4.5.u!=7&&4.G==4.5.u)?1:4.C+4.5.15)},11:9(){4.1D();6(4.P!=7&&4.Z)4.1W(1g);X 4.15(((4.5.B==\'1X\'||4.5.B==\'C\')&&4.5.u!=7&&4.C==1)?4.5.u:4.C-4.5.15)},1W:9(b){6(4.Q||4.1a||!4.P)z;8 a=r.I(4.t.y(4.E));!b?a-=4.P:a+=4.P;4.Z=!b;4.Y=4.C;4.12=4.G;4.1p(a)},15:9(i,a){6(4.Q||4.1a)z;4.1p(4.1A(i),a)},1A:9(i){6(4.Q||4.1a)z;i=r.I(i);6(4.5.B!=\'1c\')i=i<1?1:(4.5.u&&i>4.5.u?4.5.u:i);8 a=4.C>i;8 b=r.I(4.t.y(4.E));8 f=4.5.B!=\'1c\'&&4.C<=1?1:4.C;8 c=a?4.M(f):4.M(4.G);8 j=a?f:f-1;8 e=7,l=0,p=F,d=0;1q(a?--j>=i:++j<i){e=4.M(j);p=!e.K;6(e.K==0){e=4.1C(j).V(4.J(\'A-1b-1B\'));c[a?\'1u\':\'1T\'](e)}c=e;d=4.T(e);6(p)l+=d;6(4.C!=7&&(4.5.B==\'1c\'||(j>=1&&(4.5.u==7||j<=4.5.u))))b=a?b+d:b-d}8 g=4.1o();8 h=[];8 k=0,j=i,v=0;8 c=4.M(i-1);1q(++k){e=4.M(j);p=!e.K;6(e.K==0){e=4.1C(j).V(4.J(\'A-1b-1B\'));c.K==0?4.t.2y(e):c[a?\'1u\':\'1T\'](e)}c=e;8 d=4.T(e);6(d==0){2Z(\'30: 31 1N/2f 32 1k 33. 34 35 36 37 38 39. 3a...\');z 0}6(4.5.B!=\'1c\'&&4.5.u!==7&&j>4.5.u)h.3b(e);X 6(p)l+=d;v+=d;6(v>=g)1l;j++}1k(8 x=0;x<h.K;x++)h[x].1V();6(l>0){4.t.y(4.O,4.T(4.t)+l+\'U\');6(a){b-=l;4.t.y(4.E,r.I(4.t.y(4.E))-l+\'U\')}}8 n=i+k-1;6(4.5.B!=\'1c\'&&4.5.u&&n>4.5.u)n=4.5.u;6(j>n){k=0,j=n,v=0;1q(++k){8 e=4.M(j--);6(!e.K)1l;v+=4.T(e);6(v>=g)1l}}8 o=n-k+1;6(4.5.B!=\'1c\'&&o<1)o=1;6(4.Z&&a){b+=4.P;4.Z=F}4.P=7;6(4.5.B!=\'1c\'&&n==4.5.u&&(n-k+1)>=1){8 m=r.10(4.M(n),!4.5.W?\'1r\':\'1Y\');6((v-m)>g)4.P=v-g-m}1q(i-->o)b+=4.T(4.M(i));4.Y=4.C;4.12=4.G;4.C=o;4.G=n;z b},1p:9(p,a){6(4.Q||4.1a)z;4.1a=1g;8 b=4;8 c=9(){b.1a=F;6(p==0)b.t.y(b.E,0);6(b.5.B==\'1X\'||b.5.B==\'G\'||b.5.u==7||b.G<b.5.u)b.2z();b.1e();b.1Z(\'2A\')};4.1Z(\'3c\');6(!4.5.1H||a==F){4.t.y(4.E,p+\'U\');c()}X{8 o=!4.5.W?{\'2g\':p}:{\'2h\':p};4.t.1p(o,4.5.1H,4.5.24,c)}},2z:9(s){6(s!=L)4.5.1i=s;6(4.5.1i==0)z 4.1D();6(4.1f!=7)z;8 a=4;4.1f=3d(9(){a.19()},4.5.1i*3e)},1D:9(){6(4.1f==7)z;3f(4.1f);4.1f=7},1e:9(n,p){6(n==L||n==7){8 n=!4.Q&&4.5.u!==0&&((4.5.B&&4.5.B!=\'C\')||4.5.u==7||4.G<4.5.u);6(!4.Q&&(!4.5.B||4.5.B==\'C\')&&4.5.u!=7&&4.G>=4.5.u)n=4.P!=7&&!4.Z}6(p==L||p==7){8 p=!4.Q&&4.5.u!==0&&((4.5.B&&4.5.B!=\'G\')||4.C>1);6(!4.Q&&(!4.5.B||4.5.B==\'G\')&&4.5.u!=7&&4.C==1)p=4.P!=7&&4.Z}8 a=4;4.R[n?\'1y\':\'1R\'](4.5.2c,4.2n)[n?\'1t\':\'V\'](4.J(\'A-19-1E\')).20(\'1E\',n?F:1g);4.S[p?\'1y\':\'1R\'](4.5.2e,4.2o)[p?\'1t\':\'V\'](4.J(\'A-11-1E\')).20(\'1E\',p?F:1g);6(4.R.K>0&&(4.R[0].1h==L||4.R[0].1h!=n)&&4.5.1L!=7){4.R.14(9(){a.5.1L(a,4,n)});4.R[0].1h=n}6(4.S.K>0&&(4.S[0].1h==L||4.S[0].1h!=p)&&4.5.1M!=7){4.S.14(9(){a.5.1M(a,4,p)});4.S[0].1h=p}},1Z:9(a){8 b=4.Y==7?\'2q\':(4.Y<4.C?\'19\':\'11\');4.13(\'25\',a,b);6(4.Y!==4.C){4.13(\'26\',a,b,4.C);4.13(\'27\',a,b,4.Y)}6(4.12!==4.G){4.13(\'28\',a,b,4.G);4.13(\'29\',a,b,4.12)}4.13(\'2a\',a,b,4.C,4.G,4.Y,4.12);4.13(\'2b\',a,b,4.Y,4.12,4.C,4.G)},13:9(a,b,c,d,e,f,g){6(4.5[a]==L||(1U 4.5[a]!=\'2B\'&&b!=\'2A\'))z;8 h=1U 4.5[a]==\'2B\'?4.5[a][b]:4.5[a];6(!$.3g(h))z;8 j=4;6(d===L)h(j,c,b);X 6(e===L)4.M(d).14(9(){h(j,4,d,c,b)});X{1k(8 i=d;i<=e;i++)6(i!==7&&!(i>=f&&i<=g))4.M(i).14(9(){h(j,4,i,c,b)})}},1C:9(i){z 4.1P(\'<1v></1v>\',i)},1P:9(e,i){8 a=$(e).V(4.J(\'A-1b\')).V(4.J(\'A-1b-\'+i));a.20(\'3h\',i);z a},J:9(c){z c+\' \'+c+(!4.5.W?\'-3i\':\'-W\')},T:9(e,d){8 a=e.2C!=L?e[0]:e;8 b=!4.5.W?a.1F+r.10(a,\'2D\')+r.10(a,\'1r\'):a.2E+r.10(a,\'2F\')+r.10(a,\'1Y\');6(d==L||b==d)z b;8 w=!4.5.W?d-r.10(a,\'2D\')-r.10(a,\'1r\'):d-r.10(a,\'2F\')-r.10(a,\'1Y\');$(a).y(4.O,w+\'U\');z 4.T(a)},1o:9(){z!4.5.W?4.H[0].1F-r.I(4.H.y(\'3j\'))-r.I(4.H.y(\'3k\')):4.H[0].2E-r.I(4.H.y(\'3l\'))-r.I(4.H.y(\'3m\'))},3n:9(i,s){6(s==L)s=4.5.u;z 1n.3o((((i-1)/s)-1n.3p((i-1)/s))*s)+1}});r.17({3q:9(d){z $.17(q,d||{})},10:9(e,p){6(!e)z 0;8 a=e.2C!=L?e[0]:e;6(p==\'1r\'&&$.2r.2s){8 b={\'1w\':\'1x\',\'3r\':\'3s\',\'1N\':\'1i\'},21,22;$.2G(a,b,9(){21=a.1F});b[\'1r\']=0;$.2G(a,b,9(){22=a.1F});z 22-21}z r.I($.y(a,p))},I:9(v){v=3t(v);z 3u(v)?0:v}})})(3v);',62,218,'||||this|options|if|null|var|function||||||||||||||||||||list|size||||css|return|jcarousel|wrap|first|container|lt|false|last|clip|intval|className|length|undefined|get|div|wh|tail|locked|buttonNext|buttonPrev|dimension|px|addClass|vertical|else|prevFirst|inTail|margin|prev|prevLast|callback|each|scroll|visible|extend|parent|next|animating|item|circular|split|buttons|timer|true|jcarouselstate|auto|initCallback|for|break|hasClass|Math|clipping|animate|while|marginRight|fn|removeClass|before|li|display|block|bind|setup|pos|placeholder|create|stopAuto|disabled|offsetWidth|offset|animation|reloadCallback|buttonNextHTML|buttonPrevHTML|buttonNextCallback|buttonPrevCallback|width|ceil|format|funcResize|unbind|old|after|typeof|remove|scrollTail|both|marginBottom|notify|attr|oWidth|oWidth2|start|easing|itemLoadCallback|itemFirstInCallback|itemFirstOutCallback|itemLastInCallback|itemLastOutCallback|itemVisibleInCallback|itemVisibleOutCallback|buttonNextEvent|click|buttonPrevEvent|height|left|top|indexOf|skin|nodeName|ul|ol|funcNext|funcPrev|reload|init|browser|safari|window|resize|reset|empty|add|prepend|startAuto|onAfterAnimation|object|jquery|marginLeft|offsetHeight|marginTop|swap|new|normal|swing|UL|OL|find|class|children|load|prototype|0px|10px|lock|unlock|has|string|html|append|alert|jCarousel|No|set|items|This|will|cause|an|infinite|loop|Aborting|push|onBeforeAnimation|setTimeout|1000|clearTimeout|isFunction|jcarouselindex|horizontal|borderLeftWidth|borderRightWidth|borderTopWidth|borderBottomWidth|index|round|floor|defaults|float|none|parseInt|isNaN|jQuery'.split('|'),0,{}))}

/*jquery.prettyPhoto.js*/
/* ------------------------------------------------------------------------
 * 	Class: prettyPhoto
 * 	Use: Lightbox clone for jQuery
 * 	Author: Stephane Caron (http://www.no-margin-for-errors.com)
 * 	Version: 2.5.6
 ------------------------------------------------------------------------- */

(function($){$.prettyPhoto={version:'2.5.6'};$.fn.prettyPhoto=function(settings){settings=jQuery.extend({animationSpeed:'normal',opacity:0.80,showTitle:true,allowresize:true,default_width:500,default_height:344,counter_separator_label:'/',theme:'light_rounded',hideflash:false,wmode:'opaque',autoplay:true,modal:false,changepicturecallback:function(){},callback:function(){},markup:'<div class="pp_pic_holder"> \
      <div class="pp_top"> \
       <div class="pp_left"></div> \
       <div class="pp_middle"></div> \
       <div class="pp_right"></div> \
      </div> \
      <div class="pp_content_container"> \
       <div class="pp_left"> \
       <div class="pp_right"> \
        <div class="pp_content"> \
         <div class="pp_loaderIcon"></div> \
         <div class="pp_fade"> \
          <a href="#" class="pp_expand" title="Expand the image">Expand</a> \
          <div class="pp_hoverContainer"> \
           <a class="pp_next" href="#">next</a> \
           <a class="pp_previous" href="#">previous</a> \
          </div> \
          <div id="pp_full_res"></div> \
          <div class="pp_details clearfix"> \
           <a class="pp_close" href="#">Close</a> \
           <p class="pp_description"></p> \
           <div class="pp_nav"> \
            <a href="#" class="pp_arrow_previous">Previous</a> \
            <p class="currentTextHolder">0/0</p> \
            <a href="#" class="pp_arrow_next">Next</a> \
           </div> \
          </div> \
         </div> \
        </div> \
       </div> \
       </div> \
      </div> \
      <div class="pp_bottom"> \
       <div class="pp_left"></div> \
       <div class="pp_middle"></div> \
       <div class="pp_right"></div> \
      </div> \
     </div> \
     <div class="pp_overlay"></div> \
     <div class="ppt"></div>',image_markup:'<img id="fullResImage" src="" />',flash_markup:'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',quicktime_markup:'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',iframe_markup:'<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',inline_markup:'<div class="pp_inline clearfix">{content}</div>'},settings);if($.browser.msie&&parseInt($.browser.version)==6){settings.theme="light_square";}
if($('.pp_overlay').size()==0)_buildOverlay();var doresize=true,percentBased=false,correctSizes,$pp_pic_holder,$ppt,$pp_overlay,pp_contentHeight,pp_contentWidth,pp_containerHeight,pp_containerWidth,windowHeight=$(window).height(),windowWidth=$(window).width(),setPosition=0,scrollPos=_getScroll();$(window).scroll(function(){scrollPos=_getScroll();_centerOverlay();_resizeOverlay();});$(window).resize(function(){_centerOverlay();_resizeOverlay();});$(document).keydown(function(e){if($pp_pic_holder.is(':visible'))
switch(e.keyCode){case 37:$.prettyPhoto.changePage('previous');break;case 39:$.prettyPhoto.changePage('next');break;case 27:if(!settings.modal)
$.prettyPhoto.close();break;};});$(this).each(function(){$(this).bind('click',function(){_self=this;theRel=$(this).attr('rel');galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);var images=new Array(),titles=new Array(),descriptions=new Array();if(theGallery){$('a[rel*='+theGallery+']').each(function(i){if($(this)[0]===$(_self)[0])setPosition=i;images.push($(this).attr('href'));titles.push($(this).find('img').attr('alt'));descriptions.push($(this).attr('title'));});}else{images=$(this).attr('href');titles=($(this).find('img').attr('alt'))?$(this).find('img').attr('alt'):'';descriptions=($(this).attr('title'))?$(this).attr('title'):'';}
$.prettyPhoto.open(images,titles,descriptions);return false;});});$.prettyPhoto.open=function(gallery_images,gallery_titles,gallery_descriptions){if($.browser.msie&&$.browser.version==6){$('select').css('visibility','hidden');};if(settings.hideflash)$('object,embed').css('visibility','hidden');images=$.makeArray(gallery_images);titles=$.makeArray(gallery_titles);descriptions=$.makeArray(gallery_descriptions);image_set=($(images).size()>0)?true:false;_checkPosition($(images).size());$('.pp_loaderIcon').show();$pp_overlay.show().fadeTo(settings.animationSpeed,settings.opacity);$pp_pic_holder.find('.currentTextHolder').text((setPosition+1)+settings.counter_separator_label+$(images).size());if(descriptions[setPosition]){$pp_pic_holder.find('.pp_description').show().html(unescape(descriptions[setPosition]));}else{$pp_pic_holder.find('.pp_description').hide().text('');};if(titles[setPosition]&&settings.showTitle){hasTitle=true;$ppt.html(unescape(titles[setPosition]));}else{hasTitle=false;};movie_width=(parseFloat(grab_param('width',images[setPosition])))?grab_param('width',images[setPosition]):settings.default_width.toString();movie_height=(parseFloat(grab_param('height',images[setPosition])))?grab_param('height',images[setPosition]):settings.default_height.toString();if(movie_width.indexOf('%')!=-1||movie_height.indexOf('%')!=-1){movie_height=parseFloat(($(window).height()*parseFloat(movie_height)/100)-100);movie_width=parseFloat(($(window).width()*parseFloat(movie_width)/100)-100);percentBased=true;}
$pp_pic_holder.fadeIn(function(){imgPreloader="";switch(_getFileType(images[setPosition])){case'image':imgPreloader=new Image();nextImage=new Image();if(image_set&&setPosition>$(images).size())nextImage.src=images[setPosition+1];prevImage=new Image();if(image_set&&images[setPosition-1])prevImage.src=images[setPosition-1];$pp_pic_holder.find('#pp_full_res')[0].innerHTML=settings.image_markup;$pp_pic_holder.find('#fullResImage').attr('src',images[setPosition]);imgPreloader.onload=function(){correctSizes=_fitToViewport(imgPreloader.width,imgPreloader.height);_showContent();};imgPreloader.onerror=function(){alert('Image cannot be loaded. Make sure the path is correct and image exist.');$.prettyPhoto.close();};imgPreloader.src=images[setPosition];break;case'youtube':correctSizes=_fitToViewport(movie_width,movie_height);movie='http://www.youtube.com/v/'+grab_param('v',images[setPosition]);if(settings.autoplay)movie+="&autoplay=1";toInject=settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);break;case'vimeo':correctSizes=_fitToViewport(movie_width,movie_height);movie_id=images[setPosition];movie='http://vimeo.com/moogaloop.swf?clip_id='+movie_id.replace('http://vimeo.com/','');if(settings.autoplay)movie+="&autoplay=1";toInject=settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);break;case'quicktime':correctSizes=_fitToViewport(movie_width,movie_height);correctSizes['height']+=15;correctSizes['contentHeight']+=15;correctSizes['containerHeight']+=15;toInject=settings.quicktime_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,images[setPosition]).replace(/{autoplay}/g,settings.autoplay);break;case'flash':correctSizes=_fitToViewport(movie_width,movie_height);flash_vars=images[setPosition];flash_vars=flash_vars.substring(images[setPosition].indexOf('flashvars')+10,images[setPosition].length);filename=images[setPosition];filename=filename.substring(0,filename.indexOf('?'));toInject=settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+'?'+flash_vars);break;case'iframe':correctSizes=_fitToViewport(movie_width,movie_height);frame_url=images[setPosition];frame_url=frame_url.substr(0,frame_url.indexOf('iframe')-1);toInject=settings.iframe_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{path}/g,frame_url);break;case'inline':myClone=$(images[setPosition]).clone().css({'width':settings.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>').appendTo($('body'));correctSizes=_fitToViewport($(myClone).width(),$(myClone).height());$(myClone).remove();toInject=settings.inline_markup.replace(/{content}/g,$(images[setPosition]).html());break;};if(!imgPreloader){$pp_pic_holder.find('#pp_full_res')[0].innerHTML=toInject;_showContent();};});};$.prettyPhoto.changePage=function(direction){if(direction=='previous'){setPosition--;if(setPosition<0){setPosition=0;return;};}else{if($('.pp_arrow_next').is('.disabled'))return;setPosition++;};if(!doresize)doresize=true;_hideContent(function(){$.prettyPhoto.open(images,titles,descriptions)});$('a.pp_expand,a.pp_contract').fadeOut(settings.animationSpeed);};$.prettyPhoto.close=function(){$pp_pic_holder.find('object,embed').css('visibility','hidden');$('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animationSpeed);$pp_overlay.fadeOut(settings.animationSpeed,function(){$('#pp_full_res').html('');$pp_pic_holder.attr('style','').find('div:not(.pp_hoverContainer)').attr('style','');_centerOverlay();if($.browser.msie&&$.browser.version==6){$('select').css('visibility','visible');};if(settings.hideflash)$('object,embed').css('visibility','visible');setPosition=0;settings.callback();});doresize=true;};_showContent=function(){$('.pp_loaderIcon').hide();projectedTop=scrollPos['scrollTop']+((windowHeight/2)-(correctSizes['containerHeight']/2));if(projectedTop<0)projectedTop=0+$ppt.height();$pp_pic_holder.find('.pp_content').animate({'height':correctSizes['contentHeight']},settings.animationSpeed);$pp_pic_holder.animate({'top':projectedTop,'left':(windowWidth/2)-(correctSizes['containerWidth']/2),'width':correctSizes['containerWidth']},settings.animationSpeed,function(){$pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(correctSizes['height']).width(correctSizes['width']);$pp_pic_holder.find('.pp_fade').fadeIn(settings.animationSpeed);if(image_set&&_getFileType(images[setPosition])=="image"){$pp_pic_holder.find('.pp_hoverContainer').show();}else{$pp_pic_holder.find('.pp_hoverContainer').hide();}
if(settings.showTitle&&hasTitle){$ppt.css({'top':$pp_pic_holder.offset().top-25,'left':$pp_pic_holder.offset().left+20,'display':'none'});$ppt.fadeIn(settings.animationSpeed);};if(correctSizes['resized'])$('a.pp_expand,a.pp_contract').fadeIn(settings.animationSpeed);settings.changepicturecallback();});};function _hideContent(callback){$pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden');$pp_pic_holder.find('.pp_fade').fadeOut(settings.animationSpeed,function(){$('.pp_loaderIcon').show();if(callback)callback();});$ppt.fadeOut(settings.animationSpeed);}
function _checkPosition(setCount){if(setPosition==setCount-1){$pp_pic_holder.find('a.pp_next').css('visibility','hidden');$pp_pic_holder.find('a.pp_arrow_next').addClass('disabled').unbind('click');}else{$pp_pic_holder.find('a.pp_next').css('visibility','visible');$pp_pic_holder.find('a.pp_arrow_next.disabled').removeClass('disabled').bind('click',function(){$.prettyPhoto.changePage('next');return false;});};if(setPosition==0){$pp_pic_holder.find('a.pp_previous').css('visibility','hidden');$pp_pic_holder.find('a.pp_arrow_previous').addClass('disabled').unbind('click');}else{$pp_pic_holder.find('a.pp_previous').css('visibility','visible');$pp_pic_holder.find('a.pp_arrow_previous.disabled').removeClass('disabled').bind('click',function(){$.prettyPhoto.changePage('previous');return false;});};if(setCount>1){$('.pp_nav').show();}else{$('.pp_nav').hide();}};function _fitToViewport(width,height){hasBeenResized=false;_getDimensions(width,height);imageWidth=width;imageHeight=height;if(((pp_containerWidth>windowWidth)||(pp_containerHeight>windowHeight))&&doresize&&settings.allowresize&&!percentBased){hasBeenResized=true;notFitting=true;while(notFitting){if((pp_containerWidth>windowWidth)){imageWidth=(windowWidth-200);imageHeight=(height/width)*imageWidth;}else if((pp_containerHeight>windowHeight)){imageHeight=(windowHeight-200);imageWidth=(width/height)*imageHeight;}else{notFitting=false;};pp_containerHeight=imageHeight;pp_containerWidth=imageWidth;};_getDimensions(imageWidth,imageHeight);};return{width:Math.floor(imageWidth),height:Math.floor(imageHeight),containerHeight:Math.floor(pp_containerHeight),containerWidth:Math.floor(pp_containerWidth)+40,contentHeight:Math.floor(pp_contentHeight),contentWidth:Math.floor(pp_contentWidth),resized:hasBeenResized};};function _getDimensions(width,height){width=parseFloat(width);height=parseFloat(height);$pp_details=$pp_pic_holder.find('.pp_details');$pp_details.width(width);detailsHeight=parseFloat($pp_details.css('marginTop'))+parseFloat($pp_details.css('marginBottom'));$pp_details=$pp_details.clone().appendTo($('body')).css({'position':'absolute','top':-10000});detailsHeight+=$pp_details.height();detailsHeight=(detailsHeight<=34)?36:detailsHeight;if($.browser.msie&&$.browser.version==7)detailsHeight+=8;$pp_details.remove();pp_contentHeight=height+detailsHeight;pp_contentWidth=width;pp_containerHeight=pp_contentHeight+$ppt.height()+$pp_pic_holder.find('.pp_top').height()+$pp_pic_holder.find('.pp_bottom').height();pp_containerWidth=width;}
function _getFileType(itemSrc){if(itemSrc.match(/youtube\.com\/watch/i)){return'youtube';}else if(itemSrc.match(/vimeo\.com/i)){return'vimeo';}else if(itemSrc.indexOf('.mov')!=-1){return'quicktime';}else if(itemSrc.indexOf('.swf')!=-1){return'flash';}else if(itemSrc.indexOf('iframe')!=-1){return'iframe'}else if(itemSrc.substr(0,1)=='#'){return'inline';}else{return'image';};};function _centerOverlay(){if(doresize){titleHeight=$ppt.height();contentHeight=$pp_pic_holder.height();contentwidth=$pp_pic_holder.width();projectedTop=(windowHeight/2)+scrollPos['scrollTop']-((contentHeight+titleHeight)/2);$pp_pic_holder.css({'top':projectedTop,'left':(windowWidth/2)+scrollPos['scrollLeft']-(contentwidth/2)});$ppt.css({'top':projectedTop-titleHeight,'left':(windowWidth/2)+scrollPos['scrollLeft']-(contentwidth/2)+20});};};function _getScroll(){if(self.pageYOffset){return{scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset};}else if(document.documentElement&&document.documentElement.scrollTop){return{scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft};}else if(document.body){return{scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft};};};function _resizeOverlay(){windowHeight=$(window).height();windowWidth=$(window).width();$pp_overlay.css({'height':$(document).height()});};function _buildOverlay(){$('body').append(settings.markup);$pp_pic_holder=$('.pp_pic_holder');$ppt=$('.ppt');$pp_overlay=$('div.pp_overlay');$pp_pic_holder.attr('class','pp_pic_holder '+settings.theme);$pp_overlay.css({'opacity':0,'height':$(document).height()}).bind('click',function(){if(!settings.modal)
$.prettyPhoto.close();});$('a.pp_close').bind('click',function(){$.prettyPhoto.close();return false;});$('a.pp_expand').bind('click',function(){$this=$(this);if($this.hasClass('pp_expand')){$this.removeClass('pp_expand').addClass('pp_contract');doresize=false;}else{$this.removeClass('pp_contract').addClass('pp_expand');doresize=true;};_hideContent(function(){$.prettyPhoto.open(images,titles,descriptions)});$pp_pic_holder.find('.pp_fade').fadeOut(settings.animationSpeed);return false;});$pp_pic_holder.find('.pp_previous, .pp_arrow_previous').bind('click',function(){$.prettyPhoto.changePage('previous');return false;});$pp_pic_holder.find('.pp_next, .pp_arrow_next').bind('click',function(){$.prettyPhoto.changePage('next');return false;});};_centerOverlay();};function grab_param(name,url){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(url);if(results==null)
return"";else
return results[1];}})(jQuery);

/*addon2.js*/
var appStiTabsIds
var appImgRounded
var appStitblHideColls
var appStitblCollsNotInList
var appOrdtblHideColls
var appOrdtblCollsNotInList
var appshowbuyfailures = false;
var appPrcRangeVat
var appPrcRangeStep
var logedUser = 0

var rq_cls = ""

function getObj (name) {
    if (typeof name == "object") return name;
    if (jsDOM1) return document.getElementById(name);
    if (jsDOM0) return eval('document.all.'+name);
    else return null;
    }

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.OP9	= this.AGENT.indexOf("Opera 9")>-1							?true:false;
	this.OP		= (this.OP5 || this.OP6 || this.OP7 || this.OP8 || this.OP9);

	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.IE		= (this.IE4 || this.IE5 || this.IE6 || this.IE7 || this.IE8);

	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;
}


//*********inicializace***************
$(document).ready(function() {

  /*$.ajaxSetup({
    'beforeSend' : function(xhr) {
        xhr.overrideMimeType('text/html; charset=utf-8');
    }
  });
  */
  //addToLastVisited(5282,'link1','code1','long name of product','12322 kc');
  //curvyCorners.scanStyles();
  
  
  //getExecTime('initClosingConts()');
  //startExecTimer();
  //initI6base();
  //stopExecTimer();
  
  //JSLitmus.test('initBasketFrame',function(){initBasketFrame();}); 
  

//openPopup('nadpis','hjashjsahj  jas j  jsa  jasdj sad  jas dj a fsj  dfaj',1213000,'',true);
//window.setTimeout(function(){initI6base();},3000);

/*var n = 0;
jQuery.whileAsync({  
      delay: 100,        
      bulk: 0,        
      test: function() { return n > 0 },        
      loop: function()        {alert('ss'+n);n--; },
      end: function()        {initI6base();}
      })


*/

 /*      $.ajax({
        url:'default_jx.asp',
        cache: true,
        success: function(){initI6base();}
        });

*/

 //window.execScript(function(){initI6base();}); //snad jen pro IE6

//getExecTime('updateCompareUI();');



});

$(window).load(function() {
  initI6base();
  //roundImgCorners(appImgRounded);     //50 ms //50ms
});

function initInputs(){
      
       $("form input:not([onkeypress])").keypress(function (e) {  
           if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {                 
               if($(this).parents("form").find("input[type='submit']").length>0)
                  $(this).parents("form").find("input[type='submit']").click();
               else
                  $(this).parents("form").submit();
               return false;  
           } else {  
               return true;  
           }  
       });  
}

function bigloop(){

var nn = 9999999
while(  nn>0)
{
  nn--;
}

}


function initI6base(){
//alert('initialize page');
  initVariables();
  initAppsettings();
  $(".hint").hint('hint');//hint textboxy //40ms //ok
  initInputs();
  initCompareElements();              //400ms //220ms
  initBasketFrame();                  //20ms  //ok
  initCategoryParams();               //80ms  //10ms
  initFavourCont();                   //80ms  // chtelo by predelat at se data po prihlaseni jednorazove natahnou do cookiny
  lastVisitedInit();                  //150ms //40ms
  initClosingConts(appClosingConts);  //400ms //80ms  
  setComManData();
  
  switch(rq_cls){
   case 'stoitem':
          $('#stigalleryul').jcarousel();    //350ms //--
          initPrettyPhoto();                 //170ms //-- 
          initStoitemTabs(appStiTabsIds);     //900ms //--
          stiqtyPrewievInit('.inetstock');
          break;

   case 'stoitems':
          thumbnailPrewievInit('#stitbl');             //500ms //20ms 
          createAddonStiTable();              //100ms //60ms
          stiqtyPrewievInit('#stitbl');
          break;
   case 'spresenttrees':
          LoadFilterState();
          thumbnailPrewievInit('#stitbl');             //500ms //20ms 
          initStinoteAddons();                //800ms //120ms
          createAddonStiTable();              //100ms //60ms
          initStiSatusFilter();
          initPrcRange();
          stiqtyPrewievInit('#stitbl');       
          break;
   case 'ordbaskets':
          createAddonStiTable();              //100ms //60ms
          thumbnailPrewievInit('#ordtbl');             //500ms //20ms 
          delivPayStoreUpdateUI();
          updateBasketUI(true);       
          break;
   default: break;                          
   }
  
                                      //total 2800ms //750ms
//alert(' page initialized');
}

function initVariables(){
  
  logedUser =  Number(get_cookie('I6_logeduser'));
}

function setComManData(){

    valString = unescape(get_cookie('I6_commandetails'));
    $("#coxdebtexp").text((""+GetValueFromArray(valString,"coxdebtexp")).replace("&nbsp;"," "));

}

function initLoginData(){

  valString = escape(document.getElementById('commandetails').innerHTML);

  set_cookie('I6_commandetails',valString,null);

  $("#coxdebtexp").html(Number(GetValueFromArray(valString,"coxdebtexp")));

  updateBasketUI(true);
  
  set_cookie('I6_logeduser',1,null);
  logedUser = 1;
}

function updateLogOffUI(){
  set_cookie('I6_logeduser',0,null);
  set_cookie('i6_basket_count',0,null);
  set_cookie('i6_basket_price',0,null);
  logedUser = 0;
  set_cookie('I6_commandetails','',null);

  
  $(document).ready(function() {
    $('#i6_basket_count').html('0');
    $('#i6_basket_price').html('0');
    $('.boxcont.commaninfocont').css('display','none');
    $('.commaninfocontfake').css('display','none');
    
    updateBasketUI(true); //pouze pokud je zapnuta form autentifikace
  });
}

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {var x = Math.round(num * Math.pow(10,dec));if (x >= 0) n1=n2='';var y = (''+Math.abs(x)).split('');var z = y.length - dec; if (z<0) z--; for(var i = z; i < 0; i++) y.unshift('0'); if (z<0) z = 1; y.splice(z, 0, pnt); if(y[0] == pnt) y.unshift('0'); while (z > 3) {z-=3; y.splice(z,0,thou);}var r = curr1+n1+y.join('')+n2+curr2;return r;}

function initPrcRange(){
var rmin = $('#stipricedeffrom.stipricedeffrom').clone().val();
var rmax = $('#stipricedefto.stipricedefto').clone().val();
var rcurcode = $('#stipricedefcurcode.stipricedefcurcode').clone().val();
rmax = rmax*(1+appPrcRangeVat/100)

  $("#slider-range").slider({
  			range: true,
  			min:0,
  			step:appPrcRangeStep,
  			max: rmax,
  			values: [0, rmax],
  			slide: function(event, ui) {
  				$('#stipricedeafrom input.stipricedeafrom').val(Math.floor(ui.values[0]/(1+appPrcRangeVat/100)));
  				$('#stipricedeafrominfo').text(formatNumber(ui.values[0],0,' ','','',' '+rcurcode,'',''));
  				
  				$('#stipricedeato input.stipricedeato').val(Math.floor(ui.values[1]/(1+appPrcRangeVat/100)));
  				$('#stipricedeatoinfo').text(formatNumber(ui.values[1],0,' ','','',' '+rcurcode,'','')+' ');
  			},
  			stop: function(event,ui){
         $('#stiprcsrch').append("<input type='hidden' name='changed' value='1' disabled='disabled'/>")

  			 loadProductList(GetFilterString());
        }
  		});
  		$('#stipricedeafrominfo').text('0 '+rcurcode);
  		$('#stipricedeatoinfo').text(formatNumber(Number(rmax),0,' ','','',' '+rcurcode,'','')+' ');
}

function initPrettyPhoto(){
    $("#sti_bigimg a[rel^='prettyPhoto'], #stigalleryul a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook'}); 
}

function initLigtbox(){
//$(".jcarousel-skin-tango img").lightBox();

}

function initStoitemTabs(appStiTabsIds) {

  $("#tabs ul").empty()
  $("#tabs").tabs({ tabTemplate: '<li><div class="outer"><div class="inner"><a href="#{href}"><strong> </strong><span>#{label}</span><u> </u></a></div></div></li>' });
  
  if(appStiTabsIds.length>0){
  	 var arrPanels = appStiTabsIds.split(',');
  	 for(cc=0;arrPanels.length>cc;cc++)
  	 {
  	   if($("#"+arrPanels[cc]).length){
          $("#"+arrPanels[cc]).wrapInner('<div class="outer"><div class="inner"><div class="wrap"/></div></div>');
          $("#tabs").tabs("add","#"+arrPanels[cc],$("#"+arrPanels[cc]+" .wrap > .hdr .c").text()); 
        }
     }
  	}
}

function initStiSearch(){
  
  var srchForm = $('form[name="frmcomsearch"]');
  $('form[name="frmcomsearch"] input').change(function(){ 
      //$("#stisearchcount_jx").load('default_jx.asp?'+srchForm.serialize()+'&xsl=xstoitems_jx.xsl');  
       $.ajax({
        url:'default_jx.asp?'+srchForm.serialize()+'&xsl=xstoitems_jx.xsl',
        cache: false,
        success: function(html){
         $("#stisearchcount_jx").html(html);
        }
      });
      
      });
  $('form[name="frmcomsearch"] select').change(function(){ 
      //$("#stisearchcount_jx").load('default_jx.asp?'+srchForm.serialize()+'&xsl=xstoitems_jx.xsl');  
       $.ajax({
        url:'default_jx.asp?'+srchForm.serialize()+'&xsl=xstoitems_jx.xsl',
        cache: false,
        success: function(html){
         $("#stisearchcount_jx").html(html);
        }
      });
      
      });
}

function initStiParinf(){
  var srchForm = $('form[name="stiparinf"]');

  $('form[name="stiparinf"] input[type=checkbox]').click(function(){ 
      //$("#stiparinf_jx").load('default_jx.asp?'+srchForm.serialize()+'&xsl=xstiparinf_jx.xsl');
       $.ajax({
        url:'default_jx.asp?'+srchForm.serialize()+'&xsl=xstiparinf_jx.xsl',
        cache: false,
        success: function(html){
         $("#stiparinf_jx").html(html);
        }
      });
      
  });
  
  
}

function initParinfSPresenttree(){
  
 // var srchForm = $('#fltrparamsinput form[name="stiparinf_spresenttree"]')
  var hashUrl = window.location.hash; 
  if(hashUrl && hashUrl.length>0)
    SetFilterByUrl(hashUrl);
    
    $('#fltrparamsinput form[name="stiparinf_spresenttree"] input[type=checkbox]').click(function(){     
    
        /* var fltparamUrl = $('#fltrparamsinput form[name="stiparinf_spresenttree"]').serialize()+''
         if($('#stiprcsrch input[name="changed"]').length>0)
            fltparamUrl = fltparamUrl+"&stipricedeafrom="+$('#stiprcsrch .stipricedeafrom').val()+"&stipricedeato="+$('#stiprcsrch .stipricedeato').val();
         fltparamUrl =  'default_jx.asp?'+fltparamUrl  */
  			 loadProductList(GetFilterString());
    
         //loadProductList('default_jx.asp?'+$('#fltrparamsinput form[name="stiparinf_spresenttree"]').serialize());
      
  });
  initParamItemAsClosable();
}

function initStiSatusFilter(){
  $("#stistssrch input").change(function(){loadProductList(GetFilterString());updateStiStatusFilterUI();});
  $("#stistssrch .allprod input").unbind('change').change(function(){clearStiStatusFilter();loadProductList(GetFilterString());});
}

function clearStiStatusFilter(){
  $("#stistssrch input[value!='']").attr("checked","");
}

function updateStiStatusFilterUI(){
  if($("#stistssrch input:checked").length == 0)
    $("#stistssrch .allprod input").attr("checked","checked");
  else if ($("#stistssrch input:checked").length == 2)
    $("#stistssrch .allprod input").attr("checked","");  
}

function initStinoteAddons(){
  var strMaxDesc = "celý text"
  var strMinDesc = "skrýt text"
  var strBtnText = strMaxDesc

  var minHeight = 60;
  var cmtBlock = $('#stinotecmtblock');
  var inBlock //= $('.stinote .stinotein')
  var outBlock //= $('.stinote .stinoteout')
  var btnTop 
  var btnBottom
  var cmtBlockInnerHeight = cmtBlock.innerHeight();

  if(cmtBlockInnerHeight>minHeight)
    {
      
      cmtBlock.wrap('<div class="stinoteout" id="stinoteout"><div class="stinotein" id="stinotein"/></div>');
      inBlock = $('#stinotein');
      outBlock = $('#stinoteout');
      
      $('.stinote .hdr .c').append('<div class="btnn top" id="stinotebtnntop"><a href="#" title="'+strBtnText+'"><p>&#160;</p><strong><p>'+strBtnText+'</p></strong><span>&#160;</span></a><br class="clear"/></div>');
    
      
      //btnTop = $('.stinote .hdr .c .btnn.top');
      
      outBlock.append('<div class="btnn btm" id="stinotebtnnbtm"><a href="#" title="'+strBtnText+'"><p>&#160;</p><strong><p>'+strBtnText+'</p></strong><span>&#160;</span></a><br class="clear"/></div>');
    
      
     // btnBottom = $('.stinote .cnt .btnn.btm');
      
      
      $("#stinotebtnntop").click(function () {
  
        if(Number(inBlock.innerHeight()) < Number(cmtBlockInnerHeight))
          {
            inBlock.animate( { height:cmtBlockInnerHeight }, { queue:true, duration:400 } );
            $('#stinotebtnntop').addClass("minimize");
            $('#stinotebtnnbtm').addClass("minimize");
            $(".stinote .btnn a").attr("title",strMinDesc);
            $(".stinote .btnn a strong p").text(strMinDesc);
          } 
        else
          {
            inBlock.animate( { height:minHeight }, { queue:true, duration:400 } );
            $('#stinotebtnntop').removeClass("minimize");
            $('#stinotebtnnbtm').removeClass("minimize");
            $(".stinote .btnn a").attr("title",strMaxDesc);
            $(".stinote .btnn a strong p").text(strMaxDesc);
          }
          return false;
      });
      
      $("#stinotebtnnbtm").click(function () {
  
        if(Number(inBlock.innerHeight()) < Number(cmtBlockInnerHeight))
          {
            inBlock.animate( { height:cmtBlockInnerHeight }, { queue:true, duration:400 } );
            $('#stinotebtnntop').addClass("minimize");
            $('#stinotebtnnbtm').addClass("minimize");
            $(".stinote .btnn a").attr("title",strMinDesc);
            $(".stinote .btnn a strong p").text(strMinDesc);
          } 
        else
          {
            inBlock.animate( { height:minHeight }, { queue:true, duration:400 } );
            $('#stinotebtnntop').removeClass("minimize");
            $('#stinotebtnnbtm').removeClass("minimize");
            $(".stinote .btnn a").attr("title",strMaxDesc);
            $(".stinote .btnn a strong p").text(strMaxDesc);
          }
          return false;
      });
      
    } 

/*  if(Number($('.stinote .cnt p').innerHeight())>50)
    {
      $('.stinote .cnt').addClass('default');
      //add expand 
      alert('add expand buttons')
   
    $("button").click(function () {
      $(".stinote .cnt").slideToggle("slow");
     
      $('.stinote .cnt').removeClass('default');
     
     });   
    
    }
    */
}

function roundImgCorners(strFind)
{
  	 var arrImgTypes = strFind.split(',');
  	 for(cc=0;arrImgTypes.length>cc;cc++)
  	 {
  	   if($(arrImgTypes[cc]).length){
        $(arrImgTypes[cc]).each(function(){
          
             $(this).wrap('<div class="rndimg"><div class="outer"><div class="inner"/></div></div>"');
             $(this).parent().css({"background":"url('"+$(this).attr('src')+"')","width":$(this).width()+'px',"height":$(this).height()+'px'});
             $(this).attr('src','img/empty.gif');
           
          });
        }
     }
}

 function nxtSibling (n)
 {
  do n = n.nextSibling;
  while (n && n.nodeType != 1);
  return n;
 }

 function prevSibling (p)
 {
  do p = p.previousSibling;
  while (p && p.nodeType != 1);
  return p;
 }


function createAddonStiTable()
{
  $('#stitbl').columnManager({listTargetID:'targetcol', onClass: 'colon', offClass: 'coloff',saveState: true , hideInList: appStitblCollsNotInList,colsHidden: appStitblHideColls});
  $('#ordtbl').columnManager({listTargetID:'targetcol', onClass: 'colon', offClass: 'coloff',saveState: true , hideInList: appOrdtblCollsNotInList,colsHidden: appOrdtblHideColls});
  $('#mntools').clickMenu(); 
 
     var opt = {listTargetID: 'targetcol', onClass: 'advon', offClass: 'advoff',  
            hide: function(c){ 
                $(c).fadeOut(); 
            },  
            show: function(c){ 
                $(c).fadeIn(); 
            }};
}

function buyAsync(surl){
  if(rq_cls=='ordbaskets')
    {
      window.location.href=surl;
      return;
    }
  
  var loadingPopup = openPopup('','<p>'+GetLng("lngaddingtobskt")+'</p>',0,'basketadding',false);  
  var tmpurl = surl.replace("default","default_jx");
  $.ajax({
  url: tmpurl,
  cache: false,
  success: function(html){
   closePopup(loadingPopup,"fast");
   $("body").append('<div id="tempnode" style="display:none;">'+html+'</div>')
   if(($("#tempnode .msgbox").html() && $("#tempnode .msgbox").html().length>0))
      if(appshowbuyfailures)
        openPopup('',$("#tempnode .msgbox").html(),20000,'basketmsgbox',false);
      else
        openPopup('','<p>Produkt nelze vložit do košíku.</p>',20000,'basketfailure',false);
   else if ($("#tempnode #bsktfailure").html() && $("#tempnode #bsktfailure").html().length>0)  
      if(appshowbuyfailures)
        openPopup('',$("#tempnode #bsktfailure").html(),20000,'basketmsgbox',false);
      else
        openPopup('','<p>Produkt nelze vložit do košíku.</p>',20000,'basketfailure',false);
   else
      openPopup('','<p>'+GetLng("lngprodaddtobask")+'</p>',3000,'basketadd',false);
   $("#tempnode").remove();
   if($("form[name='sirform']").length>0)// prida zatrhnute zvyhodnene produkty z detailu produktu
    {
      $.ajax({
        url: "default.asp?cls=ordbaskets&"+$("form[name='sirform'] input[type='checkbox']:checked").parent().serialize(),
        cache: false,
        success: function(html){
        updateBasketUI(true);
      }
      });
    }
    else{updateBasketUI(true);}  
  }
  });
  //$("#bsktcont .basketdetailsframe .cnt .out .in").load(surl + " #basketitems","",function(){openPopup('','Produkt pridan do kosiku',0,'basketadd',false);
  //return true;
 
}

function createLoadingCont(cssClass){
  var retHtml
  
  retHtml = "<div id='loadingCont' class='loadingCont "+cssClass+"'><div class='outer'><div class='inner'><img src='img/empty.gif' alt='"+GetLng('lngloadingdata')+"' title='"+GetLng('lngloadingdata')+"'/><span>"+GetLng('lngloadingdata')+"</span></div></div></div>"
  
  return retHtml;
}

function initCategoryParams(){
  $("#fltrparamshdr").click(function(){
    if($("#fltrparamscnt").css("display")=='none' && $("#fltrparamsinput form").length<1 )
      {
        loadCategoryParams();
      }
  });
}

function loadCategoryParams(){
  
 var strid = $("#fltrparamsinput").text();
 
 $("#fltrparamsinput").html(createLoadingCont())

 if(Number(strid)>0){
  
  $("#fltrparamsinput").load("default_jx.asp?show=stiparinf&strid="+strid+" #categoryparams",function(){      
      $("#fltrparamsinput").wrapInner('<form action="?" name="stiparinf_spresenttree" method="get"></form>');
      $("#fltrparamsinput form").append('<input type="hidden" name="cls" value="stoitems"/><input type="hidden" name="strid" value="'+strid+'"/>');
      initParinfSPresenttree();
      });
  
/*   $.ajax({
    url: "default_jx.asp?show=stiparinf&strid="+strid,
    cache: true ,
    success: function(html){
      $("#fltrparamsinput").html(html);
      $("#fltrparamsinput").html($("#categoryparams").html());
      
      $("#fltrparamsinput").wrapInner('<form action="?" name="stiparinf_spresenttree" method="get"></form>');
      $("#fltrparamsinput form").append('<input type="hidden" name="cls" value="stoitems"/><input type="hidden" name="strid" value="'+strid+'"/>');
      
      initParinfSPresenttree();
      
    }
    });
  */
  }  
  
}

function loadProductList(sUrl){

  var loadingpart = "&jxloadparts=productlistjx"
  var loadingpartsort ="&jxloadparts=stilistsortjx"
  
  sUrl = sUrl.replace(loadingpart,"").replace(loadingpartsort,"").replace("cls=stoitems","cls=spresenttrees")
  
  //V IE problem s diakritikou (jiz se vola jednou v form.serialize())
  /*  try{
        sUrl = decodeURIComponent(sUrl);
       }
    catch(err)
       {
        sUrl=sUrl;
       }
*/
  sUrl = sUrl.replace(/&&&/g,"&").replace(/\?&/g,'?').replace(/&&/g,"&");
  var nHeight = $("#productlistjx").height();
  var nWidth  = $("#productlistjx").width();
  var leftpos = $("#productlistjx").offset().left;
  var toppos = $("#productlistjx").offset().top;
  
    $("body").append("<div id='popupbckg' class='popupbckg productlistpopupbckg'>&#160;</div>");
      $("#popupbckg").css({"position":"absolute","opacity":"0.7","top":toppos,"left":leftpos,"height":nHeight,"width":nWidth});
		  //$("#popupbckg").html(createLoadingCont());
		  $("body").append(createLoadingCont("loadingprodlist"));
      $("#loadingCont.loadingprodlist").css({"position":"absolute","top":toppos,"left":leftpos,"margin-left":nWidth/2-60});
      $("#popupbckg").fadeIn("slow");
        
      $.ajax({
        url:sUrl,
        cache: true,
        success: function(html){
        $("#productlistjx").replaceWith(html); 
        $("#popupbckg,#loadingCont.loadingprodlist").fadeOut("slow",function(){$("#loadingCont.loadingprodlist").remove();$("#popupbckg").remove();});
        makeFilterbuttonsForAjax();
        createAddonStiTable();
        }
      });
      
      var strHash = sUrl.replace("default_jx.asp?","");
      window.location.hash = strHash
 
      if(!isCallbackMode)
        insActiveFilterMsg();
      isCallbackMode=true;
 /*      $.ajax({
        url:sUrl+loadingpart,
        cache: true,
        success: function(html){
        $("#productlistjx").replaceWith(html);
       // $(".productlistjx").html($(".productlistjx .productlistjx").html());  
       $("#popupbckg").fadeOut("slow",function(){$("#popupbckg").remove();});
       makeFilterbuttonsForAjax();
        }
      });
     
      $.ajax({
        url:sUrl+loadingpartsort,
        cache: true,
        success: function(html){
        $("#stilistsortjx").replaceWith(html);      
        makeFilterbuttonsForAjax();
        createAddonStiTable();
        }
      });
  */
}

function loadCommonWebPart(sUrl,objSrcSelector,objDestSelector){

  var loadingpart = "&jxloadparts="+objSrcSelector
  
       $.ajax({
        url:sUrl+loadingpart,
        cache: true,
        success: function(html){
        $(objDestSelector).replaceWith(html);  
        }
      });
}

function prepareFilterButtonsForAjax(){
    strId =getURLParameter($("#productlistjx").attr("rel"),"strid");
    $("#filtersbtm .cnt .fulltext").css("display","none"); 
    $("#stilist_fltr_producers input").attr("name","scaid");//prejmenuji aby slo primo serialize
    $("#stilist_fltr_producers a").attr("href","javascript:void(0)")
    $("#stilist_fltr_producers input").attr("onclick","");
    $("#stilist_fltr_producers a").unbind('click').click(function(){SetProducer($(this))})
    $("#stilist_fltr_producers input").unbind('change').change(function(){loadProductList(GetFilterString());updatePrucersUI();})
    $("#stilist_fltr_producers .allprod input").unbind('change').change(function(){ClearProducers()})
    $("#stilist_fltr_producers .allprod a").unbind('click').click(function(){ClearProducers()})
}

function makeFilterbuttonsForAjax(){

        var fltparamUrl = GetFilterString()+'&';//'default_jx.asp?'+$('#fltrparamsinput form[name="stiparinf_spresenttree"]').serialize()+'&'

        $(".styletab a").click(function(){loadProductList(fltparamUrl+$(this).attr("href"));return false;});
        $(".pagenav a").unbind('click').click(function(){loadProductList(fltparamUrl+$(this).attr("href"));return false;});        
        //$(".paging input").keypress(function(){$(this).attr("onkeypress");$(this).attr("onkeypress","");return false;});
        if($(".sort .btnn.desc a").length<1)
          {
            $("#stilist_fltr_sort select.orderselector").attr("onchange","");
            $("#stilist_fltr_sort select.orderselector").unbind('change').change(function(){loadProductList(fltparamUrl+'setstiordercook='+$(this).val());});
          }
            
        $(".sort .btnn.desc a").attr("onclick","");
        $(".sort .btnn.asc a").attr("onclick","");
        $(".sort .btnn.asc a").unbind('click').click(function(){loadProductList(fltparamUrl+'setstiordercook='+$(".orderselector").val());return false;}); 
        $(".sort .btnn.desc a").unbind('click').click(function(){loadProductList(fltparamUrl+'setstiordercook='+$(".orderselector").val()+'_desc');return false;}); 

        if($("select#pagesize").length>0)
          {
            $("select#pagesize").attr("onchange","");
            $("select#pagesize").change(function(){loadProductList(fltparamUrl+"setstipagesize=1&pagesize="+$(this).val());});
          }
        else
        {        
            $("#pagesize").attr("onkeypress","");
            $('#pagesize').bind('keypress', function(e) {
            if(e.keyCode==13){
              loadProductList(fltparamUrl+"setstipagesize=1&pagesize="+($(this).val()));
              e.cancel = true;
              return false;
            }
          });
        }
}

function initClosingConts(strFind){
 
 var cookiePrefix = "i6_closingCont" 
 
  	 var arrConts = strFind.split(',');
        
          $(strFind).each(function(){
         
              //nastaveni pocatecniho stavu rozbalen/zbalen             
              var contId = $(this).attr("id");
              if(appClosingContsInCookie.indexOf(contId)>-1){
                if(contId != null && contId.length>0)
                  {
                   var contCook =  $.cookie(cookiePrefix+contId);
                   if(contCook != null && (contCook=="none" || contCook=="block" || contCook=="table")){
                      $(this).children(".cnt").css("display",contCook);
                    }
                  }
              }
              
              if($(this).children(".cnt").css("display") == "none")
                {
                  $(this).removeClass("contopened");
                  $(this).addClass("contclosed");
                }
                else
                {
                  $(this).removeClass("contclosed");
                  $(this).addClass("contopened");
                }             
    
              //akce klik na hlavicku boxu
              $(this).children(".hdr").click(function(){
                 
                  if($(this).next().css("display") == "block")
                  {
                    $(this).parent().removeClass("contopened");
                    $(this).parent().addClass("contclosed");
                  }
                  else
                  {
                    $(this).parent().removeClass("contclosed");
                    $(this).parent().addClass("contopened");
                  }
                  
                var contId = $(this).parents().attr("id");      
                if(contId != null && contId.length>0)
                  {
                    var strDisplay 
                    if($(this).next().css("display") == "none")
                      strDisplay = "block"
                    else
                      strDisplay = "none"
                      
                    $.cookie(cookiePrefix+contId,strDisplay,{expires: 9999});
          
                  }
                  
               $(this).next().toggle("slow");
              
              });
            }); 
  
  

      /*  $(arrConts[cc]+" > .cnt").each(function(){
            
            var contId = $(this).parents().attr("id");
            
            if(contId != null && contId.length>0)
              {
               var contCook =  $.cookie(cookiePrefix+contId);
               if(contCook != null && (contCook=="none" || contCook=="block" || contCook=="table")){
                  $(this).css("display",contCook);
                }
              }
            
            if($(this).css("display") == "none")
              {
                $(this).parent().removeClass("contopened");
                $(this).parent().addClass("contclosed");
              }
              else
              {
                $(this).parent().removeClass("contclosed");
                $(this).parent().addClass("contopened");
              }    
          });  

          $(arrConts[cc]+" > .hdr").click(function(){
               
                if($(this).next().css("display") == "block")
                {
                  $(this).parent().removeClass("contopened");
                  $(this).parent().addClass("contclosed");
                }
                else
                {
                  $(this).parent().removeClass("contclosed");
                  $(this).parent().addClass("contopened");
                }
                
              var contId = $(this).parents().attr("id");      
              if(contId != null && contId.length>0)
                {
                  var strDisplay 
                  if($(this).next().css("display") == "none")
                    strDisplay = "block"
                  else
                    strDisplay = "none"
                    
                  $.cookie(cookiePrefix+contId,strDisplay,{expires: 9999});
        
                }
                
             $(this).next().toggle("slow");
            
            });
*/
    
  
 /*  vybira podle css clasu  "closingcont"
  $(".closingcont > .cnt").each(function(){
      
      var contId = $(this).parents().attr("id");
      
      if(contId != null && contId.length>0)
        {
         var contCook =  $.cookie(cookiePrefix+contId);
         if(contCook != null && (contCook=="none" || contCook=="block" || contCook=="table")){
            $(this).css("display",contCook);
          }
        }
      
      if($(this).css("display") == "none")
        {
          $(this).parent().removeClass("contopened");
          $(this).parent().addClass("contclosed");
        }
        else
        {
          $(this).parent().removeClass("contclosed");
          $(this).parent().addClass("contopened");
        }    
    });   

  $(".closingcont > .hdr").click(function(){
       
        if($(this).next().css("display") == "block")
        {
          $(this).parent().removeClass("contopened");
          $(this).parent().addClass("contclosed");
        }
        else
        {
          $(this).parent().removeClass("contclosed");
          $(this).parent().addClass("contopened");
        }
        
      var contId = $(this).parents().attr("id");      
      if(contId != null && contId.length>0)
        {
          var strDisplay 
          if($(this).next().css("display") == "none")
            strDisplay = "block"
          else
            strDisplay = "none"
            
          $.cookie(cookiePrefix+contId,strDisplay,{expires: 9999});

        }
        
     $(this).next().toggle("slow");
    
    });
      */
}


function initFavourCont(){

$("#favourcont > .hdr").click(function(){
    $("#favourcont .favourdetails").toggle("slow");
        if($(this).parent().hasClass("contopened"))
        {
          $(this).parent().removeClass("contopened");
        }
        else
        {
          updateFavourUI();
          $(this).parent().addClass("contopened");
        }
    });

  $("#favourcont .favourcount").html($.cookie("i6_favour_count"));
  //updateFavourUI();  //pokud chci obsah vzdy nacitat
}

function updateFavourUI() {
  var itemsCount = 0
  
   $.ajax({
  url: "default_jx.asp?cls=stoitems&stifavourites=1&xsl=xfavour_jx.xsl",
  cache: true,
  success: function(html){
    $("#favourcont .favourdetails .in").html(html);
    $("#favourcont .favourcount").html($("#favourcont .favourdetails .stitab tr").size()-1);
    $.cookie("i6_favour_count",$("#favourcont .favourdetails .stitab tr").size()-1,{expires: 9999})
    //$("#favourcont .favourdetails .in").html($("#favourcont .favourdetails .in .stitab").html())
  }
});
}

function addToFavour(stiid){
$.ajax({
  url: "default_jx.asp?cls=iisutil&stiid="+stiid+"&action=StiFavourites&method=add&redirect="+escape('empty.html?'),
  cache: false,
  success: function(html){
    $("#favourcont .favourdetails .in").html(html);
    $("#favourcont .favourcount").html($("#favourcont .favourdetails .stitab tr").size()-1);
    //$("#favourcont .favourdetails .in").html($("#favourcont .favourdetails .in .stitab").html())
  }
});
openPopup('','<p>'+GetLng("lngprodaddtofavour")+'</p>',0,'isfavouradd',false);
updateFavourUI();
}

function lastVisitedInit(){
 $("#lastvisiteddettable").ready(function(){updateLastVisitedUI();});
}

function addToLastVisited(stiid,link,sticode,stiname,stiprice,imglink){
var countTopShow = 4
link = unescape(link);

//var tblInvited = $(".lastvisiteddetails table")
var arryData = unescape($.cookie("i6_lastvisited_data")).split('###');
var strData = '';
 for(zz=0;zz<arryData.length && zz<countTopShow;zz++)
  {
    if($.trim(arryData[zz]).length>0 && arryData[zz] !=null)
    { 
      strData += arryData[zz]+'###';
    
      if(stiid == GetValueFromArray(arryData[zz],'stiid'))
        { 
          //updateLastVisitedUI();
          //alert('jiz existuje');
          return;
        }
    }
  }
  
  strData = 'stiid$$$'+stiid+'@@@link$$$'+link+'@@@sticode$$$'+sticode+'@@@stiname$$$'+stiname+'@@@stiprice$$$'+stiprice+'@@@imglink$$$'+imglink+'###'+strData;
  $.cookie("i6_lastvisited_data",strData,{expires: 9999});
 // updateLastVisitedUI();

}

function updateLastVisitedUI(){
  var itemsCount = 0;
  var arryData = unescape($.cookie("i6_lastvisited_data")).split('###');
  
  if (unescape($.cookie("i6_lastvisited_data")).length<10)
  {
    return;
  }
  for(zz=0;zz<arryData.length;zz++)
  {
    if($.trim(arryData[zz]).length>0)
    {
      stiid = GetValueFromArray(arryData[zz],'stiid'); 
      if(stiid>0)
      {
        $("#lastvisiteddettable").append("<tr id='lastinv"+stiid+"' class='item'><td class='left'><input type='hidden' name='stiid' value='"+stiid+"'/></td><td class='img'><img src='"+GetValueFromArray(arryData[zz],'imglink')+"'/></td><td class='code'>"+GetValueFromArray(arryData[zz],'sticode')+"</td><td class='name'><a href='"+GetValueFromArray(arryData[zz],'link')+"'>"+GetValueFromArray(arryData[zz],'stiname')+"</a></td><td class='prc wvat'>"+GetValueFromArray(arryData[zz],'stiprice')+"</td><td class='right'>&#160;</td></tr>");
        itemsCount++;
      }
    }
  }
  
  $("#lastvisiteddettable tr:even").addClass("color_row");
}

function removeFavour(stiid){
$.ajax({
  url: "default_jx.asp?cls=iisutil&stiid="+stiid+"&action=StiFavourites&method=del&redirect="+escape('empty.html?'),
  cache: false,
  success: function(html){
    $("#favourcont .favourdetails .in").html(html);
    $("#favourcont .favourcount").html($("#favourcont .favourdetails .stitab tr").size()-1);
    //$("#favourcont .favourdetails .in").html($("#favourcont .favourdetails .in .stitab").html())
  }
});
openPopup('','<p>'+GetLng("lngprodremoved")+'</p>',0,'isfavourrem',false);
updateFavourUI();
}

function stiqtyPrewievInit(tabId){	
	/* CONFIG */
		xOffset = 10;
		yOffset = 20;		
/* --------- */

  var jxCall
  var Timer
  
	$(tabId+" .stiqtyinet").hover(function(e){
		//this.t = $(this).find("img").attr("title");
    var stiid = $(this).attr("rel");
    
    $(this).find("*").attr("title","");
    Timer = setTimeout(function(){
    
                jxCall = $.ajax({
                    url:'default_jx.asp?cls=stoitem&stiid='+ stiid +'&xsl=xstoitem_jx',
                    cache: false,
                    success: function(html){
                            $("body").append("<div id='stiqtypreview'><div class='outer'><div class='inner'><p>" +html+ "</p></div></div></div>");								 
                        		$("#stiqtypreview")
                        			.css("top",(e.pageY - xOffset) + "px")
                        			.css("left",(e.pageX + yOffset) + "px")
                        			.fadeIn("fast");		
                    }
                  });
                },700);			
    },
	function(){
		//$(this).find("img").attr("title",this.t);
    
    if(Timer) {
        clearTimeout(Timer);
        timer = null;
      }

    if(jxCall)
    jxCall.abort();	
		
    $("#stiqtypreview").remove();
    });	
    
    
	$(tabId+" .stiqtyinet").mousemove(function(e){
		$("#stiqtypreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
  
		
};

function startExecTimer(){

  execcTime = null;

  execcTime = new Date().getTime();

}

function stopExecTimer(){

  var stopTime = new Date().getTime();

  var totalTime = Number(stopTime) - Number(execcTime);

  //alert('start: '+execcTime+';end time: '+stopTime+';Execution time: '+totalTime+' ms');
  alert('Execution time: '+totalTime+' ms');
  
  return totalTime;
}

function getExecTime(f){
  startExecTimer();
  eval(f);
  stopExecTimer();

}

function HtmlDecode(s)
{
      var out = "";
      if (s==null) return;
      var l = s.length;
      
      for (var i=0; i<l; i++)
      {
      var ch = s.charAt(i);
            if (ch == '&')
            {
                  var semicolonIndex = s.indexOf(';', i+1);

            if (semicolonIndex > 0)
            {
                        var entity = s.substring(i + 1, semicolonIndex);
                        if (entity.length > 1 && entity.charAt(0) == '#')
                        {
                              if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X')
                                    ch = String.fromCharCode(eval('0'+entity.substring(1)));
                              else
                                    ch = String.fromCharCode(eval(entity.substring(1)));
                        }
                    else
                      {
                              switch (entity)
                              {
                                    case 'quot': ch = String.fromCharCode(0x0022); break;
                                    case 'amp': ch = String.fromCharCode(0x0026); break;
                                    case 'lt': ch = String.fromCharCode(0x003c); break;
                                    case 'gt': ch = String.fromCharCode(0x003e); break;
                                    case 'nbsp': ch = String.fromCharCode(0x00a0); break;
                                    case 'iexcl': ch = String.fromCharCode(0x00a1); break;
                                    case 'cent': ch = String.fromCharCode(0x00a2); break;
                                    case 'pound': ch = String.fromCharCode(0x00a3); break;
                                    case 'curren': ch = String.fromCharCode(0x00a4); break;
                                    case 'yen': ch = String.fromCharCode(0x00a5); break;
                                    case 'brvbar': ch = String.fromCharCode(0x00a6); break;
                                    case 'sect': ch = String.fromCharCode(0x00a7); break;
                                    case 'uml': ch = String.fromCharCode(0x00a8); break;
                                    case 'copy': ch = String.fromCharCode(0x00a9); break;
                                    case 'ordf': ch = String.fromCharCode(0x00aa); break;
                                    case 'laquo': ch = String.fromCharCode(0x00ab); break;
                                    case 'not': ch = String.fromCharCode(0x00ac); break;
                                    case 'shy': ch = String.fromCharCode(0x00ad); break;
                                    case 'reg': ch = String.fromCharCode(0x00ae); break;
                                    case 'macr': ch = String.fromCharCode(0x00af); break;
                                    case 'deg': ch = String.fromCharCode(0x00b0); break;
                                    case 'plusmn': ch = String.fromCharCode(0x00b1); break;
                                    case 'sup2': ch = String.fromCharCode(0x00b2); break;
                                    case 'sup3': ch = String.fromCharCode(0x00b3); break;
                                    case 'acute': ch = String.fromCharCode(0x00b4); break;
                                    case 'micro': ch = String.fromCharCode(0x00b5); break;
                                    case 'para': ch = String.fromCharCode(0x00b6); break;
                                    case 'middot': ch = String.fromCharCode(0x00b7); break;
                                    case 'cedil': ch = String.fromCharCode(0x00b8); break;
                                    case 'sup1': ch = String.fromCharCode(0x00b9); break;
                                    case 'ordm': ch = String.fromCharCode(0x00ba); break;
                                    case 'raquo': ch = String.fromCharCode(0x00bb); break;
                                    case 'frac14': ch = String.fromCharCode(0x00bc); break;
                                    case 'frac12': ch = String.fromCharCode(0x00bd); break;
                                    case 'frac34': ch = String.fromCharCode(0x00be); break;
                                    case 'iquest': ch = String.fromCharCode(0x00bf); break;
                                    case 'Agrave': ch = String.fromCharCode(0x00c0); break;
                                    case 'Aacute': ch = String.fromCharCode(0x00c1); break;
                                    case 'Acirc': ch = String.fromCharCode(0x00c2); break;
                                    case 'Atilde': ch = String.fromCharCode(0x00c3); break;
                                    case 'Auml': ch = String.fromCharCode(0x00c4); break;
                                    case 'Aring': ch = String.fromCharCode(0x00c5); break;
                                    case 'AElig': ch = String.fromCharCode(0x00c6); break;
                                    case 'Ccedil': ch = String.fromCharCode(0x00c7); break;
                                    case 'Egrave': ch = String.fromCharCode(0x00c8); break;
                                    case 'Eacute': ch = String.fromCharCode(0x00c9); break;
                                    case 'Ecirc': ch = String.fromCharCode(0x00ca); break;
                                    case 'Euml': ch = String.fromCharCode(0x00cb); break;
                                    case 'Igrave': ch = String.fromCharCode(0x00cc); break;
                                    case 'Iacute': ch = String.fromCharCode(0x00cd); break;
                                    case 'Icirc': ch = String.fromCharCode(0x00ce ); break;
                                    case 'Iuml': ch = String.fromCharCode(0x00cf); break;
                                    case 'ETH': ch = String.fromCharCode(0x00d0); break;
                                    case 'Ntilde': ch = String.fromCharCode(0x00d1); break;
                                    case 'Ograve': ch = String.fromCharCode(0x00d2); break;
                                    case 'Oacute': ch = String.fromCharCode(0x00d3); break;
                                    case 'Ocirc': ch = String.fromCharCode(0x00d4); break;
                                    case 'Otilde': ch = String.fromCharCode(0x00d5); break;
                                    case 'Ouml': ch = String.fromCharCode(0x00d6); break;
                                    case 'times': ch = String.fromCharCode(0x00d7); break;
                                    case 'Oslash': ch = String.fromCharCode(0x00d8); break;
                                    case 'Ugrave': ch = String.fromCharCode(0x00d9); break;
                                    case 'Uacute': ch = String.fromCharCode(0x00da); break;
                                    case 'Ucirc': ch = String.fromCharCode(0x00db); break;
                                    case 'Uuml': ch = String.fromCharCode(0x00dc); break;
                                    case 'Yacute': ch = String.fromCharCode(0x00dd); break;
                                    case 'THORN': ch = String.fromCharCode(0x00de); break;
                                    case 'szlig': ch = String.fromCharCode(0x00df); break;
                                    case 'agrave': ch = String.fromCharCode(0x00e0); break;
                                    case 'aacute': ch = String.fromCharCode(0x00e1); break;
                                    case 'acirc': ch = String.fromCharCode(0x00e2); break;
                                    case 'atilde': ch = String.fromCharCode(0x00e3); break;
                                    case 'auml': ch = String.fromCharCode(0x00e4); break;
                                    case 'aring': ch = String.fromCharCode(0x00e5); break;
                                    case 'aelig': ch = String.fromCharCode(0x00e6); break;
                                    case 'ccedil': ch = String.fromCharCode(0x00e7); break;
                                    case 'egrave': ch = String.fromCharCode(0x00e8); break;
                                    case 'eacute': ch = String.fromCharCode(0x00e9); break;
                                    case 'ecirc': ch = String.fromCharCode(0x00ea); break;
                                    case 'euml': ch = String.fromCharCode(0x00eb); break;
                                    case 'igrave': ch = String.fromCharCode(0x00ec); break;
                                    case 'iacute': ch = String.fromCharCode(0x00ed); break;
                                    case 'icirc': ch = String.fromCharCode(0x00ee); break;
                                    case 'iuml': ch = String.fromCharCode(0x00ef); break;
                                    case 'eth': ch = String.fromCharCode(0x00f0); break;
                                    case 'ntilde': ch = String.fromCharCode(0x00f1); break;
                                    case 'ograve': ch = String.fromCharCode(0x00f2); break;
                                    case 'oacute': ch = String.fromCharCode(0x00f3); break;
                                    case 'ocirc': ch = String.fromCharCode(0x00f4); break;
                                    case 'otilde': ch = String.fromCharCode(0x00f5); break;
                                    case 'ouml': ch = String.fromCharCode(0x00f6); break;
                                    case 'divide': ch = String.fromCharCode(0x00f7); break;
                                    case 'oslash': ch = String.fromCharCode(0x00f8); break;
                                    case 'ugrave': ch = String.fromCharCode(0x00f9); break;
                                    case 'uacute': ch = String.fromCharCode(0x00fa); break;
                                    case 'ucirc': ch = String.fromCharCode(0x00fb); break;
                                    case 'uuml': ch = String.fromCharCode(0x00fc); break;
                                    case 'yacute': ch = String.fromCharCode(0x00fd); break;
                                    case 'thorn': ch = String.fromCharCode(0x00fe); break;
                                    case 'yuml': ch = String.fromCharCode(0x00ff); break;
                                    case 'OElig': ch = String.fromCharCode(0x0152); break;
                                    case 'oelig': ch = String.fromCharCode(0x0153); break;
                                    case 'Scaron': ch = String.fromCharCode(0x0160); break;
                                    case 'scaron': ch = String.fromCharCode(0x0161); break;
                                    case 'Yuml': ch = String.fromCharCode(0x0178); break;
                                    case 'fnof': ch = String.fromCharCode(0x0192); break;
                                    case 'circ': ch = String.fromCharCode(0x02c6); break;
                                    case 'tilde': ch = String.fromCharCode(0x02dc); break;
                                    case 'Alpha': ch = String.fromCharCode(0x0391); break;
                                    case 'Beta': ch = String.fromCharCode(0x0392); break;
                                    case 'Gamma': ch = String.fromCharCode(0x0393); break;
                                    case 'Delta': ch = String.fromCharCode(0x0394); break;
                                    case 'Epsilon': ch = String.fromCharCode(0x0395); break;
                                    case 'Zeta': ch = String.fromCharCode(0x0396); break;
                                    case 'Eta': ch = String.fromCharCode(0x0397); break;
                                    case 'Theta': ch = String.fromCharCode(0x0398); break;
                                    case 'Iota': ch = String.fromCharCode(0x0399); break;
                                    case 'Kappa': ch = String.fromCharCode(0x039a); break;
                                    case 'Lambda': ch = String.fromCharCode(0x039b); break;
                                    case 'Mu': ch = String.fromCharCode(0x039c); break;
                                    case 'Nu': ch = String.fromCharCode(0x039d); break;
                                    case 'Xi': ch = String.fromCharCode(0x039e); break;
                                    case 'Omicron': ch = String.fromCharCode(0x039f); break;
                                    case 'Pi': ch = String.fromCharCode(0x03a0); break;
                                    case ' Rho ': ch = String.fromCharCode(0x03a1); break;
                                    case 'Sigma': ch = String.fromCharCode(0x03a3); break;
                                    case 'Tau': ch = String.fromCharCode(0x03a4); break;
                                    case 'Upsilon': ch = String.fromCharCode(0x03a5); break;
                                    case 'Phi': ch = String.fromCharCode(0x03a6); break;
                                    case 'Chi': ch = String.fromCharCode(0x03a7); break;
                                    case 'Psi': ch = String.fromCharCode(0x03a8); break;
                                    case 'Omega': ch = String.fromCharCode(0x03a9); break;
                                    case 'alpha': ch = String.fromCharCode(0x03b1); break;
                                    case 'beta': ch = String.fromCharCode(0x03b2); break;
                                    case 'gamma': ch = String.fromCharCode(0x03b3); break;
                                    case 'delta': ch = String.fromCharCode(0x03b4); break;
                                    case 'epsilon': ch = String.fromCharCode(0x03b5); break;
                                    case 'zeta': ch = String.fromCharCode(0x03b6); break;
                                    case 'eta': ch = String.fromCharCode(0x03b7); break;
                                    case 'theta': ch = String.fromCharCode(0x03b8); break;
                                    case 'iota': ch = String.fromCharCode(0x03b9); break;
                                    case 'kappa': ch = String.fromCharCode(0x03ba); break;
                                    case 'lambda': ch = String.fromCharCode(0x03bb); break;
                                    case 'mu': ch = String.fromCharCode(0x03bc); break;
                                    case 'nu': ch = String.fromCharCode(0x03bd); break;
                                    case 'xi': ch = String.fromCharCode(0x03be); break;
                                    case 'omicron': ch = String.fromCharCode(0x03bf); break;
                                    case 'pi': ch = String.fromCharCode(0x03c0); break;
                                    case 'rho': ch = String.fromCharCode(0x03c1); break;
                                    case 'sigmaf': ch = String.fromCharCode(0x03c2); break;
                                    case 'sigma': ch = String.fromCharCode(0x03c3); break;
                                    case 'tau': ch = String.fromCharCode(0x03c4); break;
                                    case 'upsilon': ch = String.fromCharCode(0x03c5); break;
                                    case 'phi': ch = String.fromCharCode(0x03c6); break;
                                    case 'chi': ch = String.fromCharCode(0x03c7); break;
                                    case 'psi': ch = String.fromCharCode(0x03c8); break;
                                    case 'omega': ch = String.fromCharCode(0x03c9); break;
                                    case 'thetasym': ch = String.fromCharCode(0x03d1); break;
                                    case 'upsih': ch = String.fromCharCode(0x03d2); break;
                                    case 'piv': ch = String.fromCharCode(0x03d6); break;
                                    case 'ensp': ch = String.fromCharCode(0x2002); break;
                                    case 'emsp': ch = String.fromCharCode(0x2003); break;
                                    case 'thinsp': ch = String.fromCharCode(0x2009); break;
                                    case 'zwnj': ch = String.fromCharCode(0x200c); break;
                                    case 'zwj': ch = String.fromCharCode(0x200d); break;
                                    case 'lrm': ch = String.fromCharCode(0x200e); break;
                                    case 'rlm': ch = String.fromCharCode(0x200f); break;
                                    case 'ndash': ch = String.fromCharCode(0x2013); break;
                                    case 'mdash': ch = String.fromCharCode(0x2014); break;
                                    case 'lsquo': ch = String.fromCharCode(0x2018); break;
                                    case 'rsquo': ch = String.fromCharCode(0x2019); break;
                                    case 'sbquo': ch = String.fromCharCode(0x201a); break;
                                    case 'ldquo': ch = String.fromCharCode(0x201c); break;
                                    case 'rdquo': ch = String.fromCharCode(0x201d); break;
                                    case 'bdquo': ch = String.fromCharCode(0x201e); break;
                                    case 'dagger': ch = String.fromCharCode(0x2020); break;
                                    case 'Dagger': ch = String.fromCharCode(0x2021); break;
                                    case 'bull': ch = String.fromCharCode(0x2022); break;
                                    case 'hellip': ch = String.fromCharCode(0x2026); break;
                                    case 'permil': ch = String.fromCharCode(0x2030); break;
                                    case 'prime': ch = String.fromCharCode(0x2032); break;
                                    case 'Prime': ch = String.fromCharCode(0x2033); break;
                                    case 'lsaquo': ch = String.fromCharCode(0x2039); break;
                                    case 'rsaquo': ch = String.fromCharCode(0x203a); break;
                                    case 'oline': ch = String.fromCharCode(0x203e); break;
                                    case 'frasl': ch = String.fromCharCode(0x2044); break;
                                    case 'euro': ch = String.fromCharCode(0x20ac); break;
                                    case 'image': ch = String.fromCharCode(0x2111); break;
                                    case 'weierp': ch = String.fromCharCode(0x2118); break;
                                    case 'real': ch = String.fromCharCode(0x211c); break;
                                    case 'trade': ch = String.fromCharCode(0x2122); break;
                                    case 'alefsym': ch = String.fromCharCode(0x2135); break;
                                    case 'larr': ch = String.fromCharCode(0x2190); break;
                                    case 'uarr': ch = String.fromCharCode(0x2191); break;
                                    case 'rarr': ch = String.fromCharCode(0x2192); break;
                                    case 'darr': ch = String.fromCharCode(0x2193); break;
                                    case 'harr': ch = String.fromCharCode(0x2194); break;
                                    case 'crarr': ch = String.fromCharCode(0x21b5); break;
                                    case 'lArr': ch = String.fromCharCode(0x21d0); break;
                                    case 'uArr': ch = String.fromCharCode(0x21d1); break;
                                    case 'rArr': ch = String.fromCharCode(0x21d2); break;
                                    case 'dArr': ch = String.fromCharCode(0x21d3); break;
                                    case 'hArr': ch = String.fromCharCode(0x21d4); break;
                                    case 'forall': ch = String.fromCharCode(0x2200); break;
                                    case 'part': ch = String.fromCharCode(0x2202); break;
                                    case 'exist': ch = String.fromCharCode(0x2203); break;
                                    case 'empty': ch = String.fromCharCode(0x2205); break;
                                    case 'nabla': ch = String.fromCharCode(0x2207); break;
                                    case 'isin': ch = String.fromCharCode(0x2208); break;
                                    case 'notin': ch = String.fromCharCode(0x2209); break;
                                    case 'ni': ch = String.fromCharCode(0x220b); break;
                                    case 'prod': ch = String.fromCharCode(0x220f); break;
                                    case 'sum': ch = String.fromCharCode(0x2211); break;
                                    case 'minus': ch = String.fromCharCode(0x2212); break;
                                    case 'lowast': ch = String.fromCharCode(0x2217); break;
                                    case 'radic': ch = String.fromCharCode(0x221a); break;
                                    case 'prop': ch = String.fromCharCode(0x221d); break;
                                    case 'infin': ch = String.fromCharCode(0x221e); break;
                                    case 'ang': ch = String.fromCharCode(0x2220); break;
                                    case 'and': ch = String.fromCharCode(0x2227); break;
                                    case 'or': ch = String.fromCharCode(0x2228); break;
                                    case 'cap': ch = String.fromCharCode(0x2229); break;
                                    case 'cup': ch = String.fromCharCode(0x222a); break;
                                    case 'int': ch = String.fromCharCode(0x222b); break;
                                    case 'there4': ch = String.fromCharCode(0x2234); break;
                                    case 'sim': ch = String.fromCharCode(0x223c); break;
                                    case 'cong': ch = String.fromCharCode(0x2245); break;
                                    case 'asymp': ch = String.fromCharCode(0x2248); break;
                                    case 'ne': ch = String.fromCharCode(0x2260); break;
                                    case 'equiv': ch = String.fromCharCode(0x2261); break;
                                    case 'le': ch = String.fromCharCode(0x2264); break;
                                    case 'ge': ch = String.fromCharCode(0x2265); break;
                                    case 'sub': ch = String.fromCharCode(0x2282); break;
                                    case 'sup': ch = String.fromCharCode(0x2283); break;
                                    case 'nsub': ch = String.fromCharCode(0x2284); break;
                                    case 'sube': ch = String.fromCharCode(0x2286); break;
                                    case 'supe': ch = String.fromCharCode(0x2287); break;
                                    case 'oplus': ch = String.fromCharCode(0x2295); break;
                                    case 'otimes': ch = String.fromCharCode(0x2297); break;
                                    case 'perp': ch = String.fromCharCode(0x22a5); break;
                                    case 'sdot': ch = String.fromCharCode(0x22c5); break;
                                    case 'lceil': ch = String.fromCharCode(0x2308); break;
                                    case 'rceil': ch = String.fromCharCode(0x2309); break;
                                    case 'lfloor': ch = String.fromCharCode(0x230a); break;
                                    case 'rfloor': ch = String.fromCharCode(0x230b); break;
                                    case 'lang': ch = String.fromCharCode(0x2329); break;
                                    case 'rang': ch = String.fromCharCode(0x232a); break;
                                    case 'loz': ch = String.fromCharCode(0x25ca); break;
                                    case 'spades': ch = String.fromCharCode(0x2660); break;
                                    case 'clubs': ch = String.fromCharCode(0x2663); break;
                                    case 'hearts': ch = String.fromCharCode(0x2665); break;
                                    case 'diams': ch = String.fromCharCode(0x2666); break;
                                    default: ch = ''; break;
                              }
                        }
                        i = semicolonIndex;
                  }
            }    
            out += ch;
      }
      return out;
}

function HtmlQuickDecode(s)
{
 //     alert(s.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"'));

     return s.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&amp;/g,'&');

}

function utf8_encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	}

/*----------------------------------------------------------*/
/* Memo form  - pokud form ma class 'memoForm' hodnoty jeho prvku jsou zalohovany do cookie*/
var memoCookiePrefix = 'I6_frmmem_';
var spch = '$$';
var eqch = '##';

function initMemoForms(){

  var frmelm

  var formColl = document.forms;

  if(formColl && formColl != null && formColl.length )
  {
    for (z=0;z<formColl.length ;z++)
      {
        if(formColl[z].className.toString().indexOf("memoform")>-1)
          {
            fillMemoForm(formColl[z].name);
            
            frmelm = formColl[z].elements;
            for(iii=0;iii<frmelm.length;iii++)
            {
              if(frmelm[iii].type!='hidden')
                {
                  frmelm[iii].onchange= function (e) {var e=window.event || e; memoFormChanged(e);};
                }
            }
          }
      }
  }
  
}

function fillMemoForm(objFormName){
  /*naplni inputy s cookiny*/
  var objForm
  var inpName
  var inpValue  
  var arrInp
  
  //alert('fillmemoform...'+objForm.name);
  objForm = document.forms[objFormName];
  
  var cookieString = unescape(get_cookie(memoCookiePrefix+objFormName));
  arrInp = cookieString.split(spch);
  
  if(cookieString == null || cookieString=='')
  return;
  
  //alert('filling form...  InCookie:s'+cookieString+'e');
  
  if(!arrInp || arrInp == null)
    return;
   
    
  for(ii=0;ii<arrInp.length;ii++)
  {
    if(arrInp[ii].split(eqch) == null || arrInp[ii].split(eqch).length !=2 )
      return;
  
    //alert('inpstring:'+arrInp[ii]+';');
    //alert('name:'+arrInp[ii].split(eqch)[0]+';value:'+arrInp[ii].split(eqch)[1]+';');
  
    inpName = arrInp[ii].split(eqch)[0];
    inpValue = arrInp[ii].split(eqch)[1];
    
    //alert('next input named: '+inpName)
    //alert(objForm.elements[inpName]);
    
    if((objForm.elements[inpName] && (objForm.elements[inpName].type== 'text' || objForm.elements[inpName].type== 'textarea')) && inpValue.length >0)
      {
      if(objForm.elements[inpName] && objForm.elements[inpName] != null)
        {
          if(!objForm.elements[inpName].value || objForm.elements[inpName].value =='' || objForm.elements[inpName].value ==null)
              {
                objForm.elements[inpName].value = inpValue;   
              }
        }
        
      } 
  }
  return;
}

function memoFormChanged(e){
  //alert('memo form changed...!');
  var contName = '';
  var objForm,objInput  
  var cookieString = '';
  var arr
 
 objInput = e.currentTarget || e.srcElement
 if(!objInput || objInput == null)
  return;
  
  objForm = objInput.form
 if(!objForm || objForm == null)
  return;
  
  /* vyhodim oktualni hodnotu inputu z cookiny*/ 
  cookieString = unescape(get_cookie(memoCookiePrefix+objForm.name));
  arr = cookieString.split(spch)
  cookieString = '';  
  if(!arr || arr == null)
    return;
  
  for(ii=0;ii<arr.length;ii++)
    {
      if(!arr[ii].match(objInput.name) && arr[ii].length >0)   
         {
            if(cookieString.length >0)
              cookieString = cookieString +spch+ arr[ii];
            else
              cookieString = arr[ii];
         }
    }
  
  /*pridam novou hodnotu do cookiny*/
  if(cookieString.length >0)
    cookieString = cookieString + spch +objInput.name+eqch+objInput.value;  
  else
    cookieString = objInput.name+eqch+objInput.value;
    
  set_cookie(memoCookiePrefix+objForm.name,cookieString,10000);

}

function fireEventOnChange(objToFire)
{

//On IE
if(objToFire.fireEvent)
{
  objToFire.fireEvent('onchange');
}
//On Gecko based browsers
if(document.createEvent)
{
var evt = document.createEvent('HTMLEvents');
if(evt.initEvent)
{
evt.initEvent('change', true, true);
}
if(objToFire.dispatchEvent)
{
objToFire.dispatchEvent(evt);
}

}
} 

/* end of  Memo form */

function delivPayStoreUpdateUI()
{
  /*-----------inicializace---------------*/
  if ($(".deliverydiv input[rel]").length==0)//pokud nejsou vyplneny zadne vazby v rel skoncim
    {return;}
  //zrusim starou funkcnost (vyber typu dobirka/ostatni)
  $(".deliverydiv input").attr("onclick","");
  $("#PayWayDiv").attr("style","");
  $("#PayWayDiv .rowbox").attr("style","");
  
  //nastavim hodnoty dle predvyplnenych hodnot
  changeDeliveryStates($("select[name='ordxqudid']"));
  if($(".deliverydiv input:checked").length>0)
    {
      changePaymentStates($(".deliverydiv input:checked"));
    }
  
  $("#PayWayDiv input").click(function(){
      //alert('Pay changed');
  });
  
  $(".deliverydiv input").click(function(){
      changePaymentStates($(this));
  });
  
    $("select[name='ordxqudid']").change(function(){
      changeDeliveryStates($(this));
  });
  
}


function changeDeliveryStates(sel){
 //pouziva specialni forma {pp,pp,pp,pp,pp; ss ss ss ss } kde pp jsou id doprav a ss jsou id skladu
 
 if($(".deliverydiv input[rel~="+sel.val()+"]").length>0)
    {
      $(".deliverydiv input").parent().removeClass("ds_block").addClass("ds_none");
      $(".deliverydiv input[rel~="+sel.val()+"]").parent().removeClass("ds_none").addClass("ds_block");
    }  
 else
    $(".deliverydiv input").parent().removeClass("ds_none").addClass("ds_block");   
}

function changePaymentStates(inp){
  
  var arrPayStore,arrPay,arrStore
  if(inp.attr("rel"))
    arrPayStore = inp.attr("rel").split(";");
  else
    arrPayStore ="";
  arrPay = arrPayStore[0].split(",");
  if(arrPayStore[1])
  arrStore = arrPayStore[1].split(" ");
  
  $("#PayWayDiv input").parent().addClass("ds_none").removeClass("ds_block");
  
  
  if(arrPay.length>0 && $.trim(arrPay[0])!="")
    for(ii=0;arrPay.length>ii;ii++)
    {  
      $("#payid_"+$.trim(arrPay[ii])).parent().removeClass("ds_none").addClass("ds_block");
    }
  else
  {
    $("#PayWayDiv input").parent().removeClass("ds_none").addClass("ds_block");
  }  
  
  if($("#PayWayDiv .rowbox.ds_block input:checked").length == 0)
    $("#PayWayDiv input").attr("checked","");
  
}
function initLogOnCont(userName,usrPass){
  $(document).ready(function(){
    if($("form[name='login'] input[type='text']").length>0 && $("form[name='login'] input[type='text']").val().length<2)
      {
        $("form[name='login'] input[type='text']").val(userName);
        $("form[name='login'] input[type='password']").val(usrPass);
      } 
  });     
}

function validateURL(sUrl)
{
  lengthValue = $.trim(sUrl);
  lengthValue = lengthValue.length;
    if(lengthValue != 0)
    {
      var j = new RegExp();
      j.compile("^[A-Za-z]+://[A-Za-z0-9-]+\.[A-Za-z0-9]+");
      lengthValue = $.trim(sUrl);
        if (!j.test(lengthValue))
        {
          return false;
        }
      return true;
    }
  return false;
}

function initStatusFilterAsForm(){
  $("form[name=stistssrch] input").attr("checked","");
  $("form[name=stistssrch]").deserialize(document.location.href);
  
  updateStiStatusFilterUI();
  $("#stistssrch input").change(function(){updateStiStatusFilterUI();document.location.href="default.asp?"+$("#productlistjx").attr("rel").replace(/&status=[0-9]+/g,"").replace(/&status=/g,"")+"&"+$("form[name=stistssrch]").serialize()});
   $("#stistssrch .allprod input").unbind('change').change(function(){document.location.href="default.asp?"+$("#productlistjx").attr("rel").replace(/&status=[0-9]/g,"")+"&status="});
}

function rwn5carousel_initCallback(carousel)
{
   // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

 carousel.container.append("<div class='jcarousel-control jcarousel-control-paging'><div class='outer'><div class='inner'></div></div></div>");
  
  for(ii = 0;ii < carousel.container.find("li").length;ii++)
  {
     var classname = "page"+(ii+1);
     if(ii == 0)
     {classname += " first";}
     else if(Number(carousel.container.find("li").length) < (ii+2))
     {classname += " last";}
     carousel.container.find(".jcarousel-control-paging .inner").append('<span class="'+classname+'"><a href="#">'+(ii+1)+'</a></span>');
  }
  carousel.container.find('.jcarousel-control-paging a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

}

function rwn5carousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
   carousel.container.find(".jcarousel-control-paging span.active").removeClass("active");
  carousel.container.find(".jcarousel-control-paging .page"+i).addClass("active");
};


function initWn5ProdCarusel(){

 $('#webnews .wn5 ul').jcarousel({
          scroll:1,
          auto: 5,
          wrap: 'last',
          initCallback: rwn5carousel_initCallback ,
          itemVisibleInCallback: {onBeforeAnimation: rwn5carousel_itemVisibleInCallback}
  });
 
}
