// Preview in new window
function preview(link, title) {
	var	id = Math.floor(Math.random() * 1000 + 1), // random ID for IE 6-
		win = window.open('', 'win'+ id, 'top=50, left=200, width='+ 300 +', height='+ 300 +', toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes');
	win.document.write(
		'<html>'+
			'<head>'+
				'<title>' + (title || '') + '</title>'+
				'<style type="text/css">* {margin: 0; padding: 0; border: 0; font: 0 none;}</style>'+
			'<head>'+
			'<body>'+
				'<a href="#" onclick="window.close()">'+
					'<img src="'+ link +'" alt="" onload="if ('+ $.browser.mozilla +') {window.resizeTo(this.width + 30, this.height + 30); window.resizeTo(this.width + 8, this.height + 53)} else window.resizeTo(this.width, this.height)" />'+
				'</a>'+
			'</body>'+
		'</html>'
	);
	win.document.close();
}

$(document).ready(function() {
	// hide
	$('head').append('<style type="text/css">.submenu, .big ul, .faq dd.answer, ul.togshoplists{display: none;}</style>');

	// Menu
	$('#header .menu li').hover(
		function() {$(this).find('div').show()},
		function() {$(this).find('div').hide()}
	);

	// Models list
	$('.big > li > a').click(function() {
		$(this).parents('ul').find('ul').hide();
		$(this).parents('li').find('ul').toggle();
		return false;
	});

	// FAQ
	$('.faq a.button, .faq dt.question a').click(function() {
		$(this).parents('dl').find('dd.answer').toggle();
		return false;
	});

        //where2buy
	$('.shlist > li > a').click(function() {
		$(this).parents('li').find('ul').toggle();
		return false;
	});


	// Product thumbnails
	$('.product .image a').click(function() {
		preview($(this).attr('href'));
		return false;
	});
	$('.product .thumbnails a').click(function() {
		$(this).parents('.images').find('.image')
			.find('a')
				.attr('href', $(this).attr('href'))
			.find('img')
				.attr('src', $(this).attr('href').replace('big', 'middle'))
		$(this).parents('ul').find('li')
			.removeClass('active')
		$(this).parents('li')
			.addClass('active');
		return false;
	});

	// Operating mode
	$('div.operating-mode .description')
		.hide()
		.eq(0).show();
	$('div.operating-mode li').eq(0)
		.addClass('active');
	$('div.operating-mode li a').click(function(num) {
		$(this).parents('ul').find('li')
			.removeClass('active');
		$(this).parents('li')
			.addClass('active');
		$(this).parents('.operating-mode').find('.description')
			.hide();
		$($(this).attr('href'))
			.show();
		return false;
	});
});


