if (typeof console == 'undefined') {
	console = {};
	console.log = function() {
	};
	console.error = function() {
	};
	console.info = function() {
	};
}
API.defaultContent.set({label: '#searchBox label'});
API.menu.create();
API.menu.create({
	menu: '.navigation',
	children: '.children',
	hover: 'hover'
});
API.carousel.create();
$(document).ready(function(){
	Cufon.replace('h1:not(.ignore),h2:not(.ignore),h3:not(.ignore),p.title:not(.ignore),.replace');
	setTimeout(function(){
		$('#body .box, .shadow').boxShadow( 2, 2, 2, "#444" );			
	},20);
	
	$('li.comments').click(function(){
		var elm = $(this);
		if(!elm.hasClass('comments_opened')){
			$(this).addClass('comments_opened');
			$('div.comments').slideDown();	
		}else{
			$('div.comments').slideUp();
			$(this).removeClass('comments_opened');	
		}
		return false;
	});
});

$(document).ajaxSuccess(function() {
	Cufon.refresh();
	API.menu.create();
	API.menu.create({
		menu: '.productDescription .navigation,.product .navigation',
		children: '.children',
		hover: 'hover'
	});
	//ajax popup form
	API.ajaxform.create({
		container: '.tl_cnt.ajaxContent:first',
		pagination: false
	});
});
//products
API.ajaxform.create({
	form: null,
	container: 'body:not(.shop_check) #main.ajaxContent:first',
	select: '#main'
});
//microcheck
API.ajaxform.create({
	container: '.shop_check #main.ajaxContent:first' 
});
API.rows = new function(){	
	
	this.create = function(params){
		return new rows(params);		
	}	

	var rows = function(params){
		
		var instance = this;
	    this.params = {
			boxes: '.microCheck .categories .category'	             
	    };
	    
	    $.extend(this.params, params);
	    
	    this.init = function(){
	        var boxes = $(instance.params.boxes);	        
	        var height = 0;

	        boxes.each(function(){
	        	var el = $(this);
	        	var size = {};
	            size.height = el.height();
	            height = (size.height > height) ? size.height : height;        
	        });
	        boxes.each(function(){
	        	var el = $(this);
	            el.css('height', height);
	        }); 
	    }
		
		$(document).ready(function(){
			instance.init();			
		});
		
	}
}
API.rows.create();

$(document).ready(function() {	
	$('a.toplayer').click(function(){
		
		var url = $(this).attr('href');
		var title = $(this).attr('title');
		if(url != null){			
			API.toplayer.add({
				url: url,
				buttons: {
					test: {
						label: 'Test',
                        href: 'test',
                        cssClass: 'TEST',
                        action: function(e,i){
                        	i.close();
                        }  
					}
				},
				layer: {
					label: title
				}
			});			
		}
		return false;				
	});	
});



