if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}







CC = {}

CC.Formcheck = {};



CC.Helpers = {
	Stack: []
	,hideAll: function ()
	{
		for (var i = 0; Helper = CC.Helpers.Stack[i]; i ++)
			Helper.style.display = 'none';
	}
	
	,showError: function(ErrText, Err)
	{
		if (!arguments[1])
			Err = 1;
		
		$('help_error_' + Err).innerHTML = ErrText;
		$('help_error_' + Err).style.display = 'block';
	}
	
	,hideError: function(Err)
	{
		if (!arguments[1])
			Err = 1;
		
		$('help_error_' + Err).style.display = 'none';
	}
}

/**
 * FormCheck-Objekt für Registrierungsformular
 */
CC.Formcheck.Checks = {
	
	 Errors: ''
	,ErrorCount: 0
	,FocusOn: null
	,YesNo: []
	
	,step4: function()
	{
	    this.checkEmpty($('description'), 	'Gib eine Beschreibung');
	    this.checkEmpty($('wishes'),		'Gib Deine Wünsche an');
	    this.checkLength($('description'), 	100, 'Die Beschreibung erfordert min. 100 Zeichen');
	    this.checkLength($('wishes'),		100, 'Die Wünsche erfordert min. 100 Zeichen');
	    
		for (i = 0; i < this.YesNo.length; i ++)
		{
			var OnID = this.YesNo[i];
			var Obj1 = $('yesno_' + OnID + '_yes');

			var Obj2 = $('yesno_' + OnID + '_no');
			
		    if (Obj1.checked != true && Obj2.checked != true)
		    {
				this.addError('Geben Sie Ihr Interesse für ' + OnID + ' an');
		        this.setFocus(Obj1);
		    }
		}
	    
		return this.endCheck();
	},
	
	endCheck: function()
	{
	    if (this.FocusOn == null)
	    {
	        return true;
	    }
	    else
	    {
	        alert(this.Errors);
	        this.FocusOn.focus();
	        return false;
	    }
	},
	
	
	setFocus: function(Obj)
	{
		var Err;
		
		try
		{
			if (Obj.addClass)
			{
				Obj.addClass('error');	
//				Obj.addEvent('onchange', function(){
//				});
			}
	
	        if (this.FocusOn == null)
	        {
	            this.FocusOn = Obj;	
	        }
		}
		catch (e)
		{
			Err = e;
		}
		
		if (Err)
		{
			console.log('Setting Focus:: ' + Err);
		}
	},
	
	addError: function(Msg, Obj)
	{
		console.log('concatenateing: ' + Msg);
		this.Errors += '- ' + Msg + '\n';	
		this.ErrorCount ++;
	}
	
	,addLine: function(Content)
	{
		this.Errors += Content + '\n';
	}
	
	,checkLength: function(Obj, Length, Msg)
	{
		if (!Obj.value)
			return;
			
	    if (Obj.value.length < Length)
	    {
			this.addError(Msg);
	        this.setFocus(Obj);
	    }
	}
	
	,checkMaxLength: function(Obj, Length, Msg)
	{
		if (!Obj.value)
			return;
			
	    if (Obj.value.length > Length)
	    {
			this.addError(Msg);
	        this.setFocus(Obj);
	    }
	},
	
	checkChecked: function(Obj, Msg)
	{
	    if (Obj.checked != true)
	    {
			this.addError(Msg);
	        this.setFocus(Obj);
	    }
	},
	
	checkSelect: function(Obj, Msg)
	{
		if (!Obj)
			alert(Msg);
		
	    if (Obj.options[Obj.options.selectedIndex].value == ''
	    || Obj.options[Obj.options.selectedIndex].value == 0)
	    {
			this.addError(Msg);
	        this.setFocus(Obj);
	    }
	},
	
	checkCheckedOneOf: function(IDs, Msg)
	{
		var OneChecked = false;
		
		for (i = 0; i < IDs.length; i ++)
		{
			if ($(IDs[i]).checked == true)
				OneChecked = true;
		}
		
	    if (false === OneChecked)
	    {
			this.addError(Msg);
	    }
	},
	
	checkEmpty: function(Obj, Msg)
	{
		if (!Obj)
			alert(Msg);

	    if (!Obj.value || Obj.value == '')
	    {
			this.addError(Msg);
	        this.setFocus(Obj);
	    }
	},
	
	checkEquality: function(Obj, Obj2, Msg)
	{
		if (Obj.value != Obj2.value)
		{
			this.addError(Msg);
	        this.setFocus(Obj);
		}
	},
	
	checkRadio: function(Objs, Msg)
	{
	    Objs.hasCheck = false;
	    
	    for (i = 0; i < Objs.length; i ++)
	    {
	        if (Objs[i].checked == true)
	        {
	            Objs.hasCheck = true;
	        }
	    }
	    if (false == Objs.hasCheck)
	    {
			this.addError(Msg);
	        this.setFocus(Objs[0]);
	    }
	}
}

