function dialog_box()
{
	$(function () {
		$( "#dialog-confirm" ).dialog({
			resizable: false,
			//width:600,
			height:140,
			modal: true,
			buttons: { 
				"Ignora": function()  {
					$.post('/ro/index/dialog',{answer: 'no'});
					$( this ).dialog( "close" );					
				},
				"OK": function() {
					$.post('/ro/index/dialog',{answer: 'yes'}, function (data) {
						if(data == 'success')
						{
							$( this ).dialog( "close" );
							window.location = '/ro/index/index/';
						}
					});
					
				}
			}
		});
});
}

function ascunde_tot() {
	var e = document.getElementById('foo');
	e.style.display = 'none';
}

function comuta_viz(id) {
	var e = document.getElementById(id);
	if(e.style.display == 'none')
	e.style.display = 'block';
	else
	e.style.display = 'none';
}

function comuta_viz(id) {
	var e = document.getElementById(id);
	if(e.style.display == 'none')
	e.style.display = 'block';
	else
	e.style.display = 'none';
}

function changeLanguage(nLang) 
{
	
	if(nLang=='ro')
	{
		$('#lang_id').attr("src", "/imgs/en.png");
		window.location.href='/lang/en/';
	}
	else
	{
		$('#lang_id').attr("src", "/imgs/ro.png");
			window.location.href='/lang/ro/';
	}
}

/* --------------- suport chat ------------*/

function pctYoutube(id)
{
	var puncte = "<div class='bara'>"; 
	$.getJSON('/admin/support/puncte/id/'+id, function (data) {
		for(var i in data) 
		{
			var timp= parseInt(data[i].minute*60)+parseInt(data[i].second);
			puncte += "<span ref='"+id+"' class='"+timp+" punct-vid' title='"+data[i].name_ro+"'>";
			puncte += data[i].minute+":"+data[i].second;
			puncte += "</span>";
		}
		puncte +="</div>";
	});
	//alert(puncte);
	setTimeout(function() {
		 $(".video-bar").html(puncte);
	}, 4000);
}
$(document).ready(function() {
	

	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	$("#setImages img").click(function() { 
		var hreful = this.src;
		var source = hreful.replace("/thumb","");
		serverCall.sync.setDisplay('<img src="'+source+'" alt="Alien Concept" />');
	 });
	 
	$("#setVideos img").click(function() {
		serverCall.sync.setDisplay('<object width="600px" height="400px"><param name="movie" value="http://www.youtube.com/v/'+ this.alt +'?enablejsapi=1&amp;version=3"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+ this.alt+'" type="application/x-shockwave-flash" wmode="transparent" width="600px" height="400px"></embed></object>');		
		pctYoutube(this.alt);
	 });

//	$(".video-bar span img[ref]").tooltip({
//		effect: 'slide',
//		offset: [0, 0]
//	}).dynamic({ bottom: { direction: 'down', bounce: true } });
	
	$('.video-bar span').live('click', function() {
		var source = $(this).attr('ref');
		var time = $(this).attr('class');
		serverCall.sync.setDisplay('<object width="600px" height="400px"><param name="movie" value="http://www.youtube.com/v/'+source+'&amp;start='+time+'&amp;autoplay=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+source+'&amp;start='+time+'&amp;autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="600px" height="400px"></embed></object>');
		pctYoutube(source);
	});
	
	

/* ------------- layout ----------------- */

	$("#suport").makeFloat({
					x: 0,
					y: 100
	});
	
	$('#hello').innerfade({ 
			speed: 'slow', 
			timeout: 5000, 
			type: 'sequence', 
			containerheight: '400px' 
		}); 
	
	$('.scroll-pane').each(
			function()
			{
				$(this).jScrollPane(
					{
						showArrows: $(this).is('.arrow')
					}
				);
				var api = $(this).data('jsp');
				var throttleTimeout;
				$(window).bind(
					'resize',
					function()
					{
						if ($.browser.msie) {
							// IE fires multiple resize events while you are dragging the browser window which
							// causes it to crash if you try to update the scrollpane on every one. So we need
							// to throttle it to fire a maximum of once every 50 milliseconds...
							if (!throttleTimeout) {
								throttleTimeout = setTimeout(
									function()
									{
										api.reinitialise();
										throttleTimeout = null;
									},
									50
								);
							}
						} else {
							api.reinitialise();
						}
					}
				);
			}
		)
});
