// new_element_tr = document.createElement('TR');
// new_element_td = document.createElement('TD');
// new_element_td = document.createElement('INPUT');

/* -------------- */

window.onload = onload_start;

var marked_row = new Array;
var xml_http_obj = false;
var delivery = {};
var user_money_limit = 'unlim';
var focused_element;
var client_pc = navigator.userAgent.toLowerCase();
var client_ver = parseInt(navigator.appVersion);
var is_ie = ((client_pc.indexOf('msie') != -1) && (client_pc.indexOf('opera') == -1));
var is_win = ((client_pc.indexOf('win') != -1) || (client_pc.indexOf('16bit') != -1));

var reg_id = /^([a-z0-9_\-])+$/;
var reg_email = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,32})$/;
var reg_login = /^([A-Za-z0-9_\-\.])+$/;

function onload_start()
{
	mark_rows();
	on_focus();
}

function jq_modal_window(a_id, a_fadeIn, a_fadeTo, a_top, a_left)
{
	if ((a_fadeIn == undefined) || (a_fadeIn == null)) {
		a_fadeIn = 500;
	}
	if ((a_fadeTo == undefined) || (a_fadeTo == null)) {
		a_fadeTo = 0.3;
	}
	if ((a_top == undefined) || (a_top == null)) {
		a_top = 4;
	}
	if ((a_left == undefined) || (a_left == null)) {
		a_left = 2;
	}

	id = $('#'+a_id).get();

	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();

	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});

	//transition effect
	$('#mask').fadeTo('slow', a_fadeTo);

	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();

	//Set the popup window to center
	$(id).css('top',  winH/a_top-$(id).height()/a_top);
	$(id).css('left', winW/a_left-$(id).width()/a_left);

	//transition effect
	$(id).fadeIn(a_fadeIn);
	
	//if close button is clicked
	$('#'+a_id+' .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#mask').hide();
		$('#'+a_id).hide();
	});
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('#'+a_id).hide();
	});
}

function remove_from_id(a_id)
{
	var element = document.getElementById(a_id);
	element.parentNode.removeChild(element);
}

function submitenter(a_field, a_event)
{
	var keycode;
	if (window.event) {
		keycode = window.event.keyCode;
	} else if (a_event) {
		keycode = a_event.which;
	} else {
		return true;
	}
	if (keycode == 13) {
		a_field.form.submit();
		return false;
	} else {
		return true;
	}
}

function on_focus()
{
	var element;
	if (element = document.getElementById('form')) {
		element = element.elements;
		for (var i=0; i<element.length; i++) {
			if (element[i].type != 'button') {
				element[i].onfocus=function() {
					focused_element=this;
				}
			}
		}
	}
}

var tags = {
	'b':{'open':'<b>', 'close':'</b>'},
	'i':{'open':'<i>', 'close':'</i>'},
	'u':{'open':'<u>', 'close':'</u>'},
	'p':{'open':'<p>', 'close':'</p>'},
	'a':{'open':'<a href="">', 'close':'</a>'},
	'div':{'open':'<div>', 'close':'</div>'},
	'span':{'open':'<span>', 'close':'</span>'},
	'ol':{'open':'<ol>', 'close':'</ol>'},
	'ul':{'open':'<ul>', 'close':'</ul>'},
	'li':{'open':'<li>', 'close':'</li>'},
	'abbr':{'open':'<abbr title="" lang="">', 'close':'</abbr>'},
	'br':{'open':'<br />', 'close':false},
	'aquo':{'open':'«', 'close':'»'},
	'dquo':{'open':'“', 'close':'”'},
	'mdash':{'open':'—', 'close':false},
	'ndash':{'open':'–', 'close':false},
	'square':{'open':'²', 'close':false}
}


function input_tag(tag_name)
{
	if (tags[tag_name]['close']) {
		set_tags(tags[tag_name]['open'], tags[tag_name]['close']);
	} else {
		insert_text(tags[tag_name]['open']);
		focused_element.focus();
	}
}

