var blank = {
  config:
  {
    wrapperId: '#wrapper'
  },
  init: function()
  {
    if(!$(this.config.wrapperId).length) return false;
  }
}

function log(e)
{
  //return false;
  if(typeof(console)=='object') console.log(e);
  //else alert(e);  
}

//find max value in array
var max = function(array)
{
  var mxm = array[0];
  for (i = 0; i < array.length; i++) 
  {
    if (array[i] > mxm) 
    {
      mxm = array[i];
    }
  }
  return mxm;
 };

//preloader of images
var preloader = {
  load: function(source)
  {
    var key = this.images.length;
    this.images[key] = new Image();
    this.images[key].src = source;
  },
  images: new Array()
}

//auto rollovers
var imageHover = {
  elementsFilter: '*[src*=but_]',
  replaceSrcNormal: '.png',
  replaceSrcHover:  '_hover.png',
  init: function()
  {
    if(!$(this.elementsFilter).length) return false;
    $(this.elementsFilter).each(function(key){
      imageHover.images[key] = new Image();
      imageHover.images[key].src = $(this).attr('src').replace(imageHover.replaceSrcNormal,imageHover.replaceSrcHover);
      if(imageHover.isLoaded(imageHover.images[key]))
      {
        $(this).hover(
          function(){ $(this).attr('src',$(this).attr('src').replace(imageHover.replaceSrcNormal,imageHover.replaceSrcHover)); },
          function(){ $(this).attr('src',$(this).attr('src').replace(imageHover.replaceSrcHover,imageHover.replaceSrcNormal)); }
        );
      }
    });
  },
  isLoaded: function(el)
  {
     if (!el.complete) {
        return false;
     }
     if (typeof el.naturalWidth != "undefined" && el.naturalWidth == 0) {
        return false;
     }
     return true;
  },
  images: new Array()
}

var autoTableHover = {
  config:
  {
    table: '.autoHover',
		hoverClass: 'hover'
  },
	settings:
	{
		rowClick: false
	},
  init: function(settings)
  {
    if(!$(this.config.table).length) return false;
		this.settings = settings;
		$(this.config.table+' tr').hover(function(){ $(this).addClass(autoTableHover.config.hoverClass); },function(){ $(this).removeClass(autoTableHover.config.hoverClass); })
		if(this.settings.rowClick)
			$(this.config.table+' tr').each(function(){ $(this).children().css('cursor','pointer').click(function(){ window.location = $(this).parent().find('a').get(0).href }) })
  }
}

//--------------------------------------------------------------------------

var indexNews = {
  config:
  {
    wrapperId: '#newsBox',
    headerEl: 'h3',
    imageWrapperEl: 'p',
    fadeDuration: 300
  },
  init: function()
  {
    if(!$(this.config.wrapperId).length) return false;
    //hide unvisible images
    $(this.config.wrapperId+' '+this.config.imageWrapperEl+'[class]').removeClass().hide().find('img').hide();
    //set event to header
    $(this.config.wrapperId+' '+this.config.headerEl).mouseover(function(){ indexNews.hover($(this), false) });
    indexNews.hover( $(this.config.wrapperId+' '+this.config.headerEl+':first'), true );
  },
  hover: function(el, first)
  {
    
		if (!$(el).parent().hasClass('opened')) 
		{
			$(el).parent().parent().children().removeClass('opened')
			$(el).parent().addClass('opened')
		
			//if(!first)
	    {
	      $(indexNews.config.wrapperId+' '+indexNews.config.headerEl)
	        .removeClass('hover')
	          .next(indexNews.config.imageWrapperEl)
	          .find('img')
	          .fadeOut(indexNews.config.fadeDuration)
	          .parent()
	            .parent()
	            .hide()
	    }
	      
	    el.addClass('hover')
	      .next(indexNews.config.imageWrapperEl).show()
	      .find('img')
	      .fadeIn(indexNews.config.fadeDuration);
				
				
			}
  }

}

