/* JQUERY REQUIRED */

var scripts = document.getElementsByTagName("script");
eval( scripts[ scripts.length - 1 ].innerHTML );
var active_group = 0;

;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);

(function(E,B){var C=function(G){var F,H=[];for(F in G){H.push(F+'="'+G[F]+'"')}return H.join("")},D=function(H){var F,J,I=[],G;for(F in H){if(typeof H[F]=="object"){G=[];for(J in H[F]){G.push([J,"=",encodeURIComponent(H[F][J])].join(""))}H[F]=G.join("&amp;")}I.push(['<param name="',F,'" value="',H[F],'" />'].join(""))}return I.join("")},A=false;E[B]=(function(){var F="0,0,0",G=navigator.plugins["Shockwave Flash"]||ActiveXObject;F=G.description||(function(){try{return(new G("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}catch(H){}}());F=F.match(/^[A-Za-z\s]*?(\d+)[\.|,](\d+)(?:\s+r|,)(\d+)/);return{available:F[1]>0,activeX:!G.name,version:{major:F[1]*1,minor:F[2]*1,release:F[3]*1},hasVersion:function(I){var L=this.version,J="major",K="minor",H="release";I=(/string|number/.test(typeof I))?I.toString().split("."):I||[0,0,0];I=[I[J]||I[0]||L[J],I[K]||I[1]||L[K],I[H]||I[2]||L[H]];return(I[0]<L[J])||(I[0]==L[J]&&I[1]<L[K])||(I[0]==L[J]&&I[1]==L[K]&&I[2]<=L[H])},expressInstall:"expressInstall.swf",create:function(H){if(!E[B].available||A||!typeof H=="object"||!H.swf){return false}if(H.hasVersion&&!E[B].hasVersion(H.hasVersion)){H={swf:H.expressInstall||E[B].expressInstall,attrs:{id:"SWFObjectExprInst",height:Math.max(H.height||137),width:Math.max(H.width||214)},params:{flashvars:{MMredirectURL:location.href,MMplayerType:(E[B].activeX)?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}};A=true}else{H=E.extend(true,{attrs:{height:H.height||180,width:H.width||320},params:{wmode:H.wmode||"opaque",flashvars:H.flashvars}},H)}return"<object "+(C(H.attrs))+(E[B].activeX?' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="'+H.swf+'" />':' type="application/x-shockwave-flash" data="'+H.swf+'">')+(D(H.params))+"</object>"}}}());E.fn[B]=function(F){if(typeof F=="object"){this.each(function(){var G=document.createElement(B);G.innerHTML=E[B].create(F);if(G.childNodes[0]){this.appendChild(G.childNodes[0])}})}else{if(typeof F=="function"){this.find("object").andSelf().filter("object").each(function(){var H=this,G="jsInteractionTimeoutMs";H[G]=H[G]||0;if(H[G]<660){if(H.clientWidth||H.clientHeight){F.call(this)}else{setTimeout(function(){E(H)[B](F)},H[G]+66)}}})}}return this}}(jQuery,"flash"));

$(document).ready( function() {

	$(".closePG").click( function () { $(this).parent().parent().parent().parent().parent().parent().fadeOut("fast"); } );
	
	$(".close-recommend").click( function () { $(this).parent().parent().parent().parent().parent().parent().fadeOut("fast"); } );
	
	$(".changephoto").click( function () {

		var cat_id = $(this).attr("cat");
		
		$("#popup-"+cat_id+" .changephoto").removeClass("act");
		$(this).addClass("act");

		var img = new Image();
		
		$(img).load( function () {
							   
			$("#" + preview).attr("src", img.src);

		});
		
		var preview = "preview-" + cat_id;
		
		$("#photo-desc-" + cat_id).html($(this).attr('title'));
		
		img.src = "uploads/photogallery/" + $(this).attr("url");
		
		return false;

	});
	
	$("#btnRecommendShow").click( function () {
				
		var i = new Image();

		$("#popup-recommend").css("top", $(this).offset().top);
	
		if ($(document).scrollTop() < $(this).offset().top + 655) {
			
			$(document).scrollTo($(this).offset().top - 30, 400);
			
		}
		
		$(i).load( function () {
							 
			$("#recommend-bg-5").css("background", "url(templates/i/pop-grad-2.jpg) no-repeat 0 0 #fff");
			document.getElementById("popup-recommend").style.display = "block";
			
		});
		
		i.src = 'templates/i/pop-grad-2.jpg';
		
	});
	
	$(".star").hover( function () {

		if ($(this).parent().hasClass("voted")) return false;
		
		$(this).parent().addClass("nobg");
		var index = $(this).attr("title");
		$(this).parent().children("DIV:lt("+index+")").addClass("act");

	}, function () {

		if ($(this).parent().hasClass("voted")) return false;
		
		$(this).parent().children("DIV").removeClass("act");
		$(this).parent().removeClass("nobg");

	});
	
	$(".star").click( function () {
								
		if ($(this).hasClass("voted")) return false;		
		
		var index = $(this).attr("title");
		
		var item_id = $(this).parent().attr("id");
		item_id = item_id.substring(5);

		$(this).parent().children().unbind();

		$.post('ajax/vote.php',
			   {
				   
				   hymn_id: item_id,
				   stars:	index,
				   vote: true
				   
				}, 
			   function (data) {
				   
				   eval(data);
				   
			   });
								
	});
	
	if (doScroll != '') {
		$.scrollTo(doScroll);
	}

	$(".read-all").toggle( function () {
							
		$(this).prev().slideDown("slow");
		$(this).html("Slėpti");
									
	}, function () {
		
		$(this).prev().slideUp("slow");
		$(this).html($(this).attr("lang"));
		
	});
	
});

function popup(url) {
	win = window.open(url, 'popup', 'width = 50, height = 50, toolbar = 0, scrollbars = 1, status = 0');	
	return false;
}

function openpg(id) {
	
	$(".popups").hide();
	
	$("#popup-" + id).css("top", 50);

	if ($(document).scrollTop() < $("#popup-" + id).offset().top + 655) {
		
		$(document).scrollTo(20, 400);
		
	}

	var i = new Image();
	
	$(i).load( function () {

		$(".gallery-nav").css("background", "url(templates/i/gallery-nav.jpg) no-repeat 0 0 #fff");

		$("#popup-" + id).show();

	});

	i.src = 'templates/i/gallery-nav.jpg';
	
}

function nextPhoto(id) {
	
	var it = $("#popup-" + id + " .visible").next();
	
	if (it.length > 0) {
		
		$(it).prev().removeClass("visible").hide();
		$(it).show().addClass("visible");
		
	}
	
}

function prevPhoto(id) {
	
	var it = $("#popup-" + id + " .visible").prev();
	
	if (it.length > 0) {
		
		$(it).next().removeClass("visible").hide();
		$(it).show().addClass("visible");
		
	}
	
}

function recommend() {
	
	$("#popup-recommend .error").removeClass("error");
	$("#popup-recommend .note").remove();
	
	$.post('./ajax/recommend.php', { your_email: $("#your_elpastas").val(),
									 friend_email: $("#friend_email").val(),
									 email_content: $("#email_content").val(),
									 recommend: 1 },
									 
									 
		function (data) {
			
			eval(data);
			
		});
	
}