function set_tags(tag_open, tag_close)
{
	theSelection = false;
	if (focused_element == undefined) {
		return;
	}
	focused_element.focus();
	if ((client_ver >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (theSelection) {
			document.selection.createRange().text = tag_open + theSelection + tag_close;
			focused_element.focus();
			theSelection = '';
			return;
		}
	} else if (focused_element.selectionEnd && (focused_element.selectionEnd - focused_element.selectionStart > 0)) {
		mozWrap(focused_element, tag_open, tag_close);
		focused_element.focus();
		theSelection = '';
		return;
	}
	var caret_pos = getCaretPosition(focused_element).start;
	var new_pos = caret_pos + tag_open.length;
	insert_text(tag_open + tag_close);
	if (!isNaN(focused_element.selectionStart)) {
		focused_element.selectionStart = new_pos;
		focused_element.selectionEnd = new_pos;
	} else if (document.selection) {
		var range = focused_element.createTextRange();
		range.move("character", new_pos); 
		range.select();
		storeCaret(focused_element);
	}
	focused_element.focus();
	return;
}

function insert_text(a_text)
{
	if (focused_element == undefined) {
		return;
	}
	if (!isNaN(focused_element.selectionStart)) {
		var sel_start = focused_element.selectionStart;
		var sel_end = focused_element.selectionEnd;
		mozWrap(focused_element, a_text, '')
		focused_element.selectionStart = sel_start + a_text.length;
		focused_element.selectionEnd = sel_end + a_text.length;
	} else if (focused_element.createTextRange && focused_element.caretPos) {
		if (baseHeight != focused_element.caretPos.boundingHeight) {
			focused_element.focus();
			storeCaret(focused_element);
		}
		var caret_pos = focused_element.caretPos;
		caret_pos.a_text = caret_pos.a_text.charAt(caret_pos.a_text.length - 1) == ' ' ? caret_pos.a_text + a_text + ' ' : caret_pos.a_text + a_text;
	} else {
		focused_element.value = focused_element.value + a_text;
	}
}

function bookmark(title, url) {
	if (title == undefined){
		title = document.title;
	}
	if (url == undefined){
		url = top.location.href;
	}
	if (window.sidebar) {
		window.sidebar.addPanel(title, url, '');
	} else if (window.opera && window.print) {
		var t = document.createElement('a');
		t.setAttribute('rel', 'sidebar');
		t.setAttribute('href', url);
		t.setAttribute('title', title);
		t.click();
	} else {
		window.external.AddFavorite(url, title);
	}
}

function add_panel_input(element, iteration)
{
	if(!control){
		num = iteration;
		control = true;
	}
	var active_row = document.getElementById('id_'+element+'_1');
	var button = document.getElementById(element+'_button');
	num += 1;
	for(var i = 1; i <= num; i++){
		if(!document.getElementById('id_'+element+'_' + i)){
			num = i;
			break;
		}
	}
	if (!current_tr)
	var cloned_row = active_row;
	cloned_row = active_row.cloneNode(true);
	cloned_row.id = 'id_'+element+'_' + num;
	var i=1;
	for(; i < languages.length; i++){
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[0].firstElementChild.setAttribute('for', 'poll_option[' + num + '][option_title_' + num + '][' + languages[i] + ']');
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[1].firstElementChild.setAttribute('name', 'poll_option[' + num + '][option_title_' + num + '][' + languages[i] + ']');
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[1].firstElementChild.setAttribute('id', 'poll_option[' + num + '][option_title_' + num + '][' + languages[i] + ']');
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[1].firstElementChild.value = '';
		cloned_row.getElementsByTagName('label')[1].innerHTML = lang['result'] + ' 0';
	}
	i--;
	active_row.parentNode.insertBefore(cloned_row, button);
	document.getElementById(element+'_result_'+num).innerHTML = ''; return 0;
}

function remove_panel_input(me)
{
	if (me.parentNode.parentNode.parentNode.parentNode.id.substr(-2) != '_1') {
		me.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(me.parentNode.parentNode.parentNode.parentNode);
	} else {
		var inputs = me.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (var i in inputs) {
			if (inputs[i].type == 'text') {
				inputs[i].value = '';
			}
		}
// 		me.parentNode.parentNode.cells[1].firstElementChild.value = '';
	}
}

function add_email(m)
{
	if(!control){
		num = m;
		control = true;
	}
	var active_row = document.getElementById('id_email_1');
	for (var end=0; end < 20; end++) {
		if (document.getElementById('id_email_'+end)) {
			var active_row = document.getElementById('id_email_'+end);
			break;
		}
	}
	var button = document.getElementById('email_button');
	num += 1;
	for(var i = 1; i <= num; i++){
		if(!document.getElementById('id_email_' + i)){
			num = i;
			break;
		}

	}
	if (!current_tr)
	var cloned_row = active_row;
	cloned_row = active_row.cloneNode(true);
	cloned_row.id = 'id_email_' + num;
	var i=1;
	for(; i < languages.length; i++){
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[0].firstElementChild.setAttribute('for', 'content_content[email_' + num + '][title][' + languages[i] + ']');
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[1].firstElementChild.setAttribute('name', 'content_content[email_' + num + '][title][' + languages[i] + ']');
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[1].firstElementChild.setAttribute('id', 'content_content[email_' + num + '][title][' + languages[i] + ']');
		cloned_row.getElementsByClassName('row_' + languages[i])[0].cells[1].firstElementChild.value ='';
	}
	i--;
	cloned_row.rows[i].cells[0].firstElementChild.setAttribute('for', 'email_' + num);
	cloned_row.rows[i].cells[1].firstElementChild.setAttribute('name', 'email_' + num);
	cloned_row.rows[i].cells[1].firstElementChild.setAttribute('id', 'email_' + num);
	cloned_row.rows[i].cells[1].firstElementChild.value ='';
	active_row.parentNode.insertBefore(cloned_row, button);
	return 0;
}

/**
* From http://www.massless.org/mozedit/
*/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	var scrollTop = txtarea.scrollTop;
	if (selEnd == 1 || selEnd == 2) {
		selEnd = selLength;
	}
	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	txtarea.selectionStart = selEnd + open.length + close.length;
	txtarea.selectionEnd = txtarea.selectionStart;
	txtarea.focus();
	txtarea.scrollTop = scrollTop;
	return;
}

function caretPosition()
{
	var start = null;
	var end = null;
}

function getCaretPosition(txtarea)
{
	var caretPos = new caretPosition();
	if(txtarea.selectionStart || txtarea.selectionStart == 0) {
		caretPos.start = txtarea.selectionStart;
		caretPos.end = txtarea.selectionEnd;
	} else if(document.selection) {
		var range = document.selection.createRange();
		var range_all = document.body.createTextRange();
		range_all.moveToElementText(txtarea);
		var sel_start;
		for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) {
			range_all.moveStart('character', 1);
		}
		txtarea.sel_start = sel_start;
		caretPos.start = txtarea.sel_start;
		caretPos.end = txtarea.sel_start;
	}
	return caretPos;
}

function check_id(a_id)
{
	var a_element;
	var a_type;
	if ((a_type = document.getElementById('structure_type_' + a_id)) && (a_type.value == 'url')) {
		if (menu_button_add = document.getElementById('menu_button_add')) {
			menu_button_add.disabled = '';
			return true;
		}
	}
	if (a_element = document.getElementById('structure_id_' + a_id)) {
		var menu_button_add;
		var l_label;
		if ((reg_id.test(a_element.value)) || (a_element.value == '@null@') || (a_element.type == 'hidden')) {
			if (l_label = document.getElementById('label_' + a_element.id)) {
				l_label.innerHTML = '';
			}
			if (menu_button_add = document.getElementById('menu_button_add')) {
				menu_button_add.disabled = '';
			}
		} else {
			if (l_label = document.getElementById('label_' + a_element.id)) {
				l_label.innerHTML = lang.use_only + ' \'a-z\', \'0-9\', \'_\', \'-\'';
			} else {
				alert('ID: ' + lang.use_only + ' \'a-z\', \'0-9\', \'_\', \'-\'');
			}
			if (menu_button_add = document.getElementById('menu_button_add')) {
				menu_button_add.disabled = 'disabled';
			}
		}
	}
}

function feedback_submit()
{
	var error = false;
	var personal_email;
	var nam = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var message = document.getElementById('message').value;
	var secure_code = document.getElementById('secure_code').value;

	if (personal_email = document.getElementById('personal_email')) {
		var personal_email = personal_email.value;
		var l_label = document.getElementById('label_personal_email');
		if (personal_email == 0) {
			l_label.innerHTML = lang.you_must_select_a_recipient;
			l_label.style.display = 'block';
			error = true;
		} else {
			l_label.innerHTML = '';
			l_label.style.display = 'none';
		}
	}

	var l_label = document.getElementById('label_name');
	if (nam == '') {
		l_label.innerHTML = lang.must_be_not_empty;
		l_label.style.display = 'block';
		error = true;
	} else {
		l_label.innerHTML = '';
		l_label.style.display = 'none';
	}

	var l_label = document.getElementById('label_email');
	if (email == '') {
		l_label.innerHTML = lang.must_be_not_empty;
		l_label.style.display = 'block';
		error = true;
	} else if(!reg_email.test(email)) {
		l_label.innerHTML = lang.incorrect_email;
		l_label.style.display = 'block';
		error = true;
	} else {
		l_label.innerHTML = '';
		l_label.style.display = 'none';
	}

	var l_label = document.getElementById('label_message');
	if (message == '') {
		l_label.innerHTML = lang.must_be_not_empty;
		l_label.style.display = 'block';
		error = true;
	} else {
		l_label.innerHTML = '';
		l_label.style.display = 'none';
	}

	var l_label = document.getElementById('label_secure_code');
	if (secure_code == '') {
		l_label.innerHTML = lang.must_be_not_empty;
		l_label.style.display = 'block';
		error = true;
	} else {
		l_label.innerHTML = '';
		l_label.style.display = 'none';
	}

	var frm;
	if (frm = document.getElementById('user_form')) {
		if (error == false) {
			frm.submit();
			return true;
		} else {
			return false;
		}
	}
}