CC.Jax = {
	pageRefresh: function()
	{
		if (CC.Jax.lastRequest.url)
		{
			try
			{
				new ajax(
					CC.Jax.lastRequest.url
					,{
						 method: 'post'
						,postBody: 'JaxCall=1'
						,onComplete: CC.Jax.lastRequest.onComplete.bind(CC.Jax.lastRequest.bind)
					}
				);	
			}
			catch (e)
			{
				document.location.href = CC.Jax.lastRequest.url;
			}
		}
		else
		{
			document.location.reload();
		}
	}
	
	,lastRequest: {
		 url: null
		,onComplete: null
		,bind: null
	}
}

CC.Jax.TopAdd = new Class();
CC.Jax.TopAdd.prototype = {
	 initialize: function(Target)
	{
		this.Target = Target;
		this.TimeOut = window.setInterval(this.loadAd.bind(this), 30000);
	}
	
	,Target: null
	,TimeOut: null
	
	,loadAd: function()
	{
		new ajax(
			'/anzeigen/banner.php',
			{
				 method: 'post'
				,postBody: 'Page=' + document.location.href
				,onComplete: this.receiveResponse.bind(this)
			}
		);
	}
	
	,receiveResponse: function(Response)
	{
		this.Target.innerHTML = Response.responseText;
	}	
}








































function updatePartyTip()
{
	window.setInterval(updatePartyTip_Do, 30000);
}

function updatePartyTip_Do()
{
	new ajax(
		'/partytip_jax.php',
		{
			method: 'get',
			onComplete: updatePartyTip_Paint
		}
	);
}

function updatePartyTip_Paint(req)
{
	$('partytip_box').innerHTML = req.responseText;
}




function openPNRead(PN)
{
    PNWindow = openWindow('/community/messenger/view.php?PN=' + PN, 450, 400);
}

function toggleDescription(DescNumber)
{
	Description = document.getElementById('desc' + DescNumber);
	if (Description.style.display == 'none')
		Description.style.display = 'block';
	else
		Description.style.display = 'none';		
}

function toggleNav(ID)
{
	var Status = toggleElement(ID);

	var	Navs = $S('ul.subnav');

	for (i = 0; Nav = Navs[i]; i ++)
	{
		if (Nav.id != ID)
		{
			Nav.style.display = 'none';
		}
	}

	new ajax('/plugin/de.newmedia-tech/ajax/notifyNav.php', {
		 postBody: 'Nav=' + ID + '&Status=' + Status
	});
}

function toggleElement(ID)
{
	TheElement = $(ID);
	
	if (TheElement.style.display == 'none')
	{
		TheElement.style.display = 'block';
	}
	else
	{
		TheElement.style.display = 'none';	
	}
	
	return TheElement.style.display;
}


function picureToGuestbook()
{
	popUp('/includes/popups/community/addguestposting.php?Photo=' + $('picture_id').value + '&User=' + $('guestbook_name').value, 'width=500,height=400,resizable=yes');
	return false;
}


function openPNWrite()
{
    PNWindow = openWindow('/includes/popups/messenger/write.php', 450, 400);
}

function openPNWriteEmfpaenger(Emfpaenger)
{
    PNWindow = openWindow('/includes/popups/messenger/write.php?empfaenger=' + Emfpaenger, 450, 400);
}

    
    function popUpClose()
    {
        PopUp.close();
        window.location.reload();
    }
