// JavaScript Document
    $(document).ready(function() {

    //выбираем все тэги a  с именем modal
    $('a[name=modal]').click(function(e) {
    //Отменяем связи
    e.preventDefault();

  $('.shou_blok').remove();

  var adr = $(this).attr('href');
  //alert(adr);
  
	var tit = $(this).attr('title');
	var arraysrc = adr.split('.');
	
	//alert(arraysrc[1]);
	
	var pix=$(this).attr('rel');
  var arraypix=pix.split('x');
  
  var titul='';
  if(tit.length>0){titul='<h1  class=\'shou_title\'>'+tit+'</h1>';}else{titul='';}
  
  
  
	//alert(arraysrc);  	

	
	if(arraysrc[1]=='swf'){
		$('#window').append('<div class=\"shou_blok\" >'+titul+'<object  class=\'shou_swf\' classid=\'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\'><param name=\'menu\' value=\'false\' /><param name=\'src\' value=\''+adr+'\' /><embed type=\'application/x-shockwave-flash\' class=\'shou_swf\' src=\''+adr+'\' menu=\'false\'></embed></object></div>');
	}
	if((arraysrc[1]=='jpg')||(arraysrc[1]=='jpeg')||(arraysrc[1]=='gif')){
		$('#window').append('<div class=\"shou_blok\" >'+titul+'<img border=\"0\" class=\"shou_jpg\"  src=\"'+adr+'\" /></div>');
	}
	if((arraysrc[0]=='http://www')&&(arraysrc[1]=='youtube')&&(arraysrc[2].lastIndexOf('com')==0)){
		$('#window').append('<div class=\"shou_blok\" >'+titul+'<object  class=\'shou_youtube\' classid=\'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\'><param name=\'menu\' value=\'false\' /><param name=\'src\' value=\''+adr+'\' /><embed type=\'application/x-shockwave-flash\' class=\'shou_youtube\' src=\''+adr+'\' menu=\'false\'></embed></object></div>');
	}
	
	var nwidth=0;
  var nheight=0;
  if(arraypix.length==2){
     nwidth=parseInt(arraypix[0]);
     nheight=parseInt(arraypix[1]);
     var width=nwidth;
     var height=nheight;
     
     height=nheight+20;
     if(tit.length>0){     
     $('.shou_title').css('width','90%');
     }
     
     $('.shou_blok').css('width',width);
     $('.shou_blok').css('height',height);
     
     $('.shou_swf').css('width',nwidth);
     $('.shou_swf').css('height',nheight);
     
     $('.shou_jpg').css('width',nwidth);
     $('.shou_jpg').css('height',nheight);
     
     $('.shou_youtube').css('width',nwidth);
     $('.shou_youtube').css('height',nheight);
     
     $('.window').css('width',width);
     $('.window').css('height',height);
     
     //alert(nwidth+'-'+nheight);
     //alert(width+'-'+height);
  }
	

    //размеры рабочей области
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //устанавлиаем замеры для маски
    $('#mask').css({'width':maskWidth,'height':maskHeight});

    //эффект появления
    $('#mask').fadeIn(1000);
    $('#mask').fadeTo("slow",0.8);

    //размеры окна
    var winH = $(window).height();
    var winW = $(window).width();

    //устанавливаем окно в центр рабочей области
    $('#window').css('top', winH/2-$('#window').height()/2+$(window).scrollTop());
    $('#window').css('left', winW/2-$('#window').width()/2);

    //эффект перехода
    $('#window').fadeIn(200);

    });

    //если нажали закрыть
    $('.window .close').click(function (e) {
    e.preventDefault(); 
    $('#mask').hide();
    $('.window').hide();
	   $('.shou_blok').remove();
    });

    //если кликнули по маске
    $('#mask').click(function () {
    $(this).hide();
    $('.window').hide();
	   $('.shou_blok').remove();
    });
	return false;
    });

