var sCopyTitle = null;
var oCurrToolTip = null;
var oToolTipPos = null;
//
function showTooltip(obj, blShow){
    if (blShow) {
        sCopyTitle = obj.title;
        obj.title = '';
        oCurrToolTip = document.createElement('span');
        oCurrToolTip.innerHTML = sCopyTitle;
        oCurrToolTip.className = 'tooltip';
        
        oToolTipPos = document.createElement('span');
        oToolTipPos.className = 'tooltippos';
        oToolTipPos.appendChild(oCurrToolTip);
        
        obj.parentNode.insertBefore(oToolTipPos, obj);
    }
    else {
        obj.title = sCopyTitle;
        sCopytitle = '';
        if (oToolTipPos != null) {
            obj.parentNode.removeChild(oToolTipPos);
            oToolTipPos = null;
        }
    }
}

function setSellList(oInObj){
    //for module wlist
    var _wlist = document.getElementById("_wlist");
    if (_wlist != null) {
        if ('[{$urlsign}]' == '&') 
            _wlist.href = _wlist.href + "&" + oInObj.name + "=" + oInObj.value;
        else 
            _wlist.href = _wlist.href + "[{$urlsign}]" + oInObj.name + "[{$urlsign}]" + oInObj.value;
    }
    //for original selectlist
    var _wlist = document.getElementById("_slist");
    if (_wlist != null) {
        if ('[{$urlsign}]' == '&') 
            _wlist.href = _wlist.href + "&" + oInObj.name + "=" + oInObj.value;
        else 
            _wlist.href = _wlist.href + "[{$urlsign}]" + oInObj.name + "[{$urlsign}]" + oInObj.value;
    }
}


function pMoreDetails(oObj){
    if (oObj != null && oObj.href.length > 0) {
        fenster_attribute = "status=yes,scrollbars=no,menubar=no,width=430,height=500";
        open(oObj.href, "send_link", fenster_attribute);
    }
}

$(function() {
	$(".external").attr("target","_blank");
});
$(function() {
	$(".autocompleteOff").attr("autocomplete","off");
	$("#rateSubmit").mouseover(function(){
		$(this).addClass("active");
	}).mouseout(function(){
		$(this).removeClass("active");
	}).click(function(){
		if($('input[name=ratevalue]:checked').size() != 0){
			$("#rateme").submit();
		}else{
			$("#rateme .inlineError").toggle();
		}
	})
});
$(function(){
		$("#articleImage img").attr({longdesc: $("#picsList a.first").find("img").attr("longdesc")});
		$("#picsList a").mouseover(function(){
			$("#articleImage img").attr({style: "background:url("+ $(this).attr("href")+") no-repeat 50% 50%;", longdesc: $(this).find("img").attr("longdesc")});
			return false;
			}).click(function(){return false;});
});

$(document).ready(function(){
		curSelItem = '';
		$("#sortParams").css({left: ($("#sortTarget").offset().left + 'px')});
		if ($("#sortParams a").hasClass("active")) {
			$("#sortOrder").css({"display":"block"});
			curSelItem = $("#sortParams a.active").html();
			curClass = $("#sortParams a.active").attr("class");
			curLink = $("#sortParams a.active").attr("href")
			$("#sortOrder").attr("class", curClass).attr("href", curLink);
		}
		if (curSelItem !='') {
			$("#sortTarget").html(curSelItem);
		}else{
			$("#sortTarget").html("Pasirinkite");
		}
        $("#sortTarget").click(function(){
        	if ($("#sortParams").css('display') == "none") {
				$("#sortParams").show();
				$(this).addClass("sortValueActive");
			}
			else {
				$("#sortParams").hide();
				$(this).removeClass("sortValueActive");
			}
            return false;
        });

        $('#sortParams').click(function(e) {
            e.stopPropagation();
        });
        $(document).click(function() {
            $('#sortParams').hide();
			$("#sortTarget").removeClass("sortValueActive");
        });
    });

$(function(){
 $(".linkSubmit").click(function(){
 	$(this).closest("form").submit();
 });
 $("#wrongPerson").click(function(){
 	 $('#identifybox').hide();
 });
$('#dialog').jqm();  
$('#dialog').jqmAddTrigger('a.dialog'); 

});



$(function() {
 $('.cmsPage a[href*=#]').click(function() {

   var $target = $(this.hash);
   $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
   if ($target.length) {
      var targetOffset = $target.offset().top-10;
  $('html,body').animate({scrollTop: targetOffset}, 1000);
    return false;
   }  
  })
})
