/* <![CDATA[ */

// moose logo-ani
/*
image1=new Image();
image2=new Image();
image3=new Image();

image1.src="img/moose2b.gif";
image2.src="img/moose2_ani2.gif";
image3.src="img/moos.gif";

function logoAni(){ document.images[0].src=image2.src; }
function logoStill(){ document.images[0].src=image1.src; }
function logoMoos(){ document.images[0].src=image3.src; }
*/

function clAd(tx,ax)
{
  ax = encodeURIComponent(ax);
  tx = encodeURIComponent(tx);
  
  // netsacpe sync
  if(navigator.appName == "Netscape")
  {
    async = false;
  }
  
  // msie,... async
  else {
    async = true;
  }
  
  httpReq("clx.php","ax="+ax+"&tx="+tx,"POST",async);
}

// tx type ax ...
var http = false;
function httpReq(url,query,method,async) {

  http = false;
  if(window.XMLHttpRequest)
  {
    // Mozilla, Safari,...
    http = new XMLHttpRequest();
    if(http.overrideMimeType)
    {
      http.overrideMimeType('text/xml');
    }
  }
  
  // IE
  else if(window.ActiveXObject)
  { 
    try {
      http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e)
    {
      try {
        http = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
    }
  }
  
  if(http)
  {
    if(method == "POST")
    {
      // POST
  
      // The first argument defines which method to use
      // when sending the request (GET or POST).
      // The second argument specifies the URL of the server-side script.
      // The third argument specifies that the request should be handled asynchronously.
      
      http.open("POST", url+"?sid="+Math.round(Math.random()*10000), async);
      
      //Send the proper header information along with the request
      http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http.setRequestHeader("Content-length", query.length);
      http.setRequestHeader("Connection", "close");
      
    } else
    {
      // GET:
      http.open("GET",url+"?"+query+"&sid="+Math.round(Math.random()*10000), async);
    }
    
    // 0	The request is not initialized
    // 1	The request has been set up
    // 2	The request has been sent
    // 3	The request is in process
    // 4	The request is complete
    
    //Call a function when the state changes.
    /*http.onreadystatechange = function()
    {
    	if(http.readyState == 4 && http.status == 200)
      {
        // alert(http.responseText);
        // document.getElementById('foo').innerHTML = http.responseText;
    	}
    }*/
    
    if(method == "POST")
    {
      http.send(query);
    } else
    {
      http.send(null);
    }
  }
  
  return false;
}

function sfc(){ document.q_top.q.focus(); }
function openWind(url,name,w,h){
  newWind=window.open(url,name,"width="+w+",height="+h+",resizable=no,scrollbars=no,menubar=no,toolbar=no");
  newWind.focus();
}

function openWindScroll(url,name,w,h) {
  newWind=window.open(url,name,"width="+w+",height="+h+",resizable=yes,scrollbars=yes,menubar=no,toolbar=no");
  newWind.focus();
}

// progress bar
function showBar(){
  document.getElementById('progress').style.visibility="visible";
}

function fade(id,param){ /* parameter: in - out */
  if(param=="in"){
    document.getElementById(id).style.filter='Alpha(opacity=70)';
    document.getElementById(id).style.MozOpacity='0.70';
  }else if(param=="out"){
    /*item_id.style.filter='Alpha(opacity=50)';*/
    document.getElementById(id).style.filter='none';
    document.getElementById(id).style.MozOpacity='1';
  }
}

// toggle visibility of element
function toggle(id){ /* parameter: in - out */
  if(document.getElementById(id).style.visibility=='hidden'){
    document.getElementById(id).style.display='block';
    document.getElementById(id).style.visibility='visible';
  }else if(document.getElementById(id).style.visibility=='visible'){
    document.getElementById(id).style.display='none';
    document.getElementById(id).style.visibility='hidden';
  }
}

// Set search action
function setAction(type)
{
  if(type == "wiki") {
    document.q_top.action = "http://www.online-lexikon.com/index.php";
  } else if(type == "business") {
    document.q_top.action = "http://www.firmen-suche.at/index.php";
  } else if(type == "news") {
    document.q_top.action = "http://www.open-info.org/index.php";
  } else {
    document.q_top.action = "http://www.oesterreich-suche.com/index.php";
  }
}

// external search links (form_top)
function getExtLink(i,search){
  
  // check index
  if(isNaN(i)||(i>12))
    return false;
  
  // send link
  var links = new Array();
  links[0] = 'http://www.picsearch.de/search.cgi?q='+escape(search);
  links[1] = 'http://images.google.at/images?q='+escape(utf8_encode(search));
  links[2] = 'http://picasaweb.google.at/lh/searchbrowse?q='+escape(utf8_encode(search));
  links[3] = 'http://de.images.search.yahoo.com/search/images?p='+escape(search);
  links[4] = 'http://www.alltheweb.com/search?cat=img&q='+escape(search);
  links[5] = 'http://tools.wikimedia.de/~tangotango/mayflower/search.php?q='+escape(utf8_encode(search));
  links[6] = 'http://de.truveo.com/search.php?query='+escape(utf8_encode(search));
  links[7] = 'http://video.google.de/videosearch?q='+escape(utf8_encode(search));
  links[8] = 'http://de.video.yahoo.com/search/video?p='+escape(utf8_encode(search));
  links[9] = 'http://de.youtube.com/results?search_query='+escape(utf8_encode(search))+'#';
  links[10] = 'http://www.myvideo.de/news.php?rubrik=uoijv&searchWord='+escape(utf8_encode(search));
  links[11] = 'http://www.clipfish.de/searchfish.php?type=video&order=new&word='+escape(search);
  links[12] = 'http://www.blinkx.com/videos/'+escape(utf8_encode(search));
  return links[i];
}

function utf8_decode ( str_data ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
 
    var string = "", i = 0, c = c1 = c2 = 0;
 
    while ( i < str_data.length ) {
        c = str_data.charCodeAt(i);
        if (c < 128) {
            string += String.fromCharCode(c);
            i++;
        } else if((c > 191) && (c < 224)) {
            c2 = str_data.charCodeAt(i+1);
            string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);
            c3 = str_data.charCodeAt(i+2);
            string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    }
 
    return string;
}

function utf8_encode ( str_data ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
 
    str_data = str_data.replace(/\r\n/g,"\n");
    var utftext = "";
 
    for (var n = 0; n < str_data.length; n++) {
        var c = str_data.charCodeAt(n);
        if (c < 128) {
            utftext += String.fromCharCode(c);
        } else if((c > 127) && (c < 2048)) {
            utftext += String.fromCharCode((c >> 6) | 192);
            utftext += String.fromCharCode((c & 63) | 128);
        } else {
            utftext += String.fromCharCode((c >> 12) | 224);
            utftext += String.fromCharCode(((c >> 6) & 63) | 128);
            utftext += String.fromCharCode((c & 63) | 128);
        }
    }
 
    return utftext;
}

// text console
function insert(aTag, eTag, form_name, input_name) {
  var input = document.forms[form_name].elements[input_name];
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
}

// php-timestamp initialized js-clock
// for free use (moe@moose.at)
var clock_ids = new Array();
var active = false;
var type = 1; /*1=node, 2=value*/

// 1.) initialize clock
// format: 1 = 24 hours, 2 = 12 hours
function clock(time_stamp,format,id,set,gmt_diff){
  type = set;
  clock_ids[id] = format; // set tag-id
  current_stamp = (time_stamp*1000);
  current_time = new Date(current_stamp); // add/sub timezone
  current_offset = current_time.getTimezoneOffset()*60000;
  current_stamp = current_stamp + current_offset + parseInt(gmt_diff); // Add Gmt difference
  current_time = new Date(current_stamp);
  clearInterval(active); tick_tack();
  active = setInterval('tick_tack()',1000);
}

// 2.) set seconds
function tick_tack(){
  
  // set new time
  current_stamp += 1000;
  current_time.setTime(current_stamp);
  
  // get current
  var h = current_time.getHours();
  var i = current_time.getMinutes();
  var s = current_time.getSeconds();
  
  // format time
  if(h < 10) h = '0' + h;
  if(i < 10) i = '0' + i;
  if(s < 10) s = '0' + s;
  
  // update display
  for(id in clock_ids){
    var m = "";
    if(clock_ids[id] != "1"){
      var m = " AM";
      if (h >= 12){
        m = " PM";
        if (h > 12){
          h -= 12;
        }
      }
    }
    if(type==1){
      document.getElementById(id).firstChild.nodeValue = h + ':' + i + ':' + s + m;
    }else{
      document.getElementById(id).value = ' ' + h + ':' + i + ':' + s + m;
    }
  }
}

function stopClock(){
  clearInterval(active);
}
/* ]]> */