var lobas = {
  config:
  {
    wrapperIdBasket: '#headerBasket',
    wrapperIdLogin: '#headerLogin',
    loginSwitch: '#hlSwitch',
    basketSwitch: '#hbSwitch',
    contentIdBasket: '#headerBasketContent',
    contentIdLogin: '#headerLoginContent',
    slideDuration: 100
  },
  init: function()
  {
    if(!$(this.config.wrapperIdBasket).length) return false;
    
    $(this.config.contentIdBasket+','+this.config.contentIdLogin).css('display','none'); 
    
		//attach event on BASKET
    $(this.config.wrapperIdBasket).hover(function(){ 
        lobas.show(lobas.config.wrapperIdBasket,lobas.config.contentIdBasket); 
      }, 
      function(){ 
        lobas.hide(lobas.config.wrapperIdBasket,lobas.config.contentIdBasket); 
      });
		//attach vevent on LOGIN	
    $(this.config.wrapperIdLogin).hover(function(){  
        lobas.show(lobas.config.wrapperIdLogin,lobas.config.contentIdLogin); 
      }, function(){ 
        lobas.hide(lobas.config.wrapperIdLogin,lobas.config.contentIdLogin);
      });
    
  },
  show: function(wId,eId)
  {
    if( !$(eId).hasClass('opening') )
    {
      lobas.sDown(wId,eId);
    }
  },
  hide: function(wId,eId,lateCheck)
  {
    if( !$(eId).hasClass('opening') && !lateCheck )
    {
      lobas.sUp(wId,eId);
			//log('hide normal '+lateCheck);
    }
		if(lateCheck)
		{
			lobas.sUp(wId,eId);	
			//log('hide late '+lateCheck);
		}
		if(!lateCheck)
			setTimeout( "lobas.hide('"+wId+"','"+eId+"',true)" ,lobas.config.slideDuration);
  },
  sDown: function(wId,eId)
  {
    $(wId).addClass('hover');
    $(eId).addClass('opening').slideDown(lobas.config.slideDuration).queue(function(){ $(this).removeClass('opening'); $(this).dequeue(); });
    if(jQuery.browser.msie && ( parseInt(jQuery.browser.version) <= 6) )
    $('select[name=items_per_page]').css('visibility','hidden');
  },
  sUp: function(wId,eId)
  {
    $(eId).addClass('opening').slideUp(lobas.config.slideDuration).queue(function(){ $(this).removeClass('opening'); 
    $(wId).removeClass('hover'); $(this).dequeue(); });
    //if(jQuery.browser.msie && ( parseInt(jQuery.browser.version) <= 6) )
    $('select[name=items_per_page]').css('visibility','visible');
  }
}