function report_abuse()
{
	var item;
	var report_abuse = prompt(lang.report_abuse_about_the_content_page + ':\n' + document.location.href, '');
	if (report_abuse != null) {
		var parameters = 'report_abuse=' + encodeURI(report_abuse) + '&url=' + document.location.href;
		xml_http_obj = get_xml_http_object();
		xml_http_obj.open('POST', base + 'main/report_abuse', true);
		xml_http_obj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xml_http_obj.setRequestHeader('Content-length', parameters.length);
		xml_http_obj.setRequestHeader('Connection', 'close');
		xml_http_obj.send(parameters);
		alert(lang.your_report_abuse_has_been_sent);
		if (item = document.getElementById('reportabuse')) {
			item.parentNode.removeChild(item);
		}
	}
}

function remove_photo(a_id)
{
	var item;
	if (!confirm(lang.delete_confirm)) {
		return;
	}
	if (item = document.getElementById('photo_' + a_id)) {
		item.parentNode.removeChild(item);
	}
	xml_http_obj = get_xml_http_object();
	xml_http_obj.open('GET', base + 'photos/remove/' + a_id + '.html', true);
	xml_http_obj.send(null);
}



function disable_input(a_id)
{
	var l_element;
	if (l_element = document.getElementById(a_id)) {
		l_element.disabled = 'disabled';
	}
}

function enable_input(a_id)
{
	var l_element;
	if (l_element = document.getElementById(a_id)) {
		l_element.disabled = '';
	}
}

/* Select text id field */
function select_text(a_element)
{
	var content = eval(a_element);
	content.focus();
	content.select();
}

/* Reload security images */
function security_images_reload(a_id)
{
	var date = new Date();
	var uniq = date.getTime();
	var l_element = document.getElementById(a_id);
	l_element.src = base + lang_current + 'user/' + uniq + '/securityimages/';
}

function collapse_one_table_section(a_table, a_class)
{
	var l_table = document.getElementById(a_table);
	var l_rows = l_table.getElementsByTagName('TR');
	for(i = 0; i < l_rows.length; i++) {
		if (l_rows[i].className == a_class) {
			l_rows[i].style.display = '';
		} else if (l_rows[i].className != '') {
			l_rows[i].style.display = 'none';
		}
	}
}

/* Collapse table rows */
function collapse_table_section(a_table, a_class)
{
	var l_table = document.getElementById(a_table);
	var l_rows = l_table.getElementsByTagName('TR');
	var l_int = document.getElementById('id_tr_' + a_class);
	for(i = 0; i < l_rows.length; i++) {
		if (l_rows[i].className == a_class) {
			
			if ((l_rows[i].style.display == 'table-row') || (l_rows[i].style.display == '')) {
				l_rows[i].style.display = 'none';
				l_int.firstChild.nodeValue = '[+]';
			} else {
				l_rows[i].style.display = '';
				l_int.firstChild.nodeValue = '[-]';
			}
		}
	}
}

/* Collapse table rows on select input */
function collapse_table_select(a_select, a_table)
{
	var l_class = a_table + '_' + a_select.value;
	var l_table = document.getElementById(a_table);
	var l_rows = l_table.getElementsByTagName('TR');
	for (i = 0; i < l_rows.length; i++) {
		if ((l_rows[i].className == l_class) || (l_rows[i].className == a_table)) {
			l_rows[i].style.display = '';
		} else {
			l_rows[i].style.display = 'none';
		}
	}
}

/* Collapse table rows as tabs */
function collapse_table_tab(a_class, a_table_id)
{
	var l_table;
	if (l_table = document.getElementById('form_data_' + a_table_id)) {
		var l_rows = l_table.getElementsByTagName('TR');
		var l_tabs = document.getElementById('tabs_' + a_table_id);
		var l_a_tabs = l_tabs.getElementsByTagName('A');
		for (i = 0; i < l_a_tabs.length; i++) {
			if (l_a_tabs[i].id == ('tab_' + a_class)) {
				l_a_tabs[i].className = 'active';
			} else {
				l_a_tabs[i].className = null;
			}
		}
		for(i = 0; i < l_rows.length; i++) {
			if (l_rows[i].className == 'row_' + a_class) {
				l_rows[i].style.display = '';
			} else if (l_rows[i].className.substr(0, 4) == 'row_') {
				l_rows[i].style.display = 'none';
			}
		}
	}
}

/* Show element */
function element_show(a_id, a_display)
{
	var l_element;
	if (l_element = document.getElementById(a_id)) {
		l_element.style.display = a_display;
	}
}

/* Display or hide alternative input for field*/
function control_alternative_input(a_element, a_id)
{
	var base_element;
	var alternative_element;
	if (a_id != '') {
		a_id = '_' + a_id;
	}
	if ((base_element = document.getElementById(a_element + a_id)) && (alternative_element = document.getElementById(a_element + '_alternative' + a_id))) {
		if (base_element.value == '') {
			alternative_element.style.display = '';
			alternative_element.disabled = '';
		} else {
			alternative_element.style.display = 'none';
			alternative_element.disabled = 'disabled';
			alternative_element.value = '';
		}
	}
}

/* Set listener 'setphoto' onclick atelement - temporary function */
function set_listener(a_element)
{
	a_element.onclick = function(){setphoto(a_element);};
}

