jQuery.extend({
 ddata : function(wt) {
 
	  var kas = wt; var ndata=new Array(); var data = new Date();
	  
	  var metai = data.getFullYear();	var menuo = data.getMonth()+1; var diena = data.getDate(); var valanda = data.getHours(); var minutes = data.getMinutes(); var seconds = data.getSeconds();	  
	  
	  if (menuo < 10)
		menuo = '0'+menuo;
	  if (diena < 10)
		diena = '0'+diena;	 
	  if (minutes < 10)
		minutes = '0'+minutes;			
	  if (valanda < 10)
		valanda = '0'+valanda;	
	  if (seconds < 10)
		seconds = '0'+valanda;			
			
	  ndata['metai'] = metai;	ndata['menuo'] = menuo;	ndata['diena'] = diena;	ndata['valanda'] = valanda;	ndata['minutes'] = minutes;	ndata['data'] = metai+'-'+menuo+'-'+diena;	ndata['laikas'] = valanda+':'+minutes+':'+seconds; ndata['full'] = ndata['data']+' '+ndata['laikas'];
	 
	return ndata[kas]
 }
});

(function($)
{
    $(function()
    {
        // Siusti draugui
        $("#content_middle .below_h1 .send_to_friend a.show_send_to_friend").click(function()
        {
            $("#content_middle .below_h1 .send_to_friend_form_main").toggle();
        });
        $("#content_middle .below_h1 .send_to_friend_form").each(function()
        {
            var that = this;
            $(".close", this).click(function()
            {
                $(that).hide();
            });
        });
    });
})(jQuery);



(function($){
 $.fn.extend({
 
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {
	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="'+options.outer+'"><span class="'+options.inner+'">'+currentSelected.text().substr(0,options.lenght)+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).height(selectBoxHeight).change(function(){
				selectBoxSpanInner.text($("#"+$(this).attr('id')+" :selected").text().substr(0,options.lenght)).parent().addClass('changed');
				
			});
			
	  });
	  }
	}
 });
})(jQuery);





function submit_login_form() {	
	$('<input type="hidden" name="ctl00$ContentPlaceHolder1$lbtRemindPassword" value="true" />').appendTo('#aspnetForm');
	document.aspnetForm.submit();
	return ret_false();
}


function validateSearchContacts() {	
	var street=$("input[name=street]").val();
	var city=$("select[name=city]").val();	
	if (street!='' && city=='') {
		alert('Pasirinkite miestą kuriame ieškosite');
		return ret_false();
	} else return true;
}

function gotoUrl(object) {	
	document.location.href = '/kontaktai/konsultantu-kontaktai/,city.' + $(object).val();	
}



//Return false response
function ret_false() {
	try
	{window.event.returnValue = false; } catch (error)
	{return false;}	
}

//Is defined or not
function isdefined( variable) {
    return (typeof(window[variable]) == "undefined")?  false: true;
}


