$(document).ready(function(){
	$.ajaxSetup({
		url: "includes/request.php",
		timeout: 3000,
		type: "POST",
		cache: false,
		async: true,
		contentType: "application/x-www-form-urlencoded"
	});
	$("a.brand").click(function(){
		var rel = $(this).attr('rel');
		$.ajax({
			   data:"event=model&id="+$(this).attr("name")+"&rel="+rel,
			   success: function(XMLHttpRequest, textStatus){
				   $("#models"+rel).html(XMLHttpRequest);
			   }
		   })
	});
	$("img.main_img, a.show_img").click(function(){
		var img_link = $('img.main_img').attr('src');
		img_link = img_link.substr(0, img_link.length-5);
		void window.open('/image.php?src='+img_link+'b.jpg', 'ImagePreview', 'resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=640,height=640,left=20,top=20');
	});
	Mod();
});

function Mod()
{
	$("a.model").click(function(){
		var rel = $(this).attr('rel');
		var id = $(this).attr('name');
		var name = $(this).html();
		$.ajax({
			   data:"event=item&id="+id+"&rel="+rel,
			   success: function(XMLHttpRequest, textStatus){
				   $("#item"+rel).html(XMLHttpRequest);
				   if ($("#sel"+rel)) $("#sel"+rel).html(name);
				   if ($("#selitem"+rel)) $("#selitem"+rel).attr('value', id);
			   }
		   })
	});
}