$$.hideembed =function(el, html) 
{
	if($.browser.msie && el && $('embed', el).length != 0)
	{
		$('embed', el).parent().each(function() 
		{
			$(this).css({height:$('embed',this).height()})[0].html = $(this).html();
			$(this).html('').addClass('hiddedembed');
		});
		$('embed').css({visibility:'hidden'});
	}
	else $('embed').css({visibility:'hidden'});
}

$$.showembed = function(el) 
{
	if($.browser.msie && el && $('.hiddedembed', el).length != 0) 
	{
		$('.hiddedembed',el).each(function() 
		{ 
			$(this).html(this.html).removeClass('hiddedembed');	
		});
		$('embed').css({visibility:''});
	}
	else $('embed').css({visibility:''});
}
	
$$.popup_isopened = false;
$$.popup_contain = false;
$$.popup = function(url, force, popup, popup_title, popup_center) 
{	
	if($$.popup_isopened && typeof(url) != "object")
	{
		$("#popup").hide();			
		$("#popup-overlay").hide();
		if($$.popup_contain) $$.popup_contain.append($("#popup-center :first"));
		$$.popup_contain = false;
		$("#popup-center").html("");
		$$.showembed();
		$$.popup_isopened = false;
	}
	else
	{
		$$.popup_isopened = true;
		$("#popup-close").unbind('click').one('click', function() { return $$.popup(); });			
		popup = $("#popup")
		$$.hideembed();
		$("#popup-overlay").show();					
		
		if(typeof(url) != "object")
		{
			$.get(url, null, function(data, w, h) 
			{		
				var myHeight=0;if(typeof(window.innerWidth)=='number'){myHeight=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myHeight = document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myHeight=document.body.clientHeight;}
				var scrOfY = 0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;}			
				data = $(data)
				if(data.attr("width")) w = data.attr("width");
				else w = 438;
				data.appendTo($("#popup-center"))				
				popup.css({ display:'block', opacity:1 });
								
				$("#popup-title, #popup-center, #popup-bottom").width(w);				
				data.width('auto')
				$$.define(popup);
				$("#popup-title").css({ marginTop: myHeight/2 - popup.height()/2 })					
				popup.css({ opacity:1 });								
			});
		}
		else
		{
			//url = url.clone();
			$$.popup_contain = url.parent();
			if(url.attr("width")) w = url.attr("width");
			else w = 438;
			$("#popup-center").html("");
			$("#popup-title, #popup-center, #popup-bottom").width(w);
			url.show().appendTo($("#popup-center"));
			popup.css({ display:'block', opacity:1 });
			$$.define(popup);
		}			
	}
	return false;
}
	
$$.imgzoom_isopened = false;
$$.imgzoom = function(cont, img, imgmove, imgzoom, mini, title, desc, titleh, w, h, l, t, ow, oh, ol, ot )
{
	if($$.imgzoom_isopened) { $("#imgzoom img").trigger('click'); return false; }	
	$$.imgzoom_isopened = true;
	cont = $(cont);
	var myHeight=0;if(typeof(window.innerWidth)=='number'){myHeight=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myHeight = document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myHeight=document.body.clientHeight;}
	var scrOfY = 0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;}				  
	$$.hideembed();	  		  
	mini = $(".mini", cont);
	ow = mini.width(); oh = mini.height();
	ol = mini.offset().left - 9; ot = mini.offset().top;	
	imgzoom = $("#imgzoom").css({ zIndex: 9999997, opacity:0, display:'block' });
	img = $(".large", cont).clone();
	imgmove = img.clone().css({ 
		cursor: "url(/images/css/base/popup/diapo/zoomoutie.cur), auto",
		zIndex: 9999998, position:'absolute',  left: ol, top: ot, opacity: 1, display: 'block' }).appendTo(document.body);
	title = $(".title", cont).html();
	desc = $(".desc", cont).html();	
	if(desc.replace(" ","") == "") { 
		$("#imgzoom-middle").css("padding-right", 5);
		desc = null; $("#imgzoom-middle2").attr("id", "imgzoom-middle3").width(0) }
	else {
		$("#imgzoom-middle").css("padding-right", 15);
		$("#imgzoom-middle2").width(200);
	}	
	if(desc) $("#imgzoom-middle2").html(desc);
	$("#imgzoom-middle").append(img.show());	
	$("#imgzoom-title").width((desc?200:0)+img.width());
	$("#imgzoom-title h5").html(title);		
	imgzoom.css({ 
		left: $(document.body).width()/2 - imgzoom.width()/2, 
		top: scrOfY + myHeight/2 - imgzoom.height()/2 
	});	
	w = img.width(); h = img.height();
	l = img.offset().left; t = img.offset().top;	
	imgmove.css({ width: ow, height: oh, left: ol, top: ot }).animate({ 
		width: w, height: h, 
		left:  l, top: t }, 300,function(){
		imgzoom.css({ opacity: 1 });
	});	
	$("body").one('click', function() { imgmove.trigger('click'); });
	$("#imgzoom a.close").one('click', function() { imgmove.trigger('click'); });	
	$("#imgzoom").bind('click', function() { return false; });	
	imgmove.unbind('click').one('click', function()
	{
		$("body").unbind('click');
		$("#imgzoom a.close").unbind('click');
		$("#imgzoom").unbind('click');
		img.animate({ opacity: 0 }, 300, function() { $(this).remove() } );
		imgmove.remove();
		mini.animate({ opacity: 1 }, 300);
		imgzoom.animate({ opacity: 0 }, 300 ,function() 
		{
			imgzoom.hide();	
			$$.showembed();			
			$("#imgzoom-title h5").html("")
			$("#imgzoom-middle3").attr("id", "imgzoom-middle2");
			$("#imgzoom-middle2").html("");			
			$$.imgzoom_isopened = false;	
		});	
		return false;	
	});
	return false;
}

$$.addAction("#edit_cv_bar a.close", function(el) {$(el).bind('click', function(){ $(this).hide(); $("#edit_cv_bar").slideUp(300);})});
$$.addAction(".image_view", function(el) {$("img.mini", el).bind('click', function(){return $$.imgzoom($(this).parent());})});
$$.addAction("#cryptedinfo", function(el) {
	setTimeout(function(mail, mail_contact, msn, msn_contact, user_id)	{		
		$.post(banneruri+"/displayemail/", { user_id: el.attr("name") }, function(data) {			
			data = data.split("#");			
			if(data[0]) $(".tel", el).html('<a>'+data[0]+'</a>');
			if(data[1]) $(".cell", el).html('<a>'+data[1]+'</a>');
			if(data[2]) $(".email", el).html('<a href="mailto:'+data[2]+'">'+data[2]+'</a>');
			if(data[3]) $(".skype", el).html('<a href="callto:'+data[3]+'">'+data[3]+'</a>');
			if(data[4]) $(".msn", el).html('<a href="mailto:'+data[4]+'">'+data[4]+'</a>');
		});
	}, 20);
})