(function ($) {
		
    $.floatbox = function (options) {
	    var naukstis = options.baukstis;
	    
        var settings = $.extend({
            bg : "floatbox-background",
            box : "floatbox-box",
            content : "",
			button: "<div style='position: absolute; top: 0; right: 0px'><a role='button' href='javascript:void(0);' class='close-floatbox'><img src='/images/fancybox/fancy_closebox.png' style='height: 18px; width: 19px; border: 0px;'></a></div>",
			desc: "This is a popup box, press esc key to close.",
            fade : false,
			ajax: null,
            bgConfig : {
                position: ($.browser.msie) ? "absolute" : "fixed",
                zIndex: 8,
                width: "100%",
                height: "100%",
                top:  "0px",
                left: "0px",
                backgroundColor: "#000",
                opacity: "0.3",
                display: "none"
            },
            boxConfig : {
                position : ($.browser.msie) ? "absolute" : "fixed",
                zIndex: 9,
                //width: ($(window).width() / 2) + "px",
                padding: "15px 1px 15px 15px",
                border: "1px solid #cdcfd4",
                width: "500px",
                marginLeft: "-250px",
           //     marginLeft: "-" + (($(window).width()-500) / 2) + "px",
                height: options.baukstis,
                overflow: "auto",
                overflowX: "hidden",
                top: "50%",
                left: "50%",
                backgroundColor: "#fff",
                display: "none"
            }
        }, options);

        //inserts floatbox and sets its content
        var showBox = function () {
	        
			var content = typeof settings.content === "string" ? settings.content : settings.content.clone();
            //inserts the background element in the document
            $("<div></div>")
                .bind("click", function () {
                    closeBox();
                })
                .attr("id", settings.bg)
                .css(settings.bgConfig)
                .width(($.browser.msie) ? document.body.clientWidth : "100%")
                .height(options.aukstis)
                .appendTo("body");
            //inserts the floating box in the document
            $("<div></div>")
                .attr({id: settings.box, role: "alertdialog"}) 
                .html('<div style="overflow: auto; overflow-x: hidden; width:'+options.pwidth+'px; height: '+naukstis+'px; padding: 0px '+options.mright+'px 0px 1px">'+content+'</div>')
                .append(settings.button)
                .css(settings.boxConfig)
                .appendTo("body")
                .css("margin-top", "-" + $("#" + settings.box).height() / 2 + "px")
                .find(".close-floatbox").bind("click", function () {
                    closeBox();
                })
                .end();
            //checks if it needs to fade or not
            if (settings.fade) {
                $("#" + settings.bg)
                .fadeIn(200, function () {
                    $("div#" + settings.box).fadeIn(200);
                    scroll(0,options.pozicija);
                    scroll(0,options.pozicija2);
                });
            } else {
                $("#" + settings.bg)
                .show()
                .parent().find("#" + settings.box).show();
            }
			//sets if ajax is needed(already detectets if it is POST or GET)
			if (settings.ajax) {
				$.ajax({
					type: settings.ajax.params === "" ? "GET" : "POST",
					url: settings.ajax.url,
					data: settings.ajax.params,
					
					beforeSend: function () {
						$("#" + settings.box).html(settings.ajax.before);
					},
					
					success: function (data) {
						$("#" + settings.box)
							.html(data)
							.append(settings.button)							
							.find(".close-floatbox").bind("click", function () {
								closeBox();
							});
					},
					contentType: "html"
				});
			}
        };
        //hides floatingbox and background
        var closeBox = function () {
            if (settings.fade) {
                $("#" + settings.box).fadeOut(200, function () {
                     $("#" + settings.bg).fadeOut(200, function () {
						$("#" + settings.box).remove();
						$("#" + settings.bg).remove();
                    });
                });
            } else {
				//for opera issues hide first and a timeout is needed to remove the elements
				$("#" + settings.box + ",#" + settings.bg).hide();
				setTimeout(function () {
					$("#" + settings.box).remove();
					$("#" + settings.bg).remove();
				}, 500);
            }
        };
        //inits the floatbox
        var init = function () {
            //shows box
            showBox();
			//adds cross browser event to esc key to hide floating box
            $(document).one("keypress", function (e) {
                var escKey = $.browser.mozilla ? 0 : 27;
                if (e.which === escKey) {
                    closeBox();
                }
            });
			//if msie6, adds event to browser scroll to keep floatbox ina fixed position and uses css hack for full background size
	        if ($.browser.msie) {
	            $("body, html").css({height: "100%", width: "100%"});
	            $(window).bind("scroll", function () {
	                $("#" + settings.box).css("top", document.documentElement.scrollTop +  ($(window).height() / 2) + "px");
	            });
	        }
        };
        //starts the plugin
        init();
    };
    
})(jQuery);




function ch(id, tlin){
    
	var pozicija = document.body.scrollTop;	
	if (pozicija == 0){ if (window.pageYOffset)	pozicija = window.pageYOffset; 	else   	pozicija = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0; }
 	
	pozicija=pozicija+1;
	var pozicija2=pozicija-2;
	document.getElementById(id).style.display='block';
	var aukstis = document.getElementById(id).offsetHeight; 
	if (!aukstis) {aukstis = 400}
	aukstis = aukstis-20;
	document.getElementById(id).style.display='none';
    var braukstis = document.documentElement.clientHeight-70;

        
    if (!braukstis) {braukstis = 400;}


			if ((navigator.appName == "Microsoft Internet Explorer") && (parseFloat(navigator.appVersion.split("MSIE")[1])) < 8) {
				 if (aukstis > braukstis){var mright="33"; var pwidth="467";}else{var mright="15"; var pwidth="485";}
		 	}else{var mright="15"; var pwidth="485";}
	if (aukstis > braukstis){aukstis = braukstis;}	
	
	
$.floatbox({
        content: document.getElementById(id).innerHTML,
        aukstis: document.getElementById("content_middle").offsetHeight+280,
        baukstis: aukstis,
        pozicija: pozicija,
        pozicija2: pozicija2,
        mright: mright,
        pwidth: pwidth,
        fade: true
    });

}

