var allowClipAutoStart = 0;

function closePopup()
{
	jQuery('#opaco').toggleClass('hidden').removeAttr('style');
	jQuery('#popup').toggleClass('hidden');
/* 	jQuery('#player_form').html(jQuery('#popup').html());
	jQuery('#popup').html(''); */
		
  return false;
}

//open pop-up
function showPopup(popup_type)
{
  //when IE - fade immediately
  if(jQuery.browser.msie)
  {
	jQuery('#opaco').width(jQuery(document).width());
	jQuery('#opaco').height(jQuery(document).height()).toggleClass('hidden');
  }
  else
  //in all the rest browsers - fade slowly
  {
	  jQuery('#opaco').height(jQuery(document).height()).toggleClass('hidden').fadeTo('slow', 0.7);
  }

  allowClipAutoStart = 1;

  jQuery('#popup')
    .html(jQuery('#' + popup_type).html())
    .alignCenter()
    .toggleClass('hidden');
	/* jQuery('#' + popup_type).html(''); */

  return false;
}

function show_popup_player(popup_type, clip_id) {
	if(!clip_id) {
		return false;
	}

	jQuery('.player iframe').show();
	showPopup(popup_type);
	var clip_iframe_src = $("#player_iframe_src_" + clip_id).attr("value");
	$("#player_iframe_clip_" + clip_id).attr("src", clip_iframe_src);
	
	//alert(iframe_id);
	//document.getElementById(iframe_id).contentWindow.test_iframe();
	document.getElementById('player_iframe_clip_' + clip_id).contentWindow.isPlayerVisible = 1;
	//alert(iframe_id);
	// document.getElementById(iframe_id).contentWindow.playerVisible();

	// jQuery('.player iframe').Reset();
	// jQuery('.player iframe').isPlayerVisible = true;
	
	if(jQuery.browser.msie) {
		//jQuery('#opaco').css("width", "100%");
		//jQuery('#opaco').hide();
	}

//	jQuery('#popup').css("z-index", "30001");
//	jQuery('#opaco').css("z-index", "30000");

}

function close_popup_clip_page() {
	closePopup();
	jQuery('.player iframe').hide();
	$("#popup iframe").attr("src", "");
	
	//jQuery('.player').html(".");
  //location.reload();
}

jQuery(document).ready(function(){
	jQuery.fn.alignCenter = function() {
		//get margin left
		var marginLeft = Math.max(40, parseInt(jQuery(window).width()/2 - jQuery(this).width()/2)) + 'px';
		//get margin top
		
		var top_point = Math.max(40, parseInt(jQuery(window).height()/2 - jQuery(this).height()/2));
		var marginTop = (top_point + jQuery(window).scrollTop()) + 'px';
		 
		//return updated element
		return jQuery(this).css({'margin-left':marginLeft, 'margin-top':marginTop});
	};
//	var nAgt = navigator.userAgent;
//	var verOffset = nAgt.indexOf("MSIE");
//	var version = parseFloat(nAgt.substring(verOffset+5));
//	if(jQuery.browser.msie && (version < 7) ) {
//		showPopup('save');
//	}

});

