function verify_age() {
 $.ajax({
   type: "GET",
   url: "age_verification.php",
   success: function(msg){
		$("#age_confirm").fadeOut();
		$(".tvc").fadeIn();
		showVideo();
   }
 });
}

function get_news_item(id) {
 $.ajax({
   type: "GET",
   url: "news_item.php",
   data: "id="+id,
   success: function(msg){
		$("#news_item_long").html(msg);
   }
 });
}

function get_cocktail_item(id,obj) {
 $.ajax({
   type: "GET",
   url: "cocktail_item.php",
   data: "id="+id,
   success: function(msg){
		$("#right").html(msg);
		$(".item").removeClass("item_selected");
		$(obj).addClass("item_selected");
   }
 });
}

function get_gallery(id,obj) {
 $.ajax({
   type: "GET",
   url: "gallery.php",
   data: "id="+id,
   success: function(msg){
		$(".gallery_right_container").html(msg);
   }
 });
}

function get_promo(id,obj) {
 $.ajax({
   type: "GET",
   url: "promo.php",
   data: "id="+id,
   success: function(msg){
		$(".promo_right_container").html(msg);
		$(".light").lightBox();
   }
 });
}

function show_passfield() {
	$("#pass").html("<input type=\"password\" name=\"password\" id=\"passfield\" onBlur=\"if (this.value=='') hide_passfield(); \" />");
	$("#passfield").focus();
	$("#passfield").focus();
}

function hide_passfield() {
	$("#pass").html("<input type=\"text\" name=\"password\" value=\"парола\"  onFocus=\"javascript:show_passfield(); \" />");
}

function show_shortnews(curr) {
 $.ajax({
   type: "GET",
   url: "short_news.php",
   data: "current="+curr,
   success: function(msg){
     $(".news_short").html(msg);
   }
 });
}

function manipulate_login_field($in_or_out) {
	if ($in_or_out=="in") {
		$(".login_field").fadeIn("slow");
		if (typeof(ctime)=='undefined') {
			var ctime = setTimeout("null",1000);
		}
		$(".login_field_hider").fadeIn("slow").hover(
													 function() {ctime = setTimeout("manipulate_login_field('out')",2000);},
													 function() {clearTimeout(ctime);}
													 );
	} else {
		$(".login_field").fadeOut();
		$(".login_field_hider").fadeOut();
	}
}

function login(action) {
	var str = $("#login_form").serialize();
 $.ajax({
   type: "POST",
   url: "login.php",
   data: "action="+action + "&" + str,
   success: function(msg){
	   var arr = msg.split("###");
	   if (action == "login") {
		   if (arr[0] == "loginok") {
			   $(".login_field").text("Влязохте успешно в системата, "+arr[1]+"!");
			   $(".login_link").text("Излез, "+arr[1]);
			   $(".login_link").attr("href","javascript:login('logout');");
			   window.location.reload();
			   history.go(0);
			   window.location.href=window.location.href;
		   } else {
			   $(".login_field").css("backgroundColor","#993333");
		   }
	   } else if (action == "logout") {
			   $(".login_link").text("Вход");
			   $(".login_link").attr("href","javascript:login();manipulate_login_field('in');");			   
			   window.location.reload();
			   history.go(0);
			   window.location.href=window.location.href;
	   } else {
		   $(".login_field").html(msg);
		   $('#username_field').focus();
	   }
   }
 });
}

function rate(rating) {
 $.ajax({
   type: "POST",
   url: "rating.php",
   data: "action=rate&movie_id="+movie_clip_id+"&rating="+rating,
   success: function(msg){
     $("#rating_container").html(msg);
   }
 });

//	alert("voted "+rating+" for "+movie_id );
}

	function showVideo() {
		$(".tvc").html('<img src="images/egi.png" /><br /><br />    <object height="374" align="middle" width="610" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">    <param value="image=&amp;file=tvc.f4v&amp;skin=overlay.swf&amp;frontcolor=ffffff&amp;lightcolor=cc9900&amp;controlbar=over&amp;play_now=true" name="flashvars" />    <param value="always" name="allowScriptAccess" />    <param value="true" name="allowFullScreen" />    <param value="hurricane/player.swf" name="movie" />    <param value="high" name="quality" />    <param value="#000000" name="bgcolor" />    <param name="wmode" value="transparent" />     <embed src="hurricane/player.swf" width="610" height="374" align="middle" flashvars="image=&amp;file=tvc.f4v&amp;skin=overlay.swf&amp;frontcolor=ffffff&amp;lightcolor=cc9900&amp;controlbar=over&amp;play_now=true" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" name="film_quiz" bgcolor="#000000" quality="high" wmode="transparent"></embed> </object>    <div class="tvc_background" onClick="javascript:hideVideo();"></div><br /><br />    <a href="javascript:hideVideo();">Затвори</a>');
	}
	
	function hideVideo() {
		$(".tvc").fadeOut().html("&nbsp;");
	}
