u1 = new Object();
u1.flashstring='';
u1.stop = function(e){
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}
u1.enter = function(event){
if(!event){
		event = window.event;
	}
	if(event.keyCode==13){
		return true;
	}else{
		return false;
	}
}

u1.entf = function(event){
if(!event){
		event = window.event;
	}
	/*
	if(event.keyCode==46){
		neuurl = document.location.href.replace(document.location.search,'')+'?entf=1';
		//document.location.href=neuurl;
	}
	*/
}

u1.tastenverteiler = function(event){
	if(!event){
		event = window.event;
	}
	/*
	if(event.keyCode==46){
		neuurl = document.location.href.replace(document.location.search,'')+'?entf=1';
		//document.location.href=neuurl;
	}else if(event.keyCode==39){
		neuurl = document.location.href.replace(document.location.search,'')+'?go1px=rechts';
		//document.location.href=neuurl;
	}else if(event.keyCode==37){
		neuurl = document.location.href.replace(document.location.search,'')+'?go1px=links';
		//document.location.href=neuurl;
	}else if(event.keyCode==38){
		neuurl = document.location.href.replace(document.location.search,'')+'?go1px=hoch';
		//document.location.href=neuurl;
	}else if(event.keyCode==40){
		neuurl = document.location.href.replace(document.location.search,'')+'?go1px=runter';
		//document.location.href=neuurl;
	}
	*/

}


u1.browser = function(){
	if(navigator.appName.indexOf('Opera')>-1)return "OP";
	if(navigator.appName.indexOf('Microsoft')>-1)return "IE";
	if(navigator.appName.indexOf('Netscape')>-1 || navigator.userAgent.indexOf('Gecko')>-1)return "MO";
}


u1.mouse = function (event)
{
	if(!event){
		event = window.event;
	}
    return {x:event.clientX, y:event.clientY};
}
u1.init = function(){
	$('#rateusnummer').get(0).focus();
	starwars();
}
u1.sterne = [];
function starwars(){
	u1.sterne = $('.starwars');
	function sternzustand(st,x1,y1){
		this.stern = st;
		this.x = x1;
		this.y = y1;
	}

	sternzustand.prototype.durchsichtigkeit = function(){
		var o1 = Math.random();
		if(o1<0.8){
			o1 = o1/2;
		}
        var st = this.stern;
        $(st).animate({opacity:o1},1000);
	}
	for(var i = 0;i<u1.sterne.length;i++){
		$(u1.sterne[i]).animate({opacity:1},1);
		u1.sterne[i].zustand = new sternzustand(u1.sterne[i],parseInt($(u1.sterne[i]).css('left')),parseInt($(u1.sterne[i]).css('top')));
	}
	sternenzauber();
	window.setInterval('sternenzauber()',4000);
}

function sternenzauber(){
	for(var i = 0;i<u1.sterne.length;i++){
		if(Math.random()>0.6){
			u1.sterne[i].zustand.durchsichtigkeit();
		}
	}
}

function jpop(id,mitnr){
	if(mitnr!=undefined){
		var wert = $('#rateusnummer').attr('value');
		var testurl = '/admin/public/Ticket/ajaxtest/t/'+wert;
		var url = '/admin/public/Ticket/quickinput/t/'+wert;
        $('#if_'+id).get(0).src=url;
        if(wert!=undefined){
            $.ajax({
               type: "GET",
               url: testurl,
               success: function(msg){
                 if(parseInt(msg)==1){
                    window.setTimeout("jpop("+id+")", 500);
                    $('#rateusnummer').get(0).blur();
                 }else if(parseInt(msg)==0){
                    $('#content20').empty().append('Teilnahme schon erfolgt');
                    $('#rateusnummer').get(0).focus();
                 }else if(parseInt(msg)==2){
                    $('#content20').empty().append('Bitte Ticketcode überprüfen');
                    $('#rateusnummer').get(0).focus();
                 }
               }
             });
         }else{
         	$('#content20').empty().append('Bitte Ticketcode eingeben');
         	$('#rateusnummer').get(0).focus();
         }
	}else{
        //var x = parseInt((parseInt(screen.availWidth)-500)/2);
        //var y = parseInt((parseInt(screen.availHeight)-400)/2);
        var x = 170;
        var y = 87;

        if($(('#e'+id)).css('width')!='600px' || $(('#e'+id)).css('height')!='630px'){
            //$(('#ep'+id)).animate({zIndex:30},1);
            $(('#e'+id)).animate({zIndex:20},1,"linear",function(){$(('#content'+id)).animate({opacity:0},1,"linear",function(){$(('#e'+id)).animate({opacity:1,left:x,top:y,width:600,height:630}, 300,"linear",function(){$(('#content'+id)).animate({opacity:1},200);});});});
            //$(('#e'+id)).animate({opacity:1,left:x,top:y,width:600,height:400},400);
            //$(('#ep'+id)).animate({opacity:1},300);
        }else{
            c = $(('#e'+id)).get(0).className.split(' ');
            info = c[(c.length-1)];
            i = info.split('_');
            x = i[1];
            y = i[2];
            w = i[3];
            h = i[4];
            $(('#content'+id)).animate({opacity:0},200,"linear",function(){$(('#e'+id)).animate({left:x,top:y,opacity:0,width:w,height:h,zIndex:3},300,"linear",function(){$(('#content'+id)).animate({opacity:0},1);});});

        }
    }

}

function jml(){
	var u = encodeURI(document.getElementById('un').value);
	var p = encodeURI(document.getElementById('up').value);
    $.ajax({
        type: "POST",
        url: "/admin/public/",
        data: "user="+u+"&password="+p+"&al=1",
        success: function(msg){
        if(msg=='1'){
        	document.location.href='/admin/public/';
        }else{
        	document.getElementById('un').value='';
        	document.getElementById('up').value='';
        }
        }
    });

}

function createDummyCode(){
	$('#loading').show();
	$.ajax({
        type: "POST",
        url: "/admin/public/logout",
        data: "",
        success: function(msg){
			$.ajax({
                type: "POST",
                url: "/admin/public/Ginipos/createTicket/f/1/l/MID1/p/827ccb0eea8a706c4c34a16891f84e7b/s/1",
                data: "",
                success: function(msg){
                    $('#rateusnummer').get(0).value=msg;
                    $('#rateusnummer').get(0).focus();
                    $('#loading').hide();
                }
            });
        }
    });
}

function dummyAdmin(){
	$('#loading').show();
	$('#rateusnummer').get(0).value='';
	$.ajax({
        type: "POST",
        url: "/admin/public/",
        data: "user=Mandant1&password=Gast",
        success: function(msg){
        	window.open('/admin/public/');
        	$('#loading').hide();
        }
    });
}
