// JavaScript Document

function new_captcha() {
	var c_currentTime = new Date();
	var c_miliseconds = c_currentTime.getTime();
	document.getElementById('captcha').src = 'image.php?x='+ c_miliseconds;
}

$(function(){
	$('#vertical-ticker').totemticker({
		row_height	:	'44px',
		next		:	'#ticker-next',
		previous	:	'#ticker-previous',
		stop		:	'#stop',
		start		:	'#start',
		mousestop	:	true,
	});
});
$(function(){
	$('#products').slides({
		preload: true,
		preloadImage: 'images/loading.gif',
		effect: 'slide, slide',
		crossfade: true,
		play: 5000,
		slideSpeed: 350,
		fadeSpeed: 500,
		generateNextPrev: false,
		generatePagination: false
	});
});
$(function(){
	$('#products2').slides({
		preload: true,
		preloadImage: 'images/loading.gif',
		effect: 'fade, fade',
		crossfade: true,
		slideSpeed: 350,
		fadeSpeed: 500,
		generateNextPrev: false,
		generatePagination: false
	});
});
jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox({
	loadingImage : 'style/A6yafStyle/images/loading.gif',
	closeImage   : 'style/A6yafStyle/images/closelabel.png'
  })
})
$(document).ready(function(){
	$("#usual1 ul").idTabs(); 
	// Player
	$("#play .thumb span a,#play .thumb a").each(function() {
	   $(this).click(function() {
		   var href = $(this).attr("href");
		   var youtube = $(this).attr("youtube");
		   if(youtube==1) $("#play .thumb").html('<iframe width="662" height="380" src="'+href+'" frameborder="0" allowfullscreen></iframe>');
		   else {
			   flowplayer("player", "style/A6yafStyle/swf/flowplayer-3.2.3.swf");
		   }
		   return false;
	   });
	});
	// A6yaf.ps
	$("#gallery .postbox-content .gallery-ul li:nth-child(3n)").css({'marginLeft':'0'});
	$("#header ul.site li:first-child, .postbox-head #navigation li:last-child").css('background','none');
	$("#RightContent .morenews:nth-child(3n+1)").css('margin-left','0');
	$("#products .pagination li:last-child, .mr0, #multimedia .gellary .image ul li:last-child").css('marginLeft','0');
	$("#LeaftBlock ul.news li:last-child").css({'marginBottom':'0px','paddingBottom':'0px','borderBottom':'none'});
	$("#multimedia .sounds ul li:last-child, #LeaftBlock:last-child").css({'marginBottom':'0'});
	
// Captcha
$(".captcha .reload").click(function() {
	new_captcha();
	return false;	
});
	
	$("#multimedia .sounds ul li").css({'opacity':'0.4'});
	$("#multimedia .sounds ul li.player").css({'opacity':'1'});
	$("#multimedia .sounds ul li a").click(function(){
		$(this).parent().css({'opacity':'1'});
		$("#multimedia .sounds ul li.player").removeClass('player').css({'opacity':'0.4'});
		$(this).parent().addClass('player').css({'opacity':'1'});
	});
	
	$("#multimedia .sounds ul li a.play").each(function() {
		$(this).click(function(){
			var href = $(this).attr("href");
			$(".sound-player").css({'display': 'block'}).html('<object type="application/x-shockwave-flash" data="style/A6yafStyle/swf/soundPlayer.swf" id="audioplayer1" width="200" height="30px" style="" autoplay="true"><param name="movie" value="style/A6yafStyle/swf/soundPlayer.swf"><param name="FlashVars" value="playerID=AudioPlayer_163&amp;soundFile='+href+'&autostart=yes"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"></object>');
			$(".soundclose").fadeIn(510);
			return false;
		});
	});
	$(".soundclose").hide();
	$(".soundclose").click(function(){
		$(".sound-player").fadeOut(200);
		$(this).hide();
		$("#multimedia .sounds ul li").css({'opacity':'0.4'});
	return false;
	});
	
	$("#multimedia .gellary .image ul li a").each(function(){
		$(this).click(function(){
			var href = $(this).attr("href");
			var title = $(this).attr("title");
			$("#ShowImg").html("<img src='thumb.php?src="+ href +"&w=191&h=139&zc=1' width='191' height='139' alt="+ title +" />");
			$(".zoom").attr("href",href);
			return (false);
		});
	});
	
	$(".morenews .control").toggle(function(){
		$(this).animate({'bottom':'50px'},100).addClass("bg2").removeClass("bg");
		$(this).next("p.morenewstitle").animate({'bottom':'0'},100);
	},function(){
		$(this).next("p.morenewstitle").animate({'bottom':'-45px'},100);
		$(this).animate({'bottom':'5px'},100).addClass("bg").removeClass("bg2");
	});
	
	$('#navigation .r-w-m li a').hover(function(){
		$(this).parent('li').css('background','#0565c2');
		$(this).next('div').css({display:'none', visibility:'hidden'});
		$(this).next('.sub-big-menu, .sub-big-menu2').css({display:'block', visibility:'visible'});
	},function(){
		$(this).parent('li').css('background','#0B4781');
		$(this).next('.sub-big-menu, .sub-big-menu2').css({display:'none', visibility:'hidden'});
	});
	
	
  	// Font Resizing
	$('.fontsize li').click(function(){
	$(".fontsize .fontselected").removeClass('fontselected');
	$(this).addClass('fontselected');
	var TextSize=$(this).attr("sizeText");
	var lineHeightSize=  parseInt(TextSize)+8;
	$('.NewsText, .PageText').animate({fontSize:TextSize+"px", lineHeight:lineHeightSize+"px"}, 300);
	return false;
	});	

	// CUSTOMIZED AJAX VOTE, BY ME
	$("input.vote-submit").live("click", function() {
		if(!$(".vote-ajax input[type=radio]").is(":checked")) return false;
		$(".vote-submit img").removeClass("hide").addClass("show");
		$.post("index.php?ajax=vote&rand="+Math.random(), $(".vote-ajax").serialize(), function(data) {
			$("#poll").replaceWith(data);
			$$(".vote-submit img").addClass("hide").removeClass("show");
		});
		return false;
	});
	
	/* AJAX LIVE REQUEST FOR HTML FORMS, BY ME  */
	$(".ajax-submit").live("click", function() {
		var $form = $(this).parents(".ajax-form");
		var button = $(this).val();
		var action = $form.attr("action");
		var EMPTY_FLAG = false;
		$form.find(".input").each(function() {
			if($(this).val()=="") {
				$(this).focus();
				EMPTY_FLAG = true;
				return;
			}
		});
		if(!EMPTY_FLAG) {
			$form.find(".ajax-submit").attr("disabled", true);
			$form.find(".spinner").css({display:'block'}).html("");
			$("<img />",{src:"style/A6yafStyle/images/loading.gif",width:"14px",height:"14px"}).appendTo($form.find(".spinner"));
			$.post(action, $form.serialize(), function(response) {
				$form.find(".spinner").html(response);
				$form.find(".ajax-submit").removeAttr("disabled");
			});
		}
		return false;
	});
	
// Placeholder
$("input[Placeholder]").each(function(){
	$(this).addClass("focus");
	$(this).val($(this).attr("Placeholder"));			
	$(this).focusin(function(){
	if($(this).val()==$(this).attr("Placeholder")){
	$(this).val('');
	$(this).removeClass("focus");
	}
	}).focusout(function(){
	if($(this).val()==''){
	$(this).val($(this).attr("Placeholder"));
	$(this).addClass("focus");
	}	
	});
});
});
