function withrequest(text,url)
{
	if (confirm(text)) {
		document.location.href=url;
	}
}

function PopupWnd(sUrl,sWndName,iWidth,iHeight,iScrollbars)
{
	window.open(sUrl,sWndName,'location=0,status=0,scrollbars=' + iScrollbars + ',location=0,menubar=0,resizable=1,width=' + iWidth + ',height=' + iHeight);
}

function init_tinymce () {
	tinyMCE.init({
		// General options
		language: "ru",
		mode : "specific_textareas",
		editor_selector : "mceEditor",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advlink,emotions,iespell,inlinepopups,insertdatetime,images,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,uppercase",
		valid_elements: '*[*]',

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,uppercase,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,|,insertdate,inserttime,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,help,code,preview",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		file_browser_callback : "tinyBrowser",

		//Path
		relative_urls : false,
		remove_script_host : true
	});
}

function count_chars(el)
{
	$('#' + el + '_counter').html($('#' + el).val().length);
}

function init_count_chars(el)
{
	$('#' + el).keyup(function () {count_chars(el)});
	count_chars(el);
}

function CreateBookmarkLink(title,url)
{
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	} else if(window.opera && window.print) { // Opera Hotlist
	}
	return true;
}

function add_basket(id,cat_id,type,el)
{
	$('#basket_container').load('/basket/add/?id=' + id + '&type=' + type + '&cat_id=' + cat_id);
	$(el).css('color','green').unbind('click').removeAttr('onclick').parent().css('background','none');
	$(el).find('img').remove();
}

$(document).ready(function () {
	$('.fancybox').fancybox();
});

function item_chars(id, sizes, weight, price, buy_opts)
{
	$('#item_chars_' + id).html('<p>Размер: ' + sizes + '</p>' +
    		'<p>Вес: ' + weight + '</p>' +
    		'<p class="center"><span>Цена от</span> <b>' + price + '</b> руб.</p>' +
    		'<p class="bot zak">' +
				'<a href="javascript:void(0)" onclick="$(\'#prices_' + id + '\').toggle()">Заказать</a></p>' +
				'<div id="prices_' + id + '" onclick="$(this).hide()">' + buy_opts +
				'</div>');
}
