function CheckSelect(variable,msg)
{
  for (i=0; ;i++)
  {
    thisVar = variable + '_' + i;
    obj = document.getElementById(thisVar);
    if (obj)
    {
      if (obj.checked)
        return true;
    }
    else
      break;
  }
  window.alert(msg);
  return false;
}

function CheckSearch(formObj,msg)
{
 if (document.forms[formObj].elements['keywords'].value == '')
 {
   window.alert(msg);
   document.forms[formObj].elements['keywords'].focus();
   return false;
 }
 else
  return true;
}

function CheckAll(element)
{
  for(i=0;;i++)
  {
  	var thisObj = document.getElementById(element+i);
  	if (!thisObj)
  	  break;
  	thisObj.checked=true; 
  }
  return;
}

function UncheckAll(element)
{
  var allObj = document.getElementById('all_'+element);
  var allVal = true;	
  for (i=0;;i++)
  {
  	var thisObj = document.getElementById(element+i);
  	if (!thisObj)
  	  break; 
  	else if(!thisObj.checked)
  	{
  	  allVal = false;	
  	  break;	
  	}
  }
  allObj.checked = allVal;
}

//Form Validation

function eCheckEMail(sn){
    s= sn.value;
    if (s.indexOf("@") == -1) return false;
    if (s.indexOf(".") == -1) return false;
    at=false;
    dot=false;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1);
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) {
                if (ch == "@"){
                  if (at) return false;
                  else at=true;
                }
                if ((ch==".") && at)
                   dot=true;
        }
        else return false;
    }
   return dot;
}

function CheckEMail(theForm,theEmailFields,theMsg){
   for(var i=0; i<theEmailFields.length; i++)
         if (!eCheckEMail(theForm.elements[theEmailFields[i]])){
            alert(theMsg);
            theForm.elements[theEmailFields[i]].focus();
            return false;
        }
   return true;
}


function CheckRequiredFields(theForm,theRequiredFields,theMsg)
{
   for(i=0; i<theRequiredFields.length; i++)
        if(theForm.elements[theRequiredFields[i]].value==""){
            alert(theMsg);
            theForm.elements[theRequiredFields[i]].focus();
            return false;
        }
   return true;
}

function CheckForm(theForm,theEmailFields,theRequiredFields,theEmailMsg,theGlobalMsg){
     if(CheckRequiredFields(theForm,theRequiredFields,theGlobalMsg))
     if(CheckEMail(theForm,theEmailFields,theEmailMsg))
          return true;
  return false;
}

//End

/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=75

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

function changeLang()
{
  var obj = document.getElementById('chlang');
  var selectedVal = obj.options[obj.selectedIndex].value;
  
  if (selectedVal == "")
    return;
  
  location.href = selectedVal;  
}

/*  Prototype JavaScript framework, version 1.4.0
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
 *
/*--------------------------------------------------------------------------*/

//note: stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
};

Object.extend = function(destination, source) {
	for (var property in source) destination[property] = source[property];
	return destination;
};

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
};

if (!Array.prototype.forEach){
	Array.prototype.forEach = function(fn, bind){
		for(var i = 0; i < this.length ; i++) fn.call(bind, this[i], i);
	};
}

Array.prototype.each = Array.prototype.forEach;

String.prototype.camelize = function(){
	return this.replace(/-\D/gi, function(match){
		return match.charAt(match.length - 1).toUpperCase();
	});
};

var $A = function(iterable) {
	var nArray = [];
	for (var i = 0; i < iterable.length; i++) nArray.push(iterable[i]);
	return nArray;
};

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;

	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
};

if (!window.Element) var Element = {};

Object.extend(Element, {

	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	hasClassName: function(element, className) {
		element = $(element);
		return !!element.className.match(new RegExp("\\b"+className+"\\b"));
	},

	addClassName: function(element, className) {
		element = $(element);
		if (!Element.hasClassName(element, className)) element.className = (element.className+' '+className);
	},

	removeClassName: function(element, className) {
		element = $(element);
		if (Element.hasClassName(element, className)) element.className = element.className.replace(className, '');
	}

});

document.getElementsByClassName = function(className){
	var elements = [];
	var all = document.getElementsByTagName('*');
	$A(all).each(function(el){
		if (Element.hasClassName(el, className)) elements.push(el);
	});
	return elements;
};

//(c) 2006 Valerio Proietti (http://mad4milk.net). MIT-style license.
//moo.fx.js - depends on prototype.js OR prototype.lite.js
//version 2.0

var Fx = fx = {};

Fx.Base = function(){};
Fx.Base.prototype = {

	setOptions: function(options){
		this.options = Object.extend({
			onStart: function(){},
			onComplete: function(){},
			transition: Fx.Transitions.sineInOut,
			duration: 500,
			unit: 'px',
			wait: true,
			fps: 50
		}, options || {});
	},

	step: function(){
		var time = new Date().getTime();
		if (time < this.time + this.options.duration){
			this.cTime = time - this.time;
			this.setNow();
		} else {
			setTimeout(this.options.onComplete.bind(this, this.element), 10);
			this.clearTimer();
			this.now = this.to;
		}
		this.increase();
	},

	setNow: function(){
		this.now = this.compute(this.from, this.to);
	},

	compute: function(from, to){
		var change = to - from;
		return this.options.transition(this.cTime, from, change, this.options.duration);
	},

	clearTimer: function(){
		clearInterval(this.timer);
		this.timer = null;
		return this;
	},

	_start: function(from, to){
		if (!this.options.wait) this.clearTimer();
		if (this.timer) return;
		setTimeout(this.options.onStart.bind(this, this.element), 10);
		this.from = from;
		this.to = to;
		this.time = new Date().getTime();
		this.timer = setInterval(this.step.bind(this), Math.round(1000/this.options.fps));
		return this;
	},

	custom: function(from, to){
		return this._start(from, to);
	},

	set: function(to){
		this.now = to;
		this.increase();
		return this;
	},

	hide: function(){
		return this.set(0);
	},

	setStyle: function(e, p, v){
		if (p == 'opacity'){
			if (v == 0 && e.style.visibility != "hidden") e.style.visibility = "hidden";
			else if (e.style.visibility != "visible") e.style.visibility = "visible";
			if (window.ActiveXObject) e.style.filter = "alpha(opacity=" + v*100 + ")";
			e.style.opacity = v;
		} else e.style[p] = v+this.options.unit;
	}

};

