$("document")
		.ready(
				function() {
					$(".easyScroll").click(function() {
						$('html,body').animate({
							scrollTop : $($(this).attr("href")).offset().top
						}, 'slow');

						return false;
					});

					$(
							'#tab_banner_ghizbi .banner-container .x-container .close-banner')
							.click(function() {
								$('#tab_banner_ghizbi').fadeOut();
								$.ajax({
									url : "commands.php?command=hide_banner"
								});
							});

					$(
							"#tab_banner_ghizbi .banner-container .x-container .navigator")
							.click(
									function() {
										$(
												'#tab_banner_ghizbi .banner-container .x-container .navigator')
												.each(
														function() {
															$(this)
																	.removeClass(
																			'current');
														});

										var id = $(this).attr("href").substr(1);
										$(this).addClass('current');
										$
												.ajax({
													url : 'get_banner.php?banner_id='
															+ id,
													dataType : 'json',
													success : function(data) {
														$(
																"#tab_banner_ghizbi .banner-container .image-container a")
																.attr(
																		"href",
																		data.url);
														$(
																"#tab_banner_ghizbi .banner-container .image-container img")
																.attr(
																		"src",
																		data.banner);
														$(
																"#tab_banner_ghizbi .banner-container .description")
																.html(
																		data.text_descriere);
													}
												});
										return false;
									});
				});

function addBookmark() {
	try {
		if (window.sidebar) { // Mozilla Firefox Bookmark
			throw new Exception("disabled in firefox");
		} else if (window.external) { // IE Favorite
			window.external.AddFavorite(location.href, document.title);
		} else if (window.opera && window.print) { // Opera Hotlist
			this.title = document.title;
			return true;
		}
	} catch (e) {
		alert("Va rugam apasati Control+D pentru a adauga aceasta pagina la favorite!")
	}
}

function toggleLayer(whichLayer) {
	var elem, vis;
	if (document.getElementById) // this is the way the standards work
		elem = document.getElementById(whichLayer);
	else if (document.all) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if (document.layers) // this is the way nn4 works
		elem = document.layers[whichLayer];
	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	if (vis.display == '' && elem.offsetWidth != undefined
			&& elem.offsetHeight != undefined)
		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block'
				: 'none';
	vis.display = (vis.display == '' || vis.display == 'block') ? 'none'
			: 'block';
}

startList = function() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("meniu1");
		for (i = 0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					this.className += " over";
				}
				node.onmouseout = function() {
					this.className = this.className.replace(" over", "");
				}
			}
		}
	}
}

function updateCameras(camera)
{
	$.ajax({
		url:"cam.php?nr="+camera,
		dataType:'json',
		success:function(data)
		{
			var image = $("#liveCam"+camera+" img");
			var date = new Date();
			image[0].src=data.path+"?date="+date.getMilliseconds();
			
			$("#liveCam"+camera+" span.time").html(data.date);
		}
	});
}
