//galery image change
function kep_valt(mit) {
	switch (mit) {
		case 'video_usz' :
		  	$('#video_usz').css("background-color","#FFFFFF")
			$('#video_usz').css("color","#0374c9")

		  	$('#video_viz').css("background-color","#0374c9")
			$('#video_viz').css("color","#FFFFFF")
		  	$('#foto_usz').css("background-color","#0374c9")
			$('#foto_usz').css("color","#FFFFFF")
		  	$('#foto_viz').css("background-color","#0374c9")
			$('#foto_viz').css("color","#FFFFFF")
			
			$('#kep_uszas').hide();
			$('#kep_vizilabda').hide();
			$('#video_uszas').show();
			$('#video_vizilabda').hide();
		
			break;
		case 'video_viz' :
		  	$('#video_viz').css("background-color","#FFFFFF")
			$('#video_viz').css("color","#0374c9")

		  	$('#video_usz').css("background-color","#0374c9")
			$('#video_usz').css("color","#FFFFFF")
		  	$('#foto_usz').css("background-color","#0374c9")
			$('#foto_usz').css("color","#FFFFFF")
		  	$('#foto_viz').css("background-color","#0374c9")
			$('#foto_viz').css("color","#FFFFFF")

			$('#kep_uszas').hide();
			$('#kep_vizilabda').hide();
			$('#video_uszas').hide();
			$('#video_vizilabda').show();

		 	break;
		case 'foto_usz' :
		  	$('#foto_usz').css("background-color","#FFFFFF")
			$('#foto_usz').css("color","#0374c9")

		  	$('#video_usz').css("background-color","#0374c9")
			$('#video_usz').css("color","#FFFFFF")
		  	$('#video_viz').css("background-color","#0374c9")
			$('#video_viz').css("color","#FFFFFF")
		  	$('#foto_viz').css("background-color","#0374c9")
			$('#foto_viz').css("color","#FFFFFF")
		  	
			$('#kep_uszas').show();
			$('#kep_vizilabda').hide();
			$('#video_uszas').hide();
			$('#video_vizilabda').hide();

			break;
		case 'foto_viz' :
		  	$('#foto_viz').css("background-color","#FFFFFF")
			$('#foto_viz').css("color","#0374c9")

		  	$('#video_usz').css("background-color","#0374c9")
			$('#video_usz').css("color","#FFFFFF")
		  	$('#video_viz').css("background-color","#0374c9")
			$('#video_viz').css("color","#FFFFFF")
		  	$('#foto_usz').css("background-color","#0374c9")
			$('#foto_usz').css("color","#FFFFFF")

			$('#kep_uszas').hide();
			$('#kep_vizilabda').show();
			$('#video_uszas').hide();
			$('#video_vizilabda').hide();

			break;
	}
}

function nagykep(sportag,konyvtar,file,szelesseg,magassag) {
	$('#galeria_content').html('');
	$('#galeria_content').prepend('<img width="'+szelesseg+'" height="'+magassag+'" src="image/galeria/'+sportag+'/'+konyvtar+'/big/'+file+'" style="border","4px solid #FFFFFF;" />')
}

function nagyvideo(mit,utvonal) {
	$('#galeria_content').html('');
	$('#galeria_content').append('<img id="preload-img" alt="" src="'+utvonal+'" />');
	$('#preload-img').css('margin-top','150px');
	$('#galeria_content').prepend(mit);
	
	$('.video_j').css('display', 'none');
	$('.video_j').load(function()	{
		$('.video_j').css('display', 'block');
		$('#preload-img').remove();
	});
}

$(function() {		
	// initialize scrollable with mousewheel support
	var helyszin = $("#helyszin_scroller").scrollable({
    api: true,
    vertical:true,
	mousewheel: false,
    circular: true
	//speed: 3000
  	});
	//$("#helyszin_scroller").autoscroll(4000);

	// initialize scrollable with mousewheel support
	var munkatars = $("#munkatarsak_scroller").scrollable({
    api: true,
    vertical:true,
	mousewheel: false,
    circular: true
	//speed: 3000
  	});
	//$("#munkatarsak_scroller").autoscroll(4000);

	// initialize scrollable with mousewheel support
	var partner = $("#partnerek_scroller").scrollable({
    api: true,
    vertical:true,
	mousewheel: false,
    circular: true
	//speed: 3000
  	});
	//$("#partnerek_scroller").autoscroll(4000);

	var hirek = $("#hirek_scroller").scrollable({
    api: true,
    vertical:true,
	mousewheel: true,
    circular: true
  	});
	
	//$(".scrollable").scrollable({ vertical: true, mousewheel: false });	

	$("#content").scrolltastic({
		up: $("#up"),
		down: $("#down")
	});
});

