 // With onkeypress event, this verifies ?Enter? key
 /*
	Note: The verify key function is usually not necessary, but it was written to account for an bug in some older versions of Mozilla. The bug has been fixed in the latest releases, but it previously activated the onkeypress event when a user hit the Tab key, making it impossible to tab past the link without activating the event.
	thanks to: http://cookiecrook.com/AIR/2003/train/eventhandlers.php#eh_fn03
 */
function verifyKey(oElement,oEvent){
  if(oEvent.keyCode==13 && oElement.onclick){
    oElement.onclick();
  }
}

function printout() {
   window.print();
}

function setTinyStummeZeugen(url)
{
    var fo = new SWFObject("flash/stummezeugenevent_137_43.swf", "flash_teaser2", "137", "43", "6", "#FFFFFF");
    fo.addParam("quality", "high");
    fo.addVariable("detailUrl", url);
    fo.write("flash_teaser2");
}

function setSmallStummeZeugen()
{
    var fo = new SWFObject("flash/stummezeugen_159_45.swf", "flash_teaser", "159", "45", "6", "#FFFFFF");
    fo.addParam("quality", "high");
    fo.addParam("wmode", "opaque");
    fo.write("flash_teaser");
}

function setBigStummeZeugen()
{
    var fo = new SWFObject("flash/stummezeugen_137_190.swf", "flash_teaser", "136", "189", "6", "#FFFFFF");
    fo.addParam("quality", "high");
    fo.write("flash_teaser");
}