var products = {
  config:
  {
    productsWrapperId: '#productsWrapper',
    itemWrapperClass: '.productItem',
    detailWrapperId: '#productDetailWrapper',
    detailWrapperWidth: '520px',
    detailFullWidth: '784px',
		detailImageHeight: 772,
    detailCloseWrapperId: '#productDetailCloseWrapper',
    detailCloseLinkId: '#productDetailClose',
		detailClose: 
		{
			defaultTopPos: '400px'
			//wrapperHeight: ''
		},
    detailSeotextOverlay: 'productDetailSeotextOverlay',
    seotextId: '#seoText',
		productsRowClass: '.productRow',
		redirectUrlReplace: { from: 'page=detail', to: 'page=ajax-detail' },
		loading: {
			image: '/images/loading.gif',
			id: '#loadingDetail',
			el: '<div id="loadingDetail" style="background-image:url(/images/loading.gif)"></div>',
			offset: 20
		},
		controlsClass: '.controls',
		subkatsId: '#productsSubkats',
		animateDuration: 300,
		scrollDuration: 200
  },
  init: function()
  {
    if(!$(this.config.itemWrapperClass).length) return false;
		
		if(!animationToggle.state){ 
      return false;
    }
    
    $(this.config.itemWrapperClass)
		.css('cursor','pointer')
		.hover(
			function(){ $(this).addClass('hover') },
			function(){ $(this).removeClass('hover') }
		);
    $(this.config.itemWrapperClass)
		.click(function(){ products.show(this) })
		.find('a')
			.click(function(){ products.show(this); return false;});
		
		preloader.load(this.config.loading.image);
			
  },
  show: function(el)
  {
		var scrollAllow = true;
		
	
		//get product detail href
		if (typeof(el) != 'string') 
		{
			//get url to redirect
			if ($(el).get(0).tagName == 'DIV') 
			{
				var pid = $($(el).find('a').get(0)).attr('href');
				$(el).addClass('act');
			}
			else 
			{
				var pid = $(el).attr('href');
				$(el).parent().parent().addClass('act');
			}
		}
		//timed call function, pid==url
		else
		{
			var pid = el;
      scrollAllow = false;
		}
    
    //if animations off, redirect
		if( $(this.config.detailWrapperId).length && !$(this.config.detailWrapperId).hasClass('overlay') ) 
    { 
      window.location = pid;
      return false;
    }
		
		//if animations off, redirect
		if(!animationToggle.state) 
    { 
      window.location = pid;
      return false;
    }
		
		//if detail is opened
  	if(products.isOpened)
    {
      products.close(scrollAllow);
      //set timer to open
			setTimeout('products.show(\''+pid+'\')',products.config.animateDuration);
			return false;
    }
    //set state
		products.isOpened = true;

		//turn on loading image
		this.loadingProcess('on');
		
		//change redirect  / not for rewrite
		//pid2 = pid.replace(this.config.redirectUrlReplace.from,this.config.redirectUrlReplace.to);
		
    //change redirect for rewrite - extract last part of url, parse to int => id of product
		var splitURL = new Array();
		splitURL = pid.split('-');
    pid2 = '/?' + this.config.redirectUrlReplace.to + '&id=' + parseInt(splitURL[splitURL.length-1]); 
		
 		//resize all of product rows - fixes IE problem, when detail is loaded
		$(this.config.productsRowClass).each(function(){
			$(this).height($(this).get(0).offsetHeight-2); //-1px padding top, -1px padding bottom
		});
		
		//save top offset scroll
    products.scrollTop = $(document).scrollTop();
		
		//scroll page to top
		if(scrollAllow)
    $.scrollTo($('#content'),products.config.scrollDuration,{ 
		
			onAfter: function(){ 
      }});
		
				$.ajax({
			     type: "GET",   // I'm using GET method
			     url: pid2+'&overlay=true',
			     success: function(data)
			     {
		
				      
				      //extract product detail and close button from detail page      
				      var ajaxDetailBox =  $(data)//.find(products.config.detailWrapperId);
					
				          
					  	//append detail box, seotext overlay, close buton			
				      $(products.config.productsWrapperId)
								.append(ajaxDetailBox)
								.append('<div id="'+products.config.detailSeotextOverlay+'"></div>')
									//hide close button
									.find(products.config.detailCloseWrapperId)
									.css('top','-2000em');
							
					  	//resize box
				      //products.resizeDetailWrapper();
					  
				      //animate box
				      $(products.config.detailWrapperId).animate({width:products.config.detailWrapperWidth},products.config.animateDuration).queue(function(){
								//show close button
								$(products.config.detailCloseWrapperId).css('top',products.config.detailClose.defaultTopPos);
								//turn off loading image
								products.loadingProcess('off');
								//hide seotext, and controls
								products.hideCTRL();
								
								$(this).dequeue();
							});
					  
				      //animate seotext overlay box
		/*					
				      if ($(products.config.seotextId).length) 
							{
								var stHeight = $(products.config.seotextId).css('height');
								var ctHeight = $(products.config.controlsClass).css('height');
								$('#' + products.config.detailSeotextOverlay).css({
									height: stHeight,
									top: -stHeight
								}).animate({
									width: products.config.detailFullWidth
								});
							}
		*/		      
					  	//resize box
				      products.resizeDetailWrapper();
				      
					  	//refresh sifr font
						  if (typeof(sIFR) == 'object') {
						  	sIFR.replace(ffont, {
						  		selector: '#productDetail h3,#collectionProducts h4',
						  		css: ['.sIFR-root { font-weight: bold; color: ' + color + '; text-transform: uppercase; }', , 'a { color: ' + colorh + '; text-decoration: none; cursor: pointer; }', 'a:link { color: ' + color + '; }', 'a:hover { color: ' + colorh + '; }'],
						  		wmode: 'transparent'
						  	});
					  	}		      
							
							
					  	//attach close event
				      $(products.config.detailCloseLinkId).click(function(){ products.close(); return false; });
				      
  				  	//init image gallery in detail box
				      detailImages.init();
							
							//init buying ajax
							buy_ajax.init()
							
							//setInterval('products.moveCloseButton()',400);
		  				//products.moveCloseButton();
							
				      //set state
				      products.detailOpened = true;	
				   },
					 error: function()
					 {
					 	  
							products.loadingProcess('off');
						 	//redirect to static version on error
							if(!(window.location = pid))
								alert('Chyba v komunikaci!')
					 }
			   }); 
		 
		 	//}}); //scrollTo
	 

  },
  close: function(scrollAllow)
  {
    $(products.config.detailCloseWrapperId).remove();
    $(products.config.detailWrapperId).animate({width: '0px'},products.config.animateDuration).queue(function(){
      $(this).remove();
      //remove seotext overlay
      $('#'+products.config.detailSeotextOverlay).remove();
      products.detailOpened = false;
			$(products.config.itemWrapperClass).removeClass('act');
			//show seotext, and controls
			products.showCTRL();
			//save state
			products.isOpened = false;
			//if scroll is allowed - opened detail and opening other detail
			if(scrollAllow)
        products.scrollTop = $('#content');
			//restore top offset store
      $.scrollTo(products.scrollTop,products.config.scrollDuration);
      
      //resize back list height
      if(products.listHeight)
      {
        $(products.config.productsWrapperId).height(products.listHeight);
      }
       
      $(this).dequeue();
    });
  },
	hideCTRL: function()
	{
		$(products.config.seotextId).css('visibility','hidden');
		$(products.config.controlsClass).css('visibility','hidden');
		$(products.config.subkatsId).css('visibility','hidden');
    $('select[name=items_per_page]').css('visibility','hidden');
	},
	showCTRL: function()
	{
		$(products.config.seotextId).css('visibility','visible');
		$(products.config.controlsClass).css('visibility','visible');
		$(products.config.subkatsId).css('visibility','visible');
    $('select[name=items_per_page]').css('visibility','visible');
	},
  resizeDetailWrapper: function()
  {
	  this.detailHeight = $(this.config.detailWrapperId).height();
		this.listHeight   = $(this.config.productsWrapperId).height();

		/* */
    if(this.detailHeight >= this.listHeight)
		{
		  if(jQuery.browser.msie)
       offs = 14 +50 +14;
      else
       offs = 50 +14;
			$(this.config.productsWrapperId).height( $(this.config.detailWrapperId).height()  +offs );
		}
		/* */
		else
		{
			$(this.config.detailWrapperId).height( $(this.config.productsWrapperId).height() -50-14 );
		}
		/* */

	},
	loadingProcess: function(state)
	{
		//return false;
		if (state == 'on') 
		{
			$('body').append(this.config.loading.el);
			$().mousemove(function(e){
      	$(products.config.loading.id).css({ left: e.pageX+products.config.loading.offset+'px', top: e.pageY+products.config.loading.offset+'px' });
   		});
		}
		else if(state='off')
		{
			$(this.config.loading.id).remove();
		}
	},
	moveCloseButton: function()
	{

			to = $(products.config.detailWrapperId).offset().top;
			st = $('html').scrollTop();
			if(st+to<this.config.detailImageHeight)
	    	top = st+to;
		  else
			  top = this.config.detailImageHeight
			$(products.config.detailCloseWrapperId).css('top',top);
	}
}

