function showAdvSearch(){
    
    if(document.getElementById('advanced_search').style.display == "block"){
        hide('advanced_search');
    }
    else{
        show('advanced_search', 'block');
    }
}

function show(id, how){
    
    document.getElementById(id).className='';
    
    if (navigator.appName == 'Microsoft Internet Explorer') {
        element=document.getElementById(id).style;
        element.display = 'block';
    }
    else {
        element=document.getElementById(id).style;
        element.display = how;
    }
}

function hide(id){
    
    element=document.getElementById(id).style;
    element.display = 'none';
}

var current_id = document.getElementById();

function ret(id){
    
    if(current_id == id){
        current_id = id;
        return true;
    }
    else{
        current_id = id;
        return false;
    }
    
}

function switchChangebox(id){
    
    var obj1 = document.getElementById('changebox_home1');
    var obj2 = document.getElementById('changebox_home2');
    var obj3 = document.getElementById('changebox_home3');
    
    if(!id){
        
        if(obj1)  document.getElementById('changebox_home1').className = 'left';
        if(obj2)  document.getElementById('changebox_home2').className = 'hidden';
        if(obj3)  document.getElementById('changebox_home3').className = 'hidden';
        /*
        if(obj1)  document.getElementById('changebox_home1_button').onclick = new Function('return false');
        if(obj2)  document.getElementById('changebox_home2_button').onclick = new Function('switchChangebox(\'changebox_home2\')'); new Function('autoswitchChangebox(2, \'stop\')'); new Function('return false');
        if(obj3)  document.getElementById('changebox_home3_button').onclick = new Function('switchChangebox(\'changebox_home3\')'); new Function('autoswitchChangebox(3, \'stop\')'); new Function('return false');        
        */
        if(obj1)  document.getElementById('changebox_home1_button').className = 'ad_item sel';
        if(obj2)  document.getElementById('changebox_home2_button').className = 'ad_item';
        if(obj3)  document.getElementById('changebox_home3_button').className = 'ad_item';
        /*
        if(obj1)  document.getElementById('changebox_home1_button').href = document.getElementById('changebox_home_href1').title;
        if(obj2)  document.getElementById('changebox_home2_button').href = '#';
        if(obj3)  document.getElementById('changebox_home3_button').href = '#';*/
        
        if(obj1)  document.getElementById('changebox_home1_arrow').innerHTML = '<span class="leftarrow"></span>';
        if(obj2)  document.getElementById('changebox_home2_arrow').innerHTML = '';
        if(obj3)  document.getElementById('changebox_home3_arrow').innerHTML = '';
        
        
        
    }
    
    if(id == "changebox_home1"){
    
        if(obj1)  document.getElementById('changebox_home1').className = 'left';
        if(obj2)  document.getElementById('changebox_home2').className = 'hidden';
        if(obj3)  document.getElementById('changebox_home3').className = 'hidden';
        
        if(obj1)  document.getElementById('changebox_home1_button').className = 'ad_item sel';
        if(obj2)  document.getElementById('changebox_home2_button').className = 'ad_item';
        if(obj3)  document.getElementById('changebox_home3_button').className = 'ad_item';
        /*
        if(obj1)  document.getElementById('changebox_home1_button').onclick = new Function('return false');
        if(obj2)  document.getElementById('changebox_home2_button').onclick = new Function('switchChangebox(\'changebox_home2\')'); new Function('autoswitchChangebox(2, \'stop\')'); new Function('return false');
        if(obj3)  document.getElementById('changebox_home3_button').onclick = new Function('switchChangebox(\'changebox_home3\')'); new Function('autoswitchChangebox(3, \'stop\')'); new Function('return false');
        
        if(obj1)  document.getElementById('changebox_home1_button').href = document.getElementById('changebox_home_href1').title;
        if(obj2)  document.getElementById('changebox_home2_button').href = '#';
        if(obj3)  document.getElementById('changebox_home3_button').href = '#';*/
                
        if(obj1)  document.getElementById('changebox_home1_arrow').innerHTML = '<span class="leftarrow"></span>';
        if(obj2)  document.getElementById('changebox_home2_arrow').innerHTML = '';
        if(obj3)  document.getElementById('changebox_home3_arrow').innerHTML = '';
        
    //autoswitchChangebox('stop');
    //current_id = "'changebox_home1'";
        
    }
    if(id == "changebox_home2"){
        
        if(obj1)  document.getElementById('changebox_home1').className = 'hidden';
        if(obj2)  document.getElementById('changebox_home2').className = 'left';
        if(obj3)  document.getElementById('changebox_home3').className = 'hidden';
        
        if(obj1)  document.getElementById('changebox_home1_button').className = 'ad_item';
        if(obj2)  document.getElementById('changebox_home2_button').className = 'ad_item sel';
        if(obj3)  document.getElementById('changebox_home3_button').className = 'ad_item';
        /*
        if(obj1)  document.getElementById('changebox_home1_button').onclick = new Function('switchChangebox(\'changebox_home1\')'); new Function('autoswitchChangebox(1, \'stop\')'); new Function('return false');
        if(obj2)  document.getElementById('changebox_home2_button').onclick = new Function('return false');
        if(obj3)  document.getElementById('changebox_home3_button').onclick = new Function('switchChangebox(\'changebox_home3\')'); new Function('autoswitchChangebox(3, \'stop\')'); new Function('return false');
        
        if(obj1)  document.getElementById('changebox_home1_button').href = '#';
        if(obj2)  document.getElementById('changebox_home2_button').href = document.getElementById('changebox_home_href2').title;
        if(obj3)  document.getElementById('changebox_home3_button').href = '#';    */    
                
        if(obj1)  document.getElementById('changebox_home1_arrow').innerHTML = '';
        if(obj2)  document.getElementById('changebox_home2_arrow').innerHTML = '<span class="leftarrow"></span>';
        if(obj3)  document.getElementById('changebox_home3_arrow').innerHTML = '';
    //current_id = "'changebox_home2'";
        
    }
    if(id == "changebox_home3"){
        /*document.getElementById('changebox_home1').style.display = 'none';
        document.getElementById('changebox_home2').style.display = 'none';
        document.getElementById('changebox_home3').style.display = 'block';*/
        
        if(obj1)  document.getElementById('changebox_home1').className = 'hidden';
        if(obj2)  document.getElementById('changebox_home2').className = 'hidden';
        if(obj3)  document.getElementById('changebox_home3').className = 'left';
        
        if(obj1)  document.getElementById('changebox_home1_button').className = 'ad_item';
        if(obj2)  document.getElementById('changebox_home2_button').className = 'ad_item';
        if(obj3)  document.getElementById('changebox_home3_button').className = 'ad_item sel';
        /*
        if(obj1)  document.getElementById('changebox_home1_button').onclick = new Function('switchChangebox(\'changebox_home1\')'); new Function('autoswitchChangebox(1, \'stop\')'); new Function('return false');
        if(obj2)  document.getElementById('changebox_home2_button').onclick = new Function('switchChangebox(\'changebox_home2\')'); new Function('autoswitchChangebox(2, \'stop\')'); new Function('return false');
        if(obj3)  document.getElementById('changebox_home3_button').onclick = new Function('return false');
        
        if(obj1)  document.getElementById('changebox_home1_button').href = '#';
        if(obj2)  document.getElementById('changebox_home2_button').href = '#';
        if(obj3)  document.getElementById('changebox_home3_button').href = document.getElementById('changebox_home_href3').title;
        */
        if(obj1)  document.getElementById('changebox_home1_arrow').innerHTML = '';
        if(obj2)  document.getElementById('changebox_home2_arrow').innerHTML = '';
        if(obj3)  document.getElementById('changebox_home3_arrow').innerHTML = '<span class="leftarrow"></span>';
    //current_id = "'changebox_home3'";
    //autoswitchChangebox('stop');
    }
    
    
    
}
function autoswitchChangebox(arg, stop){
        
    var b2;
        
    var obj1 = document.getElementById('changebox_home1');
    var obj2 = document.getElementById('changebox_home2');
    var obj3 = document.getElementById('changebox_home3');
        
    if(obj1)    var max = 1;
    if(obj2)    var max = 2;
    if(obj3)    var max = 3;
        
    if(arg)
    {
        if(isInteger(arg) == true) var b = arg;
        else var b = 2;
    }
        
    if(arg > max){
        var b = 1;
    }
        
    if(!arg)
    {
        var b = 2;
    }
        
    if(stop){
        timer = clearTimeout(timer);
    }
    b2 = b+1;
        
    timer = setTimeout('switchChangebox("changebox_home' + b + '"); autoswitchChangebox(' + b2 + ');', 10000);
    
}

