// 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));

function onload_start()
{
	mark_rows();
	on_focus();
}

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':'”'}
}

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 add_email(m)
{
	if(!control){
		num = m;
		control = true;
	}
	var active_row = document.getElementById('id_email_1');
	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.setAttribute('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.setAttribute('value', '');
	active_row.parentNode.insertBefore(cloned_row, button);
	return 0;
}
function _removeEmail(me)
{
	if(me.parentNode.parentNode.parentNode.parentNode.id != 'id_email_1'){
		me.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(me.parentNode.parentNode.parentNode.parentNode);
	} else {
		document.getElementById('emails_block').parentNode.removeChild(document.getElementById('emails_block'));
	}
}

/**
* 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_element)
{
	var menu_button_add;
	var l_label;
	var reg_id = /^([a-z0-9_\-:/\.])+$/;
	if ((reg_id.test(a_element.value)) || (a_element.value.length == 0)) {
		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 personal_email = document.getElementById('personal_email').value;
	var nam = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var message = document.getElementById('message').value;
	var error = false;
	var reg_email = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(personal_email == 0){
		document.getElementById('label_personal_email').innerHTML = lang.you_must_select_a_recipient;
		error = true;
	} else {
		document.getElementById('label_personal_email').innerHTML = '';
	}
	if(nam == ''){
		document.getElementById('label_name').innerHTML = lang.must_be_not_empty;
		error = true;
	} else {
		document.getElementById('label_name').innerHTML = '';
	}
	if(email == ''){
		document.getElementById('label_email').innerHTML = lang.must_be_not_empty;
		error = true;
	} else if(!reg_email.test(email)) {
		document.getElementById('label_email').innerHTML = lang.incorrect_email;
		error = true;
	} else {
		document.getElementById('label_email').innerHTML = '';
	}
	if(message == ''){
		document.getElementById('label_message').innerHTML = lang.must_be_not_empty;
		error = true;
	} else {
		document.getElementById('label_message').innerHTML = '';
	}
	if(error == false){
		document.feedback_form.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 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.open('GET', base + lang_current + 'cart/' + a_id + '/products_count_update/' + el_count.value + '.html', true);
					xml_http_obj.send(null);
				}
			}
		}
		cart_form_calc_total();
	}
}

/* Calculete total from Cart form s*/
function cart_form_calc_total()
{
	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 cart_sum;
			var checkout_link;
			if ((cart_sum = document.getElementById('cart_sum')) && (checkout_link = document.getElementById('checkout_link'))) {
				cart_sum.innerHTML = total.toFixed(2);
			}
			if (user_money_limit != 'unlim') {
				if (total > user_money_limit) {
					checkout_link.innerHTML = lang.money_limit_over;
				} else {
					checkout_link.innerHTML = '<a href="' + lang_current + 'cart/checkout">' + lang.checkout + '</a>';
				}
			}
			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 + ')');
					cart_form_calc_total();
				}
			}
		}
	}
	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)
{
	l_flag = true;
	if (l_form = document.forms[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;
		}
	}
}

/* Validate user forms */
function submit_user_form(a_id, a_action, a_add_filds)
{
	var error = false;
	var filds = new Array();
	filds['photo_num'] = 'photo_num';
	filds['secure_code'] = 'secure_code';
	filds['user_email'] = 'user_email';
	filds['user_login'] = 'user_login';
	filds['user_last_name'] = 'user_last_name';
	filds['user_name'] = 'user_name';
	filds['user_patronymic'] = 'user_patronymic';
// 	filds['user_appointment'] = 'user_appointment';
// 	filds['user_city'] = 'user_city';
	filds['user_street'] = 'user_street';
	filds['user_house_number'] = 'user_house_number';
	filds['user_room_number'] = 'user_room_number';
	filds['user_phone'] = 'user_phone';
	filds['user_mobile'] = 'user_mobile';

	if (a_action == 'create') {
		filds['user_password'] = 'user_password';
		filds['user_repeat_password'] = 'user_repeat_password';
	}

	var filds_alternative = new Array();
	filds_alternative['user_counteragent'] = 'user_counteragent';
	filds_alternative['user_departments'] = 'user_departments';
	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')) {
		var delivery_id = document.getElementById('orders_delivery_id');
		if (delivery_id != null && delivery_id.type != 'hidden' && (delivery[delivery_id.value]['delivery_type'] == 'point')) {
			if (progres_bar) {
				progres_bar.style.display = 'block';
				frm.style.display = 'none';
			}
			frm.submit();
			return;
		}

		for (var key in filds) {
			if ((element = frm.elements[filds[key]]) && (element.value.length == 0) && (element.type != 'hidden')) {
				if (l_label = document.getElementById('label_' + filds[key])) {
					l_label.innerHTML = lang.must_be_not_empty;
				} else {
					alert(filds[key] + ': ' + lang.must_be_not_empty);
				}
				error = true;
			} else {
				if (l_label = document.getElementById('label_' + filds[key])) {
					l_label.innerHTML = '';
				}
			}
		}

		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;
				} 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 = '';
				}
			}
		}

		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;
				} 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 = '';
				}
			}
		}

		if (typeof frm.elements[filds['user_email']] !== 'undefined') {
			var reg_email = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			if (reg_email.test(frm.elements[filds['user_email']].value)) {
				if (l_label = document.getElementById('label_' + filds['user_email'])) {
					l_label.innerHTML = '';
				}
			} else {
				if (l_label = document.getElementById('label_' + filds['user_email'])) {
					l_label.innerHTML = lang.incorrect_email;
				} else {
					alert('user_email: ' + lang.incorrect_email);
				}
				error = true;
			}
		}

		if (typeof frm.elements[filds['user_login']] !== 'undefined') {
			var reg_login = /^([A-Za-z0-9_\-\.])+$/;
			if (reg_login.test(frm.elements[filds['user_login']].value)) {
				if (l_label = document.getElementById('label_' + filds['user_login'])) {
					l_label.innerHTML = '';
				}
			} else {
				if (l_label = document.getElementById('label_' + filds['user_login'])) {
					l_label.innerHTML = lang.use_only + ' \'A-Z\', \'a-z\', \'0-9\', \'_\', \'-\', \'.\'';
				} 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_' + user_city)) {
				l_label.innerHTML = lang.must_be_not_empty;
			} else {
				alert('user_city: ' + lang.must_be_not_empty);
			}
			error = true;
		} else {
			if (l_label = document.getElementById('label_' + user_city)) {
				l_label.innerHTML = '';
			}
		}
		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;
}

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);
		}
		cart_form_calc_total();
		xml_http_obj = get_xml_http_object();
		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 = '';
		}
	}
}

