$(document).ready(function(){
	// PRODUCT SCROLL
	$('#annotBox .r a').click(function(){
		//alert('a');
		var top = $('.variats-list').offset().top;
		top=top-20;
		$('body, html').animate({
			scrollTop: top +'px'
		}, 1000);
		return false;
	});
	
	// HIDE
	$('.cityAdd, .shopsList, #addCity optgroup, .transferList').hide();
	
	//$('#addCity optgroup#showOptgroup').show().attr('label', '');
	
	// REMOVE
	$('.remove').remove();
	
	// JS PRODUCT ADD HELP  
    if (!($.browser.msie && $.browser.version<7)) {
	    $('#productDetail .variats-list').each(function(){
	    	var $this = $(this);
			$('.basketAdd').each(function(){
				var tr = $(this).parent();
				$('input', this).hide();
				$(this).append('<a href="#" class="ajaxPrebasket"><img src="/img/btn/putToBasket.png" alt="" /></a>');
				$('a', this).attr('href', $('form', $this).attr('action')+'?basketAction=add&product='+$('input.xproduct',tr).attr('value')+'&size='+$('.size', tr).attr('value')+'&amount='+$('.int', tr).attr('value') );
				$('input.amount', tr).change(function(){
					var h = $('a', tr).attr('href');
					$('a', tr).attr('href', h.replace(/(=|=.[^=]{0,})$/, '='+$('input.amount', tr).val()));
				}).keypress(function (e) {
					if ( e.keyCode==13 ) {
						var h = $('a', tr).attr('href');
						$('a', tr).attr('href', h.replace(/(=|=.[^=]{0,})$/, '='+$('input.amount', tr).val())).trigger('click');
		                return false;
	                }
	            });
			});
		});
	}
	
	
	// PDBOX	
	$('.thickbox').pdBox({minWidth: 636});
	$('.ajaxLogin').pdBox({minWidth: 600});	
	$('.ajaxPrebasket').pdBox({
    	minWidth: 636,
    	onHide: function(){
    		var replace1 = $('#ajaxReplace p.reset').clone();
    		$('body #basket-box p.reset').replaceWith(replace1);
    	}
	});
	
	// ADJUST HEIGHTS
	function init(){
        $('.productList ul').adjustHeights({
            elements : ['h3 strong', 'li'],
            vAlign : 'top'
        });
        $('.att-images ul').adjustHeights({
            elements : ['a'],
            vAlign : 'center',
            adjust: false
        });
    }
    
    // FONT SIZE
    $(document).fontSizeListener({
        element: '#mother',
        callFunction : function(){init()}
    });
	
	// MAIM MENU
    with (navigator) {browser=appName; version=parseInt(appVersion);}
    if (browser=="Microsoft Internet Explorer" && version<6.9) {
		$('#mainMenu li').each(function(){
			var w = $('.item', this).width();
			$('strong .border', this).css('width', w+'px');
			w=w+15;
			$('a .border', this).css('width', w+'px');
		});
		$('#mainMenu li.active').each(function(){
			var w = $('.item', this).width();
			$('a .border', this).css('width', w+'px');
		});
	}
	var active = 'active';
	var $box = $('.home #motive');
	var $menu = $('.home #mainMenu');
	
	$('.spc', $box).each(function(){
		var marginTop = $('.text', this).height();
		marginTop = (156 - marginTop) / 2
		$('.text', this).css('margin-top', marginTop);
	});
	
	var changeMotiv = function(i){
		if($.browser.msie){
			$('.spc.'+active+' .text', $box).hide();
		}
		else{
			$('.spc.'+active+' .text', $box).stop().fadeTo(500, 0);	
		}
		$('.spc', $box)
			.filter('.'+active)
				.removeClass(active)
				.stop()
				.animate({
					backgroundPosition: '1300px 0'	
				},750)
				.end()
			.eq(i)
				.addClass(active)
				.css({
					backgroundPosition: '1300px 0'
				})
				.stop()
				.animate({
					backgroundPosition: '300px 0'	
				},750)
				.find('.text').each(function(){
					if($.browser.msie){
						$(this).show();	
					}
					else{
						$(this).stop().fadeTo(500, 1);	
					}
				})
					
	};
	
	$('.spc.'+active, $box).css({'background-position': '300px 0'});
	$menu.find('li').each(function(i){
		$(this)
			.bind('mouseenter', function(){
				$menu.find('.item').filter('.hover').removeClass('hover');
				$(this).find('.item').addClass('hover')
				if(!$('.spc', $box).eq(i).hasClass('.'+active))
				{
					changeMotiv(i);
				}
			});
	});
	
	// CHANGE WHY US
	var i = 0;
	var liHeight = 0;
	$('.whyUs .col-l li').each(function(){
			liHeight = $(this).height() > liHeight ? $(this).height() : liHeight	
		});
		$('.whyUs .col-l .reset').css({
			'height': liHeight + 'px',
			'position': 'relative',
			'overflow': 'hidden'
		});
		$('.whyUs .col-l li').css({
			'position': 'absolute',
			'left': '0'
		});
		$('.whyUs .col-l li').not(':eq(0)').css({
			'top': liHeight + 'px'
		});
		
  		function rotate(){
		$('.whyUs .col-l').each(function(){  		
	  		var delka = $('li', this).size()-1;
	  		if (i==delka){i=0;}
	  		else{i++;}	
				
			if (i==delka)
			{
				$('li', this).eq(i-1).animate({top: -liHeight + 'px'}, 500);
				$('li', this).eq(i).animate({top: '0px'}, 500);
	  			$('li', this).eq(0).css('top', liHeight + 'px');
			}
			else if (i==0)
			{
				$('li', this).eq(delka).animate({top: -liHeight + 'px'}, 500);
				$('li', this).eq(i).animate({top: '0px'}, 500);
	  			$('li', this).eq(i+1).css('top', liHeight + 'px');
			}
			else 
			{
				$('li', this).eq(i-1).animate({top: -liHeight + 'px'}, 500);
				$('li', this).eq(i).animate({top: '0px'}, 500);
	  			$('li', this).eq(i+1).css('top', liHeight + 'px');
			}
		});
	};
	setInterval(function(){rotate()}, 2000);
	
	// Kroky objednávky
    $('.step-list').each(function(){
    	var $step = $('li.prev, li.next', this);
    	var $prev = $('li.prev', this);
    	var $next = $('li.next', this);
    	
    	$next.click(function(){
    		$('#order .buttons .r input').trigger('click');
    	});
    	$prev.click(function(){
    		$('#order .buttons .l input').trigger('click');
    	});
    	$step.hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')});
    });
    
    // CONFIRM MAIL
    var interval = null;
    var counter = 0;
    $('#orderemail:not(.noAjax)').bind('focus blur', function(e){
        var el = $(this);
        var pEL = $(this).parents('p');
        var url = window.location.href;
        var oldEmail = el.val();
        var email = el.val();
        var rMail = /.+@.+\..+/;
             
        function testEmail(){
            email = el.val();
            if (email != oldEmail || counter == 0)
            {
                counter++;
                oldEmail = email;
                
                if (rMail.test(email))
                {  
                    $.ajax({ 
              			type: "POST",
              			url: url,
              			data: 'ajax=true&email='+email,
              			//dataType: 'xml',
              			success: function(responseXML)
              			{
              			   $('#send-pass').remove();
              			   if(responseXML!='0')
                           {  
                              pEL.addClass('highlight');
                           
                              el.after(responseXML);
                              $('#send-text').hide().slideDown(300, function(){
                                  $('#send-pass .int-text').focus().bind('keyup keydown', function(e){
                                      if(e.keyCode == '13')
                                      {
                                          $('#send-pass .btn').trigger('click');  
                                          return false;  
                                      }
                                  });
                              });
                              $('#send-pass .btn').click(function(e){
                                  var pass = $('#send-pass .int-text').val();
                                  $.ajax({ 
                              			type: "POST",
                              			url: '/uzivatel?ajax=true&xml=true',
                              			data: 'loginname='+email+'&password='+pass+'&btnLoginSubmit=Login',
                              			dataType: 'xml',
                              			success: function(responseXML)
                              			{
        					        		//var elements = $('user',responseXML).children();
        						        	$('*', $('user',responseXML)).each(function() {
        						        		$('#order'+this.tagName).val($(this).text())					
        									}); 
        									
        									// HLÁŠKY
        									$('.message').remove();
        									var mType = $('messages',responseXML).children()[0].tagName;
        									var mText = $('messages',responseXML).text();
        									var message = $('<p class="message '+ mType +'-message"></p>');
        								        message.text(mText+'');
        								        message.append('<span class="cor cor-l"></span><span class="cor cor-r"></span><span class="cor cor-bl"></span><span class="cor cor-br"></span>');
                                            $('#annotBox').after(message);
                                            
                                            // VYPNUTNÍ AJAXU
                                            if (mType=='ok'){
                                                $('#send-pass').remove();
                                                el.unbind('change keyup');
                                                $('.ajaxRemove').remove();
                                                pEL.removeClass('highlight');
                                            }
                                             
                                            // ROZKLIKAVANI CHECKBOXŮ  
                                            $('.open-box').each(function(){
                                                var $this = $(this);
                                                var size = 0;
                                                $('.box :input', $this).each(function(){
                                                    if($(this).val() != '')
                                                    {
                                                        size++;
                                                    }
                                                });
                                                if(size != 0 && !$this.data('status'))
                                                {
                                                    $(':checkbox', this).trigger('click');
                                                }   
                                            });      
                              			},
                              			complete: function(XMLHttpRequest, errorText, exception)
                              			{	 
                                             
                              			}
                                  });
                                  e.preventDefault();
                              });
                           }
                           else{
                                pEL.removeClass('highlight');
                           }             
              			},
              			complete: function(XMLHttpRequest, errorText, exception)
              			{	 
                             
              			}
                	});
                }
                else{
                    pEL.removeClass('highlight');
                    $('#send-pass').remove();
                }
            }
        }   
        
        if(e.type == 'focus')
        {
            interval = clearInterval(interval);
            interval = setInterval(function(){
            testEmail()
            }, 200);
        }
        else if (e.type == 'blur')
        {
            interval = clearInterval(interval);
        }  
            
        //return false;
    });
    
    // Open box
    $('.open-box').each(function(){
        var $this = $(this);
        var $chck = $('h2 input', this);
        var $box = $('.box', $this);
        var attr = $chck.attr('checked')
        var size = 0;
        $('.box :input', $this).each(function(){
            if($(this).is(':text') && $(this).val() != '')
            {
                size++;
            }
            else if($(this).attr('checked'))
            {
                size++;
            }
        });
        if(attr || size != 0)
        {
            $chck.attr('checked', true);
            $this.data('status', true);
        }
        else
        {
            $box.hide();
            $this.data('status', false);
        }
        $('h2 input', $this).click(function(){
            if($this.data('status'))
            {
                $chck.attr('checked', false);
                $box.slideUp('fast');
                $this.data('status', false);
            }
            else
            {
                $chck.attr('checked', true);
                $box.slideDown('fast');
                $this.data('status', true);
            }
        });
    });
    
    // addCity
	$('#addCity').change(function(){
		var url = '';
		if ( $('option', this).size()>1 ) {
			if ( $('option[value="all"]', this).is(':selected') ) {
				$('option[value!="all"]', this).each(function(){
					url = url + '&cat[]=' + $(this).attr('value');
				});
			}
			else {
				$('option', this).each(function(){
					if ( $(this).is(':selected') ) {
						url = url + '&cat[]=' + $(this).attr('value');
					}
				});
			}
			
			$.ajax({ 
	  			type: "GET",
	  			beforeSend: function(){
				 	$('.shopsList').fadeIn();
				 	$('.shopsList .spc').html('').append('<p class="center"><img src="/img/bg/ajax.gif" alt=" " /></p>');
				},
	  			url: '?ajax=1' + url,
	  			//dataType: 'xml',
	  			success: function(xml)
	  			{
	  				$('.shopsList p.center').remove();
	  				$('.shopsList .spc').append(xml);
					  	
					if ( $('.transferList').size()>0 ){
						$('.shopsList input').click(function(){
							var parent = $(this).parent();
							$('.transferList').fadeIn();
							$('.transferList label[for="transport2"] span').html( $('label', parent).html() );			
						});
					}				  			
	  			}
			});
		}
	});
	$('#addCity optgroup#showOptgroup').each(function(){
		var url = '';
		if ( $('option', this).size()>1 ) {
			if ( $('option[value="all"]', this).is(':selected') ) {
				$('option[value!="all"]', this).each(function(){
					url = url + '&cat[]=' + $(this).attr('value');
				});
			}
			else {
				$('option', this).each(function(){
					if ( $(this).is(':selected') ) {
						url = url + '&cat[]=' + $(this).attr('value');
					}
				});
			}
			
			$.ajax({ 
	  			type: "GET",
	  			beforeSend: function(){
				 	$('.shopsList').fadeIn();
				 	$('.shopsList .spc').html('').append('<p class="center"><img src="/img/bg/ajax.gif" alt=" " /></p>');
				},
	  			url: '?ajax=1' + url,
	  			//dataType: 'xml',
	  			success: function(xml)
	  			{
	  				$('.shopsList p.center').remove();
	  				$('.shopsList .spc').append(xml);
					  	
					if ( $('.transferList').size()>0 ){
						$('.shopsList input').click(function(){
							var parent = $(this).parent();
							$('.transferList').fadeIn();
							$('.transferList label[for="transport2"] span').html( $('label', parent).html() );			
						});
					}				  			
	  			}
			});
		}
	});
	
	$('.wrapHouse').each(function(){
		var $this = $(this);
		var activeEl = '';
		$('.img', this).click(function(){
			$('.img', $this).css({'width': '40px','margin-left': '0','z-index':'1'});
			$('.detail', $this).hide();
			$('.img img', $this).css({'margin-left': '0'});
			$(this).css({'width': '80px','margin-left': '-20px','z-index':'2'});
			$('img', this).css({'margin-left': '-40px'});
			activeEl = $(this).attr('id');			
			$('.'+activeEl, $this).slideDown('slow');
		});
	});
	
	
});

