var Slideshow = function(uid, pictures) {
    this._uid = uid;
    this._counter = 0;
    this._pictures = pictures;
    
    
     
    this.next = function() {
        if((this._counter+1) < this._pictures) {
            if(jQuery('#div_' + this._uid + '_' + this._counter).length > 0) {
                jQuery('#div_' + this._uid + '_' + this._counter).hide();        
            }
            this._counter++;
            if(jQuery('#div_' + this._uid + '_' + this._counter).length > 0) {
                jQuery('#div_' + this._uid + '_' + this._counter).show();        
            }
            
            this.displayLinks();
        }        
    }
    
    this.prev = function() {
        if(this._counter > 0) {
            if(jQuery('#div_' + this._uid + '_' + this._counter).length > 0) {
                jQuery('#div_' + this._uid + '_' + this._counter).hide();        
            }
            this._counter--;
            if(jQuery('#div_' + this._uid + '_' + this._counter).length > 0) {
                jQuery('#div_' + this._uid + '_' + this._counter).show();        
            }
            
             this.displayLinks(); 
        }        
    }
    
    this.displayLinks = function() {
        if(jQuery('#next_' + this._uid).length > 0) {
            if(this._counter+1 == this._pictures) {                 
                jQuery('#next_' + this._uid).hide();    
            } else {
                jQuery('#next_' + this._uid).show();
            }     
        }
        
        if(jQuery('#prev_' + this._uid).length > 0) {
            if(this._counter == 0) {                 
                jQuery('#prev_' + this._uid).hide();    
            } else {
                jQuery('#prev_' + this._uid).show();
            }     
        }    
    }

    this.print = function() {
        alert(this._pictures);    
    }  
}





//Suche Aktion
jQuery(document).ready(function() {
    jQuery('#search').focus(function() {
        if(jQuery(this).val() == "Suche") jQuery(this).val("");
    });
    
    jQuery('#search').blur(function() {
        if(jQuery(this).val()  == "") jQuery(this).val("Suche");
    });    
});

function request(method,url,ziel,postform,loadingani,newserialize){    
    if(jQuery('#'+loadingani).length > 0) jQuery('#'+loadingani).show();
    else loading();
    
    if(method=='post' || method=='POST'){
        if(newserialize) var pbody = jQuery('#' + postform).serialize(true);
        var pbody = jQuery('#' + postform).serialize();
    } else var pbody = "";
    
    jQuery.ajax({
        url: url,
        type: method,
        data: pbody,
        success: function(data, textStatus, XMLHttpRequest) {
            jQuery('#' + ziel).html(data); 
            if(jQuery('#'+loadingani).length > 0) jQuery('#'+loadingani).hide();
            else unloading();
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            jQuery('#' + ziel).html(data);
            if(jQuery('#'+loadingani).length > 0) jQuery('#'+loadingani).hide();
            else unloading();
        }    
    });
}

function doAjax(method,url,ziel,postform,loadingani,newserialize) {    
    request(method,url,ziel,postform,loadingani,newserialize);
}