/* Create elements */
function create_elements(a_parent, a_nodes, id)
{
	for (var key in a_nodes) {
		var new_element = document.createElement(a_nodes[key].element);
		if ((a_nodes[key].attributes != undefined) && (typeof(a_nodes[key].attributes) == 'object')) {
			for (var attribute in a_nodes[key].attributes) {
				if ((id) && (((attribute == 'id') || (attribute == 'name') || (attribute == 'for')))) {
					if (a_nodes[key].element == 'tr') {
						new_element.setAttribute(attribute, a_nodes[key].attributes[attribute] + '[' + id + '][' + key + ']');
					} else {
						new_element.setAttribute(attribute, a_nodes[key].attributes[attribute] + '[' + id + ']');
					}
				} else {
					if ((attribute == 'class') && (navigator.appName == 'Microsoft Internet Explorer')) {
						new_element.setAttribute('className', a_nodes[key].attributes[attribute]);
					} else {
						new_element.setAttribute(attribute, a_nodes[key].attributes[attribute]);
					}
				}
			}
		}

		if (a_nodes[key].listeners != undefined) {
			for (var event in a_nodes[key].listeners) {
				var func = a_nodes[key].listeners[event];
				if (new_element.addEventListener) {
					new_element.addEventListener(event, a_nodes[key].listeners[event], false);
				} else if (new_element.attachEvent) {
					new_element.attachEvent('on' + event, a_nodes[key].listeners[event]);
				}
			}
		}

		if (a_nodes[key].textnode != undefined) {
			if (typeof(a_nodes[key].textnode) == 'object') {
				create_elements(new_element, a_nodes[key].textnode, id);
			} else if (a_nodes[key].textnode != '') {
				if (a_nodes[key].textnode == 'id') {
					var text_node = document.createTextNode(id);
				} else {
					var text_node = document.createTextNode(a_nodes[key].textnode);
				}
				new_element.appendChild(text_node);
			}
		}
		a_parent.appendChild(new_element);
	}
}

/* Cart form calculator */
function cart_form_calc(a_id)
{
	var frm;
	if ((frm = document.getElementById('cart_poducts')) || (frm = document.getElementById('cart_poducts_' + a_id))) {
		var el_price;
		var el_count;
		var el_total;
		if ((el_price = frm.elements['products_price[' + a_id + ']']) &&
			(el_count = frm.elements['products_count[' + a_id + ']']) &&
			(el_total = frm.elements['total[' + a_id + ']'])) {
			if ((el_price.value.length > 0) && (el_count.value.length > 0)){
				if (isNaN(parseInt(el_count.value))){
					el_count.value = 1;
				} else {
					el_count.value = parseInt(el_count.value);
				}
				var l_total = el_price.value * el_count.value;
				el_total.value = l_total.toFixed(2);
				var cart_products_count;
				if ((cart_products_count = document.getElementById('cart_products_count_' + a_id)) && (document.getElementById('total_sum'))) {
					cart_products_count.innerHTML = el_count.value;
				}
				if (document.getElementById('total_sum')) {
					xml_http_obj = get_xml_http_object();
					xml_http_obj.onreadystatechange = function()
					{
						if (xml_http_obj.readyState == 4) {
							if (xml_http_obj.status == 200) {
								if (xml_http_obj.responseText == 'true') {
									get_cart_sum();
								}
							}
						}
					}
					xml_http_obj.open('GET', base + lang_current + 'cart/' + a_id + '/products_count_update/' + el_count.value + '.html', true);
					xml_http_obj.send(null);
				}
			}
		}
	}
}

/* Calculete total from Cart form s*/
function cart_form_calc_total(cart_sum)
{
	var total_sum;
	if (total_sum = document.getElementById('total_sum')) {
		total_sum.value = cart_sum;
	}
	var l_cart_sum;
	var checkout_link;
	var checkout_text = '<a href="' + lang_current + 'cart/checkout">' + lang.checkout + '</a>';
	if ((l_cart_sum = document.getElementById('cart_sum')) && (checkout_link = document.getElementById('checkout_link'))) {
		l_cart_sum.innerHTML = checkout_text + ' ' + cart_sum;
	}

	var frm;
	if (frm = document.getElementById('cart_poducts')) {
		var base_element;
		if (base_element = document.getElementById('total_sum')) {
			total = 0;
			empty = true;
			for (i = 0; i < frm.length; i++){
				if (frm.elements[i].name.substr(0, 6) == 'total[') {
					empty = false;
					total += frm.elements[i].value * 1;
				}
			}
			frm.elements['total_sum'].value = total.toFixed(2);
			var l_cart_sum;
			var checkout_link;
			var checkout_text = '<a href="' + lang_current + 'cart/checkout">' + lang.checkout + '</a>';
			if ((l_cart_sum = document.getElementById('cart_sum')) && (checkout_link = document.getElementById('checkout_link'))) {
				l_cart_sum.innerHTML = checkout_text + ' ' + total.toFixed(2);
			}
			if (user_money_limit != 'unlim') {
				if (total > user_money_limit) {
					var checkout_text = lang.money_limit_over;
				}
				checkout_link.innerHTML = checkout_text;
			}
			if (empty) {
				var total_sum_box;
				if (total_sum_box = document.getElementById('total_sum_box')) {
					frm.removeChild(total_sum_box);
					var new_element = document.createElement('h2');
					new_element.appendChild(document.createTextNode(lang.empty));
					frm.appendChild(new_element);
				}
				var cart;
				var cart_block;
				if ((cart = document.getElementById('cart')) && (cart_block = document.getElementById('cart_block'))) {
					cart.parentNode.removeChild(cart);
					var new_element = document.createTextNode(lang.empty);
					cart_block.appendChild(new_element);
				}
			}
		}
	}
}

function get_user_money_limit()
{
	xml_http_obj = get_xml_http_object();
	xml_http_obj.onreadystatechange = function()
	{
		if (xml_http_obj.readyState == 4) {
			if (xml_http_obj.status == 200) {
				if (xml_http_obj.responseText != 'false') {
					user_money_limit = eval('(' + xml_http_obj.responseText + ')');
					get_cart_sum();
				}
			}
		}
	}
	xml_http_obj.open('GET', base + lang_current + 'cart/get_user_money_limit', true);
	xml_http_obj.send(null);
}


/* Set form action nad submit. Panel function */
function form_action(a_form_name, a_url, a_element, a_confirm, a_confirm_msg)
{
	var l_flag = true;
	var l_form;
	if ((l_form = document.forms[a_form_name]) || (l_form = document.getElementById(a_form_name))) {
		if (a_element) {
			for (var i = 0; i < l_form.elements.length; i++) {
				if (l_form.elements[i].checked) {
					if (a_confirm) {
						l_result = confirm(a_confirm_msg);
					} else {
						l_result = true;
					}
					if (l_result) {
						l_form.action = a_url;
						l_form.submit();
						return true;
					}
					l_flag = false;
				}
			}
			if (l_flag){
				alert(lang.you_do_not_choose);
			}
		} else {
			if (a_url) {
				l_form.action = a_url;
			}
			l_form.submit();
		}
	}
}

/* Set data to form and submit. Panel function */
function set_data_and_submit(a_form, a_el, a_data)
{
	var l_form;
	var l_el;
	if ((l_form = document.getElementById(a_form)) && (l_el = document.getElementById(a_el))) {
		l_el.value = a_data;
		l_form.submit();
	}
}

