/* Style Loader for quick pageload in the choosen layout -- (c)2003 / alfmiti@gmx.at */
/* Use the Style Switcher available at www.stichpunkt.de                             */

var styleNames = new Array('Country','Cool_grey','Blue','Low_down','Fun','Dark','Drucken');
var cssNames =   new Array('country.css','grey.css','blue.css','lowdown.css','fun.css','dark.css','print.css');

var savedStyle = getStyleCookie('Layout');
if (savedStyle == '') savedStyle = styleNames[0];
// check for print call
var request_uri =  window.location.href;
var nr = request_uri.search(/print.+/) != -1 ? 6 : getStyleNumber(savedStyle);

str = "<link rel='stylesheet' type='text/css' media='screen' ";
str += "title='" + styleNames[nr] + "' href='/css/"  + cssNames[nr] +"?v=1.29' />";
document.write(str);


function getStyleNumber(wantStyle) {

   for (var i=0; i < styleNames.length; i++) {
       if (wantStyle == styleNames[i]) return i;
   }
   return 0;
}

function getStyleCookie(name) {
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
      var start = dc.indexOf(cname);
      if (start != -1) {
          start += cname.length;
          var stop = dc.indexOf(";", start);
          if (stop == -1) stop = dc.length;
          return unescape(dc.substring(start,stop));
      }
  }
  return null;
}


// ANTI SPAM 1
function aspam(sld_tld,account) {
  window.location.href = "mailto:" + account + '@' + sld_tld;
}

// ANTI SPAM 2
function decrypt_string(str)
{
	var low = 0;
	var high = 0;
	var retvalue = "";

	for(var i = 0; i < str.length; i += 2)
	{
		high = str.charCodeAt(i) - 48;
		low = str.charCodeAt(i + 1) - 48;

		if(high > 9)
			high -= 7;

		if(low > 9)
			low -= 7;

		retvalue += String.fromCharCode((high << 4) | low);
	}

	return retvalue;
}

function decrypt_link(sld_tld,account)
{
   sld_tld = decrypt_string(sld_tld);
   account = decrypt_string(account);
	window.location.href = "mailto:" + account + '@' + sld_tld;
}

function xml_Link(filename) {
   var filename = is_gecko || is_nav6up || is_ie6up ? filename + '.xml' : filename + '.htm';
   self.location.href = filename;
}

function set_xml_propertie() {
   var extension = is_gecko || is_nav6up || is_ie6up ? 'xml' : 'htm';
   document.form1.extension.value= extension;
}

function add_favorit() {
   if (is_ie) {
      window.external.AddFavorit(document.location.href, document.title);
   }
}




var is_getElementById   = (document.getElementById) ? true : false;

// BROWSER SNEEFER
// Check for browser with XML support
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);

var is_opera = (agt.indexOf("opera") != -1) ? true : false;
var is_konq  = (agt.indexOf('konqueror') != -1) ? true : false;
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))? true : false;
var is_khtml  = (is_safari || is_konq);

var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
   is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
   is_major = parseInt(is_minor);
}

var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
var is_ie6up = (is_ie && is_minor >= 6);

var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))? true : false;

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
       && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
       && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
       && (!is_khtml));

if ((navigator.vendor)&&
    ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&& (is_nav)) {
      is_major = parseInt(navigator.vendorSub);
      is_minor = parseFloat(navigator.vendorSub);
}

var is_nav6up = (is_nav && is_minor >= 6);


function show_search() {

  if (!is_getElementById) return;

  var googleBox = document.getElementById('google_box');
  var linkPosition = getAbsolutPosition('leftbox');
  googleBox.style.left = (linkPosition.left - 40) + 'px';
  googleBox.style.display = 'block';
  googleBox.style.top = '138px';
  document.getElementsByName('req')[0].focus();
}

function hide_box() {
 document.getElementById('google_box').style.display = 'none';
}



// @author alfmiti
function init_search_box() {

// if (is_ie) return;

var divHtml = '<form method="POST" action="/site/map/suche.htm" style="display:inline;">'
  + '<strong>Blues.at durchsuchen: </strong>'
  + '<input name="req" type="text" size="20" class="input2" value="" />'
  + '<input type="submit" name="Submit" value="Finden" class="btn" style="margin:0px 10px;" />'
  + '<input type="button" value="Abbrechen" class="btn" style="margin-right:20px;" onClick="hide_box();"/>'
  + '<img src="/img/google_25.gif" width="75" height="32" border="0" alt="google logo" title="Powered by Google" style="vertical-align:middle;" /><br />'
  + '<input type="checkbox" name="p" value="1"{google.p_checked} />Phorum '
  + '<input type="checkbox" name="g" value="1"{google.g_checked} />Gallerie '
  + '<input type="checkbox" name="t" value="1"{google.t_checked} />Termine '
  + '<input type="checkbox" name="f" value="1"{google.f_checked} />PDF '
  + ' von der Suche ausschliessen '
  + '</form>';

  // add hidden div
  ele = document.createElement('div');
  ele.id = 'google_box';
  with (ele.style) {
    position = 'absolute';
    display = 'none';
    top = '138px';
    left = '100px';
    width = '700px';
    height = '58px';
  }
  ele.innerHTML = divHtml;
  document.body.appendChild(ele);
}


// @author alfmiti -> from tinyRTE
function getAbsolutPosition (elementId) {

  var elmObj = document.getElementById(elementId);
  var y = elmObj.offsetLeft;
  var x = elmObj.offsetTop;

  var thereIsParent = elmObj.offsetParent;

  while (thereIsParent)  {
      elmObj = thereIsParent;
      x += elmObj.offsetLeft;
      y += elmObj.offsetTop;
      thereIsParent = elmObj.offsetParent;
  }

  var res = { left: x, top:y };
  return res;
};


window.onload = init_search_box;