/* AJAX get http departments */
function get_http_departments(a_id)
{
	var user_counteragents = document.getElementById('user_counteragent_' + a_id);
	var user_departments = document.getElementById('user_departments_' + a_id);
	user_departments.innerHTML = '';
/*
	if (user_counteragents.value == '') {
		var new_element = document.createElement('option');
		new_element.setAttribute('value', '');
		new_element.appendChild(document.createTextNode(lang.other));
		user_departments.appendChild(new_element);
		control_alternative_input('user_departments', a_id);
		return;
	}
*/
	xml_http_obj = get_xml_http_object();
	xml_http_obj.onreadystatechange = function()
	{
		if (xml_http_obj.readyState == 4) {
			var xmlDoc = xml_http_obj.responseXML.documentElement;
			var l_root = xmlDoc.getElementsByTagName('departments_item');
			var user_id = xmlDoc.getElementsByTagName('user_id')[0].childNodes[0].nodeValue;
			var user_departments = document.getElementById('user_departments_' + user_id);
			var user_departments_hidden = document.getElementById('user_departments_hidden_' + user_id);
			if (xmlDoc.getElementsByTagName('departments_status')[0].childNodes[0].nodeValue == 'true') {
				var new_element = document.createElement('option');
				new_element.setAttribute('value', '');
				new_element.appendChild(document.createTextNode(lang.other));
				user_departments.appendChild(new_element);
				for (i=0; i < l_root.length; i++) {
					l_id = xmlDoc.getElementsByTagName('departments_id')[i].childNodes[0].nodeValue;
					l_title = xmlDoc.getElementsByTagName('departments_name')[i].childNodes[0].nodeValue;
					var new_element = document.createElement('option');
					new_element.setAttribute('value', l_id);
					new_element.appendChild(document.createTextNode(l_title));
					if (user_departments_hidden.value == l_id) {
						new_element.setAttribute('selected', 'selected');
					}
					user_departments.appendChild(new_element);
				}
				if (user_alternativ = document.getElementById('user_departments_alternative_' + user_id)) {
					user_alternativ.value = '';
					control_alternative_input('user_departments', user_id);
				}
			}
		}
	}
	xml_http_obj.open('GET', base + lang_current + 'departments/get_list/' + user_counteragents.value + '.html', true);
	xml_http_obj.send(null);
}

function _addEmail(){
			var active_row = document.getElementById('id_email_' + num);
			var button =	 document.getElementById('email_button');
			var numb = active_row.lastIndexOf;
			var id = active_row.id;
			
			num = id[id.length - 1] * 1 + 1;

			if (!current_tr)
			var cloned_row = active_row.cloneNode(true);
			cloned_row.id = 'id_email_' + num;
			var td = cloned_row.cells;
			td[0].firstElementChild.setAttribute('for', 'email_' + num);
			td[1].firstElementChild.setAttribute('name', 'email_' + num);
			td[1].firstElementChild.setAttribute('id', 'email_' + num);
			active_row.parentNode.insertBefore(cloned_row, button);
			return 0;
		}


/*	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}}}}();