/* Set focus to element */
function set_focus(a_id)
{
	if (l_element = document.getElementById(a_id)) {
		l_element.select();
		l_element.focus();
	}
}

/* Mark table rows if class is row_dark or row_light for check checkbox input */
function mark_rows()
{
	var rows = document.getElementsByTagName('tr');
	for (var i = 0; i < rows.length; i++) {
		if ('row_dark' != rows[i].className.substr(0,8) && 'row_light' != rows[i].className.substr(0,9)) {
			continue;
		}
		if ( navigator.appName == 'Microsoft Internet Explorer' ) {
			// but only for IE, other browsers are handled by :hover in css
			rows[i].onmouseover = function() {
				this.className += ' hover';
			}
			rows[i].onmouseout = function() {
				this.className = this.className.replace( ' hover', '' );
			}
		}
		if (rows[i].className.search(/noclick/) != -1) {
			continue;
		}
		rows[i].onmousedown = function() {
			var unique_id;
			var checkbox;
			checkbox = this.getElementsByTagName( 'input' )[0];
			if (checkbox && checkbox.type == 'checkbox') {
				unique_id = checkbox.name + checkbox.value;
			} else if (this.id.length > 0) {
				unique_id = this.id;
			} else {
				return;
			}
			if (typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id]) {
				marked_row[unique_id] = true;
			} else {
				marked_row[unique_id] = false;
			}
			if (marked_row[unique_id]) {
				this.className += ' marked';
			} else {
				this.className = this.className.replace(' marked', '');
			}
			if (checkbox && checkbox.disabled == false) {
				checkbox.checked = marked_row[unique_id];
			}
		}
		var labeltag = rows[i].getElementsByTagName('label')[0];
		if (labeltag) {
			labeltag.onclick = function() {
				return false;
			}
		}
		var checkbox = rows[i].getElementsByTagName('input')[0];
		if (checkbox) {
			checkbox.onclick = function() {
				this.checked = ! this.checked;
			}
		}
	}
}

function checkElementsByClass(searchClass,node,tag,check) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			if(check == 'check'){
				els[i].checked = true;
			} else {
				els[i].checked = false;
			}
			classElements[j] = els[i];
			j++;
		}
	}
}

/* Mark all checkbox input */
function mark_all_rows(a_id)
{
	var rows = document.getElementById(a_id).getElementsByTagName('tr');
	var unique_id;
	var checkbox;
	for (var i = 0; i < rows.length; i++ ) {
		checkbox = rows[i].getElementsByTagName('input')[0];
		if (checkbox && checkbox.type == 'checkbox') {
			unique_id = checkbox.name + checkbox.value;
			if (checkbox.disabled == false) {
				checkbox.checked = true;
				if (typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id]) {
					rows[i].className += ' marked';
					marked_row[unique_id] = true;
				}
			}
		}
	}
}

/* Unmark all checkbox input */
function unmark_all_rows(a_id)
{
	var rows = document.getElementById(a_id).getElementsByTagName('tr');
	var unique_id;
	var checkbox;

	for (var i = 0; i < rows.length; i++ ) {
		checkbox = rows[i].getElementsByTagName('input')[0];
		if (checkbox && checkbox.type == 'checkbox') {
			unique_id = checkbox.name + checkbox.value;
			checkbox.checked = false;
			rows[i].className = rows[i].className.replace(' marked', '');
			marked_row[unique_id] = false;
		}
	}
}

function submit_delivery_form()
{
	var delivery_id;
	if (delivery_id = document.getElementById('orders_delivery_id')) {
		if (delivery_id.value == undefined) {
			alert(lang.for_this_location_delivery_is_absent);
			return;
		}  else if (delivery[delivery_id.value]['delivery_type'] == 'point') {
			var frm = document.getElementById('user_form');
			var progres_bar;
			if (progres_bar = document.getElementById('progres_bar')) {} else {
				progres_bar = false;
			}
			if (progres_bar) {
				progres_bar.style.display = 'block';
				frm.style.display = 'none';
			}
			frm.submit();
		} else {
			submit_user_form();
			return;
		}
	}
}

/* Validate user forms */
function submit_user_form(a_id, a_action, a_add_filds)
{
	var error = false;
	var filds = new Array();

	var filds_alternative = new Array();
	filds_alternative['user_city'] = 'user_city';

	var user_city = 'user_city';
	var user_city_alternative = 'user_city_alternative';

	if (typeof a_add_filds !== 'undefined') {
		filds[a_add_filds] = a_add_filds;
	}

	if ((typeof a_id !== 'undefined') && (a_id != '')) {
		for (var key in filds) {
			filds[key] += '[' + a_id + ']';
		}
		user_city += '[' + a_id + ']';
		user_city_alternative += '[' + a_id + ']';
	}

	var progres_bar;
	if (progres_bar = document.getElementById('progres_bar')) {} else {
		progres_bar = false;
	}

	if (frm = document.getElementById('user_form')) {
		for (i = 0; i < frm.length; i++) {
			var element = frm.elements[i];
			if ((element.required) && (element.value.length == 0)) {
				if (l_label = document.getElementById('label_' + element.id)) {
					l_label.innerHTML = lang.must_be_not_empty;
					l_label.style.display = 'block';
				} else {
					alert(element.name + ': ' + lang.must_be_not_empty);
				}
				error = true;
			} else {
				if (l_label = document.getElementById('label_' + element.id)) {
					l_label.innerHTML = '';
					l_label.style.display = 'none';
				}
			}
		}

/*
		for (var key in filds_alternative) {
			if (
					((element = frm.elements[filds_alternative[key]]) && (element.value.length == 0))
				&&
					((element_alternative = frm.elements[filds_alternative[key] + '_alternative']) && (element_alternative.value.length == 0))
				) {
				if (l_label = document.getElementById('label_' + filds_alternative[key])) {
					l_label.innerHTML = lang.must_be_not_empty;
					l_label.style.display = 'block';
				} else {
					alert(filds_alternative[key] + ': ' + lang.must_be_not_empty);
				}
				error = true;
			} else {
				if (l_label = document.getElementById('label_' + filds_alternative[key])) {
					l_label.innerHTML = '';
					l_label.style.display = 'none';
				}
			}
		}
*/

		if ((typeof frm.elements[filds['user_password']] !== 'undefined') && (typeof frm.elements[filds['user_repeat_password']] !== 'undefined')) {
			if (frm.elements[filds['user_password']].value != frm.elements[filds['user_repeat_password']].value) {
				if (l_label = document.getElementById('label_' + filds['user_repeat_password'])) {
					l_label.innerHTML = lang.password_fields_dont_match;
					l_label.style.display = 'block';
				} else {
					alert('user_repeat_password: ' + lang.password_fields_dont_match);
				}
				error = true;
			} else {
				if (l_label = document.getElementById('label_' + filds['user_repeat_password'])) {
					l_label.innerHTML = '';
					l_label.style.display = 'none';
				}
			}
		}

		if (typeof frm.elements[filds['user_email']] !== 'undefined') {
			if (reg_email.test(frm.elements[filds['user_email']].value)) {
				if (l_label = document.getElementById('label_' + filds['user_email'])) {
					l_label.innerHTML = '';
					l_label.style.display = 'none';
				}
			} else {
				if (l_label = document.getElementById('label_' + filds['user_email'])) {
					l_label.innerHTML = lang.incorrect_email;
					l_label.style.display = 'block';
				} else {
					alert('user_email: ' + lang.incorrect_email);
				}
				error = true;
			}
		}

		if (typeof frm.elements[filds['user_login']] !== 'undefined') {
			if (reg_login.test(frm.elements[filds['user_login']].value)) {
				if (l_label = document.getElementById('label_' + filds['user_login'])) {
					l_label.innerHTML = '';
					l_label.style.display = 'none';
				}
			} else {
				if (l_label = document.getElementById('label_' + filds['user_login'])) {
					l_label.innerHTML = lang.use_only + ' \'A-Z\', \'a-z\', \'0-9\', \'_\', \'-\', \'.\'';
					l_label.style.display = 'block';
				} else {
					alert('user_login: ' + lang.use_only + ' \'A-Z\', \'a-z\', \'0-9\', \'_\', \'-\', \'.\'');
				}
				error = true;
			}
		}

		if (
			((element = frm.elements[user_city_alternative]) && (element.value.length == 0))
			 && ((element2 = frm.elements[user_city]) && (element2.value.length == 0))
		) {
			if (l_label = document.getElementById('label_' + element2.id)) {
				l_label.innerHTML = lang.must_be_not_empty;
				l_label.style.display = 'block';
			} else {
				alert('user_city: ' + lang.must_be_not_empty);
			}
			error = true;
		} else {
			if (l_label = document.getElementById('label_' + user_city)) {
				l_label.innerHTML = '';
				l_label.style.display = 'none';
			}
		}

		if (!error) {
			if (progres_bar) {
				progres_bar.style.display = 'block';
				frm.style.display = 'none';
			}
			frm.submit();
		}
	}
}