function openPopup(url, wname, t, l, w, h, showtoolbox)
{
	mywindow = window.open(url, wname, 'width='+w+',height='+h+',top='+t+',left='+l+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no');
	mywindow.focus();

	return false;
}

function openCoverPreview( event )
{
	var url = getClickedLink(event).href;

	var wname = 'CoverPreview';
	var top  = 100;
	var left = 100;
	var width = 460;
	var height = 566;
	var showtoolbox = 0;

	mywindow = window.open(url, wname, 'width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
	mywindow.focus();

	return false;
}

function openDisclaimer( event )
{
	var url = getClickedLink(event).href;

	var wname = 'Disclaimer';
	var top  = 100;
	var left = 100;
	var width = 410;
	var height = 400;
	var showtoolbox = 0;

	mywindow = window.open(url, wname, 'width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
	mywindow.focus();

	return false;
}

function openPostAlert( event )
{
	var url = getClickedLink(event).href;

	var wname = 'PostAlert';
	var top  = 100;
	var left = 100;
	var width = 300;
	var height = 400;
	var showtoolbox = 0;

	mywindow = window.open(url, wname, 'width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
	mywindow.focus();

	return false;
}




function openGallery( event, windowsize )
{
	var url = getClickedLink(event).href;

	var wname = 'Gallery';
	var top  = 50;
	var left = 50;
	var width = 930;
	var height = 840;
	var showtoolbox = 0;

	if(windowsize == 'large')
	{
		height = 849;
	}

	mywindow = window.open(url, wname, 'width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no');
	mywindow.focus();

	return false;
}


function openPartyPhotoCoupon( event )
{
	var url = getClickedLink(event).href;

	var wname = 'Coupon';
	var top  = 100;
	var left = 100;
	var width = 530;
	var height = 930;
	var showtoolbox = 0;

	mywindow = window.open(url, wname, 'width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
	mywindow.focus();

	return false;
}

function openWindowClicked( event, wname, width, height)
{
	var url = getClickedLink(event).href;

	var top  = 100;
	var left = 100;
	var showtoolbox = 0;

	/* @todo: catch whitespace in wname */

	mywindow = window.open(url, wname, 'width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
	mywindow.focus();

	return false;
}


function change_me( $type, $path )
{
   	var article_id 	= 			'state_article';
   	var party_id 			= 	'state_party';
   	var buddy_id 	= 			'buddy_list';
   	var message_id 			= 	'messageCenter';

	if ( $type == 'article')
	{
		document.getElementById( article_id ).style.display = 'block';
	    document.getElementById( party_id ).style.display = 'none';
	}

	if ( $type == 'party')
	{
		document.getElementById( article_id ).style.display = 'none';
	    document.getElementById( party_id ).style.display = 'block';
	}

	if ( $type == 'message')
	{
		document.getElementById( buddy_id ).style.display = 'none';
	    document.getElementById( message_id ).style.display = 'block';
	    document.getElementById( 'btn_buddies').src = $path + 'btn_buddies.gif';
	    document.getElementById( 'btn_inbox').src = $path + 'btn_inbox_active.gif';

	}
	if ( $type == 'buddy')
	{
		document.getElementById( message_id ).style.display = 'none';
	    document.getElementById( buddy_id ).style.display = 'block';
	    document.getElementById( 'btn_buddies').src = $path + 'btn_buddies_active.gif';
	    document.getElementById( 'btn_inbox').src = $path + 'btn_inbox.gif';
	}


	return false;
}


function change_div( display_id, hide_id )
{
	document.getElementById( display_id ).style.display = 'block';
	document.getElementById( hide_id ).style.display = 'none';

	return false;
}


function setSubRegion( parent )
{
	var oldRegion = document.forms["eventmask"].elements["old_region"].value;
	if (oldRegion != '')
	{
		var div = document.getElementById('subregion_' + oldRegion);
		div.style.display = 'none';
	}

	if (parent > 0)
	{
		var div = document.getElementById('subregion_' + parent);
		div.style.display = 'inline';

		document.forms["eventmask"].elements["old_region"].value = parent;
	}
}

function cinemaChange(target)
{
	var element_name = "cinema_" + target;
	var cinema_value = document.forms["cinema_filter"].elements[element_name].value;

	document.forms["eventmask"].elements[element_name].value = cinema_value;
}

function cinemaSubmit()
{
	document.forms["eventmask"].submit();
}

var src_state  = 0;



	function setRedirectUrl()
	{
		//alert(get_cookie('redirectUrl')+'asdasdasd');

		if (get_cookie('redirectUrl'))
		{
			redirect_link_input = document.getElementById( 'redirectUrl' );

			if (redirect_link_input)
			{
				redirect_link_input.value = get_cookie('redirectUrl');
			}
			document.cookie="redirectUrl=0; expires=date.toGMTString(); path=/;"
			//alert(redirect_link_input.value);
		}
	}

	function setProfil()
	{
		//alert(get_cookie('redirectUrl')+'asdasdasd');

		if (get_cookie('ich_now') > 0 )
		{
	    	    document.cookie="ich_now=0; expires=date.toGMTString(); path=/;";
	    	    location.reload(true)
		}
		return true;
	}

	function checkReload()
	{
            if ( get_cookie('reload_now') > 0)
    	    {
//            	alert('cake');
//            	test = get_cookie('reload_now')
//            	alert(test);
	    	    document.cookie="reload_now=0; expires=date.toGMTString(); path=/;";
	    	    //test2 = get_cookie('reload_now')
//            	alert(test2);

				location.reload(true);
	    	    //document.location.href = document.location.href;

        	}


            return true;
	}

	function get_cookie(Name) {
	    var search = Name + "="
	    var returnvalue = "";
	    if (document.cookie.length > 0) {
	        offset = document.cookie.indexOf(search)
	        // if cookie exists
	        if (offset != -1) {
	            offset += search.length
	            // set index of beginning of value
	            end = document.cookie.indexOf(";", offset);
	            // set index of end of cookie value
	            if (end == -1) end = document.cookie.length;
	            returnvalue=unescape(document.cookie.substring(offset, end))
	        }
	    }
	    return returnvalue;
	}

	function getMootoolsContent(url, target )
	{
		/*	you should use "var exampleFx = ..." below
			but due to the way I execute code in these blocks,
			I declared this variable already */
		exampleFx = new Fx.Style(target, 'opacity', {
			transition: Fx.Transitions.quartInOut
		});
		/*	now we have an fx object, let's play with it:	*/
		exampleFx.start(1,0.1); /*fade it out*/

        var date = new Date();
        url = url + '?' + date.getTime();

		new Ajax(url, {
		update: target,
		evalScripts: true,
		method: 'get',
		onComplete: function(){
			exampleFx.start.pass([0.1,1], exampleFx).delay(1000);
			},
		onFailure: function(){
			exampleFx.start.pass([0.1,1], exampleFx).delay(1000);
		}
		}
		).request();
	}

	function getNewUserProto(object)
	{
	 var url = object.href;

     var pars = '';
     var target = 'homeUserTeaser';


     var load_callback = function(t)
     {
     	Element.update('homeUserTeaser', t.responseText);
     	init_FormRefiller();
     }

     var options = {
     	 method:         'get',
         parameters:     pars,
         asynchronous:   true,
         onSuccess:      load_callback
     }

     var myAjax = new Ajax.Request(url, options);
   }




