// JavaScript Document

var gScrollerWorks = false;
var gInterval = undefined;

function fadeOutAll()
{
	$("#contacts").fadeOut(1000);
	$("#accommodation").fadeOut(1000);
	$("#city_map_holder").fadeOut(1000);
	$("#news_content_wrapper").fadeOut(1000);
	$("#date").fadeOut(1000);
	$("#news").fadeOut(1000);	
	$("#news_content_wrapper").fadeOut(1000);
	$("#ms_content").html('');
	$("#ms_registracija").fadeOut(1000);
	$("#program").fadeOut(1000);
	$("#workshop").fadeOut(1000);	
	$('#photos').fadeOut(1000);
	$('#ms_black_full').fadeOut(1000);
	$('#ms_black').fadeOut(1000);
	$("#underconstruction").fadeOut(1000);
	$("#gallery_wrap").fadeOut(1000);
	$("#ms_registracija_info").fadeOut(1000);

hideAllArtists();
	$('#partners').fadeOut(1000);
}

function show_partners()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {		
	   		$('#ms_black').fadeIn(1000);
			$("#partners").fadeIn(1000);
	   }
	   , 1000
   	);
}

function show_accommodation()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {		
	   		$('#ms_black').fadeIn(1000);
			$("#accommodation").fadeIn(1000);
	   }
	   , 1000
   	);
}

function show_city_map()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {		
	   		$('#ms_black').fadeIn(1000);
			$("#city_map_holder").fadeIn(1000);
	   }
	   , 1000
   	);
}

function hideAllArtists()
{
	for (i=1;i<=8;i++)
	{
		$("#artists"+i).fadeOut(1000);
	}
}

function show_artists(id)
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {		
	   		$('#ms_black_full').fadeIn(1000);
			$("#artists"+id).fadeIn(1000);
	   }
	   , 1000
   	);
}

function show_contacts()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {		
	   		$('#ms_black').fadeIn(1000);
			$('#contacts').fadeIn(1000);
	   }
	   , 1000
   	);
}


function show_gallery()
{
	fadeOutAll();
	$("#ms_black_full").fadeIn(1000);
	setTimeout
	(
	   function()
	   {		
	   		$('#gallery_wrap').fadeIn(1000);
			$('#photos').fadeIn(1000);
	   }
	   , 1000
   	);

}



 $(document).ready(function() {
	
	
	
	gScrollerWorks=true;
	if ( gInterval==undefined )
	{
		gInterval = setInterval(
	
		function()
		{
	
		if ( gScrollerWorks )
		{
			var p = $("#news_content");
			var position = p.position();
			var top=position.top;
			top=top-1;

			if ( top==-650 )
			{
					top=120;
			}

$("#news_content").css("top",top+"px");
		
		
		}
				
			},
			
			70
		
			);
	
	}


});
 
 
 $(document).ready(function() {
		$("#presents").fadeOut(6000);				
								});
  
  


function home_page()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {				
			$("#date").fadeIn(1000);
			$("#news").fadeIn(1000);	
			$("#news_content_wrapper").fadeIn(1000);
			$("#ms_content").html('');
	   }
	   , 1000
   	);

}



function newsContentOver()
{
gScrollerWorks=false;

}

function newsContentOut()
{
gScrollerWorks=true;

}


function show_registration()
{

	fadeOutAll();

	setTimeout
	(
	   function()
	   {				
	$("#ms_registracija_info").fadeIn(1000);
	$("#ms_black").fadeIn(1000);
	   }
	   , 1000
   	);



}



