	cl = 0;
	onwin = 0;
	$(document).ready(function(){
	
	$(".popup1").hide();
	$(".popblock").hide();
	
$(".poplink").click(function () { 
   if ($(this).next().is(":hidden")) {
  $(".popblock").slideUp();
        $(this).next().slideDown();
      } else {
        $(this).next().slideUp();
      }
  
 });
	
	$(".popup1").prepend('<div class="arrow"><img src="_img/pop/arrow.png"></div><div class="close"><img src="_img/pop/close.png"></div>');
	$(".link").click(function () { 
			$('.popup1').hide();
			wid = $(this).attr('wid');
			dw = $(document).width();
			
			if(dw - $(this).offset().left > $(this).width())
				$('#'+wid).css('left',$(this).offset().left).css('top',$(this).offset().top + 20);
			else
				$('#'+wid).css('left',$(this).offset().left - $(this).width()).css('top',$(this).offset().top + 20);
			
			
			$(document).bind("click", function(e){
				cl++;
				if((cl > 1) && (onwin == 0))
				{
					$(".popup1").hide();
					cl = 0;
					$(document).unbind("click");
				}
			});
			cl = 0;
			$('#'+wid).show();
			
			$(".popup1").mouseover(function(){	onwin = 1;	}).mouseout(function(){	onwin = 0;	});
			
		});
	
	$('.close').click(function () { 
			$(this).parent('.popup1').hide();
			cl = 0;
		});				
	});
	
