﻿// JScript File

var LogoHTML = "<a href='index.aspx'><img src='menu/i/logo.gif' height='60' width='171' alt=''/></a>";

var PrivateOnHTML = "<table height=60 width=171 cellpadding=0 cellspacing=0 border=0><tr><td><span style='font-size:9px;color:White;line-height:13px;'><b>PRIVAT LÄGE PÅ</b><br/>Nu kan bara dina vänner skriva till dig. Har du påbörjat en konversation med någon kan denna självklart även svara.</span></td></tr></table>";
var PrivateOffHTML = "<table height=60 width=171 cellpadding=0 cellspacing=0 border=0><tr><td><span style='font-size:9px;color:White;line-height:13px;'><b>PRIVAT LÄGE AVSTÄNGT</b><br/>Alla medlemmar kan skriva till dig.</span></td></tr></table>";

var SoundOnHTML = "<table height=60 width=171 cellpadding=0 cellspacing=0 border=0><tr><td><span style='font-size:9px;color:White;line-height:13px;'><b>LJUD PÅ</b><br/>Ljud spelas upp när du får nytt meddelande eller vibb/flört.</span></td></tr></table>";
var SoundOffHTML = "<table height=60 width=171 cellpadding=0 cellspacing=0 border=0><tr><td><span style='font-size:9px;color:White;line-height:13px;'><b>LJUD AVSTÄNGT</b><br/>Inga ljud spelas upp när du får meddelande, vibb eller flört.</span></td></tr></table>";

var InvisibleOnHTML = "<a href='javascript:makeReq(1)' class='LightWhite2'><b>PÅ</b></a>";
var InvisibleOffHTML = "<a href='javascript:makeReq(1)' class='LightWhite2'><b>AV</b></a>";

var Clicked = false;

// varDivLogo.innerHTML = LogoHTML;

function RestoreVibeToLogo()
{
    //returnObjById("DivLogo").innerHTML = LogoHTML;
}


function RestoreVibeToLogo2()
{
    //returnObjById("DivLogo").innerHTML = LogoHTML;
}

function swDrop()
{
    if (Clicked == false)
    {
        if(returnObjById("DivDrop").style.display == 'none')
        {
        DropDown();
        }
        else
        {
         DropUp();
        }
    }
    
    Clicked = true;
    setTimeout("Clicked=false;",100)
}

function DropUp()
{
    var elem = returnObjById("DivDrop");
    elem.style.display = 'none';
    elem.style.height = "0px";
}

function DropDown()
{
    var elem = returnObjById("DivDrop");
    elem.style.display = '';
    elem.style.height = "78px";
     
    
}

if (document.images) 
    {
        img_01=new Image();  img_01.src="../menu/_flik0.jpg"; 
        img_02=new Image();  img_02.src="../menu/_flik1.jpg"; 

    }
    
    function switchF(sMenuID, loggedIn)
    {
        var i=1;
        for (i=1; i<=13; i++)
        {
        returnObjById("layerSub" + i).style.display = "none";
        }
    
       
        
        returnObjById('divC').style.display='none';
        returnObjById('divS').style.display='none';
        returnObjById('divM').style.display='none';
        
        returnObjById('div' + sMenuID.replace("f","")).style.display='';
        
        if (loggedIn==1) { returnObjById('DivLogin').style.display=''; } else { returnObjById('DivLogin').style.display='none'; }
        makeAjaxRequest('ajax_menu_sw.aspx?m=' + sMenuID.replace("f","").toLowerCase(),'noDiv');
        
        
        
        returnObjById("fM1").innerHTML = "";returnObjById("fM2").innerHTML = "<a href='#' class='light'>magazine";
        returnObjById("fC1").innerHTML = "";returnObjById("fC2").innerHTML = "<a href='#' class='light'>community";
        returnObjById("fS1").innerHTML = "";returnObjById("fS2").innerHTML = "<a href='#' class='light'>spotlight";
        
        returnObjById(sMenuID + "1").innerHTML = "&#9654;";
        if(sMenuID == "fM") { returnObjById("fM2").innerHTML = "<a href='#' class='light'><b>magazine</b>"; }
        if(sMenuID == "fC") { returnObjById("fC2").innerHTML = "<a href='#' class='light'><b>community</b>"; }
        if(sMenuID == "fS") { returnObjById("fS2").innerHTML = "<a href='#' class='light'><b>spotlight</b>"; }
        setTimeout("DropUp();",300);
    }

    function jsMenu(sMenuID, sPicID)
    {
        if (document.images) document.images["men"+sMenuID].src = "menu2010/" + sPicID + ".gif";
    }
    
    function jsMenu2(sMenuID, sPicID)
    {
        if (document.images) document.images[sMenuID].src = "menu2010/" + sPicID + ".gif";
    }
    
    function jsToggleLayer(whichLayer)
    {
    var elem, vis, AllLayers;
    
    for (i=1; i<14; i++) 
    {
        AllLayers = 'layerSub' + i*1;

        if( document.getElementById ) // this is the way the standards work
            elem = document.getElementById( AllLayers );
        else if( document.all ) // this is the way old msie versions work
            elem = document.all[AllLayers];
        else if( document.layers ) // this is the way nn4 works
            elem = document.layers[AllLayers];
    
        vis = elem.style;
    
        vis.display = 'none';
    }
    
    if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( whichLayer );
    else if( document.all ) // this is the way old msie versions work
        elem = document.all[whichLayer];
    else if( document.layers ) // this is the way nn4 works
        elem = document.layers[whichLayer];
    
    vis = elem.style;
    
    vis.display = 'block';
    }
    