var basketCounter = {
  config:
  {
    elCounter: 'input.counterPieces',
    counterCtrlPlus:  '<a href="#" class="counter" id="counterPlus" onclick="return basketCounter.change(1,this)"><span>+</span></a>',
    counterCtrlMinus: '<a href="#" class="counter" id="counterMinus" onclick="return basketCounter.change(-1,this)"><span>-</span></a>'
  },
  init: function()
  {
    if(!$(this.config.elCounter).length) return false;
    $(this.config.elCounter).before(this.config.counterCtrlPlus+this.config.counterCtrlMinus);
  },
  change: function(step, el)
  {
    //first control
    inputEl = $(el).next(this.config.elCounter);
    //second control
    if(!inputEl.length)
      inputEl = $(el).next().next(this.config.elCounter);
    
    if( parseInt(inputEl.attr('value')) + step >=0 )
     inputEl.attr('value', parseInt(inputEl.attr('value')) + step );
    
    return false;
  }
}

var photogallery = {
  config:
  {
    wrapper: 'div.storePhoto',
    imageBox: 'p.storePhotos',
    linkPrev: 'a.storePhotosPrev',
    linkNext: 'a.storePhotosNext',
    photoWidth: 245,
    photoHeight: 183,
    fadeDuration: 200
  },
  init: function()
  {
    if(!$(this.config.wrapper).length) return false;
    //for each gallery
    $(this.config.wrapper).each(function(){
      //hide photos, except first 
      $(this).children(photogallery.config.imageBox).children('a:gt(0)').hide();
      //set class to first photo
      $(this).children(photogallery.config.imageBox).children('a:first').addClass('opened');
    });
    //set events
    $(this.config.linkPrev).click(function(){ photogallery.prev($(this).parent().parent().children(photogallery.config.imageBox)); return false; });
    $(this.config.linkNext).click(function(){ photogallery.next($(this).parent().parent().children(photogallery.config.imageBox)); return false; })
  },
  prev: function(imageBox)
  {
   //has prev image
   if($(imageBox).children('a.opened').prev('a').length)
   {
     $(imageBox).children('a.opened').fadeOut(photogallery.config.fadeDuration).queue(function(){
       $(this).removeClass('opened')
       $(this).prev('a').fadeIn(photogallery.config.fadeDuration).addClass('opened');
       $(this).dequeue();
     });
   }
   //is first image
   else if($(imageBox).children('a').length>1)
   {
     $(imageBox).children('a.opened').fadeOut(photogallery.config.fadeDuration).queue(function(){
       $(this).removeClass('opened')
       $(this).parent().children('a:last').fadeIn(photogallery.config.fadeDuration).addClass('opened');
       $(this).dequeue();
     });
   }  
  },
  next: function(imageBox)
  {
   //has next image
   if($(imageBox).children('a.opened').next('a').length)
   {
     $(imageBox).children('a.opened').fadeOut(photogallery.config.fadeDuration).queue(function(){
       $(this).removeClass('opened')
       $(this).next('a').fadeIn(photogallery.config.fadeDuration).addClass('opened');
       $(this).dequeue();
     });
   }
   //is last image
   else if($(imageBox).children('a').length>1)
   {
     $(imageBox).children('a.opened').fadeOut(photogallery.config.fadeDuration).queue(function(){
       $(this).removeClass('opened')
       $(this).parent().children('a:first').fadeIn(photogallery.config.fadeDuration).addClass('opened');
       $(this).dequeue();
     });
   }
  }
}