function openWindow(Url, Width, Height)
{
    if (Width == undefined)
        Width = 520;
    if (Height == undefined)
        Height = 300;
        
    var Left    = screen.availWidth / 2 - Width / 2;
    var Top     = screen.availHeight / 2 - Height / 2;
    
    return window.open(Url, 'OpenedWindow', 'width=' + Width + ', height=' + Height + ', left=' + Left + ', top=' + Top + ', resizable=yes');
}

function closePNWrite()
{
    window.setTimeout('closePNWriteDo()', 5000);
}

function closePNWriteDo()
{
    PNWindow.close();
}

var PNChecks    = new Array();
var PNChecked   = false;

function checkAllPNChecks()
{
    for (i = 0; i < PNChecks.length; i++)
    {
        PNCheck = document.getElementById(PNChecks[i]);
        
        if (PNChecked)
        {
            PNCheck.checked = false;
        }
        else
        {
            PNCheck.checked = true;
        }
    }
        
    if (PNChecked)
    {
        PNChecked = false;
    }
    else
    {
        PNChecked = true;
    }
}

function ResizeImgs(Element) {
	if (!Element)
	{
	    Element = document.getElementById('usergb');
	}
    TraverseNode(Element, '');
}

function ResizeImgsDo(Obj) {
    alert(Obj.src);
    if (Obj.src.substring(0,22) != "http://www.clipfisch.newmedia-tech.de"){
        if (Obj.width > 400) {
            Obj.width = 400;
        }
    }
}
    


var SaveCount = 0;
var SaveBreak = 200;

function debugOut(Msg)
{
    debug = document.getElementById('debug');
    debug.innerHTML += Msg + '<br/>';
}
function openGuestbookComment(GBEntry)
{
    GuestBook = openWindow('/includes/popups/community/addguestcomment.php?GBEntry=' + GBEntry);
}


function closeViolationReport()
{
    window.setTimeout('closeViolationReportDo()', 5000);
}

function closeViolationReportDo()
{
    ViolationReport.close();
}

function closeGuestbook()
{
    GuestBook.close();
    //window.location.href = window.location.href + '#usergb';
    window.location.reload();
}

function TraverseNode(Nodes, Name)
{
	var Node = 0;
    var ActualNode;
    
    Name = Name + '>' + Nodes.nodeName;
    for (Node = 0; Node < Nodes.childNodes.length; Node++)
    {
        ActualNode = Nodes.childNodes[Node];
    
        if (ActualNode.nodeName != '#text')
        {
            if (ActualNode.nodeName == 'IMG')
            {
                if (ActualNode.src.substring(0,22) != "http://www.clipfisch.newmedia-tech.de"){
                    if (ActualNode.width > 400) {
                        ActualNode.width = 400;
                    }
                }
            }
                
            SaveCount++;
            if (SaveCount > SaveBreak)
                return;
            
            if (ActualNode.hasChildNodes())
            {
                TraverseNode(ActualNode, Name);
            }
        }
    }
}



function makeNewLocationType()
{
	parameters  = 'id=' + $('location_type_id').value;
	parameters += '&display=' + $('location_type_display').value;
	parameters += '&bild=' + $('location_type_bild').value;
	parameters += '&beschreibung=' + $('location_type_beschreibung').value;
	if ($('location_type_nav').checked == true)
	{
		parameters += '&in_nav=' + 1;
	}
	else
	{
		parameters += '&in_nav=' + 0;
	}
	
	new Ajax.Request(
		'/locations/admin/savetype.php',
		{
			method: 'get',
			parameters: parameters,
			onSuccess: setLocationsTypeSelect
		}
	);
	
	return true;
}



function getLocationType()
{
	parameters  = 'id=' + $('type').options[$('type').options.selectedIndex].value;
	
	new Ajax.Request(
		'/locations/admin/gettype.php',
		{
			method: 'get',
			parameters: parameters,
			onSuccess: setLocationsTypeOnEdit
		}
	);
	
	return true;
}