window.onload = function () {
	$('#map').each(function(){
	    var R = Raphael("map", 380, 222);
	    var attr = {
	        fill: "#dfdfdf",
	        stroke: "#9b9b9b",
	        "stroke-width": 1,
	        "stroke-linejoin": "round"
	    };
	    var attrCr = {
	        fill: "#dfdfdf",
	        stroke: "#9b9b9b",
	        "stroke-width": 5,
	        "stroke-linejoin": "round"
	    };
	    var attrActive = {
	        fill: "#ffdb00",
	        stroke: "#ffcc00",
	        "stroke-width": 5,
	        "stroke-linejoin": "round"
	    };
	    var attrHover = {
	        fill: "#ffdb00"
	    };
	    var allCr = R.path("M374.415,127.724l-5.816-3.789l-2.85-3.003l-4.98-16.133l-4.179,1.759l-8.788-4.733l-12.074-4.563l-3.977-5.372l-2.348-0.061l-7.22,8.035l-8.531-10.761l-2.916-0.659l-3.987-4.78l10.42-4.07l-2.102-10.01l-3.503-0.675l-2.472,5.217l-11.15,0.898l-4.48-4.931l-25.13-12.735l-3.345,3.869l10.614,14.584l-7.655,1.568l-11.96,9.672l-3.998-4.197l-2.214-5.328L239,62.609l-4.069-1.27l-2.827-4.176l10.794-10.277l-4.245-6.387l-12.548-1.648l-4.17,2.832l-1.629-5.32l-7.044,0.421l-3.357-6.529l-2.926-0.072l-13.882-5.465l-12.407-6.335L179.412,7.35L172.2,4.085l-9.782,1.086l1.635,5.996l-0.166,6.482l-6.424,0.197l-4.206,4.58l-8.81-3.759l1.264-6.106l-4.545,0.358l1.734-6.157l-4.787-4.177l-5.174,1.561L126.178,2l-0.634,3.346l4.744,6.485l-1.014,3.198l-5.318-0.345l-11.699,8.024l-3.341-2.638l-5.176,2.428l-2.473,5.268l-17.687,0.423l-0.792,6.371l-3.734,4.169l-5.167-6.096l-3.355,6.311l-4.984-0.491l-1.32,5.825l-10.433-0.416l-3.615,8.646l-8.184-5.101l-5.632,3.698l-10.005-0.453l-7.658,8.333L12.28,67.41l-4.613-6.734l-1.392-3.675l-3.538,1.093L2,63.933l6.464,14.088l16.534,15.542l-9.688,12.652l13.384,27.869l6.781,10.122l10.502,2.022l8.877,19.497l5.848,0.143l6.189,10.701l4.542,5.965l3.587-2.846l26.969,27.688l-1.319,5.827l16.319,3.915l7.188-6.274l13.922,5.619l7.569-15.875l8.21,1.272l3.221-21.2l8.703,2.502l1.1,2.953l7.824-3.026l13.344,7.322l9.215,5.051l5.888-1.029l15.717,10.459l16.923,2.746l7.107-7.515l7.843,1.795l6.822,7.419l7.202,0.396l0.614,7.747l3.749,0.678l12.887-21.98l11.505,5.678l3.41-4.303l4.647,4.723l8.018-3.899l12.563-6.121l2.457-7.14l7.952-1.823l3.121-12.099l4.437-10.17l8.998-1.957l4.734-5.314l4.515-5.053l3.268-5.916l9.399,1.664l5.102-3.789L374.415,127.724z").attr(attrCr);
	    var cr = {};
		cr.kraj147 = R.path("M50.18,52.508l-8.184-5.101l-5.632,3.698l-10.005-0.453l-7.658,8.333L12.28,67.41l-4.613-6.734l-1.392-3.675l-3.538,1.093L2,63.933l6.464,14.088l16.534,15.542l19.896-0.314l10.331-7.827l6.303,4.095l6.021-9.219l-3.463-21.791L50.18,52.508z").attr(attr);
	    cr.kraj142 = R.path("M182.336,92.645l4.44-6.173l-4.215-4.715l0.238-11.7l-7.57,0.001l-6.109-6.385l2.192-4.292l-1.974-10.266l-10.412-8.43l-18.461,10.875l-6.324-3.184l-7.354,11.709l-20.854,2.685L79.802,73.56l-6.712,9.31l-0.365,4.349l3.577-0.466l5.484,4.412l5.058-0.414l7.736,5.74l-0.061,5.738l-3.811,12.033l-4.3,2.051l2.959,8.006l0.177,9.303l15.901-2.267l12.614,0.04l22.787,4.944l5.417-8.324l8.893,5.779l3.699-4.937l14.84-1.378l-2.213-2.597l-1.357-4.279l3.82-4.814l6.91-0.82l2.635-3.706l5.029-3.282l2.549-8.18L182.336,92.645z").attr(attr);
	    cr.kraj145 = R.path("M192.084,175.077l-2.876-3.526l-6.434,0.265l-5.711-4.538l0.432-2.746l-6.917-2.728l-3.257,1.507l-6.648-7.663c0,0-3.059,2.424-2.816,2.088c0.24-0.331-4.164-6.314-4.164-6.314l1.461-17.625l-8.889-5.781l-5.417,8.326l-22.792-4.945l-12.612-0.041l-15.907,2.268l0.25,14.228l-4.623,12.709l-7.04,5.06l-3.104,14.07l26.969,27.688l-1.319,5.827l16.319,3.915l7.188-6.274l13.922,5.619l7.569-15.875l8.21,1.272l3.221-21.2l8.703,2.502l1.1,2.953l7.824-3.026l13.344,7.322l2.526-4.251l-5.155-4.176L192.084,175.077z").attr(attr);
	    cr.kraj152 = R.path("M238.32,133.59l-22.169-13.755l-4.365,3.767l-23.268-15.621l-5.028,3.288l-2.646,3.7l-6.901,0.82l-3.826,4.814l1.369,4.284l2.207,2.593l-14.84,1.377l-3.699,4.938l-1.461,17.625c0,0,4.404,5.983,4.164,6.314c-0.242,0.336,2.816-2.088,2.816-2.088l6.648,7.663l3.257-1.507l6.917,2.728l-0.432,2.746l5.711,4.538l6.434-0.265l2.876,3.526l-6.644,6.908l5.155,4.176l5.696,1.202l13.326-7.964l8.917,0.96l10.98-6.545l1.552-5.793l-2.136-5.005l7.729-8.939L238.32,133.59z").attr(attr);
	    cr.kraj151 = R.path("M257.765,112.972 L257.635,98.507 L261.297,95.181 L267.946,77.379 L255.986,87.051 L251.988,82.854 L244.442,83.651 L235.664,93.018 L228.413,93.946 L215.006,82.177 L206.304,81.563 L201.832,85.326 L194.424,83.723 L186.772,86.473 L182.337,92.646 L191.062,99.801 L188.518,107.98 L211.786,123.602 L216.151,119.835 L238.32,133.59 L247.362,130.427 L260.348,133.579 L263.917,125.546 L263.129,121.51z").attr(attr);
	    cr.kraj150 = R.path("M201.832,85.326 L206.304,81.563 L215.006,82.177 L228.413,93.946 L235.664,93.018 L244.442,83.651 L251.988,82.854 L249.774,77.525 L239,62.609 L234.931,61.34 L232.104,57.164 L242.898,46.887 L238.653,40.5 L226.105,38.852 L221.935,41.684 L220.306,36.363 L213.262,36.784 L209.905,30.255 L206.979,30.183 L193.097,24.718 L197.737,49.421 L189.439,48.009 L186.423,52.737 L177.707,49.523 L176.125,51.966 L169.337,49.115 L171.313,59.382 L169.119,63.674 L175.227,70.059 L182.803,70.058 L182.548,81.757 L186.772,86.473 L194.424,83.723z").attr(attr);
		cr.kraj149 = R.path("M180.69,18.383 L179.412,7.35 L172.2,4.085 L162.417,5.171 L164.052,11.167 L163.886,17.649 L157.462,17.847 L153.256,22.427 L144.447,18.668 L138.996,23.773 L134.552,21.694 L127.496,34.905 L134.142,48.377 L140.466,51.561 L158.927,40.686 L169.337,49.115 L176.125,51.966 L177.707,49.523 L186.423,52.737 L189.439,48.009 L197.737,49.421 L193.097,24.718z").attr(attr);
		cr.kraj144 = R.path("M86.399,116.318 L90.705,114.262 L94.518,102.229 L94.581,96.494 L86.841,90.75 L81.782,91.164 L76.292,86.752 L72.725,87.218 L73.088,82.874 L67.548,80.297 L61.527,89.516 L55.223,85.421 L44.894,93.248 L24.998,93.563 L15.311,106.215 L28.695,134.084 L35.476,144.206 L45.978,146.229 L54.854,165.726 L60.703,165.868 L66.892,176.569 L71.433,182.534 L75.021,179.688 L78.124,165.618 L85.164,160.559 L89.787,147.85 L89.537,133.622 L89.364,124.32z").attr(attr);
		cr.kraj153 = R.path("M301.446,188.755 L295.47,188.918 L284.692,181.245 L283.804,176.745 L277.824,177.142 L279.784,173.178 L282.665,172.811 L282.643,169.603 L280.239,169.292 L281.578,159.58 L274.473,155.467 L273.823,150.515 L267.656,141.946 L265.903,150.73 L260.797,148.849 L260.348,133.579 L247.362,130.427 L238.32,133.59 L236.662,154.077 L228.932,163.017 L231.068,168.021 L229.516,173.814 L218.536,180.359 L209.619,179.399 L196.292,187.363 L190.596,186.161 L188.07,190.412 L197.285,195.463 L203.172,194.434 L218.889,204.893 L235.812,207.639 L242.919,200.124 L250.762,201.919 L257.584,209.338 L264.787,209.734 L265.401,217.481 L269.15,218.159 L282.037,196.179 L293.542,201.856 L296.952,197.554 L301.599,202.276 L309.617,198.377z").attr(attr);
		cr.kraj143 = R.path("M345.506,143.535 L342.487,144.583 L337.187,141.554 L329.847,141.561 L323.378,139.181 L315.316,147.774 L310.396,147.274 L299.4,154.393 L292.658,149.949 L291.424,156.332 L281.578,159.58 L280.239,169.292 L282.643,169.603 L282.665,172.811 L279.784,173.178 L277.824,177.142 L283.804,176.745 L284.692,181.245 L295.47,188.918 L301.446,188.755 L309.617,198.377 L322.18,192.256 L324.637,185.116 L332.589,183.293 L335.71,171.194 L340.147,161.024 L349.145,159.067 L353.879,153.753z").attr(attr);
		cr.kraj154 = R.path("M374.415,127.724 L368.598,123.935 L365.749,120.932 L360.768,104.799 L356.589,106.558 L347.801,101.824 L335.727,97.261 L331.75,91.889 L329.403,91.828 L322.183,99.863 L313.652,89.103 L310.736,88.443 L306.749,83.663 L317.168,79.593 L315.067,69.583 L311.564,68.908 L309.092,74.125 L297.942,75.023 L293.904,79.202 L285.725,87.79 L285.67,93.293 L282.501,99.505 L284.113,102.996 L281.493,109.79 L300.868,121.518 L302.761,119.516 L311.738,122.196 L310.915,126.874 L323.378,139.181 L329.847,141.561 L337.187,141.554 L342.487,144.583 L345.506,143.535 L353.879,153.753 L358.394,148.7 L361.662,142.784 L371.061,144.448 L376.163,140.659z").attr(attr);
		cr.kraj155 = R.path("M292.658,149.949 L299.4,154.393 L310.396,147.274 L315.316,147.774 L323.378,139.181 L310.915,126.874 L311.738,122.196 L302.761,119.516 L300.868,121.518 L281.493,109.79 L284.113,102.996 L282.501,99.505 L285.67,93.293 L285.725,87.79 L293.904,79.202 L297.942,75.023 L293.461,70.093 L268.332,57.357 L264.987,61.227 L275.601,75.811 L267.946,77.379 L261.297,95.181 L257.635,98.507 L257.765,112.972 L263.129,121.51 L263.917,125.546 L260.348,133.579 L260.797,148.849 L265.903,150.73 L267.656,141.946 L273.823,150.515 L274.473,155.467 L281.578,159.58 L291.424,156.332z").attr(attr);
		cr.kraj148 = R.path("M134.142,48.377 L127.496,34.905 L134.552,21.694 L138.959,23.788 L144.449,18.669 L145.708,12.57 L141.164,12.919 L142.894,6.766 L138.113,2.576 L132.944,4.152 L126.177,2.005 L125.541,5.341 L130.289,11.832 L129.275,15.03 L123.957,14.68 L112.257,22.714 L108.917,20.074 L103.744,22.504 L101.271,27.771 L83.58,28.186 L82.783,34.562 L79.055,38.729 L73.88,32.638 L70.535,38.95 L65.547,38.458 L64.236,44.285 L53.795,43.862 L50.179,52.515 L64.085,58.506 L67.548,80.297 L73.09,82.869 L79.802,73.56 L105.934,62.771 L126.788,60.086z").attr(attr);
		cr.kraj141 = R.path("M120.859,84.884 L122.988,88.076 L123.341,97.295 L127.953,97.295 L130.789,94.814 L138.947,94.105 L140.365,88.076 L140.72,83.82 L136.109,78.502 L130.789,79.21 L125.116,81.693z").attr(attr);
		
		var activeKraj = $('#showOptgroup').attr('class');
	    var $type = $('#addCity');	
		var copy = {
			$type: $type.clone()
		};
		var current = null;
	    for (var state in cr) {
	        cr[state].color = Raphael.getColor();
	        if ( state == activeKraj ) {
				cr[state].attr(attrActive).insertBefore(cr.kraj141);
				$('.cityAdd').show();    
				$type.html(copy.$type.find('optgroup.'+state).html());
				current = state; 
			}
	        (function (st, state) {
	        	if ( copy.$type.find('optgroup.'+state).html() ) { 
		            st.mouseover(function() {  
		        		if (current != state) {        	
			                this.animate(attrHover, 500);
			                R.safari();
			            }
		        	}).mouseout(function(){
		        		if (current != state) {
							this.animate(attr, 500);
		                	R.safari();
						}                
		            }).click(function() {
		            	if (current) {
							cr[current].animate(attr, 500);
						}
						if ( current!=state ) {
		                	$('.shopsList').fadeOut();
							$('.cityAdd').fadeIn();                            
							$type.html(copy.$type.find('optgroup.'+state).html());
		                }
		        		current = state;
		                st.animate(attrActive, 500);
		                st.insertBefore(cr.kraj141);
		                R.safari();
		            });
		            if ($.browser.msie){
						st[0].style.cursor = "pointer";
					}
				}
				else {
					st[0].style.cursor = "default";
				}
	        })(cr[state], state);
	    }
	});
};

