function popup(x,y,pname,scroll)
{
  var openedobj = window.open("",pname,"width="+x+",height="+y+",scrollbars="+(scroll ? "yes" : "")+",resizable=1");
  openedobj.focus();
}
function popupurl(url,x,y,pname,scroll)
{
  var openedobj = window.open(url,pname,"width="+x+",height="+y+",scrollbars="+(scroll ? "yes" : "")+",resizable=1");
  openedobj.focus();
}

// wird nur noch im Portfolio benutzt
function setclass (id, klasse) {
  document.getElementById(id).className=klasse;
}

// Remove IE mouse flickering.
try
{
	document.execCommand( 'BackgroundImageCache', false, true ) ;
}
catch (e) 
{
	// We have been reported about loading problems caused by the above
	// line. For safety, let's just ignore errors.
}

(function($){ 
    $.fn.extend({ 
        scaleandlink: function(opt) {
    		opt = jQuery.extend({
    			width:null,
    			height: null,
    			popup: false,
    			popup_width:800,
    			popup_height:600,
    			popup_scroll:true
    		}, opt);
    		var ret;
    		if(opt.height!=null)
    			ret = this.css("height",parseInt(opt.height));
    		if(opt.width!=null)
    			ret = this.css("width",parseInt(opt.width)-50);
    		if(opt.popup){
    			ret= this.after('<a target="_blank" rel="nofollow" onclick="popupurl(\'/_plain/image?url='+$(this).attr('src')+'\','+opt.popup_width+','+opt.popup_height+','+opt.popup_scroll+')"><img src="http://img.wallstreet-online.de/blogs/button/blog_lupe_trans.png" alt="vergrößern"></a>');
    		}else{
				ret= this.after('<a rel="nofollow" target="_blank" href="/_plain/image?url='+$(this).attr('src')+'"><img src="http://img.wallstreet-online.de/blogs/button/blog_lupe_trans.png" alt="vergrößern"></a>');
    		}
    		ret= this.attr('rel','nofollow');
    		return ret;				
        } 
    }); 
})(jQuery);

function showImagesInViewport() {
    $("img.loadOnSight").each(function() {
        var scroll = $(window).scrollTop();
        var height = $(window).height();
        var position = $(this).offset();

        if(((scroll + height) > position.top) && scroll < position.top) {
            $(this).attr("src", $(this).attr("rel")).removeClass("loadOnSight").attr('rel','').attr('style','');
        }
        if($(this).attr("src")!="" && $(this).hasClass('loadOnSight')==false && $(this).hasClass('resize')==true){
        	$(this).load(function() {
        		if($(this).attr('name') !== undefined && $(this).width()>$(this).attr("longdesc")){
        			$(this).scaleandlink({width:$(this).attr("longdesc")});
        		}
        	});

        }
    });
}

function showImagesInDocument() {
    $("img.loadOnSight").each(function() {
        $(this).attr("src", $(this).attr("rel")).removeClass("loadOnSight").attr('rel','').attr('style','');
        if($(this).attr("src")!="" && $(this).hasClass('loadOnSight')==false && $(this).hasClass('resize')==true){
        	$(this).load(function() {
        		if($(this).attr('name') !== undefined && $(this).width()>$(this).attr("longdesc")){
        			$(this).scaleandlink({width:$(this).attr("longdesc")});
        		}
        	});

        }
    });
}


