
function myScope(func,obj,args) {
	return function() {
		obj.args = args;
		return func.apply(obj,arguments);
	};
};

Date.prototype.format=function(format){var returnStr='';var replace=Date.replaceChars;for(var i=0;i<format.length;i++){var curChar=format.charAt(i);if(replace[curChar]){returnStr+=replace[curChar].call(this);}else{returnStr+=curChar;}}return returnStr;};Date.replaceChars={shortMonths:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],longMonths:['January','February','March','April','May','June','July','August','September','October','November','December'],shortDays:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],longDays:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d:function(){return(this.getDate()<10?'0':'')+this.getDate();},D:function(){return Date.replaceChars.shortDays[this.getDay()];},j:function(){return this.getDate();},l:function(){return Date.replaceChars.longDays[this.getDay()];},N:function(){return this.getDay()+1;},S:function(){return(this.getDate()%10==1&&this.getDate()!=11?'st':(this.getDate()%10==2&&this.getDate()!=12?'nd':(this.getDate()%10==3&&this.getDate()!=13?'rd':'th')));},w:function(){return this.getDay();},z:function(){return"Not Yet Supported";},W:function(){return"Not Yet Supported";},F:function(){return Date.replaceChars.longMonths[this.getMonth()];},m:function(){return(this.getMonth()<9?'0':'')+(this.getMonth()+1);},M:function(){return Date.replaceChars.shortMonths[this.getMonth()];},n:function(){return this.getMonth()+1;},t:function(){return"Not Yet Supported";},L:function(){return(((this.getFullYear()%4==0)&&(this.getFullYear()%100!=0))||(this.getFullYear()%400==0))?'1':'0';},o:function(){return"Not Supported";},Y:function(){return this.getFullYear();},y:function(){return(''+this.getFullYear()).substr(2);},a:function(){return this.getHours()<12?'am':'pm';},A:function(){return this.getHours()<12?'AM':'PM';},B:function(){return"Not Yet Supported";},g:function(){return this.getHours()%12||12;},G:function(){return this.getHours();},h:function(){return((this.getHours()%12||12)<10?'0':'')+(this.getHours()%12||12);},H:function(){return(this.getHours()<10?'0':'')+this.getHours();},i:function(){return(this.getMinutes()<10?'0':'')+this.getMinutes();},s:function(){return(this.getSeconds()<10?'0':'')+this.getSeconds();},e:function(){return"Not Yet Supported";},I:function(){return"Not Supported";},O:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()/60))+'00';},P:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()/60))+':'+(Math.abs(this.getTimezoneOffset()%60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()%60));},T:function(){var m=this.getMonth();this.setMonth(0);var result=this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/,'$1');this.setMonth(m);return result;},Z:function(){return-this.getTimezoneOffset()*60;},c:function(){return this.format("Y-m-d")+"T"+this.format("H:i:sP");},r:function(){return this.toString();},U:function(){return this.getTime()/1000;}};

function byteconvert(bytes) {
	var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
	var e = Math.floor(Math.log(bytes)/Math.log(1024));
	if (bytes > 0) {
		return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
	}
	return bytes +" "+s[0];
}