function isUnsignedInteger(s) {
    return (s.toString().search(/^[0-9]+$/) == 0);
}

function isInteger(s) {
    return (s.toString().search(/^-?[0-9]+$/) == 0);
}

/*function shareFacebook(url, title) {
  var faceUrl = 'http://www.facebook.com/sharer.php?u=' + url +'&t=' + title;
  window.open(faceUrl, "Sdílej na facebooku","width=310,height=600,scrollbars=yes");
}*/

function facebookAPIinit(language)
{
    if(language == 'cz') {
        var localize = 'cs_CZ';
    }
    else if(language == 'en') {
        var localize = 'en_US';
    }
    else if(language == 'de') {
        var localize = 'de_DE';
    }


    window.fbAsyncInit = function() {
        FB.init({
            appId: '147762805235934',
            status: false,
            cookie: true,
            xfbml: true
        });
    };
    (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
        '//connect.facebook.net/'+localize+'/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
}

function shareFacebook(url, title, description) {

    FB.login(function(response) {
        if (response.session) {
            if (response.perms) {
                FB.ui(
                {
                    method: 'stream.publish',
                    attachment: {
                        name: title,
                        caption: title,
                        description: (
                            description
                            ),
                        href: url
                    },
                    action_links: [
                    {
                        text: 'Galerie Vaňkovka',
                        href: url
                    }
                    ]
                },
                function(response) {
                    }
                    );
            } else {
        // user is logged in, but did not grant any permissions
        }
        } else {
    // user is not logged in
    }
    }, {
        perms:'read_stream,publish_stream,offline_access'
    });

    
}