/*$(function() {		
	 // header middle image
	 array = new Array("ujhullam_03.jpg", 
					   "ujhullam_02.jpg", 
					   "ujhullam_04.jpg");
					   
	 var keyword = array[Math.floor(Math.random()*array.length)];
	 $("#header_center").html('<img alt="" src="image/'+keyword+'" width="513" height="266" />');
});*/

function oszlop_allit(mit)
{
	if (mit==true) {
		$("#szavazz .box_content").css('height','380px');
		document.getElementById("result").style.display = 'block';
	}
	
	left_height = document.getElementById("left").offsetHeight;
	center_height = document.getElementById("center").offsetHeight;
	right_height = document.getElementById("right").offsetHeight;
	
	if (document.getElementById('egyesulet')) {
		var kozepso = document.getElementById('egyesulet');
	}
	else {
		var kozepso = document.getElementById('kozepso');
	}
	
	partner_height = document.getElementById("partner").offsetHeight;
	kozepso_height = kozepso.offsetHeight;
	donpepe_height = document.getElementById("donpepe").offsetHeight;
	
	max_height = Math.max(left_height,center_height,right_height);
	document.getElementById('partner').style.height = max_height-left_height+partner_height + 'px';
	kozepso.style.height = max_height-center_height+kozepso_height + 'px';
	document.getElementById('donpepe').style.height = max_height-right_height+donpepe_height + 'px';
}

function oszlophelyszin_allit()
{
	left_height = document.getElementById("left").offsetHeight;
	right_height = document.getElementById("right").offsetHeight;
	
	donpepe_height = document.getElementById("donpepe").offsetHeight;
	
	max_height = Math.max(left_height,right_height);
	document.getElementById('left').style.height = max_height + 'px';
	document.getElementById('donpepe').style.height = max_height-right_height+donpepe_height + 'px';
}

//jelentkezés form
$(document).ready(function() {		
	url = window.location.toString();
	url_search = url.search("result=");

	if (url_search!=-1) {
		parameter = url.split("?");
		
		if (parameter[1]=='result=ok') {
			alert('Köszönjük jelentkezését, kollégánk hamarosan felveszi Önnel a kapcsolatot.');
		}
		else {
			alert('Hiba történt a küldés során!');
		}
	}
});

//--------------------------------------------------------------//
//begin of rotate
function theRotator() {
	//Set the opacity of all images to 0
	$('#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	
	setInterval('rotate()',8000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('#rotator ul li.show')?  $('#rotator ul li.show') : $('#rotator ul li:first'));

    if ( current.length == 0 ) current = $('#rotator ul li:first');

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#rotator ul li:first') :current.next()) : $('#rotator ul li:first'));
	
	//Un-comment the 3 lines below to get the images in random order
	
	//var sibs = current.siblings();
        //var rndNum = Math.floor(Math.random() * sibs.length );
        //var next = $( sibs[ rndNum ] );
			

	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
	$('#rotator').fadeIn(1000);
    $('#rotator ul li').fadeIn(1000); // tweek for IE
});

function urit(mit) {
hossz=mit.options.length
	for(i=1;i<=hossz;i++) {	
		mit.options[0] = null; }
}

// end of rotate
//--------------------------------------------------------------//


var ajaxRequest = null;

function valt(value,helyszin) {
	urit(document.getElementById('sportag'))

	if (window.XMLHttpRequest) { 
		ajaxRequest = new XMLHttpRequest(); 
	}
	else if (window.ActiveXObject) { 
		// Internet Explorer 
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 

	var status = 'helyszin';
	parameters = 'helyszin=' + value + '&status=' + status

	ajaxRequest.onreadystatechange = ajaxFormInfo;
	if (helyszin==true) {
	ajaxRequest.open('POST', '../modul/hirlevel/ajax.php', true);
	}
	else {
	ajaxRequest.open('POST', 'modul/hirlevel/ajax.php', true);
	}
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
	ajaxRequest.setRequestHeader("Content-length", parameters.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(parameters);
}

function ajaxFormInfo() {
    if (ajaxRequest.readyState == 4) {
         if (ajaxRequest.status == 200) {
		 	vissza=ajaxRequest.responseText;
			if (vissza.length > 0) {
				sor=vissza.split(';')
				for (i=0; i<sor.length; i++) { 
					adat=sor[i].split(",")
					if (adat[1] == 'Uszás') {adat[1]='Úszás'}
						document.getElementById('sportag').options[i] = new Option(adat[1], adat[0]); 
				} 
			}
		 }
    }
}
