// --------------------------------------------------------------
function bookmark_uni(url, title) {
	if (!url) {
		url = 'http://intim-magazin.com.ua/';
	}
	if (!title) {
		title = 'Секс Шоп Intim-Magazin.com.ua';
	}
	if (document.all) {
		window.external.addFavorite(url, title);
	} else if (window.sidebar && window.sidebar.addPanel) {
		window.sidebar.addPanel(title, url, '');
	}
}
// --------------------------------------------------------------
function jmp(url) {
	window.location.href = url;
}
// --------------------------------------------------------------
function cursor_wait(obj) {
	if (obj) {
		obj.style.cursor = 'wait';
		obj.style.color = '#777777';
	}
	document.body.style.cursor = 'wait';
}
// --------------------------------------------------------------
function ss_default(obj) {
	obj.src = '/images/ss_default.jpg';
	obj.onerror = null;
}
// --------------------------------------------------------------
var removedPaymentMethod = null;
function refreshPaymentMethod(init) {
	var obj = document.getElementById('delivery_id');
	var payment = document.getElementById('payment_id');
	if (obj.value == 3 || document.getElementById('country_id').value != 1) {
		if (!removedPaymentMethod) {
			removedPaymentMethod = payment.options[0];
			payment.options[0] = null;
			if (!init) {
				if (obj.value == 3) {
					payment.options[1].selected = true;
				} else {
					payment.options[0].selected = true;
				}
			}
		}
	} else if (removedPaymentMethod) {
		payment.options[2] = new Option(payment.options[1].text,
				payment.options[1].value);
		payment.options[1] = new Option(payment.options[0].text,
				payment.options[0].value);
		payment.options[0] = removedPaymentMethod;
		removedPaymentMethod = null;
		if (!init) {
			payment.options[0].selected = true;
		}
	}

}
var removedDeliveryMethods = null;
function refreshDeliveryMethod(init) {
	var obj = document.getElementById('country_id');
	var delivery = document.getElementById('delivery_id');
	if (obj.value != 1) {
		if (!removedDeliveryMethods) {
			removedDeliveryMethods = [ delivery.options[0], delivery.options[2] ];
			delivery.options[0] = null;
			delivery.options[1] = null;
			if (!init) {
				delivery.options[0].selected = true;
			}
		}
	} else if (removedDeliveryMethods) {
		delivery.options[1] = new Option(delivery.options[0].text,
				delivery.options[0].value);
		delivery.options[2] = removedDeliveryMethods[1];
		delivery.options[0] = removedDeliveryMethods[0];
		removedDeliveryMethods = null;
		if (!init) {
			delivery.options[0].selected = true;
		}
	}
	refreshPaymentMethod(init);
}
// --------------------------------------------------------------
function selectCurrency(code) {
	window.location.href = '/currency?code=' + code + '&return='
			+ encodeURIComponent(document.URL);
}
// --------------------------------------------------------------
function decode64(input) {
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output = output + String.fromCharCode(chr1);

		if (enc3 != 64) {
			output = output + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			output = output + String.fromCharCode(chr3);
		}
	} while (i < input.length);

	return output;
}
// --------------------------------------------------------------
function decodeEmail(data, id) {
	var email = '';
	for ( var i = data.length - 1; i >= 0; i--) {
		email += data.charAt(i);
	}
	email = decode64(email);
	document.write('<a href="mailto:' + email + '?subject='
			+ encodeURIComponent(location.href) + '">'
			+ email + '</a>');
}
// --------------------------------------------------------------