function setLocationsTypeOnEdit(req)
{
	Status 	= null;
	ChatLog	= null;
	ChatLock = false;
//	$('nfo').innerHTML = req.responseText
	eval(req.responseText);
	
	if (Status != 'OK')
	{
		alert('SomeThingWentWrong');
	}
	else
	{
		$('location_type_id').value 		 	= Type.id;
		$('location_type_display').value 		= Type.display;
		$('location_type_bild').value 			= Type.bild;
		$('location_type_beschreibung').value	= Type.beschreibung;
		
		if (Type.in_nav == '0')
		{
			$('location_type_nav').checked = false;
		}
		else
		{
			$('location_type_nav').checked = true;
		}
	}
}

function setLocationsTypeSelect(req)
{
	Status 	= null;
	ChatLog	= null;
	ChatLock = false;
//	$('nfo').innerHTML = req.responseText
	eval(req.responseText);
	
	if (Status != 'OK')
	{
		alert('SomeThingWentWrong');
	}
	else
	{
		TypeSelect = $('type');
        TypeSelect.options.length = Types.length;

        for (var i = 0; i < Types.length; i++)
        {
            TypeSelect.options[i].text  = Types[i];
            TypeSelect.options[i].value = Types[i];
        }

        TypeSelect.options.selectedIndex = Select;
	}
	
	toggleElement('location_type_edit');
}















function check_message(message)
{
 	var rueck 		= true;
 	var forentext 	= message;
 	var Ergebnis;

   	var smilies = TagScanner(forentext, ':');
   	if (smilies > 40)
   	{
    	return 'Du hast mehr als 20 Smilies in deinem Beitrag, bitte aendere das.';
   	}

   	var pictures = TagScanner(forentext, '[img]');
   	if (pictures > 4)
   	{
	    return 'Du hast mehr als 4 Bilder in deinem Beitrag, bitte aendere das.';
   	}


	for (i = 0; i < BadURLs.length; i ++)
	{
		SearchString = BadURLs[i];
		eval('Ergebnis = forentext.search(/' + SearchString + '/)');
		if (Ergebnis != -1)
		{
			return 'Die im Beitrag angegebene Internetadresse ' + SearchString + ' ist nicht zulaessig\n\n Der Betreiber der Website hat uns die Verlinkung auf Inhalte seiner Seite untersagt.';
		}
	}
	
	return false;
}

function TagScanner(Beitrag, Tag)
{
 	var Text_length = Beitrag.length;
	var Tag_length	 = Tag.length;
	var Tag_Num	 = 0;
	for (i = 0; i <= Text_length; i++)
	{
		if (Beitrag.charAt(i) == Tag.charAt(0))
		{
			var found = Beitrag.substr(i,Tag_length);
			if (found == Tag)
			{
				Tag_Num++;
			}
		}
	}
	return Tag_Num;
}


