function togleris(what){
	obj = document.getElementById("sub_"+what);
	tg = document.getElementById("sub_tg_"+what);
	if(obj.style.display==""){
		obj.style.display="none";
		tg.innerHTML = "+";
	}else{
		obj.style.display="";
		tg.innerHTML = "-";
	};
}

function check_mail(mail){
	return $.ajax({type:"GET",url:"/ajax.php",data:"act=check_mail&mail="+mail,async:false}).responseText;
}
function swap(id){
	obj = document.getElementById(id);
	if(obj.style.display==""){
		obj.style.display="none";
	}else{
		obj.style.display="";
	};
}
function get_subs(sid){
	$("#sub_cat").hide();
	$("#loader").show();
	$.getJSON("/ajax.php?act=subs&id="+sid,
        function(data){
			if(data.success==1){
				document.getElementById("sub_cat").options.length = 0;
				document.getElementById("sub_cat").options[0] = new Option("Pasirinkite...","");
				$.each(data.items, function(i,item){
					document.getElementById("sub_cat").options[item.nr] = new Option(item.name, item.value);
				});
			} else {
				document.getElementById("sub_cat").options.length = 0;
				document.getElementById("sub_cat").options[0] = new Option("...","");
			}
	});
	$("#sub_cat").show();
	$("#loader").hide();
}
$(document).ready(function() {
	$('#remejai a').qtip({ 
		style: { 
			name: 'cream', 
			tip: true
		},
		position: {
            corner: {
				tooltip: 'rightMiddle',
				target: 'leftMiddle'
			}
		}
	});
	$('#partneriai a').qtip({ 
		style: { 
			name: 'cream', 
			tip: true
		},
		position: {
            corner: {
				tooltip: 'rightMiddle',
				target: 'leftMiddle'
			}
		}
	});
})
/***********************************/
var map;
var geocoder = null;
var addressMarker;

    function showAddress(address, countryCode) {
      if (geocoder) {
        geocoder.setBaseCountryCode(countryCode);
        geocoder.getLatLng(address,
          function(point) {
            if (!point) {
              _default("Lietuva","LT");
            } else {
              if (addressMarker) {
                map.removeOverlay(addressMarker);
              }
              addressMarker = new GMarker(point);
              map.setCenter(point);
              map.addOverlay(addressMarker);
            }
          }
        );
      }
    }
	
	function _default(a,c){
      if (geocoder) {
        geocoder.setBaseCountryCode(c);
        geocoder.getLatLng(a,
          function(point) {
            if (!point) {
              /* *** */;
            } else {
              if (addressMarker) {
                map.removeOverlay(addressMarker);
              }
              addressMarker = new GMarker(point);
              map.setCenter(point,6);
              map.addOverlay(addressMarker);
            }
          }
        );
      }
	}
/**********************************************/
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function(){
	$('#jdsm > li').bind('mouseover', jsddm_open);
	$('#jdsm > li').bind('mouseout',  jsddm_timer);
});

document.onclick = jsddm_close;

