/*
** Maskierte e-mail
*/
function mask(n,d,txt) {
	if(txt == ''){ txt = n+"@"+d; }
	var string = "<a href='"+"ma"+"ilt"+"o:"+n+"@"+d+"'>"+txt+"</a>";
	document.write(string);
}

var calendarCtrl = new function(){
	this.flashID 				= 'xmlFormCalendar';
	this.currentCalendarField 	= false;
	this.currentFormat 			= false;
	this.standardFormat 		= 'D.M.Y';

	this.open = function(e,objID,format)
	{
		if(typeof(format)== 'undefined'){ var format = this.standardFormat; }
		this.currentCalendarField 	= objID;
		this.currentFormat 			= format;

		//Gibts das Feld?
	    if(this.getField() == false){ return false; }

	    //Soll der Kalender ausgeblendet werden?
	    if(this.getFlashLayer().style.display == 'block'){
	        this.hideFlash();
	        return false;
	    }
	    this.showFlash();
	}

	this.getField = function()
	{
		if((field = document.getElementById(this.currentCalendarField))){
			return  field;
		}
		return false;
	}

	this.getFlashLayer = function()
	{
		if((field = document.getElementById(this.flashID))){
			return field;
		}
		return false;
	}

	this.writeData = function(Y,M,D)
	{
		this.getField().value = this.parseFormat(Y,M,D);
		this.hideFlash();
	}

	this.parseFormat = function(Y,M,D)
	{
		//Aktuelles Format als Vorlage
		var value 	= this.currentFormat;
		//Alle Werte generieren
		var formats = new Object();
		formats.Y 	= Y;
		formats.y 	= Y.substr(Y.length-2,2);
		formats.m 	= Number(M);
		formats.M 	= (formats.m<10)?'0'+formats.m:formats.m;
		formats.d 	= Number(D);
		formats.D 	= (formats.d<10)?'0'+formats.d:formats.d;
		for(var format in formats){
			value = value.replace(format,formats[format]);
		}
		return value;
	}

	this.hideFlash = function()
	{
		this.getFlashLayer().style.display = 'none';
	}

	this.showFlash = function()
	{
		//Kalender positionieren und anzeigen
	    this.getFlashLayer().style.left 	= (Mouse.positionX+15)+'px';
	    this.getFlashLayer().style.top 		= (Mouse.positionY+5)+'px';
	    this.getFlashLayer().style.display 	= 'block';
	}
}


/* Kalender an der Richtigen Stelle anzeigen */
function ShowCalendar(e,id){
    var obj = document.getElementById(id);
    if(typeof(obj) == 'undefined'){ return false; }

    //Soll der Kalender ausgeblendet werden?
    if(obj.style.display == 'block'){
        obj.style.display = 'none';
        return false;
    }
    //Kalender positionieren und anzeigen
    obj.style.left 		= (Mouse.positionX+15)+'px';
    obj.style.top 		= (Mouse.positionY+5)+'px';
    obj.style.display 	= 'block';
}

function displayNone (id) {
  document.getElementById(id).style.display = "none";
}


/* Funktionen fuer die Datumsuebergaben im Ticketshop*/
function setDateStart(y,m,d,id) {

	//refreshDateAbreise(y,m,d);//AbreiseDatum aktualisieren

	var objDate = document.getElementById(id);
	if(typeof(objDate) == 'undefined'){ return false; }

	//Datum zurueckschreiben
	objDate.value = d+'.'+m+'.'+y;


	document.getElementById('flashCalendar'+id).style.display = 'none';
	document.filter.submit();
}



/**************************************
Mouse Controller
****************************************/
Mouse = new Object();
Mouse.positionX = null;
Mouse.positionY = null;
Mouse.moinitoring = function (e)
{
	Mouse.positionX = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	Mouse.positionY = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
}
document.onmousemove = Mouse.moinitoring;


/* Checkbox abfragen */
function checkCheckBox(obj,cvalue) {
	var id = obj.id.replace(/_\d{1,}$/,'');
    if (obj.checked) {
        document.getElementById(id).value=cvalue;
    } else{
        document.getElementById(id).value=0;
    } //IF
}