var BadURLs = [
'sunshine-familie.de',
'fuxshop.de',
'women-chat2000.de',
'dagmar-borchert.de',
'katzenstube.de',
'selber-backen.de',
'auf-dem-marktplatz.de',
'homepagestudio.de',
'heiko-hildebrandt.de',
'klassentreffen-esslingen.de',
'mayeruli.de',
'Diethelm-Glaser.de',
'Diethelm-Glaser.net',
'pedi-marketing.net',
'quasimodo52.de',
'didis-fotos.de',
'rysselchen.de',
'markuswesseling.de',
'people.freenet.de',
'amt-nennhausen.de',
'autos.cs.tu-berlin.de',
'funfire.de',
'allmystery.de',
'lustige-ecards.de',
'motordesktop.com',
'auto-sfondi-desktop.com',
'bofunk.com',
'perso.wanadoo.fr',
'seriouswheels.com',
'krankhaft.de',
'moviesanddvds.de',
'doberman.go.ro',
'bigbtv.com',
'bild.t-online.de',
'bunnys.de',
'vdownload.jubii.com',
'spass-24.com',
'victorian-music.com',
'chocopriveos.de',
'grafik-3d-portal.de',
'hotzeltopf.de',
'twoday.net',
'skyblog.com',
'pablotron.org',
'westbalkanonline.com',
'images.google.de',
'lustich.net',
'lustich.de',
'free.fr',
'natomic.com',
'advnt01.com',
'ibiblio.org',
'pp.ru',
'kwick.de',
'rotten.com',
'axellauer.de',
'cardus.com',
'smiley-channel.de',
'joy4yourlife.de',
'grandini.biz',
'kurspool.de',
'onlinepics24.de',
'szon.de',
'piccube.de',
'gehnicht.de',
'postkartenparadies.de',
'feuerwehr.de',
'faq-h.de',
'ampulove.com',
'fuchs-soest.de',
'mehr-schbass.de',
'art-foto-media.de',
'home.student.uu.se',
'uwe-dorn.de',
'sidecar-cz.com',
'ds-webtools.de',
'ohost.de',
'monstergame.de',
'monstergame.info',
'samtpfoetchen.de',
'monika.abeling',
'imagepuzzler.com',
'dala.de',
'gromith.ch',
'flowerdreams.de',
'sajonara.de',
'selk-stuttgart.de',
'zehner.ch',
'foolforfood.de',
'think-strange.de',
'b-oberholz.de',
'ircflirt.de',
'myasthenie-und-seele.de',
'hitzel.com',
'maztravel.com',
'kill-more-people.de',
'smiliemania.de',
'dopecash.com',
'ls-university.com',
'sextronix.com',
'porno.com',
'porno.de',
'poppen.de',
'ficken.de',
'poppen.com',
'ficken.com',
'epicgals.com',
'theroleplaying.com',
'702cash.com',
'filthynurses.com',
'teenflood.com',
'freehostedgallery.com',
'midnightprowl.com',
'exploitedteens.com',
'amateursgonebad.com',
'fvotd.com',
'apmhosteappealingpics.com',
'collegefuckfest.com',
'cheatinglesbians.com',
'seattlesorority.com',
'mipgals.com',
'picgals.com',
'adult.com',
'pregnantfux.com',
'pregnantschool.com',
'sweetmoney.com',
'pregnantgirlies.com',
'smutty-pages.com',
'lightspeedgirls.com',
'epicgals.com',
'pantymadness.com',
'payperscene.com',
'skintraffic.com',
'teenlabia.com',
'wannawatch.com',
'harlotgirl.com',
'asianpornoground.net',
'bethemask.com',
'jp18.com',
'spicymovies.com',
'asianschoolfuck.com',
'bustysites.com',
'amateurnest.com',
'justass.com',
'nsgalleries.com',
'makebling.com',
'momsanaladventure.com',
'dgalleries.com',
'pimpfreepics.com',
'freehotpics.com',
'nocumdodgingallowed.com',
'shegotswitched.com',
'analsuffering.com',
'analdestruction.com',
'appealingpics.com',
'pimpfreepics.com',
'porn-xxx-pictures.com',
'spunkpass.com',
'silicom.com',
'autobahnvw.net',
'nazi-lauck-nsdapao.com',
'eblogx.de',
'gronk.us',
'monstersofcock.com',
'swallowingsluts.com',
'shemalesins.com',
'tsclips.com',
'trannydestruction.com',
'pimpfreepics.com',
'freevideogallery.com',
'buttmachineboys.com',
'appealingpics.com',
'plumperfacials.com',
'fuckomat.com',
'tgppics.com',
'babes.tv',
'dildoaddicted.com',
'glamourmodelsgonebad.com',
'lonniewaters.com',
'bustycafe.net',
'easydrunkgirls.com',
'cockbrutality.com',
'brutaldildos.com',
'ravishingindians.net',
'ebonyfiesta.com',
'nastygrannies.com',
'crazypics.de',
'hell.pl',
'mikrobitti.fi',
'santabanta.com',
'drno.de',
'net-server5.de',
'jbcdetoss.nl',
'funpic.de',
'mycgiserver.com',
'friday-fun.com',
'warnet.ws',
'voak.at',
'thc-relaxer.de',
'playboard.de',
'bk-sportsmag.se',
'domula.de',
'mellesleg.hu',
'hinti.ch',
'musikverein-wiechs.de',
'yimg.com',
'scorn.com',
'scorn.us',
'break.com',
'inidia.de',
'kewl.ch',
'opeschka.de',
'starstore.com',
'lachstdu.de',
'msn.com',
'666kb.com',
'exs.cx',
'learntohate.net',
'burg-fehmarn.de',
'mk2448.de',
'burg-fehmarn.de',
'hurz.de',
'team-ulm.de',
'teamulm.de',
'el-ladies.com',
'217.160.17.126'
];


