var site = {};

site.utils = {};
site.utils.getObjectType = function(obj) {
	var toString = Object.prototype.toString,
		obj_type = false;
	switch (toString.call(obj)) {
		case "[object Array]": obj_type = 'array'; break;
		case "[object Object]": obj_type = 'object'; break;
		case "[object String]": obj_type = 'string'; break;
		case "[object Number]": obj_type = 'number'; break;
		case "[object Boolean]": obj_type = 'boolean'; break;
		case "[object Function]": obj_type = 'function'; break;
	}
	return obj_type;
};

site.utils.js = {};
site.utils.js.init = function(src) {
	switch (site.utils.getObjectType(src)) {
		case "array": for (i in src) this.init(src[i]); break;
		case "string": this.include(src); break;
	}
	return true;
};

site.utils.js.include = function(src) {
	jQuery("<script/>", {
		"charset" : 'utf-8',
		"type"    : 'text/javascript',
		"src"     : src
	}).appendTo("head");
};

site.utils.js.init([
	'/js/client/basket.js',
	'/templates/rcb/js/basket.js',
	'/templates/rcb/js/forms.js',
	'/templates/rcb/js/message.js',
	'/templates/rcb/js/captcha.js'
]);

jQuery(document).ready(function(){
	
	jQuery('#on_edit_in_place').click(function() {
		uAdmin.eip.swapEditor();
		return false;
	});
	
	if (typeof localStorage != 'undefined') {
		if (localStorage.catalog == 'list_view') {
			jQuery('.catalog').addClass('list_view');
			jQuery('.change .list').addClass('act');
			jQuery('.slab').removeClass('act');
		}
	}
	
	jQuery('.catalog .change div').click(function() {
		if (!jQuery(this).hasClass('act')) {
			jQuery('div', this.parentNode).removeClass('act');
			jQuery(this).addClass('act');
			if (jQuery(this).hasClass('list')) {
				jQuery('.catalog').addClass('list_view');
				localStorage.catalog = 'list_view' ;
			}
			else {
				jQuery('.catalog').removeClass('list_view');
				localStorage.catalog = '' ;
			}
		}
	});
});