//
/* 
This a main javascript file for Atlantis CRM
Every programmer that had at least once looked in the internet for a solution about a simple problem
knows what forums are deliverig: 80% are answers from people having more or less no knowledge.
It looks so that they like to publish - without any idea what time they are burning for people looking for the right information

Fortunately I was able to get the information I need to succeed.
I was not able to identify the real creator of the part 'read and write cookies' - see above - thanks people for the good work!
Otherwise I would like to honour these people for that.

I am
Wilhelm Poggenpohl from Germany
wilhelmP@3c-solutions.com
WilhelmP@Go4Atlantis.de

Here I like to point out a specific idea:
On nearly every WEB page today (Nov 2009) neither frames nor DIV with scrollbars are used
As a result the header of each page disapeares when scrolling.
I like to keep the header - but i am not sure if all visitors likes it in the same way.
So - what's about to let the visitor decide!!!!
I have build in the option to change it (see bottom area of my site)

If many programmer would go the same way - that would be nice.
And if you say - thats a great idea from Wilhelm Poggenpohl from Germany - please put my name and the idea about it in your code
Thanks a lot!!! 
*/
var windowHeight;
var myLogo;
var Ti = 0;
function MakeDay() { //WP
    Ti++;
    if (Ti >= 255) {
        window.clearTimeout(myInt);
        MakeDay == null;
        return null;
    }
    else if (Ti < 255) {
        document.body.style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        }
         if(Ti > 190){
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')'; 
        document.body.style.color = 'gray';
        }
        else if (Ti > 221)  {
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + 221 + ',' + Ti + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + 221 + ',' + Ti + ',' + Ti + ')';
        document.getElementById('Home').style.backgroundColor = 'silver';
        document.getElementById('Details').style.backgroundColor = 'silver';
        document.getElementById('Information').style.backgroundColor = 'silver';
        document.getElementById('Partner').style.backgroundColor = 'silver';
       }
        else if(Ti > 232) {
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + 221 + ',' + 232 + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + 221 + ',' + 232 + ',' + Ti + ')'; 
        }
        else {
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        }
        var myInt = window.setTimeout('MakeDay()', 0);
    }


function MakeNight() { //WP
    Ti--;
    if (Ti <= 52) {
        window.clearTimeout(myInt);
        MakeNight == null;
        return null;
    }
    else if (Ti > 52) {
        document.body.style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        if (Ti > 231) {
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + 221 + ',' + 232 + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + 221 + ',' + 232 + ',' + Ti + ')';
        }
        else if(Ti > 221){
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + 221 + ',' + Ti + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + 221 + ',' + Ti + ',' + Ti + ')';
        }
        else if(Ti < 150){
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        document.body.style.color = 'gray';
         document.getElementById('Home').style.backgroundColor = 'gray';
        document.getElementById('Details').style.backgroundColor = 'gray';
        document.getElementById('Information').style.backgroundColor = 'gray';
        document.getElementById('Partner').style.backgroundColor = 'gray';
       }
        else{
        document.getElementById('MainTable').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        document.getElementById('LogoOne').style.backgroundColor = 'rgb(' + Ti + ',' + Ti + ',' + Ti + ')';
        }
        
        var myInt = window.setTimeout('MakeNight()', 0);
    }
}

function SwitchLayout() { //WP
    var curCol = '';
    var x = document.getElementById('MainTable');

    if (x.currentStyle) { // iexplore
        curCol = x.currentStyle.backgroundColor;
    }
    else if (window.getComputedStyle) { //firefox
        curCol = window.getComputedStyle(x, '').getPropertyValue('background-color');
    }

    if (curCol == '#666666' || curCol == 'rgb(102, 102, 102)') {
        Ti = 52;
        MakeDay();
        Set_Cookie('StyleSheet', 'css/AtlantisDay.css');
    }
    else {
        Ti = 255;
        MakeNight();
        Set_Cookie('StyleSheet', 'css/AtlantisNight.css');
    }
 window.setTimeout('window.location.replace(window.location.href)', 3500);
}


function ShowScollbars() { //WP
    var curStyle = document.getElementById('Maintext').className;
    //alert (curStyle) ;
    if (curStyle == 'DivNoScrollbar') {
        document.getElementById('Maintext').className = 'DivScrollbar';
        curStyle = 'DivScrollbar'
    }
    else {
        document.getElementById('Maintext').className = 'DivNoScrollbar';
        curStyle = 'DivNoScrollbar'
    }
    Set_Cookie('DivMaintextClass', curStyle);
    window.location.replace(window.location.href);
}

window.onload = function() {
    ReziseMain()
}

window.onresize = function() {
    ReziseMain()
}

function ReziseMain() { //WP
    if (document.getElementById('Maintext').className == 'DivScrollbar') {
        if (self.innerHeight) { windowHeight = self.innerHeight; }
        else if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            windowHeight = document.body.clientHeight;
        }
        if (windowHeight > 225) {
            document.getElementById('Maintext').style.height = (windowHeight - 205) + 'px';
        }
    }
}

function ShowMain(TabName) { //WP
    document.getElementById('Home').className = 'TDButton';
    document.getElementById('Details').className = 'TDButton';
    document.getElementById('CrmCompetence').className = 'TDButton';
    document.getElementById('Information').className = 'TDButton';
    document.getElementById('Partner').className = 'TDButton';
    document.getElementById(TabName).className = 'TDButtonActive';
}

function Set_Cookie(name, value, domain, secure) { //unknown author
    var today = new Date();    // set time, it's in milliseconds
    today.setTime(today.getTime());
    var expires = 30; // Days from now
    var path = '/';
    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));

    document.cookie = name + '=' + escape(value) +
    ((expires) ? ';expires=' + expires_date.toGMTString() : '') +
    ((path) ? ';path=' + path : '') +
    ((domain) ? ';domain=' + domain : '') +
    ((secure) ? ';secure' : '');
}

function Get_Cookie(check_name) { //unknown author
    //	    alert(document.cookie);
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var b_cookie_found = false;
    for (i = 0; i < a_all_cookies.length; i++) {
        a_temp_cookie = a_all_cookies[i].split('=');
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
        if (cookie_name == check_name) {
            b_cookie_found = true;
            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            return cookie_value;
            break;
        }
        a_temp_cookie = null;
        cookie_name = '';
    }
    if (!b_cookie_found) {
        return null;
    }
}

function Asc(String) {
    return String.charCodeAt(0);
}

function Chr(AsciiNum) {
    return String.fromCharCode(AsciiNum)
}

function MailMe() {
    var myMailAddress = Chr(83) + Chr(101) + Chr(114) + Chr(118) + Chr(105) + Chr(99) + Chr(101) + Chr(64) + Chr(103) + Chr(111) + Chr(52) + Chr(65) + Chr(116) + Chr(108) + Chr(97) + Chr(110) + Chr(116) + Chr(105) + Chr(115) + Chr(46) + Chr(100) + Chr(101)
   // alert(myMailAddress)
    location.href = "Mailto:" + myMailAddress + "?subject=Atlantis%20CRM";
}

//
