$(document).ready(function(){
						   
						   appPop();
						  $(".imgpanel .pop").live('click',clickFunction_123);
						  $('.popup .crossbt').live('click',function(){
											     $('.popup').hide();
												 startTimer();
												});
						   });

function clickFunction_123()
{
	var vSource = $(this).attr('rel');
	createPopUp(vSource);
	stopTimer();
}

function appPop()
{
	W = $(window).width();
	H = $(window).height();
	
	
	var cStyle="position:fixed; top:0px; left:0px; display:none; z-index:9999999999999999999999999999999999";
	var shadowstyle = "position:absolute; top:0px; left:0px; width:"+W+"px; height:"+H+"px; opacity:0.5; background:#000000;";
	var pstyle = "position:absolute; top:0px; left:0px; width:420px; height:320px; background:#ff0000; overflow:hidden;";
	
	
	var htmlc = "<div class='popup' style='"+cStyle+"'><div id='sh' style='"+shadowstyle+"'></div><div id='popupcontent' style='"+pstyle+"'></div>";
	
   
    $('body').append(htmlc);
	$('.popup').hide();
}
function createPopUp(vSource)
{
	
	var source = vSource+"?title=0&amp;byline=0&amp;portrait=0";
	$('#forpopup').show();
	$('#forpopup').appendTo($('#popupcontent'));
	$('#forpopup').find("iframe").attr('src',source);
	resizing();
	$(window).resize(resizing);
	$('.popup').fadeIn('fast');
}

function resizing()
{
  W = $(window).width();
  H = $(window).height();
  $('#sh').css('width',W);
  $('#sh').css('height',H);
  $('#sh').css('overflow','hidden');
  
  wx = $('#popupcontent').width();
  hx = $('#popupcontent').height();
  $('#popupcontent').css('left',(W-wx)/2);
  $('#popupcontent').css('top',(H-hx)/2);
  $('#crossbt').css('left',((W-wx)/2)+wx);
  $('#crossbt').css('top',(H-hx)/2);
	
}