var detailImages = {
  config:
  {
    wrapperId: '#pdImages',
    detailWrapper: '#pdImagesDetail',
    imagesList: '#pdImagesList',
    preloadImage: '/images/loading.gif',
    loadindIco: '<div class="loading" style="background-image:url(/images/loading.gif)"></div>'
  },
  init: function()
  {
    if(!$(this.config.wrapperId).length) return false;
    //preload loading image
    preloader.load(this.config.preloadImage);
    //attach click event on thumbnails in list
    $(detailImages.config.imagesList+' a').click(function(){ detailImages.show($(this)); return false; });
    //hide current opened image
    detailImages.hideCurrent();
	//set first image in list active
	$(detailImages.config.imagesList+' a:eq(0)').addClass('act');
  },
  show: function(el)
  {
    this.cel = el;
	//unset active class
	$(detailImages.config.imagesList+' a').removeClass('act');
	//set active class
	$(el).addClass('act');
    //append loading image
    $(detailImages.config.detailWrapper).append(detailImages.config.loadindIco);
    //preload selected image
    $.preload($(el),{onComplete:function(){
      //change image / change href
      $(detailImages.config.detailWrapper+' img').attr('src',$(detailImages.cel).attr('href'));
      //hide this image in list
      detailImages.hideCurrent();
      //remove loading image
      $(detailImages.config.detailWrapper+' div').remove();
    }});
  }, 
  hideCurrent: function()
  {
    return false;
    $(detailImages.config.imagesList+' a').each(function(){ 
       if ( $(this).attr('href')==$(detailImages.config.detailWrapper+' img').attr('src') )
         $(this).hide();
       else
         $(this).show();  
    });             
  }, 
  isLoaded: function(el)
  {
     if (!el.complete) {
        return false;
     }
     if (typeof el.naturalWidth != "undefined" && el.naturalWidth == 0) {
        return false;
     }
     return true;
  }
}

