$(document).ready(function() {
	//alert($('select .battyp_typ'));
	//boatSwitchlist($('select .battyp_typ'));
	$('#thumbnails').thumbnails();
	//$('#cart tr.new').animateToCart();

	$('div.boatlog div.headers').click(function() {
    	var id = $(this).attr('name');
    	$('#content-'+id).slideToggle('slow');
    	return false;
	});

	$('div.boatlog a.showAll').click(function() {
		$('div.boatlog div.content').show();
    	return false;
	});
	
	$('div.boatlog a.hideAll').click(function() {
		$('div.boatlog div.content').hide();
    	return false;
	});
	
	$('a.buyme').click(function() {
		var code = $(this).attr('code');
		var extra = '';
		if (code) {
			extra ='?code='+code;
		}
		newwindow=window.open('/kopinformation.php'+extra,'kopinformation','height=600,width=1000');
		if (window.focus) {newwindow.focus()}
    	return false;
	});

	$('div.unstolen input.unstolen_btn').click(function() {
	 	if(confirm('Är du säker på att du vill avanmäla denna som stulen?')) return true; else return false;
	});
	
	$('#updateEngines a.editMe').click(function() {
		var id = $(this).attr('id');
		id = id.substr('change-'.length);
		var colToShow = $('#updateEngines div#column_'+id);
		$('#updateEngines div.engineCol').hide();
		colToShow.slideDown();
		return false;
	});
	
	$('#tab1 form').submit(function() {
		var lmnt = $('table.details select.battyp_typ');
		var ok;
		$("option:selected", lmnt).each(function() {
   			selected = $(this).val();
   			if (selected == 0) {
   				alert('Du måste välja en båttyp för att kunna spara båten.');
   				//lmnt.parent().parent().css('background', 'color: red');
   				ok = false;
   			} else {
   				ok = true;
   			}
	  	});
	  	return ok;
	});
	
	$('table.details select.battyp_typ').change(function() {
		option = $('option', this)[0];
		$(option).hide();
	});
	
	
});