// See if new messeges
function makeReq(DoThiss) {
        var http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { returnContents(http_request, DoThiss); };
        
        http_request.open('GET', encodeURI('own_checkstuff.aspx?do='+DoThiss+'&random=' + Math.random()*1000000), true);
        http_request.send(null);

    }

function returnContents(http_request, DoThiss) 
    {

        if (http_request.readyState == 4) 
        {
            if (http_request.status == 200) 
            {
                var TitleNS = "Nattstad ";
                // messeges
				if (http_request.responseText.indexOf('nytt') > -1) 
				{
				    var NewHTMLFormessageSoundDiv = http_request.responseText.substring(http_request.responseText.indexOf('<newMessSound>')+14,http_request.responseText.indexOf('</newMessSound>'));
                    returnObjById("messageSound").innerHTML = NewHTMLFormessageSoundDiv;
	                if (document.images) document.images["NewMessege"].src = "menu2010/_med2.gif";
	                document.title = "Nattstad [nytt meddelande]";
				}

				else {
				if (http_request.responseText.indexOf(':MessAc:') > -1) 
				    {
	                //if (document.images) document.images["NewMessege"].src = "menu2010/_med0.gif";
	                }
	                else
	                {
	                //if (document.images) document.images["NewMessege"].src = "menu2010/_med0.gif";
	                }
				}
				
				// check sound
//				if (http_request.responseText.indexOf('sound_on') > -1) 
//				{
//					//returnObjById("DivLogo").innerHTML = SoundOnHTML;
//				    //setTimeout("RestoreVibeToLogo2()",10000);
//	                //if (document.images) document.images["Sound"].src = "menu/i/sound_on.gif";
//				}
//				if (http_request.responseText.indexOf('sound_off') > -1) 
//				{
//					returnObjById("DivLogo").innerHTML = SoundOffHTML;
//				    setTimeout("RestoreVibeToLogo2()",10000);
//	                if (document.images) document.images["Sound"].src = "menu/i/sound_off.gif";
//				}
//				
//				// check private
//				if (http_request.responseText.indexOf('private_on') > -1) 
//				{
//				    returnObjById("DivLogo").innerHTML = PrivateOnHTML;
//				    setTimeout("RestoreVibeToLogo2()",10000);
//	                if (document.images) document.images["Private"].src = "menu/i/private_on.gif";
//				}
//				if (http_request.responseText.indexOf('private_off') > -1) 
//				{
//					returnObjById("DivLogo").innerHTML = PrivateOffHTML;
//				    setTimeout("RestoreVibeToLogo2()",10000);
//	                if (document.images) document.images["Private"].src = "menu/i/private_off.gif";
//				}
//				
//				// check invisible
				if (http_request.responseText.indexOf('invisible_on') > -1) 
				{
					returnObjById("DivLogo").innerHTML = InvisibleOnHTML;
				    //setTimeout("RestoreVibeToLogo2()",10000);
	                //if (document.images) document.images["Invisible"].src = "menu/i/invisible_on.gif";
				}
				if (http_request.responseText.indexOf('invisible_off') > -1) 
				{
					returnObjById("DivLogo").innerHTML = InvisibleOffHTML;
				    //setTimeout("RestoreVibeToLogo2()",10000);
	                //if (document.images) document.images["Invisible"].src = "menu/i/invisible_off.gif";
				}
//				
//				// check vibe
//				if (http_request.responseText.indexOf('<vibe>') > -1) 
//				{
//	                var NewHTMLForLogoDiv = http_request.responseText.substring(http_request.responseText.indexOf('<vibe>')+6,http_request.responseText.indexOf('</vibe>'));
//                    returnObjById("DivLogo").innerHTML = NewHTMLForLogoDiv;
//                    setTimeout("RestoreVibeToLogo()",25000);
//				}
//				
//				if (http_request.responseText.indexOf('<Noti>') > -1) 
//				{
//	                var NewHTMLForNotiDiv = http_request.responseText.substring(http_request.responseText.indexOf('<Noti>')+6,http_request.responseText.indexOf('</Noti>'));
//                    returnObjById("divNews").innerHTML = NewHTMLForNotiDiv;
//                    returnObjById("divNews").style.display = '';
//				}
//				else
				{
				    //returnObjById("divNews").style.display = 'none';
				}
				
				//window.document.getElementById('Online').value=(http_request.responseText.substring(http_request.responseText.indexOf('<online2>')+9,http_request.responseText.indexOf('</online2>')) + " online / " + http_request.responseText.substring(http_request.responseText.indexOf('<online>')+8,http_request.responseText.indexOf('</online>')) + " inloggade");
                //window.document.getElementById('Online').value=(http_request.responseText.substring(http_request.responseText.indexOf('<online>')+8,http_request.responseText.indexOf('</online>')) + " inloggade");
				
				if (DoThiss == 0)
				{
				setTimeout("makeReq(0)", 40000);
				}
            } 
        }
        
    }
    


function PresBild(IDnr)
	{
	if (IDnr != null) 
		{
		var new_win = window.open('visit_prespicture.aspx?ID='+IDnr,'','left=100,top=100,width=200,height=300,resizable=no;scrolling=0')	
		}
	}