// JavaScript Document

$(document).ready(function(){

	
	//csúszkához tartozó JS

	$('#slider').slider({ max:5 });
	$('#slider').slider({
			change: function(event, ui){
			$('#refDiv').fadeIn('normal');
			},
			slide: function(event, ui){
				var s=$('#slider').slider('value');


			$.ajax({
				type: "GET",
				url: "xml/reflist.xml",
				dataType: "xml",
				success: function(xml) {
					$(xml).find('element').each(function(){
						var id = parseInt($(this).find('id').text());
						if (id==s){
								var name = $(this).find('name').text();
								var url = $(this).find('url').text();
								var pic = $(this).find('pic').text();
								var tech = $(this).find('technology').text();
								var info = $(this).find('info').text();
								
								var htmlStr='';
								htmlStr='<h1>'+s+'./'+xmlMax+'</h1>';
								htmlStr+='<h1>'+name+'</h1>'+'<a href="'+url+'">'+name+'</a>';
								htmlStr+='<img src="xml/'+pic+'" alt="RefPic" />';
								htmlStr+='<h3>'+tech+'</h3>';
								htmlStr+='<p>'+info+'</p>';
								$('#refDiv').html(htmlStr);
								

						}
					});
				}
			});
			
			$('#refDiv').fadeOut('normal');

			}//slide function
			
	});//slider end

	
	//következo gombhoz tartozó js
	$('#xmlButtonNext').click(function(){

		
		var x=parseInt($(this).attr('title'));
		if (x<xmlMax){
		
			$('#refDiv').fadeOut('normal');
				
			$(this).attr('title',++x);
			$('#xmlButtonPrev').attr('title',x);
		}

		$.ajax({
			type: "GET",
			url: "xml/reflist.xml",
			dataType: "xml",
			success: function(xml) {
				$(xml).find('element').each(function(){
					var id = parseInt($(this).find('id').text());
					if (id==x){
								var name = $(this).find('name').text();
								var url = $(this).find('url').text();
								var pic = $(this).find('pic').text();
								var tech = $(this).find('technology').text();
								var info = $(this).find('info').text();
								
								var htmlStr='';
								htmlStr='<h1>'+x+'./'+xmlMax+'</h1>';
								htmlStr+='<h1>'+name+'</h1>'+'<a href="'+url+'">'+name+'</a>';
								htmlStr+='<img src="xml/'+pic+'" alt="RefPic" />';
								htmlStr+='<h3>'+tech+'</h3>';
								htmlStr+='<p>'+info+'</p>';
								$('#refDiv').html(htmlStr);
								

					}
				});
			}
		});

		if (x<=xmlMax) $('#refDiv').fadeIn('normal');
	
	}); //xmlButtonnext
	
	
	
	//elozo gombhoz tartozó JS
	$('#xmlButtonPrev').click(function(){
	

		
		var y=parseInt($(this).attr('title'));
		if (y>1){
	
			$('#refDiv').fadeOut('normal');
				
			$(this).attr('title',--y);
			$('#xmlButtonNext').attr('title',y);
		}


		$.ajax({
			type: "GET",
			url: "xml/reflist.xml",
			dataType: "xml",
			success: function(xml) {
				$(xml).find('element').each(function(){
					var id = parseInt($(this).find('id').text());
					if (id==y){
								var name = $(this).find('name').text();
								var url = $(this).find('url').text();
								var pic = $(this).find('pic').text();
								var tech = $(this).find('technology').text();
								var info = $(this).find('info').text();
								
								var htmlStr='';
								htmlStr='<h1>'+y+'./'+xmlMax+'</h1>';								
								htmlStr+='<h1>'+name+'</h1>'+'<a href="'+url+'">'+name+'</a>';
								htmlStr+='<img src="xml/'+pic+'" alt="RefPic" />';
								htmlStr+='<h3>'+tech+'</h3>';
								htmlStr+='<p>'+info+'</p>';
								$('#refDiv').html(htmlStr);
					}
				});
			}
		});
		
		$('#refDiv').fadeIn('normal');
	
	}); //xmlButtonPrev	
	

	
	
});

