var flag=false;
var unselBg = 'url(/Templates/img/tab_last.gif) top left no-repeat';
var selBg = 'url(/Templates/img/tab_selected_first.gif) top left no-repeat';
var visible = new Array();
var ViewAll = false;

$(document).ready(function(){
  $("img.pic").click(function(){
    var ipaths = $(this).attr("src").split("/");
    var ipath=ipaths[4].substr(1);
    var npath = "/"+ipaths[1]+"/"+ipaths[2]+"/"+ipaths[3]+"/"+ipath;
//alert(npath);
    $("#BigPic").children("img").attr("src",npath);
    if(!flag) $("#BigPic").show("slow");
    flag=true;
  });
  $("#BigPic").click(function(){
    if(flag) $(this).hide("slow");
    flag=false;
  });
  $("#BigPic div#closePic").click(function(){
    if(flag) $(this).parent().hide("slow");
    flag=false;
  });
  
  $("img.pict").click(function(){
    var ipaths = $(this).attr("src").split("/");
    var ipath=ipaths[5].substr(1);
    var npath = "/"+ipaths[1]+"/"+ipaths[2]+"/"+ipaths[3]+"/"+ipaths[4]+"/"+ipath;
//alert(npath);
	var ww = $("#container").width();
    var wh = $(window).height();
    var posx = Math.floor(ww/2-311);
    var posy = Math.floor(wh/2-300);
    var scroll = $(window).scrollTop();
//alert("scroll="+scroll+", pos Y="+posy+", pox X="+posx);
  
    $("#BigPic").css("top",posy + scroll);
    $("#BigPic").css("left",posx);
	var altTxt = $(this).attr("alt");
	$("#BigPic").css("display","");
    $("#BigPic").children("img").attr("src",npath);
	if(altTxt != "") $("#BigPic p").html(altTxt);
    if(!flag) $("#BigPic").show("slow");
    flag=true;
  });
  
  //открыть картинку в верхней части страницы (по образцу ford.ru)
  $("img.pictq").click(function(){
    
    var ipaths = $(this).attr("src").split("/");
    var ipath=ipaths[5].substr(1);
    var npath = "/"+ipaths[1]+"/"+ipaths[2]+"/"+ipaths[3]+"/"+ipaths[4]+"/"+ipath;
//alert(npath);
	$("#TopImage").fadeOut();
    $("#TopImage").children("img").attr("src",npath);    
	$("#TopImage").fadeIn();
  });  
  
  //наборы вкладок
  $(".linkVkl").click(function(){
//  alert(this.id);
	var n = this.id.split("_");
	$(".OneVkld").hide();
	$(".linkVkl").css('background',unselBg)
	$(this).css('background',selBg);
	$("#vklBd_"+n[1]).show();
	
  });
  
  $("div.answ").each(function(){
	//alert("!");
	var i = 1;
	visible[i++] = (!ViewAll || typeof(ViewAll) == 'undefined') ? false : true;
	
	$(this).css("overflow","visible");
	$(this).css("height","auto");
	if(!ViewAll || typeof(ViewAll) == 'undefined') $(this).hide();
   });
   $("div.quest").click(function(e){
//	e.stop();
	var num = Number($(this).attr("id").substr(1));
	if(!visible[num]){
	   $("#a"+num).slideDown("slow");
	   visible[num] = true;
	   $(this).css("background","#d5d5d5 url(/images/a_down_b.png) 5px 50% no-repeat");
	}
	else{
	   $("#a"+num).slideUp("slow");
	   visible[num] = false;
	   $(this).css("background","#d5d5d5 url(/images/a_right_b.png) 5px 50% no-repeat");
	}
	return false;
//alert(num);
     });
});


