/* Ordiseite */

var active_gallery = 0;

function ChangeActiveGallery(id) {
    active_gallery = id;
}

function ShowGallery(id) {
    for(i=0;i<gallerypix.length;i++) {
        document.getElementById('galpic_'+gallerypix[i]).style.display='none';
    }
    document.getElementById('galpic_'+gallerypix[id]).style.display='block'
}


// Array für zusätzliche Funktionen die in der js_onload ausgeführt werden sollen
// Allgemeine Variablen
window_loaded = false;

window.onload = js_onload;
window.onresize = js_resize;

function js_onload(){
    window_loaded = true;
    
    js_resize();
}

//Seite aufgrund der Auflösung anpassen
function js_resize() {
    if (window_loaded){
        
        obj_logo = document.getElementById('logo');
        obj_nav = document.getElementById('navbg');
        obj_whitelinie = document.getElementById('whiteLine2');
        obj_whitelinie1 = document.getElementById('whiteLine1');
        obj_content = document.getElementById('content');
        obj_headline_container = document.getElementById('headline_container');
        obj_author = document.getElementById('author');
        obj_contactinfo = document.getElementById('contactinfo');
        obj_bottom = document.getElementById('bottom');
        obj_hintergrund = document.getElementById('hintergrund');
        
        if(document.getElementById('hintergrund'))
        obj_hintergrund = document.getElementById('hintergrund');
        obj_functions = document.getElementById('functions');
        obj_headline = document.getElementById('headline');
        obj_subheadline = document.getElementById('subheadline');
        obj_slogan = document.getElementById('slogan');
        obj_zitat = document.getElementById('zitat');
        obj_haus = document.getElementById('haus');
                
        body_width = document.body.offsetWidth;
            
        if (body_width<850){    
            obj_logo.style.left = '270px';
            obj_nav.style.top = '0px';
            obj_nav.style.left = '0px';
            obj_nav.style.bottom = '0px';
            obj_whitelinie.style.display = 'none';
            obj_whitelinie1.style.display = 'none';
            obj_content.style.right = '2px';
            obj_content.style.left = '250px';
            obj_content.style.bottom = '50px';
            obj_author.style.right = '2px';
            obj_author.style.bottom = '2px';
            obj_contactinfo.style.display = 'none';
            obj_bottom.style.height = '50px';
            obj_bottom.style.left = '250px';
            if (obj_hintergrund) obj_hintergrund.style.bottom = '50px';
            if (obj_hintergrund) obj_hintergrund.style.left = '-100px';
            obj_functions.style.left = '0px';
            obj_headline.style.right = '20px';
            obj_subheadline.style.right = '20px';
                                            


            
                        
            if(iam_startpage){
                obj_slogan.style.left = '0';
                obj_slogan.style.top = '2px';
                obj_zitat.style.top = '170px';
                obj_zitat.style.left = '70px';
                obj_haus.style.display = 'none';

            }
            
        } else {
            obj_subheadline.style.right = '';
            //obj_headline.style.right = '';
            obj_logo.style.left = '';
            obj_nav.style.top = '';
            obj_nav.style.left = '';
            obj_nav.style.bottom = '';
            obj_whitelinie.style.display = 'block';
            obj_whitelinie1.style.display = 'block';
            obj_content.style.right = '';
            obj_content.style.left = '';
            obj_content.style.bottom = '';
            obj_author.style.right = '';
            obj_author.style.bottom = '';
            obj_contactinfo.style.display = '';
            obj_bottom.style.height = '';
            obj_bottom.style.left = '';
            if (obj_hintergrund) obj_hintergrund.style.bottom = obj_hintergrund.style.left;
            obj_functions.style.left = '';
            
            
            
            if(iam_startpage){
                obj_slogan.style.left = '';
                obj_slogan.style.top = '';
                obj_zitat.style.top = '';
                obj_zitat.style.left = '';
                obj_haus.style.display = 'block';
            }
            
            if (body_width<1040){
                
                obj_logo.style.left = '';
                obj_subheadline.style.right = '20px';
                //obj_headline.style.right = '20px';
                obj_nav.style.top = '';
                obj_nav.style.left = '';
                obj_nav.style.bottom = '';
                obj_whitelinie.style.display = 'none';
                obj_whitelinie1.style.display = 'block';
                obj_content.style.right = '5px';
                obj_content.style.left = '';
                obj_content.style.bottom = '';
                obj_headline_container.style.right = '5px';
                obj_headline_container.style.left = '';
                obj_headline_container.style.bottom = '';
                obj_author.style.right = '20px';
                obj_author.style.bottom = '';
                obj_contactinfo.style.display = '';
                obj_bottom.style.height = '';
                obj_bottom.style.left = '';
                obj_hintergrund.style.bottom = '';
                obj_hintergrund.style.left = '';
                obj_functions.style.left = '';
            
                
                
                if(iam_startpage){
                    obj_slogan.style.left = '';
                    obj_slogan.style.top = '';
                    obj_zitat.style.top = '';
                    obj_zitat.style.left = '';
                    obj_haus.style.display = 'block';
                }
            }
        }
        
    }
}




/*function getAdr(prefix, postfix, lnkparam, lnktxt) {
    lnktxt = lnktxt.replace(/TMPL_MAIL/, prefix + '@' + postfix);
    document.write('<a ' + lnkparam + ' href="mailto:' + prefix + '@' + postfix + '">' + lnktxt);
}*/


function getAdr(prefix, postfix, text) {
    document.write('<a href="mailto:' + prefix + '@' + postfix + '">' + (text ? text.replace(/&quot;/g, '"').replace(/%EMAIL%/, prefix + '@' + postfix) : prefix + '@' + postfix) + '</a>');
}


function swapImage(element, newimage) {
    var oldsrc = element.src
    element.src = newimage
    if (!element.onmouseout)
        element.onmouseout = function (event) { swapImage(this, oldsrc); };
}

function popup(url,typ,para1,width,height)
{
    attrib = "";
    Y = (screen.height - width) / 2;
    X = (screen.width - height) / 2;
    X = Math.round(X);
    Y = Math.round(Y);
    if (para1 == 'CENTER') {attrib += 'height=' + height + ',width=' + width + ',top=' + Y + ',left=' + X;}
    if (typ == 'TYP1') {attrib += ",scrollbars=no";}
    if (typ == 'TYP2') {attrib += ",scrollbars=yes";}
    if (typ == 'TYP3') {attrib += ",scrollbars=yes,menubar=yes";}
    x = Math.random();
    fenster = window.open(url, 'win', attrib);
    return false;
}

function js_popup_image(image, image_width, image_height) {
    window_width = image_width + 'px';
    window_height = image_height + 'px';
    window.open(image,'_blank','location=no,menubar=no,resizable=no,status=no,toolbar=no,dependent=yes,scrollbars=no,width=' + window_width + ',height=' + window_height);
}

// Leerzeichen hinten und vorne bei einem String Objekt wegschneiden
function js_trim(string) {
    return string.replace(/^\s*|\s*$/,'');
}


function js_checkEmail(val) {
    if (val) {
        var usr = "([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
        var domain = "([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
        var regex = "^"+usr+"\@"+domain+"$";
        var myrxp = new RegExp(regex);
        var check = (myrxp.test(val));
        if (check!=true) {
            return false;
        }
        else {
            return true;
        }
    }
}