$(document).ready(function(){
	$(".devider_left h2:first-child").css({marginTop:'0'});
	
	$(".expl").mouseover(function(){
		$(".expltext").css({display: 'block', top:$(this).offset().top-5, left:$(this).offset().left+$(this).width()+2});
	});
	
	$(".expl").mouseout(function(){
		$(".expltext").hide();
	});
	
	
	$('.select_st').customStyle({outer: 'select_st', inner: 'select_stInner', lenght: '11'});
	$('.select_t5').customStyle({outer: 'select_t5', inner: 'select_t5Inner', lenght: '11'});
	
	$('input[type="text"]').focus(function() {  
        if ((this.value == this.defaultValue) && ($(this).attr('class') != 't1' && $(this).attr('class') != 't2')){  
            this.value = '';  
        }  
        if(this.value != this.defaultValue){  
            this.select();  
        }
    });  
    
	$('input[type="text"]').blur(function() {  
        if(this.value == ''){  
            this.value=this.defaultValue;  
        }     
    }); 
    
	
	$('input[type="radio"]').click(function() {  
	  if ($(this).parent().find('label').attr('for'))
		var tipas = $(this).parent().find('label').attr('for');
	  else
		var tipas = $(this).parent().parent().find('label').attr('for'); 

	
	
	
      if( $("."+$(this).attr('alt')).css('display') != 'block'){			
		$("."+tipas).slideUp();	

		$("."+tipas+'.'+$(this).attr('alt')).slideDown();
	  }
	  
	}); 	
	
	$('input[type="checkbox"]').click(function() {  
	
		if ($(this).attr('alt') == 'inv')
			var dirc = ($("."+$(this).attr('name')).css('display') != 'block' && $(this).attr('checked') != '');
		else
			var dirc = ($("."+$(this).attr('name')).css('display') != 'block' && $(this).attr('checked') == '');


      if( dirc ){			
		$("."+$(this).attr('name')).slideUp();	

		$("."+$(this).attr('name')+'.'+$(this).attr('name')).slideDown();
	  }else{
		$("."+$(this).attr('name')).slideUp();	
	  }

	});
	
	
	$('.file').change(function() {
		var rks = $(this).val(); 
		
		if (!rks)
			rks = $(this).next('.fileinput').find('.nera').html();
		$(this).next('.fileinput').find('.ikeltas').html(rks);
	});
	
	
	$('.rd').click(function(){
		
		
		if ($(this).prev().attr('type') == "radio"){
			$(this).prev().attr("checked", "checked");
			$(this).prev().click();
			
		}else{
		
		  if ($(this).attr('alt') == 'inv'){
			cc = "checked"; cd = "";
		  }else{
			cc = ""; cd = "checked"	
		  }	
		
		  if (!$(this).prev().attr("checked") || $(this).prev().attr("checked") == ''){
			
			$(this).prev().attr("checked", cc);
			$(this).prev().click(); 
			$(this).prev().attr("checked", cc);
		  }else{	
			
			$(this).prev().attr("checked", cd);		
			$(this).prev().click();
			$(this).prev().attr("checked", cd);	
		  }	
		}

		
	});
	
	
	
	
	//$('input[name="valstybinis_numeris"], input[name="k_numeris"]').mask("aaa-999");  
	
}); 



openprint = function(content, aurl, title){ 
var win=window.open("", "newwin", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes");
win.moveTo(screen.availWidth/2-350,screen.availHeight/2-280);
win.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>');
win.document.write('<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>PZU</title>');
win.document.write('<link rel="stylesheet" type="text/css" href="http://www.pzu.lt/styles/style.css" ></head>');
win.document.write('<body onLoad="print()"><div style="width:800px;"><div><a href="http://www.pzu.lt/" title="PZU"><img src="http://www.pzu.lt/images/logo.jpg"/></a></div><br/><div id="content_middle_print" style="clear:both !important;"><div class="content_area"><h1 class="black">'+title+'</h1><div>'+content+'</div><div class="clear"></div></div><div class="hr"><!-- --></div><div class="fs11">'+$.ddata('full')+' <br/><br/>'+aurl+'</div></div></div></body></html>');
win.document.close();
}