CC.Violation = {
	user: function(User)
	{
		CC.Violation.exec('User=' + User);
		return false;	
	}
	
	,profilbild: function(User)
	{
		CC.Violation.exec('Profilbild=' + User);
		return false;
	}
	
	,comment: function(Comment)
	{
		CC.Violation.exec('Comment=' + Comment);
		return false;	
	}
	
	,photo: function(Photo)
	{
		CC.Violation.exec('Photo=' + Photo);
		return false;
	}
	
	,userphoto: function(Photo)
	{
		CC.Violation.exec('Usergalerie=' + Photo);
		return false;
	}
	
	,exec: function(Request)
	{
		popUp('/includes/popups/verstoss/abuse.php?' + Request + '&Location=' + encodeURIComponent(document.location.href), 'width=520,height=450,resizable=yes,scrollbars=yes');
	}
}

function openGuestbook(User)
{
    GuestBook = openWindow('/includes/popups/community/addguestposting.php?User=' + User);
}
    
function openStats(User)
{
    Stats = openWindow('/includes/popups/community/yourprofile_stats.php?User=' + User);
}


function selectText(ID)
{
	var TA = $(ID);
	TA.focus();
	TA.select();
}





function changeTab(Tab, Tabs)
{
	var TabID = Tab.parentNode.parentNode.parentNode.id;
	
	var TabTrigger = $$('.' + TabID + '_trigger');

	for (i = 0; Node = TabTrigger[i]; i ++)
	{
		if (Node.id != Tab.id)
		{
			Node.removeClass('active');
		}
		else
		{
            Node.addClass('active');
		}
	}
	
	var TabContents = $$('.' + TabID);

	for (i = 0; Node = TabContents[i]; i ++)
	{
		if (Node.id != Tab.id)
		{
			Node.style.display = 'none';
			Node.removeClass('active');
		}
	}
	
	var TabContent = $('tab_content_' + Tab.id.split(/_/).pop());
	TabContent.style.display = 'block';
}



function geoLoadStates(Trigger)
{
	var Country = Trigger.options[Trigger.options.selectedIndex].value;

	new Ajax(
		'/plugin/de.newmedia-tech/ajax/getGeoSelect-States.php',
		{
			 method: 'post'
			,postBody: 'Country=' + Country
			,onComplete: geoLoadStatesReceive
		}
	).request();
}

function geoLoadCities()
{
	var State = this.options[this.options.selectedIndex].value;

	new Ajax(
		'/plugin/de.newmedia-tech/ajax/getGeoSelect-Cities.php',
		{
			 method: 'post'
			,postBody: 'State=' + State
			,onComplete: geoLoadCitiesReceive
		}
	).request();
}

function geoLoadCitiesReceive(Response)
{
	var Container = $('city_container');
//	Container.innerHTML = Response.responseText;
	Container.innerHTML = Response;
}

function geoLoadStatesReceive(Response)
{
//	console.log(Response);
	var Container = $('region_container');
	Container.innerHTML = Response;
	
	var SelectElem = $('state');
	SelectElem.onchange = geoLoadCities;
}



   function popUp(URL, Options, Unique)
{
	var width = Options.split(/,/)[0];
	var height = Options.split(/,/)[1];

	width	= width.split(/=/)[1];
	height 	= height.split(/=/)[1];

	var c = Util.centerScreen(width, height);

	Options	+=
		',screenX=' + c.x +
		',screenY=' + c.y;

//    if (true == Unique)
//    {
        window.open(URL, '', Options);
//    }
//    else
//    {
//        PopUp = window.open(URL, "Zweitfenster", Options);
//        PopUp.focus();
//    }
}



