function showClass (id) {
    document.getElementById(id).className='active';
}

function hideClass (id) {
    document.getElementById(id).className='';
}

/*function selectColor(id, color) {
    $.getJSON("/handlers/color_photos.php",{id:id,color:color}, function(data){
    	var content = '';
        $.each(data, function(i, item){
            content += '<a href="/img/catalog/photo_' + i + '.' + item + '" target="_blank" onclick="selectPhoto(' + i + ', \'' + item + '\'); return false;"><img src="/img/catalog/photo_' + i + '_m.' + item + '" width="123" /></a>';
        });
        $("#colorPhotosList").html(content);
    });
}*/

function selectColor(id, color, dimension) {
    var dimensionSelection = $("#dimensionSelection"); 
	dimensionSelection.removeOption(/./);
	dimensionSelection.ajaxAddOption("/handlers/color_dimensions.php", {
		id: id, color: color
	}, "id_model", function(data) {
		if (dimension) {
			dimensionSelection.selectOptions(dimension, true);
		} else {
			dimensionSelection.attr("selectedIndex", 0);
		}
		selectModification(id, color, dimensionSelection.attr('options')[dimensionSelection.attr("selectedIndex")].value);
	});
}

/*function selectModification(id) {
	$.getJSON("/handlers/modification_info.php",{id:id}, function(data){
    	if (data.marking) {
    		$("#markingSpan").html(data.marking);
    	}
    	if (data.price) {
    		$("#priceSpan").html(data.price);
    	}
		if (data.imgext) {
			var a = $("#mainPhotoLink");
			a.attr('href', '/img/catalog/photo_' + data.id + '.' + data.imgext);
			a.html('<img border="0" src="/img/catalog/photo_' + data.id + '_s.' + data.imgext + '" />');
		}
    });
}*/
function selectModification(id, color, dimension, select) {
	$.getJSON("/handlers/modification_info.php",{id:id, color:color, dimension:dimension}, function(data){		
		if (data[0]) {
			if (data[0].marking) {
	    		$("#markingSpan").html(data[0].marking);
	    	}
	    	if (data[0].price) {
	    		$("#priceSpan").html(data[0].price);
	    	}
	    	//if (select && data[0].imgext) {
	    	if (data[0].imgext) {
				var a = $("#mainPhotoLink");
				a.attr('href', '/img/catalog/photo_' + data[0].id + '.' + data[0].imgext);
				a.html('<img border="0" src="/img/catalog/photo_' + data[0].id + '_s.' + data[0].imgext + '" />');
			}
		}
		if (data.length == 1) {
			$("#colorPhotosListHeader").attr('style', 'display:none;');
			$("#colorPhotosList").attr('style', 'display:none;');
		} else if (data.length > 1) {
			$("#colorPhotosListHeader").attr('style', '');
			$("#colorPhotosList").attr('style', '');
			var content = '';
	        $.each(data, function(i, item){
	            content += '<a href="/img/catalog/photo_' + item.id + '.' + item.imgext + '" target="_blank" onclick="selectPhoto(' + item.id + ', \'' + item.imgext + '\'); return false;"><img src="/img/catalog/photo_' + item.id + '_m.' + item.imgext + '" width="80" /></a>';
	        });
	        $("#colorPhotosList").html(content);
		}
    });
}

function selectPhoto(id, imgext) {
	var a = $("#mainPhotoLink");
	a.attr('href', '/img/catalog/photo_' + id + '.' + imgext);
	a.html('<img border="0" src="/img/catalog/photo_' + id + '_s.' + imgext + '" />');
}

function show(id) {
	document.getElementById(id).style.display='block';
	}
	
function hide(id) {
	document.getElementById(id).style.display='none';
	}
