﻿// JScript File

// Funksjoner for å vise "tooltip"
function showTip(sText) {
	document.getElementById('tooltip_content').innerHTML = sText;
	document.getElementById('tooltip').style.visibility="visible";
	document.getElementById('tooltip').style.display="block";
}

function hideTip() {
	document.getElementById('tooltip').style.visibility="hidden";
	document.getElementById('tooltip').style.display="none";
}

// O'Store AJAX
function HTTPpost(url){
	var xmlhttp=false;
	var returnValue=new String();
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
	returnValue=xmlhttp.responseText;
	return returnValue;
}

function setResult(msgid, field, hideThis)
{
    alert("Denne funksjonen er for tiden ute av drift");
    return;
    if (getBrowser() == "Internet Explorer")
    {
        alert("Denne funksjonen er dessverre ikke støttet i Internet Explorer enda.\n\nDu kan sjekke status for en melding ved hjelp av en annen nettleser.");
    }
    else
    {
        if (confirm("Å hente status-melding koster en credit. Er du sikker på at du vil gjøre dette?")){
            setValue("aspnetForm", hideThis, "Vent...", null);
            //alert(HTTPpost("http://kjappsms.no/api/getSmsStatus.aspx?msgid=" + msgid));
            setValue("aspnetForm", field, HTTPpost("http://kjappsms.no/api/getSmsStatus.aspx?msgid=" + msgid), hideThis);
            return;
        }
        else {
            alert("henting av statusmelding avbrutt");
        }
    }
}

// SetValue - Copyright Sinco (c) 2006 -
function setValue(formName,fieldName,value,hideThis)    
{
    document.forms[formName][fieldName].value=value;
    if( hideThis != null )
    {
        document.forms[formName][hideThis].value="";
        document.forms[formName][hideThis].style.visibility="hidden";
    }
    return;
}

function getBrowser()   {

        var detect = navigator.userAgent.toLowerCase();
        var OS,browser,version,total,thestring;

        if (checkIt('konqueror'))
        {
              browser = "Konqueror";
              OS = "Linux";
        }
        else if (checkIt('safari')) browser = "Safari"
        else if (checkIt('omniweb')) browser = "OmniWeb"
        else if (checkIt('opera')) browser = "Opera"
        else if (checkIt('webtv')) browser = "WebTV";
        else if (checkIt('icab')) browser = "iCab"
        else if (checkIt('msie')) browser = "Internet Explorer"
        else if (!checkIt('compatible'))
        {
              browser = "Netscape Navigator"
              version = detect.charAt(8);
        }
        else browser = "An unknown browser";

        if (!version) version = detect.charAt(place + thestring.length);

        if (!OS)
        {
              if (checkIt('linux')) OS = "Linux";
              else if (checkIt('x11')) OS = "Unix";
              else if (checkIt('mac')) OS = "Mac"
              else if (checkIt('win')) OS = "Windows"
              else OS = "an unknown operating system";
        }

        return browser;

        function checkIt(string)
        {
              place = detect.indexOf(string) + 1;
              thestring = string;
              return place;
        }
}
