function checkEnter(e) {
    var code;
    if (window.event) {
        code=event.keyCode;
    }
    else {
        code= e.which;
    }
    if (code == 13) {
        loginTask('login');
    }
}

function toggle(id,hId){
    if(document.getElementById(id).style.display=='none'){
        document.getElementById(id).style.display = 'block';
        document.getElementById(hId).style.fontWeight = 'bold';
    }else{
        document.getElementById(id).style.display = 'none';
        document.getElementById(hId).style.fontWeight = 'normal';       
    }
}
function show(id,hId){
    document.getElementById(id).style.display = 'block';
    document.getElementById(hId).style.fontWeight = 'bold';
}
function hide(id,hId){
    document.getElementById(id).style.display = 'none';
    document.getElementById(hId).style.fontWeight = 'normal';      
}
var admin = false;
function hideAll(){
    hide('msgPopup','messages');
    if(!admin){
    hide('prjPopup','projects');
    }
}

function select(id,hId){
    hideAll();
    show(id,hId);
}

function loginTask(task){
    if(task=='login'){
        AjaxRequest("GET","login?user="+document.getElementById("user").value+"&pass="+document.getElementById("pass").value+"&task="+task,loginFinished)
    }else{
        AjaxRequest("GET","login?task="+task,loginFinished)
    }
}

function signup(){
    showPage("signup.jsp");
}
    
function loginFinished(){ 
    if (xmlHttp.readyState==4){ 
        document.getElementById("panel").innerHTML= xmlHttp.responseText;//xmlDoc.getElementsByTagName("mainPane")[0].childNodes[0].nodeValue;;
        showPage("home.jsp?ssq="+generateSsq());
        if(document.getElementById("AdminPanel")!=null){
            admin=true;
        }else{
            admin=false;
        }
    }
}
    
function showHome(){ 
    showPage("home.jsp?ssq="+generateSsq());
}
    
function showAbout(){ 
    showPage("about.xml");
}
    
function showProducts()
{ 
    showPage("products.xml");
}
    
function showServices()
{ 
    showPage("services.xml");
}
function showContact()
{ 
    showPage("contact.xml");
}
function showNews()
{ 
    showPage("news.xml");
}
    
function showPage(mainPaneContents)
{ 
    
    AjaxRequest("GET",mainPaneContents,stateChanged);
}
        
function stateChanged() 
{ 
    if (xmlHttp.readyState==4)
    { 
        //var xmlDoc=xmlHttp.responseXML.documentElement;
        document.getElementById("mainPane").innerHTML= xmlHttp.responseText;
    }
}