/* Get XML HTTP Request Object */
function get_xml_http_object()
{
	try {
		xml_http_obj = new XMLHttpRequest();
	} catch (e) {
		try {
			xml_http_obj = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xml_http_obj = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xml_http_obj;
}

/* AJAX get delivery for location */
function get_cart_sum()
{
	xml_http_obj = get_xml_http_object();
	xml_http_obj.onreadystatechange = function()
	{
		if (xml_http_obj.readyState == 4) {
			if (xml_http_obj.status == 200) {
				var json = eval('(' + xml_http_obj.responseText + ')');
				cart_form_calc_total(json.toFixed(2));
			}
		}
	}
	xml_http_obj.open('GET', base + lang_current + 'cart/get_cart_sum/', true);
	xml_http_obj.send(null);
}

function get_http_user_search(a_user_search_form, a_user_search_field)
{
	var parameters = 'user_email=' + document.getElementById('search_user_email').value
		+ '&user_login=' + document.getElementById('search_user_login').value
		+ '&user_last_name=' + document.getElementById('search_user_last_name').value
		+ '&user_name=' + document.getElementById('search_user_name').value
		+ '&user_phone=' + document.getElementById('search_user_phone').value;

	var search_user_city = document.getElementById('search_user_city_alternative').value;
	if (search_user_city == '') {
		search_user_city = document.getElementById('search_user_city').value;
	}
	parameters += '&user_city=' + search_user_city;

	document.getElementById('search_result').innerHTML = '<tr><td colspan="4" align="center">' + lang.search_in_progress + '</td></tr>';
	xml_http_obj = get_xml_http_object();
	xml_http_obj.onreadystatechange = function()
	{
		if (xml_http_obj.readyState == 4) {
			var search_result = document.getElementById('search_result');
			search_result.innerHTML = '';
			var xmlDoc = xml_http_obj.responseXML.documentElement;
			var l_root = xmlDoc.getElementsByTagName('users');
			if (xmlDoc.getElementsByTagName('status')[0].childNodes[0].nodeValue == 'true') {
				for (i=0; i<l_root.length; i++) {
					user_id = xmlDoc.getElementsByTagName('user_id')[i].childNodes[0].nodeValue;
					user_email = xmlDoc.getElementsByTagName('user_email')[i].childNodes[0].nodeValue;
					user_last_name = xmlDoc.getElementsByTagName('user_last_name')[i].childNodes[0].nodeValue;
					user_name = xmlDoc.getElementsByTagName('user_name')[i].childNodes[0].nodeValue;
					search_result.innerHTML += '<tr><td align="center"><a href="javascript:set_data_and_submit(\'' + a_user_search_form + '\', \'' + a_user_search_field + '\', \'' + user_id + '\');">' + user_id + '</a></td><td>' + user_email + '</td><td>' + user_last_name + '</td><td>' + user_name + '</td></tr>';
				}
			} else {
				search_result.innerHTML += '<tr><td colspan="4" align="center">' + lang.nothing_found + '</td></tr>';
			}
		}
	}
	xml_http_obj.open('POST', base + lang_current + 'ajax/search_user/', true);
	xml_http_obj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xml_http_obj.setRequestHeader('Content-length', parameters.length);
	xml_http_obj.setRequestHeader('Connection', 'close');
	xml_http_obj.send(parameters);
}

/* AJAX get http products remove */
function get_http_products_remove(a_id)
{
	if ((frm = document.getElementById('cart_poducts')) && (el = document.getElementById('products_' + a_id))) {
		frm.removeChild(el);
	}
	if ((frm = document.getElementById('cart')) && (el = document.getElementById('cart_products_' + a_id))) {
		frm.removeChild(el);
	}
	xml_http_obj = get_xml_http_object();
	xml_http_obj.onreadystatechange = function()
	{
		if (xml_http_obj.readyState == 4) {
			if (xml_http_obj.status == 200) {
				if (xml_http_obj.responseText == 'true') {
					get_cart_sum();
				}
			}
		}
	}
	xml_http_obj.open('GET', base + lang_current + 'cart/products_remove/' + a_id + '.html', true);
	xml_http_obj.send(null);
}

/* AJAX get delivery for location */
function get_delivery(a_with_out_type, a_with_out_delivery_id)
{
	var user_location = document.getElementById('user_city');
	if (user_location.value != '') {
		var location_id = user_location.value + '.html';
	} else {
		var location_id = '';
	}
	xml_http_obj = get_xml_http_object();
	xml_http_obj.onreadystatechange = function()
	{
		if (xml_http_obj.readyState == 4) {
			if (xml_http_obj.status == 200) {
				var orders_delivery_box = document.getElementById('orders_delivery_box');
				if (orders_delivery_id = document.getElementById('orders_delivery_id')) {
					orders_delivery_box.removeChild(orders_delivery_id);
				}
				if (xml_http_obj.responseText != 'false') {
					var new_select = document.createElement('select');
					new_select.setAttribute('name', 'orders_delivery_id');
					new_select.setAttribute('id', 'orders_delivery_id');
					if (new_select.addEventListener) {
						new_select.addEventListener('change', delivery_control, false);
					} else if (new_select.attachEvent) {
						new_select.attachEvent('onchange', delivery_control);
					}
					orders_delivery_box.appendChild(new_select);
					var json = eval('(' + xml_http_obj.responseText + ')');
					delivery = {};
					for (var key in json) {
						delivery[json[key]['orders_delivery_id']] = json[key];
						var new_element = document.createElement('option');
						new_element.setAttribute('value', json[key]['orders_delivery_id']);
						if (json[key]['delivery_type'] == 'courier_service') {
							var l_title = '«' + json[key]['orders_delivery_title'] + '»';
						} else {
							var l_title = json[key]['orders_delivery_title'] + ' - ' + lang[json[key]['delivery_type']];
						}
						new_element.appendChild(document.createTextNode(l_title));
						new_select.appendChild(new_element);
					}
					delivery_control();
				} else {
					var new_div = document.createElement('div');
					new_div.setAttribute('id', 'orders_delivery_id');
					new_div.appendChild(document.createTextNode(lang.for_this_location_delivery_is_absent));
					orders_delivery_box.appendChild(new_div);
				}
			}
		}
	}
	var url = base + lang_current + 'ordersdelivery/locations/' + location_id;
	if (((a_with_out_type != undefined) || (a_with_out_type != '')) && ((a_with_out_delivery_id != undefined) || (a_with_out_delivery_id != ''))) {
		var parameters = 'with_out_type=' + a_with_out_type + '&with_out_delivery_id=' + a_with_out_delivery_id;
		xml_http_obj.open('POST', url, true);
		xml_http_obj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xml_http_obj.setRequestHeader('Content-length', parameters.length);
		xml_http_obj.setRequestHeader('Connection', 'close');
		xml_http_obj.send(parameters);
	} else {
		xml_http_obj.open('GET', url, true);
		xml_http_obj.send(null);
	}
}

/* Control delivery filds */
function delivery_control()
{
	if ((delivery_type = document.getElementById('orders_delivery_id')) && (delivery[delivery_type.value] != undefined)) {
		hidden_courier_filds(delivery[delivery_type.value]['delivery_type']);
		var order_sum;
		var delivery_sum;
		var order_sum;
		if ((order_sum = document.getElementById('order_sum')) && (delivery_sum = document.getElementById('delivery_sum'))) {
			if ((delivery[delivery_type.value]['orders_delivery_price_min']*1 == 0) || (order_sum.value*1 >= delivery[delivery_type.value]['orders_delivery_price_min']*1)) {
				delivery_sum.innerHTML = '0.00 ' + currency;
			} else {
				delivery_sum.innerHTML = delivery[delivery_type.value]['orders_delivery_price'] + ' ' + currency;
			}
		}
	}
}

function hidden_courier_filds(a_delivery_type)
{
	var l_table = document.getElementById('delivery');
	var l_rows = l_table.getElementsByTagName('TR');
	for (i = 0; i < l_rows.length; i++) {
		if ((a_delivery_type == 'point') && (l_rows[i].className == 'courier')) {
			l_rows[i].style.display = 'none';
		} else {
			l_rows[i].style.display = '';
		}
	}
}

/*	SWFObject v2.2 <http://code.google.com/p/swfobject/>
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();

// ?object=filetransmit&action=img_blueshoes_tree/plus3&object_id=gif

$(function() {
	$('.products_item a').lightBox({
		imageLoading: base + '?object=filetransmit&action=img_lightbox/lightbox-ico-loading&object_id=gif',
		imageBtnPrev: base + '?object=filetransmit&action=img_lightbox/lightbox-btn-prev&object_id=gif',
		imageBtnNext: base + '?object=filetransmit&action=img_lightbox/lightbox-btn-next&object_id=gif',
		imageBtnClose: base + '?object=filetransmit&action=img_lightbox/lightbox-btn-close&object_id=gif',
		imageBlank: base + '?object=filetransmit&action=img_lightbox/lightbox-blank&object_id=gif',
	});
});

/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.2N.3g=6(4){4=23.2H({2B:\'#34\',2g:0.8,1d:F,1M:\'18/5-33-Y.16\',1v:\'18/5-1u-2Q.16\',1E:\'18/5-1u-2L.16\',1W:\'18/5-1u-2I.16\',19:\'18/5-2F.16\',1f:10,2A:3d,2s:\'1j\',2o:\'32\',2j:\'c\',2f:\'p\',2d:\'n\',h:[],9:0},4);f I=N;6 20(){1X(N,I);u F}6 1X(1e,I){$(\'1U, 1S, 1R\').l({\'1Q\':\'2E\'});1O();4.h.B=0;4.9=0;7(I.B==1){4.h.1J(v 1m(1e.17(\'J\'),1e.17(\'2v\')))}j{36(f i=0;i<I.B;i++){4.h.1J(v 1m(I[i].17(\'J\'),I[i].17(\'2v\')))}}2n(4.h[4.9][0]!=1e.17(\'J\')){4.9++}D()}6 1O(){$(\'m\').31(\'<e g="q-13"></e><e g="q-5"><e g="5-s-b-w"><e g="5-s-b"><1w g="5-b"><e 2V="" g="5-k"><a J="#" g="5-k-V"></a><a J="#" g="5-k-X"></a></e><e g="5-Y"><a J="#" g="5-Y-29"><1w W="\'+4.1M+\'"></a></e></e></e><e g="5-s-b-T-w"><e g="5-s-b-T"><e g="5-b-A"><1i g="5-b-A-1t"></1i><1i g="5-b-A-1g"></1i></e><e g="5-1s"><a J="#" g="5-1s-22"><1w W="\'+4.1W+\'"></a></e></e></e></e>\');f z=1D();$(\'#q-13\').l({2K:4.2B,2J:4.2g,S:z[0],P:z[1]}).1V();f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]}).E();$(\'#q-13,#q-5\').C(6(){1a()});$(\'#5-Y-29,#5-1s-22\').C(6(){1a();u F});$(G).2G(6(){f z=1D();$(\'#q-13\').l({S:z[0],P:z[1]});f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]})})}6 D(){$(\'#5-Y\').E();7(4.1d){$(\'#5-b,#5-s-b-T-w,#5-b-A-1g\').1b()}j{$(\'#5-b,#5-k,#5-k-V,#5-k-X,#5-s-b-T-w,#5-b-A-1g\').1b()}f Q=v 1j();Q.1P=6(){$(\'#5-b\').2D(\'W\',4.h[4.9][0]);1N(Q.S,Q.P);Q.1P=6(){}};Q.W=4.h[4.9][0]};6 1N(1o,1r){f 1L=$(\'#5-s-b-w\').S();f 1K=$(\'#5-s-b-w\').P();f 1n=(1o+(4.1f*2));f 1y=(1r+(4.1f*2));f 1I=1L-1n;f 2z=1K-1y;$(\'#5-s-b-w\').3f({S:1n,P:1y},4.2A,6(){2y()});7((1I==0)&&(2z==0)){7($.3e.3c){1H(3b)}j{1H(3a)}}$(\'#5-s-b-T-w\').l({S:1o});$(\'#5-k-V,#5-k-X\').l({P:1r+(4.1f*2)})};6 2y(){$(\'#5-Y\').1b();$(\'#5-b\').1V(6(){2u();2t()});2r()};6 2u(){$(\'#5-s-b-T-w\').38(\'35\');$(\'#5-b-A-1t\').1b();7(4.h[4.9][1]){$(\'#5-b-A-1t\').2p(4.h[4.9][1]).E()}7(4.h.B>1){$(\'#5-b-A-1g\').2p(4.2s+\' \'+(4.9+1)+\' \'+4.2o+\' \'+4.h.B).E()}}6 2t(){$(\'#5-k\').E();$(\'#5-k-V,#5-k-X\').l({\'K\':\'1C M(\'+4.19+\') L-O\'});7(4.9!=0){7(4.1d){$(\'#5-k-V\').l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9-1;D();u F})}j{$(\'#5-k-V\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9-1;D();u F})}}7(4.9!=(4.h.B-1)){7(4.1d){$(\'#5-k-X\').l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9+1;D();u F})}j{$(\'#5-k-X\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9+1;D();u F})}}2k()}6 2k(){$(d).30(6(12){2i(12)})}6 1G(){$(d).11()}6 2i(12){7(12==2h){U=2Z.2e;1x=27}j{U=12.2e;1x=12.2Y}14=2X.2W(U).2U();7((14==4.2j)||(14==\'x\')||(U==1x)){1a()}7((14==4.2f)||(U==37)){7(4.9!=0){4.9=4.9-1;D();1G()}}7((14==4.2d)||(U==39)){7(4.9!=(4.h.B-1)){4.9=4.9+1;D();1G()}}}6 2r(){7((4.h.B-1)>4.9){2c=v 1j();2c.W=4.h[4.9+1][0]}7(4.9>0){2b=v 1j();2b.W=4.h[4.9-1][0]}}6 1a(){$(\'#q-5\').2a();$(\'#q-13\').2T(6(){$(\'#q-13\').2a()});$(\'1U, 1S, 1R\').l({\'1Q\':\'2S\'})}6 1D(){f o,r;7(G.1h&&G.28){o=G.26+G.2R;r=G.1h+G.28}j 7(d.m.25>d.m.24){o=d.m.2P;r=d.m.25}j{o=d.m.2O;r=d.m.24}f y,H;7(Z.1h){7(d.t.1l){y=d.t.1l}j{y=Z.26}H=Z.1h}j 7(d.t&&d.t.1A){y=d.t.1l;H=d.t.1A}j 7(d.m){y=d.m.1l;H=d.m.1A}7(r<H){1z=H}j{1z=r}7(o<y){1B=o}j{1B=y}21=v 1m(1B,1z,y,H);u 21};6 1p(){f o,r;7(Z.1Z){r=Z.1Z;o=Z.2M}j 7(d.t&&d.t.1F){r=d.t.1F;o=d.t.1Y}j 7(d.m){r=d.m.1F;o=d.m.1Y}2q=v 1m(o,r);u 2q};6 1H(2C){f 2x=v 2w();1q=2h;3h{f 1q=v 2w()}2n(1q-2x<2C)};u N.11(\'C\').C(20)}})(23);',62,204,'||||settings|lightbox|function|if||activeImage||image||document|div|var|id|imageArray||else|nav|css|body||xScroll||jquery|yScroll|container|documentElement|return|new|box||windowWidth|arrPageSizes|details|length|click|_set_image_to_view|show|false|window|windowHeight|jQueryMatchedObj|href|background|no|url|this|repeat|height|objImagePreloader|arrPageScroll|width|data|keycode|btnPrev|src|btnNext|loading|self||unbind|objEvent|overlay|key||gif|getAttribute|images|imageBlank|_finish|hide|left|fixedNavigation|objClicked|containerBorderSize|currentNumber|innerHeight|span|Image|bind|clientWidth|Array|intWidth|intImageWidth|___getPageScroll|curDate|intImageHeight|secNav|caption|btn|imageBtnPrev|img|escapeKey|intHeight|pageHeight|clientHeight|pageWidth|transparent|___getPageSize|imageBtnNext|scrollTop|_disable_keyboard_navigation|___pause|intDiffW|push|intCurrentHeight|intCurrentWidth|imageLoading|_resize_container_image_box|_set_interface|onload|visibility|select|object|top|embed|fadeIn|imageBtnClose|_start|scrollLeft|pageYOffset|_initialize|arrayPageSize|btnClose|jQuery|offsetHeight|scrollHeight|innerWidth||scrollMaxY|link|remove|objPrev|objNext|keyToNext|keyCode|keyToPrev|overlayOpacity|null|_keyboard_action|keyToClose|_enable_keyboard_navigation|right|hover|while|txtOf|html|arrayPageScroll|_preload_neighbor_images|txtImage|_set_navigation|_show_image_data|title|Date|date|_show_image|intDiffH|containerResizeSpeed|overlayBgColor|ms|attr|hidden|blank|resize|extend|close|opacity|backgroundColor|next|pageXOffset|fn|offsetWidth|scrollWidth|prev|scrollMaxX|visible|fadeOut|toLowerCase|style|fromCharCode|String|DOM_VK_ESCAPE|event|keydown|append|of|ico|000|fast|for||slideDown||100|250|msie|400|browser|animate|lightBox|do'.split('|'),0,{}))