function getXY(oElement,reference) {
	var iReturnValue = { 'x': 0, 'y': 0 };
	while ((oElement != null) && (oElement != reference)) {
		iReturnValue.y += oElement.offsetTop;
		iReturnValue.x += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;

}

function getY(oElement,reference) {
	var iReturnValue = 0;
	while( oElement != null) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}

function getX(oElement,reference) {
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
var myURL = function(url) {
	
	this.url = ''+url;

	this.params = {};

	this.initQuery = function (all, name, value) {
		if (name) {
			this.params[name] = value;
		}
		return this;
	}

	this.setQuery = function (name, value) {
		if (name) {
			this.params[name] = value;
		}
		return this;
	}

	this.getQueryValue = function (name) {
		return this.params[name];
	}

	this.init = function() {
		//log.info(this.url);
		var reg1 = /(https?:\/\/)?([a-zA-Z0-9_\-\.]+)?(:[0-9]+)?\/?([^\?#]*)?(\?([^#]*)?)?(#(.*))?/;
		var result = this.url.match(reg1);
		this.scheme = result[1];
		this.host = result[2];
		this.port = result[3];
		this.path = result[4];
		this.query = result[6];
		this.hash = result[8];

		if (this.query) {
			var reg2 = /(?:^|&)([^&=]*)=?([^&]*)/g;
			var result = this.query.match(reg2);

			this.query.replace(reg2, myScope(this.initQuery,this));
		}
	}

	this.getScheme = function() {
		return ((this.scheme)?(this.scheme):(''));
	}

	this.getHost = function() {
		return ((this.host)?(this.host):(''));
	}

	this.getPort = function() {
		return ((this.port)?(':'+this.port):(''));
	}

	this.getPortValue = function() {
		return ((this.port)?(this.port):(''));
	}

	this.getPath = function() {
		return ((this.path)?('/'+this.path):(''));
	}

	this.getPathValue = function() {
		return ((this.path)?(this.path):(''));
	}

	this.addToString = function(k,v) {
		if (v !== false) { 
			this.queryString = ((this.queryString)?(this.queryString+'&'):('?')) + k + '=' +v;
		}
	}

	this.getQuery = function() {
		this.queryString = '';
		$.each(this.params,myScope(this.addToString,this));
		return this.queryString;
	}

	this.getHash = function() {
		return ((this.hash)?('#'+this.hash):(''));
	}

	this.getHashValue = function() {
		return ((this.hash)?(this.hash):(''));
	}

	this.getURL = function() {
		return this.getScheme() + this.getHost() + this.getPort() + this.getPath() + this.getQuery() + this.getHash();
	}

	this.init();
}


var eventArray = function(source,name) {

	this.source = source;
	this.name = name;
	this.size = 0;
	this.events = new Array();

	this.add = function(callback) {
		this.size++;
		this.events.push(callback);
		return true;
	}

	this.call = function() {
		var result = true;
		var index = 0;
		while ((result) && (this.size > index)) { 
			result = this.events[index](arguments);
			index++;
		}
		return result;
	}

	return this;
};

var log = false;
var logger = function() {

	this.last = '';
	this.span = false;
	this.count = 0;
	this.log = false; 
	this.make_log = false;
	//this.make_log = true;

	this.init = function() {
		if ($('#log').length == 0 && this.make_log) {
			$('head').append('<link rel="stylesheet" type="text/css" href="/js/jquery.utils.css" media="screen" />');
			$('body').append('<ul id="log"></ul>');
			this.log = $('#log').hide();
			//this.log.hide();
			this.log.dblclick(myScope(this.hide,this));
			//$(document).keypress(myScope(this.show,this));
		}
	}

	this.show = function(e) {
		/*
		if (e.keyCode == 112) {
			this.log.toggle();
			return false;
		}
		*/
		return true;
	}

	this.hide = function(e) {
		this.log.hide();
		return false;
	}

	this.error = function(message) {
		this.message(message,'error');
	}

	this.infoObjectItem = function(name,value) {
		log.info('+'+name + ':' + value);
	}

	this.infoObject = function(obj) {
		log.info('Object:');
		$.each(obj,myScope(this.infoObjectItem,this));
		return true;
	}

	this.info = function(message) {
		this.message(message,'info');
	}

	this.obj = function(obj,message) {
		this.message('[' + obj.name + ']: '+message,'info');
	}

	this.message = function(message,type) {
		if (this.log) {
			this.log.show();
			if ((message == this.last) && (this.span)) {
				this.count += 1;
				this.span.html(this.count+'x');
			} else {
				this.count = 1;
				this.log.prepend('<li class="'+type+'">'+message+'<span></span></li>');
				this.span = $('li:first span',this.log);
			}
			this.last = message;
		}
	}

	this.init();
};

var log = false;
$(document).ready(function() {
	log = new logger();
});

$.fn.settings = function() {

	this.idValues = {};
	this.objValues = {};

	this.add = function(idName,values) {
		if (typeof this.idValues[idName] == 'undefined') {
			this.idValues[idName] = {};
		}
		$.extend(this.idValues[idName],values);
	}

	this.addByObject = function(objName,values) {
		if (typeof this.objValues[objName] == 'undefined') {
			this.objValues[objName] = {};
		}
		
		$.extend(this.objValues[objName],values);
	}

	this.get = function(name) {
		if (this.values[name]) {
			return this.values[name];
		} 
		return false;
	}

	this.get = function(name) {
		if (typeof this.idValues[name] != 'undefined') {
			return this.idValues[name];
		} 
		return false;
	}

	this.getByObject = function(name) {
		if (typeof this.objValues[name] != 'undefined') {
			return this.objValues[name];
		} 
		return false;
	}
};

var settings = new $.fn['settings']();

$.fn.openers = function() {

	this.windows = new Array();

	this.open = function(obj,url,w,h,s) {
		var newWindow = window.open(url, s+"_jswin", "toolbar=no,width="+w+",height="+h+",scrollbars=yes,resizable=yes");
		this.windows.push({ 'caller': obj, 'window': newWindow });
		return newWindow;
	}

	this.call = function(w,func,data) {
		for (var i = 0; i < this.windows.length; i++) {
			if (this.windows[i]['window'] == w) {
				return this.windows[i]['caller'][func](data);
			}
		}
		return false;
		
	}

	this.close = function(obj) {
		for (var i = 0; i < this.windows.length; i++) {
			if (this.windows[i]['caller'] == obj) {
				this.windows[i]['window'].close();
				this.windows.splice(i,1);
				return true;
			}
		}
		return false;
		
	}
}

var openers = new $.fn['openers']();

$.fn.collection = function(name) {

	this.name = name;
	this.layers = new Array();

	this.add = function(layer) {
		this.layers.push(layer);
	}

	this.getValue = function(func) {
		for (var i = 0; i < this.layers.length; i++) {
			if (this.layers[i][func]()) {
				return true;
			}
		}
		return false;
	}

	this.setOnlyMe = function(layer,name_on,name_off) {
		var result = false;
		for (var i = 0; i < this.layers.length; i++) {
			if (this.layers[i] == layer) {
				result = this.layers[i][name_on]();
			} else {
				this.layers[i][name_off]();
			}
		}
		return result;
	}

	this.set = function(name,args) {
		for (var i = 0; i < this.layers.length; i++) {
			this.layers[i][name](args);
		}
	}
}

var changeItems = new $.fn['collection']('changeItems');
var bubbles = new $.fn['collection']('bubbles');

$.fn.load = function(name, callback) {
	if (!$.fn[name]) {
	}

	return false;
};

var loader = function(name,makers) {
	this.name = name;
	this.makers = makers;
	this.done = false;
	this.data = new Array();
	this.index = 0;

	this.loadDone = function() {
		this.done = true;
		this.call();
	};

	this.add = function(data) {
		this.data.push(data);
		if (this.done) {
			this.call();
		}
	}

	this.init = function() {
		log.info('Loading: /js/jquery.'+name+'.js');
		if (typeof $.fn[name] == 'undefined') {
			$.getScript('/js/jquery.'+name+'.js', myScope(this.loadDone,this));
		} else {
			this.loadDone();
		}
	};

	this.call = function() {
		var item = false;
		while (item = this.data.pop()) {
			this.create(this.index,item);
			this.index++;
		}
	}

	this.create = function(index,item) {
		var id = $(item.object).attr('id');
		if (typeof item.settings == 'undefined') {
			item.settings = {};
		}

		jQuery.extend(item.settings, settings.get(id));
		jQuery.extend(item.settings, settings.getByObject(this.name));

		if ($.fn[name]) {
			log.info('Create obj: ('+index+')' +name );
			var newObj = new $.fn[name](item.object,index,item.settings);
			if (typeof item.callback == 'function') {
				item.callback(newObj);
			}
			return true;
		}
		return false;
	}
	this.init();

	return this;
}

var makers = function() {
	
	this.names = new Array();

	this.add = function(name,data) {
		if (typeof this.names[name] == 'undefined') {
			var load = new loader(name,this);
			this.names[name] = load;
		}
		this.names[name].add(data);
	}

	return this;
}

var makers = new makers();

$.fn.make = function(name,settings,callback) {

	if (this.length == 0) { return false; }
	$.each(this,function(index,object) { makers.add(name, { 'object': object, 'settings': settings, 'callback': callback } ); });
	
	return this;
};

function make_calls(calls,local_settings,obj) {
	if (calls) {
		for (var i = 0; i < calls.length; i++) {
			//log.message(calls[i].selector + ': '+$(calls[i].selector,obj).length);
			//log.message(calls[i].name);
			$(calls[i].selector,obj).make(calls[i].name,local_settings); 
		}
	}
}

jQuery.fn.swap = function() {

	var a = this[0];
	var b = this[1];


	if (a && b) {
		var parentNode = b.parentNode;

		if (a.nextSibling == b) {
			parentNode.replaceChild(a,b);
			parentNode.insertBefore(b,a);
		} else {
			parentNode.replaceChild(b,a);
			parentNode.insertBefore(a,b);
		}
	}
 
	return this;
};

function openWindow(url,w,h) {
        window.open(url, "_tree", "toolbar=no,width="+w+",height="+h+",scrollbars=yes,resizable=yes");
};

function send_content(root_id, o) {
                var div = document.getElementById(o);
                if (div) {
                parent.recieve_content(root_id,div.innerHTML);
                }
};



function initData(context) {
	//$('body').make('bodyObject');
	//$('#head .dateTime').make('time');
	//$('#map').make('googleMap');
	//$('.printMe').make('myPrint');
	$('.saveMe').make('saveMe');
	$('.focusToggle').make('searchInput');
	//$('.bubble').make('bubble');
};

Array.prototype.sum = function() {
  return (! this.length) ? 0 : this.slice(1).sum() + ((typeof this[0] == 'number') ? this[0] : 0);
};

$(document).ready(function() {

	initData(document);
	
	$('.printMe').click(function () {
 		window.print();
    $('body').prepend( $('.printHead').remove() );
    $('.printHead').show();
	});
	
	//searchInput
	$('.focusToggle').each(function () {
		
		$(this).focus( function() {		
			if ( $(this).attr('title') == $(this).attr('value') ) {
	    	$(this).attr('value', '');
	  	}		
		});
		
		$(this).blur( function() {		
			if ( $(this).attr('value') == '' ) {
		  	$(this).attr('value', $(this).attr('title') );
			}		
		});
		
		if ( $(this).attr('value') == '' ) {
	  	$(this).attr('value', $(this).attr('title') );
		}
	});
	
	//vyhledávání - nezadán text
	$('#head .search form').submit(function () {
		if ( this.dialog == undefined ) {
			this.dialog = $('.message', this).dialog({
				modal: false,
			  title: 'Nevyplněné položky',
			  autoOpen: false,
			  resizable: false,
			  position: ['right','top'], 
			  buttons: {Ok: function() {$(this).dialog('close');}}
			});
		}		
		if( ($('input[type=text]', this).attr('value') == '') || ($('input[type=text]', this).attr('value') == $('input[type=text]', this).attr('title')) ) {				
			$(this.dialog).dialog('open');
			return false;
		}		
	});
	
	//bublina
	$('.bubble').each(function () {
		
		$('.bubble').hover(function(e) {
			e.preventDefault();
			if ( $(this).attr('title').length == 0 && $(this).next('.bubblePopUp').length == 0 && $('.bubblePopUp', this).length == 0 ) {
	    	return false;
	  	}
			if ( $(this).next('.bubblePopUp').length || $('.bubblePopUp', this).length) { 
				$(this).next('.bubblePopUp').show(0);
				$('.bubblePopUp', this).show(0);	    		    	
	  	}
			else {
				if ( ($.browser.msie) && ($.browser.version=="6.0" || $.browser.version=="7.0") ) {
					$(this).closest('div').css('z-index', '900').css('position', 'relative');
					$(this).closest('table').css('z-index', '900').css('position', 'relative');										
				}
				//$(this).after('<div class="bubblePopUp">'+ $(this).attr('title') +'</div>').show().css('z-index', '1600');
				$('div', this).append('<div class="bubblePopUp">'+ $(this).attr('title') +'</div>').show().css('z-index', '1600');
				$(this).removeAttr('title');
			}
		}, function (e) {
	 		$('.bubblePopUp').hide(0);
		});
		
	})
	
	//řazení, tabulka
	this.sorting = Number($('div.katalogTable table').attr('summary'));
	
	//řazení tabulky produktů
	if (this.sorting > 0) {
		$('div.katalogTable table').tablesorter({
			textExtraction: 'complex',
			sortList: [[this.sorting,0]]
		});
	}
	else {
   $('div.katalogTable table').tablesorter({
			textExtraction: 'complex'
		});
	}	
	$('.katalogTable table tr:odd').addClass('high2');
		
	
	//drobečkovka v detailu
	if ( $('#produktDetail h1').length ) {
		$('#navigace .clear').before( '<span>&gt;</span><a>'+ $('#produktDetail h1').html() +'</a>' );
	}
	
	//porovnání
	$('div.katalogTable').ready(function() {
		//check
		$('.check .all', this).click(function () {
    	$(this).closest('.katalogTable').find('input[type=checkbox]').attr('checked', true);
			$(this).closest('.katalogTable').find('input[type=checkbox]').parent().addClass('high');                           
    })
    $('.check .cnone', this).click(function () {
    	$(this).closest('.katalogTable').find('input[type=checkbox]').attr('checked', false);
			$(this).closest('.katalogTable').find('input[type=checkbox]').parent().removeClass('high');                           
    })
    $('.check .inv', this).click(function () {
    	$(this).closest('.katalogTable').find('input[type=checkbox]').each(function () {
      	$(this).attr('checked', $(this).attr('checked') == true ? false : true );
				if ( $(this).attr('checked') == true ) {
					$(this).parent().addClass('high');
				}
				else {
		      $(this).parent().removeClass('high');
		    }
    	});
			                           
    })
		
		//submit
		$('.katalogTable .infoBox').dialog({
			modal: false,
		  title: 'Nevyplněné položky',
		  autoOpen: false,
		  resizable: false,
		  buttons: {Ok: function() {$(this).dialog('close');}}
		});
		$('.katalogTable form').submit(function() {
			if( $('input[checked]', this).length == 0 ) {				
				$('.infoBox').dialog('open');
				return false;
			} 
		});
	});

	//detail produktu - galerie
	$('#produktDetail .gallery .thumbs a').click(function () {
		$(this).closest('.thumbs').prev('.big').find('img').attr('src', '/images/loading.gif');
		$(this).closest('.thumbs').prev('.big').find('img').attr('src', $(this).attr('href'));
		event.stopImmediatePropagation();
		return false;
	});
	$('#produktDetail .thumbs').resizable({minWidth:330,maxWidth:330,minHeight:75,containment: '#produktDetail'});//,maxWidth:308,grid:[95, 84]
	$('#produktDetail .params table tr:even').addClass('high');
	
	//galerie - lightbox
	$('a[rel=gallery]').lightbox();
	
	//newsletter
	$('form.newsletterAjax').submit( function() {
		$(this).append('<div class="loading"><div></div></div>');
		$.ajax({
			url: "/newsletter_main/",
			type: "GET",
			async: false, 
			data: {email: $('input[name=email]', this).attr('value')},
			cache: true,
			dataType: 'html',
			success: myScope(function(data) {
				$('input[name=email]', this).attr('value', '');
				$('.loading', this).remove();				
				$(this).prepend('<div class="message">'+data+'</div>');
				$('.message', this).click(function(){$(this).fadeOut(200);});				
			}, this)
		});
		return false;
	});
	
	//odeslani vyhledávaciho formulare
	$('div.katalogFiltr form').submit(function () {
		cnt = new Array();
		canPost = false;
		$('input[type=text], select', this).each(function () {
   		//parametry z propojovací tabulky
			if ( $(this).attr('value') != '' && $(this).attr('name').match(/^[a-z_]*\[([0-9]+)\]$/i) != null ) {
      	this.keyname = $(this).attr('name').replace(/^[a-z_]*\[([0-9]+)\]$/i,'$1');
      	cnt[this.keyname] = 1;
			}
			//statické parametry u produktu
			if ( $(this).attr('value') != '' && $(this).attr('name').match(/^[a-z_]*\[([0-9]+)\]$/i) == null ) {
				canPost = Number(canPost) + 1;
			}
		})
		//nastavení nezbytných hodnot formuláře
		$('input[name=cnt]', this).attr('value', cnt.sum() );
		$('input[name=trida_name]', this).attr('value', $('select[name=trida] option:selected', this).html() );
		$('input[name=vyrobce_name]', this).attr('value', $('select[name=vyrobce] option:selected', this).html() );
		//formulář nelze odeslat
		if (cnt.sum() == 0 && canPost == false) {
			$("#fdialog").dialog({
				modal: false,
			  title: 'Nevyplněné položky',
			  autoOpen: false,
			  resizable: false,
			  buttons: {
				  Ok: function() {
				  	$(this).dialog('close');
				  }
			  }
			});
			$("#fdialog").dialog('open');
			return false;
    }
	});
	
	//dohledání kategorie pomocí <select>ů
	$('div.katalogFiltr form .ajax select').live('change', function (event, param1) {
		
		this.actionToDo = $(this).closest('div.katalogFiltr').find('.action').attr('title');
		this.parentid = $('option:selected', this).attr('id').replace(new RegExp(this.actionToDo +'_'),'');
		
		if (param1 != 10) {
			$(this).closest('.katalogFiltr').append('<div class="loading"><div></div></div>');		
			
		}
		//poslední, určující informace o kategorii
		if ( $(this).attr('class') == 'last' ) {			
    	concatenated = '';
			$('select', $(this).closest('.katalogFiltr') ).each(function (i) {
      	//vytvori se url
				concatenated = concatenated +'/'+ $(this).attr('value');
				if ( $(this).attr('class') == 'last'  ) {
		      //akce - (přesměrovat na kat. nebo načíst odpovídající formulář)
					switch (this.actionToDo) {
						case 'redirKatalog': 
							window.location.href = '/' + $(this).closest('div.katalogFiltr').find('.katalogUrl').attr('title') + concatenated;
							return false;
							break;
						case 'loadFiltr':
							$.ajax({
								url: "/ajax/katalog/filtr-form/",
								type: "GET",
								async: false, 
								data: {q: this.parentid},
								cache: true,
								dataType: 'html',
								success: myScope(function(data) {
									$('.loading', $(this).closest('.katalogFiltr')).remove();
									$(this).closest('.katalogFiltr').find('.content').html(data);
									$(this).closest('.katalogFiltr').find('input[name=cat]').attr('value', this.parentid);
								}, this)
							});
							break;
					}
		    } 
      })   	
  	}		
		if (param1 != 10) {
			//načte obsah dalšího selectu
			$.ajax({
				url: "/ajax/katalog/kategorie-select/",
				type: "GET",
				async: false, 
				data: {q: this.parentid, action: this.actionToDo},
				cache: true,
				dataType: 'html',
				success: myScope(function(data) {				
					if (data == 'null') {
	      		$(this).addClass('last');
	      		$(this).trigger('change', 10);
	      		$(this).next().attr("disabled", true);
	    		}
	    		else {
	        	$(this).next().attr("disabled", false);
	        }
					$('.loading', $(this).closest('.katalogFiltr')).remove();
					
					$(this).next('select').html(data);
				}, this)
			});
		}
	});
	
	//hlavní menu - submenu
	$('#mainMenu ul li.hasChildren').hoverIntent(function() {
		
		if($.browser.msie && $.browser.version=="6.0") {
	    $('select').hide();
	  }
		
		if ($('.subMenu', this).length > 0) {
			$('.subMenu', this).slideDown(50);
		}
		else {
			$.ajax({
				url: "/ajax/submenu/",
				type: "GET",
				async: false, 
				data: "q="+ $('.idHolder', this).attr('title'),
				cache: true,
				dataType: 'html',
				success: myScope(function(data) {
					if (data != 'null') {						
						$(this).append(data).slideDown(50);
					}
				}, this)
			});
		}
	},
	function() {
		$('.subMenu', this).slideUp(200);
		if($.browser.msie && $.browser.version=="6.0") {
			$('select').show();
		}
	});	
	
	//externi odkaz
	$('a[rel=external]').attr('target', '_blank');
	
	//hp - subkategorie v katalogu
	$('#hpKategorie .subs a.ajax').live('click', function() {	
		$(this).parent().append('<div class="loading"></div>');
		$.ajax({
			url: '/ajax/katalog/kategorie/',
			method: 'POST',
			cache: true,
			async: false,
			dataType: 'html',
			data: {kategorie_id: $(this).attr('rel'), r: Math.floor(Math.random()*30)},
			success: myScope(function(data) {
        $(this).parent().html(data);
      }, this)
		});
		$('.loading', $(this).parent()).remove();
		return false;
	});
	//zpětné tlačítko tamtéž
	$('#hpKategorie .subs .back').live('click', function() {
		$(this).closest('.subs').html($(this).closest('.subs').next('.subs-prev').html());
	});
	
	//porovnání v katalogu - checkbox 
	$('.katalogTable table td a').click(function(e) {
		e.stopPropagation();
	});
	$('.katalogTable table td.check input').click(function(e) {
		e.stopPropagation();
		if ($(this).attr('checked') == true) {		
			$(this).parent().addClass('high');
		}
		else {	   
	    $(this).parent().removeClass('high');
	  }
	});
	$('.katalogTable table tr').click(function(e) {
		if ($('input[type=checkbox]', this).attr('checked') == true) {
			$('input', this).attr('checked', false);
			$('td.check', this).removeClass('high');
		}
		else {
	    $('input[type=checkbox]', this).attr('checked', true);
	    $('td.check', this).addClass('high');
	  }	  
	});
	
	//go back
	$('.takeMeBack').click(function () {
  	window.history.go(-1);                      
  });
	
	//porovnání produktů
	$('.compareTable table tr').hover(function() {
			$(this).addClass('high');
		},
		function() {
			$(this).removeClass('high');
		}	
	);
	
	//loga organizátorů - hover
	$('.sideOrganizer img').hover(
		function() {
			$(this).attr('src', $(this).attr('src').replace(/\.gif/,'h.gif'));
		},
		function () {
			$(this).attr('src', $(this).attr('src').replace(/h\.gif/,'.gif'));
		}
	);

	//taby v boxu x dole na stránce
	$('.tabsContainer h3 a').click(function() {
		this.container = $(this).closest('.tabsContainer');
		this.target = $(this).attr('href');
		$('h3.active', this.container).removeClass('active');
		$('div.content-active', this.container).removeClass('content-active');
		$('#'+ this.target, this.container).addClass('content-active');
		$(this).closest('h3').addClass('active');
		return false;
	});





	//animace log
	//jQuery.fx.off = true;
	/*
	aniHorizontal = function(offset, obj) {
		aniWidth = 0;
		$(obj).css('display', 'block');
		$('.item', obj).each(function() {aniWidth += $(this).width();});
		this.num = $('.item', obj).length;
		this.items = aniWidth + this.num * 20;
		this.width = offset == 0 ? $(obj).parent().width() : offset;
		this.time = this.num * 10000;		
		//.css('left', (this.items * (-1)) +'px')
		$(obj).css('width', this.items +'px').startAnimation({'left': this.width +'px'}, this.time, 'linear', function() {
			$(this).startAnimation({'left': ($(this).width() * (-1)) +'px'}, 1, 'linear', function() {
				aniHorizontal(2 * $(this).width(), this);
			});
		});
	}
	aniVertical = function(offset, obj) {
		aniHeight = 0;
		$(obj).css('display', 'block');
		$('.item', obj).each(function() {aniHeight += $(this).height();});
		this.num = $('.item', obj).length;
		this.items = aniHeight + this.num * 20;
		this.height = offset == 0 ? $(obj).parent().height() : offset;
		this.time = this.num * 8000;
		//.css('top', (this.items * (-1)) +'px')
		$(obj).css('height', this.items +'px').startAnimation({'top': this.height +'px'}, this.time, 'linear', function() {
			$(this).startAnimation({'top': ($(this).height() * (-1)) +'px'}, 1, 'linear', function() {
				aniVertical(2 * $(this).height(), this);
			});
		});
	}
	aniPause = function (obj) {
		$('.item', obj).hover(function() {
				$(obj).pauseAnimation();
			}, 
			function() {
				$(obj).resumeAnimation();
			}
		);
	}
	
	aniHorizontal(0, $('#bottomPartneri .tape'));
	aniPause($('#bottomPartneri .tape'));
	aniVertical(0, $('#sidePartneri .tape'));
	aniPause($('#sidePartneri .tape'));
	*/



});