var detailCollectionItems = {
  config:
  {
    wrapperId: 'table#cplist',
		offset: 20
  },
  init: function()
  {
    if(!$(this.config.wrapperId).length) return false;
		$(this.config.wrapperId+' tr').each(function(){
			$(this).hover(function(){ detailCollectionItems.showImage($(this)) },function(){ detailCollectionItems.hideImage($(this)) });
		});
  },
	showImage: function(el)
	{
			$(el).find('div div').fadeIn();
	},
	hideImage: function(el)
	{
		  $(el).find('div div').fadeOut();
	}
}



var genderFilter = {
  config:
  {
    wrapperGenderId: 'form#genderFilter',
		wrapperBrandsId: 'form#brandsFilter'
  },
  init: function()
  {
    if(!$(this.config.wrapperGenderId).length) return false;
		$(this.config.wrapperGenderId+' input').click(function(){ $(genderFilter.config.wrapperGenderId).submit(); });
		$(this.config.wrapperBrandsId+' input').click(function(){ $(genderFilter.config.wrapperBrandsId).submit(); });
  }
}

var buy_ajax = {
  config:
  {
    wrapperId: 'div#pdPriceBox form',
		buyButtonName: 'buy',
		message: 'Zboží bylo přidáno do košíku.',
		basketId: '#headerBasket'
  },
  init: function()
  {
    if(!$(this.config.wrapperId).length) return false;
		//$(this.config.wrapperId+' input[name='+this.config.buyButtonName+']').click( function(){ buy_ajax.buy(); return false; } )
    $(this.config.wrapperId).submit(function(){ if(!buy_ajax.ret){ buy_ajax.buy(buy_ajax.config.wrapperId); } return buy_ajax.ret; })
  },
  ret: false,
	buy: function(form)
	{
		
    data = $(form).serialize();
		url = $(form).attr('action');
		if(url=='') url = 'index.php'
		$.ajax({
	     type: "GET",   
	     url: url+'?'+data,
	     success: function(data)
	     {
          buy_ajax.ret = false;
					alert(buy_ajax.config.message);
					buy_ajax.refreshBasket();
		   },
			 error: function()
			 {
          buy_ajax.ret = true;    
          $(form).submit();  
			 }
	   }); 
	},
	refreshBasket: function()
	{
		//load updated basket
		$.get('/index.php?page=ajax-kosik', function(data){ 
			$(buy_ajax.config.basketId).children().remove();
			$(buy_ajax.config.basketId).append( $(data).children() );
  	})
	}
}

