//var host = 'http://'+location.hostname;

$(function () {

  $('#header_pics').jqFancyTransitions({effect: 'curtain', width: 980, height: 300, titleOpacity: 0, titleSpeed: 0,navigation: false });
  
  // slider lectors
  theRotator();
	$('div.rotator').fadeIn(1000);
  $('div.rotator ul li').fadeIn(1000); // tweek for IE
  
  $('.lector_detail').simpleDialog({
    showCloseLabel: false
  });
   
  $('#menu_sdk_battle').mouseenter(function () {
    $('#menu_preselections').show();
  });
  $('#menu_sdk_battle').mouseleave(function () {
    $('#menu_preselections').hide();
  });
  $('#menu_travel').mouseenter(function () {
    $('#menu_location').show();
  });
  $('#menu_travel').mouseleave(function () {
    $('#menu_location').hide();
  });
  $('#menu_gallery').mouseenter(function () {
    $('#menu_sub_gallery').show();
  });
  $('#menu_gallery').mouseleave(function () {
    $('#menu_sub_gallery').hide();
  });
  $('#menu_acc').mouseenter(function () {
    $('#menu_food').show();
  });
  $('#menu_acc').mouseleave(function () {
    $('#menu_food').hide();
  });
  $('#menu_price').mouseenter(function () {
    $('#menu_enter').show();
  });
  $('#menu_price').mouseleave(function () {
    $('#menu_enter').hide();
  });
  $('#menu_schedule').mouseenter(function () {
    $('#menu_dj').show();
  });
  $('#menu_schedule').mouseleave(function () {
    $('#menu_dj').hide();
  });
  

  $("ul.thumb li").hover(function() {
  	$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
  	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
  		.animate({
  			marginTop: '-210px', /* The next 4 lines will vertically align this image */ 
  			marginLeft: '-210px',
  			top: '50%',
  			left: '50%',
  			width: '490px', /* Set new width */
  			height: '500px', /* Set new height */
  			padding: '5px'
  		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
  
  	} , function() {
  	$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
  	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
  		.animate({
  			marginTop: '0', /* Set alignment back to default */
  			marginLeft: '0',
  			top: '0',
  			left: '0',
  			width: '190px', /* Set width back to default */
  			height: '190px', /* Set height back to default */
  			padding: '5px'
  		}, 400);
  });

});

/* JQUERY SLIDER EKTORI */
function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.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()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

    if ( current.length == 0 ) current = $('div.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')) ? $('div.rotator ul li:first') :current.next()) : $('div.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');
	
};
/* END LEKTORI */


function menu_on_off(id){
	//var element = document.getElementById('submenu_'+id);
	//element.style.display = "block";
	
	if ($('#submenu_'+id).is(":visible")) {
	 // $('#submenu_'+id).hide();
	}
	else {
	 $('#submenu_'+id).show();
	 return false;
	}
}
function menu_off(id){
	var element = document.getElementById('submenu_'+id);
	element.style.display = "none";
}
function show_size(i){
	var elem = document.getElementById('sb_' + i);
	var chBox = document.getElementById('t_box_' + i);
	
	if(chBox.checked == true)
		elem.style.display = 'block';
	else
		elem.style.display = 'none';
	
}
function smile(i){
	var area = document.getElementById('forum_area');
	area.value += '['+i+']';	
	area.focus();
}

function display_date(value)
{
	var div = document.getElementById('datum');
	switch (value) {
		case 'BATTLE':
		case 'SOUT̮':
			div.style.display = "block";
			break;
		default:
			div.style.display = "none";
			break;
	}
}

$(function () {
	$("#forum_anti_spam").val('232323');
	$("#news_slider_box > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	
});

$(function () {
	$("#add_person_anch_button").click(function () {
		$('html, body').animate({scrollTop: $("#add_person_anch").offset().top}, 'slow');
		return false;
	});
});

