/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//Änderung der URL ohne Seitenreload
function changeURL(newURL, endung){
    window.history.replaceState('test', '', newURL + '.'+endung+'');
}


function changeTitle(title){
    
    $('title').replaceWith("<title>JGV Vernawahlshausen</title>");
}

//Sendet POST-Request an Php-Skript und bindet html ausgabe in angegebenen Container ein
function loadContent(skript, container, options) {
    options = options.split("-");
    $.post('system/serverscript_head.php', {alias: ''+skript+'', options: ''+options[0]+'', options2: ''+options[1]+''},
    function(data) {
        $('#'+container+'').html(data);
    });
 }
 
 //Bild src ändern
 function activePagePic(alias){   
     document.getElementById('start').src="sites/jgv/images_layout/start.png";
     document.getElementById('verein').src="sites/jgv/images_layout/verein.png";
     document.getElementById('bilder').src="sites/jgv/images_layout/bilder.png";
     document.getElementById('pranger').src="sites/jgv/images_layout/pranger.png";
     document.getElementById('links').src="sites/jgv/images_layout/links.png";

     document.getElementById(alias).src="sites/jgv/images_layout/"+alias+"_active.png";
     
 }

//Läd teile der Seite mit änderung der Seite neu ohne kompletten reload


function loadContainer(content, container){
    changeURL(content);
    loadContent(content, container);
}

function reloadPage(skript, container, url, name, options){
    changeURL(url,'html');  
    url = url.split("/");
    activePagePic(url[0]);   

    changeTitle(name);     
    loadContent(skript, container, options);
    


}
function reloadPic(skript, container, url, name, options){
    changeURL(url,'jpg');  
    url = url.split("/");
    activePagePic(url[0]);   

    changeTitle(name);     
    loadContent(skript, container, options);
    
    $('#dummy').load(function(){

        
    });
    
}

/*HTML Objekte manipulieren*/

//Layer
function openLayer(){
    document.body.style.overflow="hidden";
    document.getElementsByTagName("html")[0].style.marginRight="15px";
    document.getElementById('Layer').style.display="inline";
}

function closeLayer(){
    document.body.style.overflow="auto";
    document.getElementsByTagName("html")[0].style.marginRight="";
    document.getElementById('Layer').style.display="none";
}

//Element nach einem bestimmten Element einfügen
    function after(gallery){
        //Bilder Sliden
        $(".Bild").animate({
            left: "-=600"
        }, 500 );
        //nächstes Bild wird eingefügt
        $.post('system/serverscript_head.php', {alias: 'php_echo $_SESSION[Gallery_.$_SESSION[Gallery_List]->getAkt_Gallery()]->nextPic();'},
            function(data){           
                $('#nr').html(''+data.bildnr+'');
                $('#Bilder').append(data.img);
                $('#'+data.del+'').remove();
                changeURL(gallery+'/'+data.bildnr, 'jpg');
            },"JSON");
        
    }
//Element vor einen bestimmten Element einfügen
    function before(element, insert){
        //Bilder sliden
        $(".Bild").animate({
            left: "+=600"
        }, 500 );
         //nächstes Bild wird eingefügt
        $.post('system/serverscript_head.php', {alias: 'php_echo $_SESSION[Gallery_.$_SESSION[Gallery_List]->getAkt_Gallery()]->prevPic();'},
            function(data){           
                $('#nr').html(''+data.bildnr+'');
                $('#Bilder').prepend(data.img);
                $('#'+data.del+'').remove();
                changeURL(gallery+'/'+data.bildnr, 'jpg');
            },"JSON");
    }


function pic_load() {
        $(".load").fadeIn("slow");
}

function pic_close(){
        $(".slide").hide();
}


