/*---------------------------------------------------------------------------
 project name:	javascript unit
 task name:	w_unit.js
 author:	wiktor@freemail.hu as always... :)

 started	@ long long time ago... :)
 last modified	@ 2004.07.24.
---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------
 INIT
---------------------------------------------------------------------------*/

// Determine browser.
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;

// need for detectBrowser
var detect = navigator.userAgent.toLowerCase();
var OS, browser, version;
var version, total, thestring;

/*---------------------------------------------------------------------------
 MAIN
---------------------------------------------------------------------------*/

detectBrowser();

/*---------------------------------------------------------------------------
 --> FUNCTIONS
---------------------------------------------------------------------------*/
function w_unit_onload() {
	externalLinks();
}


function externalLinks() 
 { 
   if (!document.getElementsByTagName) return; 
   var anchors = document.getElementsByTagName("a"); 
//   alert(anchors.length);
   for (var i=0; i<anchors.length; i++) 
    { 
      var anchor = anchors[i]; 
      if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
       { anchor.target = "_blank"; }
    } 
 } 

function KiemelesekEltavolitasa()
 {
   valtas("searchon","searchoff");
 }

function KiemelesekHozzaadasa()
 {
   valtas("searchoff","searchon");
 }

function valtas(mirol,mire)
 {
   var nodeList=document.getElementsByTagName("SPAN");
   for (var i=0; i<nodeList.length; i++)
    {
      if (nodeList[i].className==mirol)
       { nodeList[i].className=mire; }
    }
 }

function KiemelesAllapot(allapot)
 {
   if (allapot=="on")  
    { return KiemelesekHozzaadasa(); } else
    { return KiemelesekEltavolitasa(); } 

 }

function url(tourl)
 {
   window.location=tourl;
 }

function confirm_url(tourl)
 {
   if (confirm('Biztos benne?'))
    { url(tourl); }
 }

/*
function changeClass(obj,cla) {
	if (browser=="Internet Explorer") {
		alert('ie');
		obj.style.className=cla;
	} else {
		alert('ns');
		obj.style.class=cla;
	}
}
*/

function getWindowWidth() {

  if (isMinNS4)
    return window.innerWidth;
  if (isMinIE4)
    return document.body.clientWidth;
  return -1;
}

function getWindowHeight() {

  if (isMinNS4)
    return window.innerHeight;
  if (isMinIE4)
    return document.body.clientHeight;
  return -1;
}

function detectBrowser() {
	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";
	}
}

function checkIt(string) {
   place = detect.indexOf(string) + 1;
   thestring = string;
   return place;
}