Fx.Style = Class.create();
Fx.Style.prototype = Object.extend(new Fx.Base(), {

	initialize: function(el, property, options){
		this.element = $(el);
		this.setOptions(options);
		this.property = property.camelize();
	},

	increase: function(){
		this.setStyle(this.element, this.property, this.now);
	}

});

Fx.Styles = Class.create();
Fx.Styles.prototype = Object.extend(new Fx.Base(), {

	initialize: function(el, options){
		this.element = $(el);
		this.setOptions(options);
		this.now = {};
	},

	setNow: function(){
		for (p in this.from) this.now[p] = this.compute(this.from[p], this.to[p]);
	},

	custom: function(obj){
		if (this.timer && this.options.wait) return;
		var from = {};
		var to = {};
		for (p in obj){
			from[p] = obj[p][0];
			to[p] = obj[p][1];
		}
		return this._start(from, to);
	},

	increase: function(){
		for (var p in this.now) this.setStyle(this.element, p, this.now[p]);
	}

});

//Transitions (c) 2003 Robert Penner (http://www.robertpenner.com/easing/), BSD License.

Fx.Transitions = {
	linear: function(t, b, c, d) { return c*t/d + b; },
	sineInOut: function(t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; }
};

//Ticker

var currentNews = 0;
var intTickSpeed = 5000;

function buttonDown(obj) {
  if (!arrNewsItems.length)
    return;
    	
  obj.style.cssText = "margin: 7px 5px 0px 2px;";
}

function buttonUp(obj) {
  if (!arrNewsItems.length)
    return;	
	
  obj.style.cssText = "";
}

function nextNews() {
  setNews(currentNews);
}

function prevNews() {
  setNews(currentNews-2);
}

function initTicker() {
  if (!arrNewsItems.length)
    return;
    
  $("ticker").onmouseover = stopTicker;
  $("ticker").onmouseout = resumeTicker;
  $("back").onclick = prevNews;
  $("next").onclick = nextNews;
  $("back").onmouseover = stopTicker;
  $("next").onmouseover = stopTicker;
  $("next").onmouseout = resumeTicker;
  $("back").onmouseout = resumeTicker;
  
  playTicker();
}

function stopTicker() {
  clearTimeout(autoTimerID);
}

function resumeTicker() {
  clearTimeout(autoTimerID);
  autoTimerID = self.setTimeout("playTicker()", intTickSpeed);
}

function playTicker() {
  setNews(currentNews);	
  autoTimerID = self.setTimeout("playTicker()", intTickSpeed);
}

function setNews(intPos)
{	
  if (arrNewsItems.length < intPos+1)
    intPos = 0;	
  else if (intPos < 0)
    intPos = arrNewsItems.length - 1;  
    
  strResults = '';
  strResults += '<div id="typer"><img src="/images/typer.gif" width="8" height="10" class="typerimg"></div><table border="0" cellpadding="0" cellspacing="0"><tr><td class="tickContent"><a class="tickerlnk" href="' + arrNewsItems[intPos][1] + '" target="_top">';
  strResults += arrNewsItems[intPos][0] + '</a></td></tr></table>';
  $("ticker").innerHTML = strResults;
  efekt = new Fx.Style('typer','width',{duration:700,onComplete:function(){
  	$('typer').style.visibility = "hidden";
  }
  });
  efekt._start($('typer').offsetWidth,0);
  currentNews = intPos+1;
}

function printThis()
{
  document.styleSheets[0].disabled=true;	
  document.styleSheets[1].disabled=false;
  window.print();
  setTimeout('printDone()', 700);
}

function printDone()
{
  document.styleSheets[1].disabled=true;	
  document.styleSheets[0].disabled=false;
}

//End

function CheckLogin(formObj,msg1,msg2,msg3)
{
  var usrVal = document.forms[formObj].elements['cuser'].value;
  var pasVal = document.forms[formObj].elements['cpass'].value;
  
  if (usrVal == "" && pasVal == "")
  {
    window.alert(msg1);	
    document.forms[formObj].elements['cuser'].focus();
  	return false;
  }
  else if (usrVal == "")
  {
  	window.alert(msg2);	
  	document.forms[formObj].elements['cuser'].focus();
  	return false;
  }
  else if (pasVal == "")
  {
  	window.alert(msg3);
  	document.forms[formObj].elements['cpass'].focus();	
  	return false;
  }
  else
    return true;
}

//Menu Functions

function menuOver(obj,val,lang)
{
  // obj.style.cssText = "color:#cd9e40;background:#e2dddb;cursor:pointer;";
  document.getElementById("mimage"+val).src = "images/layout/"+lang+"/menue_corner_hover.gif";
  obj.className = "tool3";
}

function menuOut(obj,val,lang)
{
  // obj.style.cssText = "color:white;background:none;cursor:none;";
  document.getElementById("mimage"+val).src = "images/layout/"+lang+"/menue_corner.gif";
  obj.className = "tool2";
}

function menuClick(url)
{
  location.href = url;	
}

//End
