    
    function addEvent(elm, evType, fn, useCapture) {
    	if (elm.addEventListener) {
    		elm.addEventListener(evType, fn, useCapture);
    		return true;
    	}
    	else if (elm.attachEvent) {
    		var r = elm.attachEvent('on' + evType, fn);
    		return r;
    	}
    	else {
    		elm['on' + evType] = fn;
    	}
    }
        
    
    //
    // produktu katalogo skriptai
    //

	function order(a) {
		document.getElementById('ord').value = a;
		document.getElementById('fform').submit();
		return false;
	}
	
	function go_to_page(a) {
		document.getElementById('psl').value = a;
		document.getElementById('fform').submit();
        return false;
	}
	
	function addToCart(a) {
		document.getElementById('preke').value = a;
		document.getElementById('ff').submit();
	}
	
	function addToEqu(a) {
		document.getElementById('equ').value = a;
		document.getElementById('fform').submit();
	}

    function removeEqu(val){
		document.getElementById('dele').value=val;
		document.getElementById('fe').submit();
	}
	
	function insertEqu(val){
		document.getElementById('adde').value=val;
		document.getElementById('fe').submit();
	}

    

    //
    // popup lango atidarymas
    //
    function open_wnd(exp_bar,width,height,url,status_bar) {
        winName = "_blank";
        theURL = url;
        page_height = (height != '')?height:600;
        page_width = (height != '')?width:500;
        toolbar = (exp_bar == 1)?'yes':'no';
        statusbar = (status_bar == 1)?'yes':'no';
        page_top = Math.round((screen.height-page_height)/2);
        page_left = Math.round((screen.width-page_width)/2);
        size = "width="+page_width+",height="+page_height+",top="+page_top+",left="+page_left;
        features = 'status='+statusbar+',toolbar='+toolbar+',scrollbars=auto,resizable=yes,'+size;
        window.open(theURL,winName,features);
    }


	
function validateMail(strEmail) {
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

	if (strEmail.search(validRegExp) == -1) {
		
		return false;
	} else {
		return true;
	}
		
}
	
	
	
	
        // prepare the form when the DOM is ready 
        $(document).ready(function() { 
		
		
		
		
		
		
		if ($("#sendForm1").length > 0) {
		
	    $("#sendForm1").submit(function() {
		
			var sender_email = $("input[@name='xmail1']").val();
			var rec_email = $("input[@name='xmail2']").val();
			var lll = $("input[@name='xmaillang']").val();
			if (validateMail(sender_email) == false || validateMail(rec_email) == false) {
				alert($("input[@name='xerror']").val());
				return false;
			}
			
	        var post_data = $("#sendForm1").serialize();
			
	        $.post("index.php?page=sendMail1&ajx=1&lang="+lll, post_data, function(data){

	                if ($.trim(data) == "") {
					
						$("#sendFTBL").fadeOut();
						$("#sentok").fadeIn();
						
						
					} else {
						
						alert(data);
					}
	        
			});

	        return false;

	    });	}
		
		
		
		
		
		
		
		
		
		if ($("#sendForm2").length > 0) {
		
	    $("#sendForm2").submit(function() {
		
			var sender_email = $("input[@name='xmail17']").val();

			var lll = $("input[@name='xmaillang']").val();
			
			if (validateMail(sender_email) == false) {
				alert($("input[@name='xerror']").val());
				return false;
			}
			
	        var post_data = $("#sendForm2").serialize();
			
	        $.post("index.php?page=sendMail2&ajx=1&lang="+lll, post_data, function(data){

	                if ($.trim(data) == "") {
					
						$("#sendFTBL2").fadeOut();
						$("#sentok2").fadeIn();
						
						
					} else {
						
						alert(data);
					}
	        
			});

	        return false;

	    });	}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

        if (jQuery.browser.version < "4.0")
             $("#page_text").css("paddingBottom", "1px");

			$(document.getElementById("component_login_user")).click(function(){
				
				if (($("#component_login_user").val() == "Prisijungimo vardas:") 
				|| ($("#component_login_user").val() == "Login:") 
				|| ($("#component_login_user").val() == "логин:"))
				$("#component_login_user").val("");
			});
			
			$(document.getElementById("component_login_pass")).click(function(){
				
				if (($("#component_login_pass").val() == "Slaptažodis") 
				|| ($("#component_login_pass").val() == "Password") 
				|| ($("#component_login_pass").val() == "пароль"))
				$("#component_login_pass").val("");
			});
		
		});
    
function realign_footer() {



		if ($("#page_text").height() < 220) {
			if ($.browser.msie == true) {
				$("#page_text").css("height", "390px");
			} else if ($.browser.opera == true) {
				$("#page_text").css("height", "390px");
			} else {
				$("#page_text").css("height", "220px");
			}
		}

		var bt = Math.round(($(document).height() - 630) / 2);
		var outer_bg_left = ($(".outer_bg").width() - 1004) / 2;
		
		if (bt < 5) bt = 20;
		$("#footer_intro").css("bottom", bt);
		
		if (bt > 4)
		$("#fbg").css("height", bt);
		
		if ($.browser.msie == false) {
			$("#footer2_inside").css("left", "-89px");
		}
		if ($.browser.opera == true) {
			$("#footer2_inside").css("left", "-89px");
		}
		
		
		
	
		outer_bg_left = Math.round(outer_bg_left) + "px 0";
		
		$(".outer_bg").css("background-position", outer_bg_left);
	

};

$(window).bind('resize', function() {
	realign_footer();
	}
);

$(window).bind('load', function() {
	realign_footer();
	}
);




function CloseSendForm() {
	$("#SendFormContainer").fadeOut();
}
function CloseSendForm2() {
	$("#SendFormContainer2").fadeOut();
}

function ShowSendForm2() {
	$("#SendFormContainer2").fadeIn();
}


function ShowSendForm() {
	$("#SendFormContainer").fadeIn();
}

