/* JQUERY REQUIRED */

var scripts = document.getElementsByTagName("script");
eval( scripts[ scripts.length - 1 ].innerHTML );
	
$(document).ready(function(){
	
	var delay = false;
	var itemIndex = (HOMEPAGE) ? 1 : 2;
	
	if (itemIndex == 1) {
		$("#main_menu_popup").css("margin-left", $("#mainmenu LI:eq(0)").width() + 15 + 194)
							 .mouseover( function () { delay = true; } )
							 .mouseout( function () { delay = false; } );	
	} else {
		$("#main_menu_popup").css("margin-left", $("#mainmenu LI:eq(0)").width() + $("#mainmenu LI:eq(1)").width() + 15 + 23 + 194)
							 .mouseover( function () { delay = true; } )
							 .mouseout( function () { delay = false; } );	
	}

	$("#mainmenu LI:eq("+itemIndex+")").mouseover( function () { $("#main_menu_popup").slideDown("fast"); delay = true; } );
	$("#mainmenu LI:eq("+itemIndex+")").mouseout( function () { setTimeout(function() { menuHide() }, 500) } );
	
	function menuHide() {
		if (delay) {
			setTimeout( function () { menuHide(); }, 500);
		} else 
			$("#main_menu_popup").slideUp("fast");
	}
	
	$("A[href='#']").attr("href", "javascript:void(0)");
	
	$("#btnPrint").click( function () { printpage() } );

	var active_group = 1;
		
		$("#pg .i A").each( 
			function (index) { 
				$(this).click( function () {	

										 		 var fn = $("#pg .i A IMG:eq("+index+")").attr("src");
												 var r = '';

												 for (var i = (fn.length - 1); i > 0; i--) {
													 if (fn.charAt(i) == '=') {
														 break;
													 }
													 r = fn.charAt(i) + r;
												 }
												 
										 		 r = r.substr(1, r.length-1);
												
												 var img = new Image();
												 $(img).load( function () {
																		 
																		 $("#preview").fadeOut("fast", function () { 
																														$(this).attr("src", r).fadeIn("fast");
																													});
																																
																			});
												 img.src = r;

												 $("#pg .i A").removeClass("act");
												 $(this).addClass("act"); 												 

										 	});
			}
		);
		
		$("#btnNext").click( function () {
												
												$("#pg LI.group-"+active_group).fadeOut("fast", function () { 
																												  
													$("#btnPrev").removeClass("hide2");												
													
													$("#pg LI.group-"+(active_group)).removeClass("hide").fadeIn("fast");

													if ($("#pg LI.group-"+(active_group+1)).length == 0) {
														$("#btnNext").addClass("hide2");
													}
													
												});
												
												active_group++;
											
									   		});
		
		
		$("#btnPrev").click( function () {
												$("#pg LI.group-"+active_group).fadeOut("fast", function () { 
																										  
													$("#btnNext").removeClass("hide2");																										  
												
													$("#pg LI.group-"+(active_group)).removeClass("hide").fadeIn("fast");

													if ($("#pg LI.group-"+(active_group-1)).length == 0) {
														$("#btnPrev").addClass("hide2");
													}
													
												});
											
												active_group--;
												
									   		});
		

	$(".hide_email").each(function () { 
									$(this).attr("href", "mailto:" + $(this).attr("name") + "@" + $(this).attr("title"))
										   .html($(this).attr("name") + "@" + $(this).attr("title")); });
	
	if (MOD == 'companies') {
		
	}
	
	$("#input-search").click(function () {

		if ($(this).val() == $(this).attr('lang'))
			$(this).val('');
									   
	});
	
	$("#input-search").blur(function () {
									   
		if ($(this).val() == '')
			$(this).val($(this).attr("save"));
									   
	});
	
	$("#input-search").attr("save", $("#input-search").val());	
	
	$("#input-image").click( function() {
									  
		if (($("#input-search").val() == '') || ($("#input-search").val() == $("#input-search").attr('save'))) {
			$("#input-search").val('').focus();
			return false;
		}
									  
	});
	
});



function printpage() {
	var url = document.location.href;
	
	for (i = url.length; i > 0; i--) {
		if (url[i] == '?') {
			url = url + '&';
			break;
		} else if ((url[i] == '/') || (url[i] == '\\')) {
			url = url + '?';
			break;
		}
	} // pridet ? jei nera paramu, pridet & jei yra paramu

	win = window.open(url + 'do=print', 'popup', 'toolbar = 0, scrollbars = 1, status = 0');
	win.window.print();
}
http://localhost/_new/axis/assets/scripts/popup.php?imgUrl=../uploads/companies/sert/index-1-3.jpg
function openPopup(url, w, h) {
	w = 50;
	h = 50;
	win = window.open(BASE_HREF + 'assets/scripts/popup.php?imgUrl=../.'+url, 'popup', 'toolbar = 0, scrollbars = 1, status = 0, width = ' + w + ', height = ' + h);
}