(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(g.state==0){g.start=c(g.elem,e);g.end=b(g.end)}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);

var animation = null;

$(document).ready( function () {
							 
	$("#formComment").submit( function () {
										
		if ($("#submitComment").attr("clear") == "do") {
			
			$("#submitComment").attr("clear", "").val("Send");
			
			$("#commentContent").animate( { 			
											backgroundColor: "#ffff00",
											color: "#000"
											
										}, 1000 );
			
			$("#commentContent").val("");
			
			return false;
			
		}
						
		$.post( $(this).attr("action"),
				{ commentEmail: $("#commentEmail").val(),
				  commentElpastas: $("#commentElpastas").val(),
				  commentUrl: $("#commentUrl").val(),
				  commentName: $("#commentName").val(),
				  commentContent: $("#commentContent").val(),
				  submitComment: true },
				 
				 function (data) {
					 
					 eval(data);
					 
				 });
										
		return false;

	});
	
	var slider_title = $("#slider-01 p");
	var slider_active = 1;
	var slider_count = $("#slider-01 .tac a").length;
	
	var animation_direction = 'next';
	var auto_click = false;
	
	if ($("#slider-01").length == 1) {
		
		animation = setInterval(function () {
										  
			auto_click = true;
										  
			if (animation_direction == 'next') {
				
				if (slider_active + 1 == slider_count) animation_direction = 'prev';
				
				$("#slider-01 a:last").click();
				
			} else {
				
				if (slider_active == 1) animation_direction = 'next';
				
				$("#slider-01 a:last").prev().click();
				
			}
										  
		}, 1500);
		
	}	
	
	$("#slider-01 a:last").prev().click(function () {
												  
		if (!auto_click) clearInterval(animation);
										   
		$(this).next().css("visibility", "visible");
		
		slider_active--;
		
		if (slider_active == 1) 
			$(this).css("visibility", "hidden");		
		
		$("#slider-01 div.tac div").animate( { left: (-1) * 176 * (slider_active-1) }, 400 );
		
		$("#slider-01 p").html($("#slider-01 div.tac a:eq("+(slider_active-1)+")").attr("title"));
		
		auto_click = false;
										   
	});	
	
	$("#slider-01 a:last").click(function () {
										   
		if (!auto_click) clearInterval(animation);										   

		if (slider_active + 1 == slider_count)
			$(this).css("visibility", "hidden");

		$(this).prev().css("visibility", "visible");

		slider_active++;

		$("#slider-01 div.tac div").animate( { left: (-1) * 176 * (slider_active-1) }, 400 );
		
		$("#slider-01 p").html($("#slider-01 div.tac a:eq("+(slider_active-1)+")").attr("title"));
		
		auto_click = false;

	});
	
	$(".goto-on-change").change(function () {
											 
		document.location = $(this).val();
											 
	});
	
	$("#switch-event-type a").click( function () {
		
		$("#switch-event-type li").removeClass("active");
		
		$(this).parent().addClass("active");
		
		$(".event-list").hide();
		
		var str = $(this).attr("href").match(/\d+/);
		
		$("#event-list-" + str).show();
		
		$(".event-links div").hide();
		
		$("#event-links-" + str).show();
		
	});

	if ($("#googlemap").length == 1) {
		
		loadmaps($("#googlemap").attr("lat"), $("#googlemap").attr("long"), "googlemap", $("#googlemap").attr("title"));
		
	}
	
	$("#btnClearSubscription").click( function () {
			
		$("#subscription_form input[type='text']").val('');
		$("#subscription_form :selected").removeAttr("selected");
												
	});
	
	$("#subscription_form").submit( function () {
									  
		$.post($(this).attr("action"), { subscription_fname: 		$("#subscription_fname").val(),
										 subscription_lname: 		$("#subscription_lname").val(),
										 subscription_company: 		$("#subscription_company").val(),
										 subscription_company_type: $("#subscription_company_type").val(),
										 subscription_activity: 	$("#subscription_activity").val(),										 
										 subscription_elpastas: 	$("#subscription_elpastas").val(),
										 submit_subscription: 		true,
										 return_js: 				true }, function (data) { eval(data); });
		
		return false;
											  
	});
	
	$("#faq_form").submit( function () {

		$.post($(this).attr("action"), { faq_fname: $("#faq_fname").val(),
										 faq_elpastas: $("#faq_elpastas").val(),
										 faq_question: $("#faq_question").val(),
										 submit_faq: true,
										 return_js: true }, function (data) { eval(data); });
		
		return false;
											  
	});
	
	$("#btnClearFaq").click( function () {
									   
		$(".form-01 input[type='text']").val('');	
		$(".form-01 textarea").val('');	
									   
	});	
	
	$(".btnShowAnswer").toggle( function () {
											   
		$(this).parent().children("div").slideDown("fast");
											   
	}, function () {
		
		$(this).parent().children("div").slideUp("fast");
		
	});
	
});

function loadmaps(center_lat, center_long, id, text) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById(id));
		map.setCenter(new GLatLng(center_lat, center_long), 16);
		var mapTypeControl = new GMapTypeControl();
		var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10, 10));
		var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 10));
		map.addControl(mapTypeControl, topRight);
		map.addControl(new GSmallMapControl());

		marker0 = new GMarker(new GLatLng(center_lat, center_long));
		map.addOverlay(marker0);
		marker0.openInfoWindowHtml('<p style="text-align: center"><b>ICC Lietuva</b><br />'+text+'</p>');
	}
}

function printpage() {
	var url = document.location.href;
	
	for (i = url.length; i > 0; i--) {
		if (url.charAt(i) == '?') {
			url = url + '&';
			break;
		} else if ((url.charAt(i) == '/') || (url.charAt(i) == '\\')) {
			url = url + '?';
			break;
		}
	}

	win = window.open(url + 'do=print', 'popup', 'toolbar = 0, scrollbars = 1, status = 0');
	win.window.print();
}