function show_registration_form()
{

	fadeOutAll();

	setTimeout
	(
	   function()
	   {				
	$("#ms_registracija").fadeIn(1000);
	$("#ms_black").fadeIn(1000);
	$("#ms_content").fadeIn(1000);
	$("#ms_content").html
(
'<div id="formular"><form id="form1" name="form1" method="post" action="#" onsubmit="form_submit();return false;" >    <table width="200" border="0">      <tr>        <td align="right" valign="top"><div class="whitefont">Name:</div></td>        <td align="left" valign="top"><label>          <input type="text" name="name" id="name" maxlength="25" size="25" />        </label></td>      </tr>      <tr>        <td align="right" valign="top"><div class="whitefont">Lastname:</div></td>        <td align="left" valign="top"><label>          <input type="text" name="lastname" id="lastname"  maxlength="25" size="25"  />        </label></td>      </tr>      <tr>        <td align="right" valign="top"><div class="whitefont">Phone:</div></td>        <td align="left" valign="top"><label>          <input type="text" name="phone" id="phone" maxlength="25" size="25"  />        </label></td>      </tr>      <tr>        <td align="right" valign="top"><div class="whitefont">Email:</div></td>        <td align="left" valign="top"><label>          <input type="text" name="email" id="email" maxlength="128" size="25"  />        </label></td>      </tr>      <tr>        <td align="right" valign="top"><div class="whitefont">Classes and milongas:</div></td>        <td align="left" valign="top"><label>          <textarea name="programi" id="programi" cols="30" rows="3"></textarea>        </label></td>      </tr>    <tr><td></td><td><label><input type="submit" name="submit" id="submit" value="Register"></label></td></tr></table>  </form></div>'

);
	   }
	   , 1000
   	);



}

function show_construction()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {				
	$("#ms_black").fadeIn(1000,function(){  
	$("#ms_black").css("opacity","0.7"); 
	$("#ms_black").css("filter","alpha(opacity=70)"); 
	$("#underconstruction").fadeIn(1000);
			$("#ms_content").html('');
	   }
	   , 1000
   	);

}
);
}

function show_workshop()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {				
	$("#workshop").fadeIn(1000);
	$("#ms_black").fadeIn(1000);
	   }
	   , 1000
   	);

}



function show_program()
{
	fadeOutAll();

	setTimeout
	(
	   function()
	   {				
	$("#program").fadeIn(1000);
	$("#ms_black").fadeIn(1000);
	   }
	   , 1000
   	);
}





function test()
{
	$("#ident").html("pera");
}

var lastEntry=undefined;

function menu_out()
{
	$("#menu_picture").hide();
	$("#menu_picture").css("background-image","none");
	$("#menu_picture").show();
	
}


function menu_over(item)
{
			lastEntry=item;
			$("#menu_picture").hide();
			$("#menu_picture").css("background-image","url(images/menu_over_"+item+".png)");
			$("#menu_picture").show();

/*
	setTimeout( function()
		{
			lastEntry=item;
			$("#menu_picture").hide();
			$("#menu_picture").css("background-image","url(images/menu_over_"+item+".png)");
			$("#menu_picture").fadeIn(200, function() {$("#menu_picture").show();} );
		}
		,150
	);
*/
}


function galerry_out()
{
	$("#gallery_selection").hide();
	$("#gallery_selection").css("background-image","none");
	$("#gallery_selection").show();
	
}


function galerry_over(item)
{
			lastEntry=item;
			$("#gallery_selection").hide();
			$("#gallery_selection").css("background-image","url(images/photogallery_over_"+item+".png)");
			$("#gallery_selection").show();
}



function logo_out()
{
	$("#logo_picture").hide();
	$("#logo_picture").css("background-image","none");
	$("#logo_picture").show();
	
}

function logo_over(item)
{
			lastEntry=item;
			$("#logo_picture").hide();
			$("#logo_picture").css("background-image","url(images/logo_over_"+item+".png)");
			$("#logo_picture").show();
}


function register_button_out()
{
	$("#registruj_se_button").hide();
	$("#registruj_se_button").css("background-image","url(images/register_button.png)");
	$("#registruj_se_button").show();
	
}

function register_button_over(item)
{
			lastEntry=item;
			$("#registruj_se_button").hide();
			$("#registruj_se_button").css("background-image","url(images/register_button_"+item+".png)");
			$("#registruj_se_button").show();
}







function form_submit()
{	

$.post("/reg.php",
			   {
					name: $("#name").val(),
					lastname: $("#lastname").val(),
					phone: $("#phone").val(),
					email: $("#email").val(),
					programi: $("#programi").val(),
					rand:Math.random()
				},
			   function(data)
			   {
					if (data=="ok" )
					{
						alert("Thank you for registering. You will receive confirmation mail soon. See you in Belgrade, and don't foret to bring your dancing shoes :)");
						return;
					}
					if ( data=='err_sending_email' )
					{
						alert("Doslo je do greske prilikom registracije, molimo vas pokusajte ponovo kasnije");
						return;
					}
					alert("Please fill in all the fields");
				}
		   )

}