var Util = {
	
	ucFirst: function(Str)
	{
        var F = Str.substr(0, 1);
        var R = Str.substr(1, Str.length - 1);
	    return F.toUpperCase() + R.toLowerCase();
	},
	
    snapTo: function(Snap, To, Style, OffSet, Options)
    {
        if (!arguments[2])
        {
            Style = 'lud';
        }

        if (!arguments[3])
        {
            OffSet = {x: 0, Y: 0};
        }

        if (!arguments[4])
        {
            Options = {noTransition: false};
        }
            
		if (!OffSet.x)
		{
			OffSet = {x: OffSet, y: OffSet};
		}

        to      = {x: 0, y: 0};
        SnapTo  = To.getCoordinates();
        SnapTo.x = SnapTo.left;
        SnapTo.y = SnapTo.top;
        console.log(SnapTo);
//        c = getClientDimension();
        Screen = Util.innerDimension();
        Screen.x -= 30; // Scrollbar

        var Probe = {x: 0, y: 0};
        
        console.log('SNapStyle: ' + Style);
        
        switch (Style)
        {
            case 'ruh' :
                to.x    = OffSet.x;
                to.y    = SnapTo.y;
                break;
            case 'rud' :
                to.x    = SnapTo.x + To.offsetWidth + OffSet;
                Probe.x = to.x + Snap.offsetWidth;
                if (Probe.x > Screen.x)
                    to.x    = SnapTo.x + To.offsetWidth + OffSet - (Probe.x - Screen.x);

                to.y    = SnapTo.y - Snap.offsetHeight - OffSet;
                if (to.y < 1)
                    to.y    = SnapTo.y + To.offsetHeight + OffSet;
                break;

            case 'lud' :
                to.x    = SnapTo.x - Snap.offsetWidth - OffSet;
                if (to.x < 1)
                    to.x    = SnapTo.x - Snap.offsetWidth - OffSet + (Math.abs(to.x));

                to.y    = SnapTo.y - Snap.offsetHeight - OffSet;
                if (to.y < 1)
                    to.y    = SnapTo.y + To.offsetHeight + OffSet;
                break;

            case 'luh' :
                to.x    = SnapTo.x - Snap.offsetWidth - OffSet;
                if (to.x < 1)
                    to.x    = SnapTo.x - Snap.offsetWidth - OffSet + (Math.abs(to.x));

                to.y    = SnapTo.y;
                break;

            case 'luv' :
                to.x    = SnapTo.x;
                to.y    = SnapTo.y - OffSet - Snap.offsetHeight;
                break;

            case 'rbv' :
                to.x    = SnapTo.x + To.offsetWidth - Snap.offsetWidth;
                if (to.x < 1)
                    to.x    = 0;


                to.y    = SnapTo.y + To.offsetHeight + OffSet;
//                if (to.y > Screen.y)
//                    to.y    = SnapTo.y - Snap.offsetHeight - OffSet;
                break;

            case 'lbv' :
                to.x    = SnapTo.x;
                if (to.x + Snap.offsetWidth > Screen.x)
                    to.x    = Screen.x - Snap.offsetWidth;


                to.y    = SnapTo.y + To.offsetHeight + OffSet;
                if (to.y > Screen.y)
                    to.y    = SnapTo.y - Snap.offsetHeight - OffSet;
                break;

            case 'lu' :
                leftPos     = SnapTo.x + To.offsetWidth + Snap.offsetWidth;
                bottomPos   = SnapTo.y + To.offsetHeight + Snap.offsetHeight;
                
                if (leftPos > Screen.x)
                {
                    to.x = SnapTo.x - OffSet - Snap.offsetWidth;
                }
                else
                {
                    to.x = SnapTo.x + OffSet + To.offsetWidth;
                }
                
                if (bottomPos > Screen.y)
                {
                    to.y = SnapTo.y - Snap.offsetHeight + To.offsetHeight;
                }
                else
                {
                    to.y = SnapTo.y;
                }
                break;
                
            case 'lb' :
                leftPos = SnapTo.x + Snap.offsetWidth;
                bottomPos = SnapTo.y + To.offsetHeight + Snap.offsetHeight;
                
                if (leftPos > Screen.x)
                {
                    to.x = SnapTo.x + To.offsetWidth - OffSet - Snap.offsetWidth;
                }
                else
                {
                    to.x = SnapTo.x;
                }
                
                if (bottomPos > Screen.y)
                {
                    to.y = SnapTo.y - Snap.offsetHeight + To.offsetHeight;
                }
                else
                {
                    to.y = SnapTo.y + OffSet + To.offsetHeight;
                }
                break;
        }
        console.log(to);
        
        if (to.y < Util.scrollingOffset().y)
        {
            to.y = Util.scrollingOffset().y;
        }
        
        
        console.log(to);
        
        if (Options.noTransition)
        {
	        Snap.style.left     = parseInt(to.x) + 'px';
	        Snap.style.top      = parseInt(to.y) + 'px';
        }
        else
        {
			var exampleFx = new Fx.Styles(Snap);
			exampleFx.start({
				'left':[parseInt(Snap.style.left),to.x],
				'top':[parseInt(Snap.style.top),to.y]
			});
        }
    },

    pageDimension: function()
    {
        var x,y;
        var test1 = document.body.scrollHeight;
        var test2 = document.body.offsetHeight
        if (test1 > test2) // all but Explorer Mac
        {
        	x = document.body.scrollWidth;
        	y = document.body.scrollHeight;
        }
        else // Explorer Mac;
             //would also work in Explorer 6 Strict, Mozilla and Safari
        {
        	x = document.body.offsetWidth;
        	y = document.body.offsetHeight;
        }
		
		return {x: x, y: y};
    },

	scrollingOffset: function()
	{
		var x,y;
		if (self.pageYOffset) // all except Explorer
		{
			x = self.pageXOffset;
			y = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}
		
		return {x: x, y: y};
	},
	
	innerDimension: function()
	{
		var x,y;
		if (self.innerHeight) // all except Explorer
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		
		return {x: x, y: y};
	},

	/**
	 * Einem Element eine (weitere) Klasse zuweisen.
	 * Bestehende Klassen werden nicht entfernt.
	 */
	addClass: function(Elem, addClassName) {
		if (Elem) {
			CurrentClass = $(Elem).className.split(' ');
			// nicht mehrfach hinzufuegen:
			isSet = false;
			for (ci = 0; ci < CurrentClass.length; ci++) {
				if (CurrentClass[ci] == addClassName) {
					isSet = true;
				}
			}
			if (!isSet) {
				CurrentClass.push(addClassName);
			}
			$(Elem).className = CurrentClass.join(' ');
		}
	},

	/**
	 * Einem Element gezielt eine Klasse entfernen, ohne eventuell
	 * weitere Klassen zu stoeren.
	 */
	stripClass: function(Elem, stripClassName) {
		if (Elem) {
			CurrentClass = $(Elem).className.split(' ');
			for (ci = 0; ci < CurrentClass.length; ci++) {
				if (CurrentClass[ci] == stripClassName) {
					CurrentClass.splice(ci, 1);
				}
			}
			$(Elem).className = CurrentClass.join(' ');
		}
	},
	
	
	
	
	centerScreen: function(width, height)
	{
		var X = (self.screen.width - width) / 2;
		var Y = (self.screen.height - height) / 2;

//		$('content').innerHTML =
//			'width: ' + width + '<br />' +
//			'height: ' + height + '<br />' +
//			'X: ' + X + '<br />' +
//			'Y: ' + Y + '<br />'
//			;
		return {x: X, y: Y};
	},
	
	getPos: function(obj)
	{
		return {
			x: Util.findPosX(obj),
			y: Util.findPosY(obj)
		}
	},
	
	findPosX: function(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft;
//				obj.style.border = '1px solid green';
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
		{
			curleft += obj.x;   
//            obj.style.border = '1px solid blue';
		}
		return curleft;
	},
	
	findPosY: function(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	},
	
	mousePos: function(e)
	{
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY)
		{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY)
		{
			posx = e.clientX + document.body.scrollLeft;
			posy = e.clientY + document.body.scrollTop;
		}
		// posx and posy contain the mouse position relative to the document
		// Do something with this information
		
		return {x: posx, y: posy};
	},
	
	keepAlive: function() {
	    new ajax ('/plugin/de.masstisch.ajax/KeepAlive.php', {
	    });    
	}
	
}












window.addEvent('domready', function()
{
	var Tips2 = new Tips($$('.tip'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 300, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	})
	
});