var animationToggle = {
	state: true,
	textOff: 'Vypnout animaci detailu produktu',
  textOn:  'Zapnout animaci detailu produktu',
  init: function()
  {
		var cVal = $.cookie('allow_animation2');
		
		if(cVal=='yes')
			this.state = true;
		else if(cVal=='no')
		  this.state = false;
		else
			this.state = true;
			
		if(animationToggle.state)
			$('div#footer p.fl').append(' <span>|</span> <a id="aniToggle" href="#" onclick="animationToggle.off(); return false;">'+animationToggle.textOff+'</a>');
		else 
			$('div#footer p.fl').append(' <span>|</span> <a id="aniToggle" href="#" onclick="animationToggle.on(); return false;">'+animationToggle.textOn+'</a>'); 
  },
	on: function()
	{
		animationToggle.state = true;
		$.cookie('allow_animation2', 'yes', { expires: 7, path: '/' });
		$('a#aniToggle').remove();
		$('div#footer p.fl').append('<a id="aniToggle" href="#" onclick="animationToggle.off(); return false;">'+animationToggle.textOff+'</a>');
		location.reload(true);

	},
	off: function()
	{
		animationToggle.state = false;
		$.cookie('allow_animation2', 'no', { expires: 7, path: '/' });
		$('a#aniToggle').remove();
		$('div#footer p.fl').append('<a id="aniToggle" href="#" onclick="animationToggle.on(); return false;">'+animationToggle.textOn+'</a>');
	}
}


function show_map(map_element_id, gps1, gps2, zoom) {
	if (typeof(GBrowserIsCompatible)=='function' && GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById(map_element_id));
		map.setMapType(G_HYBRID_MAP);
		var pozice = new GLatLng(gps1, gps2); //seskladani pozice
//		var companyMarker = new GIcon();
//		companyMarker.image= "/images/logo-smartcompanies.png";
//		companyMarker.iconSize = new GSize(55, 52); //width, height
//		companyMarker.iconAnchor = new GPoint(6, 20);
//		companyMarker.infoWindowAnchor = new GPoint(5, 1);
		var marker = new GMarker(pozice)//, companyMarker);
      	//var companyMarker = createMarker(pozice, companyMarkerImage, companyMarkerSize);
		map.addControl(new GSmallMapControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0,20))); //tlacitka pozice, nastaveni pozice tlacitek, paddingy
		map.addControl(new GMapTypeControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0,0))); //tlacitka typ
		map.setCenter(pozice, zoom); //nastaveni stredu mapy
		map.addOverlay(marker); //nastaveni markeru na pozici
//		GEvent.addListener(map, "click", function() {
//	      window.location.href='http://maps.google.com/maps?f=q&hl=cs&geocode=&time=&date=&ttype=&q=Kon%C4%9Bvova+2660%2F141,+Praha&sll=37.0625,-95.677068&sspn=33.435463,81.738281&ie=UTF8&ll=50.091787,14.474809&spn=0.006608,0.019956&z=16&iwloc=addr&om=0';
//	    });
	}
}
	
window.onload = function() { 
	if( jQuery('#storeDMapBrno').length )
		show_map('storeDMapBrno', 49.1936678, 16.6083802, 15);
	if( jQuery('#storeDMapBrnoOutlet').length )
		show_map('storeDMapBrnoOutlet', 49.1936678, 16.6083802, 15);
	if( jQuery('#storeDMapOva').length )
		show_map('storeDMapOva', 49.8349604, 18.2902423, 15);
	if( jQuery('#storeDMapPce').length )
		show_map('storeDMapPce', 50.0349112, 15.7741532, 15);
};
	
$(document).ready(function() {     

  lobas.init();
  indexNews.init();
	animationToggle.init();
  products.init();
  detailImages.init();
  basketCounter.init();
  photogallery.init();
  imageHover.init();
  genderFilter.init();
	buy_ajax.init();
  $('a[@rel*=lightbox]').lightBox();
	autoTableHover.init({rowClick:true});
	//detailCollectionItems.init();

	
	
})


